# APM GO Agent Capture instrumented transaction

**URL:** https://discuss.elastic.co/t/apm-go-agent-capture-instrumented-transaction/293619
**Category:** APM
**Tags:** go
**Created:** [January 6, 2022, 5:58am UTC](https://discuss.elastic.co/t/apm-go-agent-capture-instrumented-transaction/293619 "2022-01-06T05:58:35Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![tarund](https://avatars.discourse-cdn.com/v4/letter/t/977dab/32.png) [@tarund](https://discuss.elastic.co/u/tarund)
#### Post date: [January 6, 2022, 5:58am UTC](https://discuss.elastic.co/t/apm-go-agent-capture-instrumented-transaction/293619/1 "2022-01-06T05:58:35Z")

</div>

**Elasticsearch version** : 7.9.2  
**APM Server version** : 7.15.0  
**APM Agent language and version** : Go 1.x  
"[go.elastic.co/apm](http://go.elastic.co/apm)"  
\_ "[go.elastic.co/apm/module/apmlambda](http://go.elastic.co/apm/module/apmlambda)"

Instrumented AWS Lambda function using above go apmlambda agent module.

We are creating new transaction using 'apm.DefaultTracer.StartTransaction' function, which works fine. But we also get the default transaction in apm-server. So, we get 2 transactions for every invocation.

Is there any property to stop capturing default transactions. we tried the below properties, didn't work for us.

> ELASTIC\_APM\_INSTRUMENT  
> ELASTIC\_APM\_RECORDING

OR is there a way to capture & set labels on the default transaction. below function throws run time exception

```auto
var ctx context.Context // request context
tx := apm.TransactionFromContext(ctx)

```

---

<div class="post-metadata">

### Author: ![marclop](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marclop/32/119339_2.png) [@marclop](https://discuss.elastic.co/u/marclop)
#### Post date: [January 6, 2022, 8:14am UTC](https://discuss.elastic.co/t/apm-go-agent-capture-instrumented-transaction/293619/2 "2022-01-06T08:14:39Z")

</div>

Currently, the `apmlambda` module does not support context propagation as is. We may extend it in the future to support that.

Since the context does not contain a transaction, calling `apm.TransactionFromContext(ctx)`, will return a nil `tx`, thus causing a panic.

Ideally, we'd support context propagation in the `apmlambda` module. In the meantime if you don't want the transactions that are tracing the lambda invocation and want to trace your application manually, you can opt to not import the `apmlambda` module and just use the `apm` module.

---

<div class="post-metadata">

### Author: ![tarund](https://avatars.discourse-cdn.com/v4/letter/t/977dab/32.png) [@tarund](https://discuss.elastic.co/u/tarund)
#### Post date: [January 6, 2022, 11:02am UTC](https://discuss.elastic.co/t/apm-go-agent-capture-instrumented-transaction/293619/3 "2022-01-06T11:02:22Z")

</div>

hi @marclop , I tried with not importing **apmlambda** module, but did not make any difference. still getting the default auto generated transaction. can we set labels on this transaction ?

---

<div class="post-metadata">

### Author: ![marclop](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marclop/32/119339_2.png) [@marclop](https://discuss.elastic.co/u/marclop)
#### Post date: [January 10, 2022, 1:47am UTC](https://discuss.elastic.co/t/apm-go-agent-capture-instrumented-transaction/293619/4 "2022-01-10T01:47:45Z")

</div>

Our APM SDK (`go.elastic.co/apm`) will not generate any transactions by default unless certain auto-instrumentation modules are imported (such as `apmlambda`).

Can you make sure you're not importing the module anywhere in your lambda codebase? If you're seeing the auto-instrumented lambda transactions, it means that the module is being imported somewhere.

Is this what are you referring to as "default auto generated transaction"?

---

<div class="post-metadata">

### Author: ![tarund](https://avatars.discourse-cdn.com/v4/letter/t/977dab/32.png) [@tarund](https://discuss.elastic.co/u/tarund)
#### Post date: [January 21, 2022, 5:42am UTC](https://discuss.elastic.co/t/apm-go-agent-capture-instrumented-transaction/293619/5 "2022-01-21T05:42:12Z")

</div>

Thanks @marclop . I found the apmlambda module was imported in one another location. After removing the module, auto-instrumented lambda transactions were not generated.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [February 11, 2022, 1:43am UTC](https://discuss.elastic.co/t/apm-go-agent-capture-instrumented-transaction/293619/6 "2022-02-11T01:43:08Z")

</div>

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.
