---
title: Trace asynchronous applications
source: https://docs.newrelic.com/docs/apm/agents/go-agent/features/trace-asynchronous-applications
---

The ability to trace asynchronous segments with the `NewGoroutine` API is available as of [Go agent version 2.6.0](https://docs.newrelic.com/docs/release-notes/agent-release-notes/go-release-notes). If you do not have version 2.6.0 or higher, update your Go agent to the latest version.

## NewGoroutine [#enable]

The `Transaction.NewGoroutine() Transaction` method allows transactions to create segments in multiple goroutines.

`NewGoroutine` returns a new reference to the `Transaction`. This must be called any time you are passing the `Transaction` to another goroutine which makes segments. Each segment-creating goroutine must have its own `Transaction` reference. It does not matter if you call this before or after the other goroutine has started.

All `Transaction` methods can be used in any `Transaction` reference. The `Transaction` will end when `End()` is called in any goroutine.

Example passing a new `Transaction` reference directly to another goroutine:

```go
go func(txn *newrelic.Transaction) {
    defer txn.StartSegment("async").End()
    time.Sleep(100 * time.Millisecond)
}(txn.NewGoroutine())
```

Example passing a new `Transaction` reference on a channel to another goroutine:

```go
ch := make(chan *newrelic.Transaction)
go func() {
    txn := <-ch
    defer txn.StartSegment("async").End()
    time.Sleep(100 * time.Millisecond)
}()
ch <- txn.NewGoroutine()
```
