opentelemetry-lambda
opentelemetry-lambda copied to clipboard
GlobalOpenTelemetry.get() returns Noop implementation when using java lambda layer
Describe the bug
When in AWS lambda using the java agent layer, both for layer v1 and v2. You can't access the Opentelemetry instance defined by the layer. GlobalOpenTelemetry.get()
returns a DefaultOpenTelemetry{propagators=DefaultContextPropagators{textMapPropagator=NoopTextMapPropagator}}
.
However my code is correctly instrumented and traces are being forwarded to my collector also context is correctly propagated/injected on to produced records on my Kafka topic.
Steps to reproduce
Deploy AWS java lambda with layer arn:aws:lambda:${aws:region}:184161586896:layer:opentelemetry-javaagent-0_2_0:1
. Add implementation("io.opentelemetry:opentelemetry-api:1.32.0")
to the classpath and try to get the global opentelemetry instance using GlobalOpenTelemetry.get()
What did you expect to see?
GlobalOpenTelemetry.get()
returns the OpenTelemetry instance used by layer.
What did you see instead?
GlobalOpenTelemetry.get()
returns OpenTelemetry.noop()
What version of collector/language SDK version did you use?
- arn:aws:lambda:${aws:region}:184161586896:layer:opentelemetry-javaagent-0_1_0:1
- arn:aws:lambda:${aws:region}:184161586896:layer:opentelemetry-javaagent-0_2_0:1
What language layer did you use? Java 17
You still need to add the javaagent or use the wrapper.
Try adding the following environment variable.
AWS_LAMBDA_EXEC_WRAPPER=/opt/otel-handler
@Thul95 Yes, @tylerbenson is correct. You are missing setting AWS_LAMBDA_EXEC_WRAPPER
environment variable. Otherwise, Java agent is not activated and in this case it is expected that there is no trace context started.