APM GO Agent Capture instrumented transaction

Elasticsearch version: 7.9.2
APM Server version: 7.15.0
APM Agent language and version: Go 1.x
"go.elastic.co/apm"
_ "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

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

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.

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 ?

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"?

1 Like

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

1 Like