Comments (7)
I am asking the above question because in the first experimentation with opentelemetry/api in combination with Lambda and Layer extesion installed, i get the following results:
(with this result i am out of ideas or sources to read in order to continue ... by first creating spans and adding to current active context)
So,
In method invocation of Lambda
const handler = async (event, context)=>{
const tracer = opentelemetryAPI.trace.getTracer("nameOfTracer"); // tracer is a ProxyTracer
const provider = opentelemetryAPI.trace.getTracerProvider(); // tracerProvider is a ProxyTracerProvider
const span = tracer.startSpan("do some work"); // span is undefined
const currentSpan = opentelemetryAPI.trace.getSpan(opentelemetryAPI.context.active()); // currentSpan is undefined
}
After reading the tests of the opentelemetryAPI , i understand that when no delegate is set
it should return proxy tracers
and 'startSpan should return Noop Spans
Link tests: https://github.com/open-telemetry/opentelemetry-js-api/blob/main/test/proxy-implementations/proxy-tracer.test.ts
Also by logging the event object in method Lambda invocation i get Propagation Headers
values for:
x-b3-spanid, x-b3-traceid, "x-b3-sampled": "1", X-Amzn-Trace-Id and traceParent
The question is how do get a Tracer from Tracer Provider in order to create spans and add spans to an active context ?
from aws-otel-lambda.
Hi @niko-achilles - we store the lambda span into the current context here
Without it other instrumentation would not connect to the trace.
So your code snippet seems like it's supposed to work. Are you able to create a small repro?
from aws-otel-lambda.
Hi @anuraaga , thanks for the link, nice to learn from this.
So,
i created a small repo here : https://github.com/niko-achilles/lambda-otel-spans/blob/main/functions/hello.js
Notice in this line that i get a ProxyTracer
from provider : https://github.com/niko-achilles/lambda-otel-spans/blob/main/functions/hello.js#L25
and here the getSpan
is undefined: https://github.com/niko-achilles/lambda-otel-spans/blob/main/functions/hello.js#L13
Can you help on how to get a tracer in order to create Spans and how to get the active context ?
from aws-otel-lambda.
Thanks for the repro @niko-achilles. Just wondering, do you see the behavior on all requests, not just the first?
Here's where we set a "real" tracer
Due to the design of detectResources
though it's asynchronous, and I guess it is possible for the first execution of a handler to happen before it completes. If this is the issue, there seems to be a long-standing PR on helping with it
open-telemetry/opentelemetry-js#1484
Will ping it
from aws-otel-lambda.
hi @anuraaga
i modified the code to add timer execution, in order to
a. execute after the tracer starts a Span with the purpose to get the span created
b. execute after the tracer ends the created span with the purpose to see the app-developer created traces in X-RAY
https://github.com/niko-achilles/lambda-otel-spans/blob/main/functions/hello.js#L23
Additionally i invoked the function under oberservabilty 50 times via a script in order to be able to answer your question about
Just wondering, do you see the behavior on all requests, not just the first?
Yes the behavior is the same .
I get in the setup, results :
/* -- Tracer instance Log --
tracer ProxyTracer {
_provider: ProxyTracerProvider {},
name: 'helloTracer',
version: '1.0'
} */
and created spans as undefined
from aws-otel-lambda.
update i also added a waiting behavior before getting a tracer ,
https://github.com/niko-achilles/lambda-otel-spans/blob/main/functions/hello.js#L38
but i get the same results:
/* -- Tracer instance Log --
tracer ProxyTracer {
_provider: ProxyTracerProvider {},
name: 'helloTracer',
version: '1.0'
} */
and created spans as undefined
from aws-otel-lambda.
@anuraaga with interacting with openetelemetry-js community contrib. i managed to get information for a workaround , in order to create custome span names.
I unistalled "@opentelemetry/api": "^1.0.0" and installed "@opentelemetry/api": "^1.0.0-rc.0".
Then i get a NodeTraceProvider and with openetelemetry api i can set/get Spans .
from aws-otel-lambda.
Related Issues (20)
- Support Java 17 runtime for Lambda Layers HOT 2
- Support for Python 3.10 HOT 2
- Allow the source of the parent context to be configurable. HOT 4
- Documentation for S3 Confmap Provider is incorrect HOT 4
- Documentation for included Processors is incorrect HOT 1
- Error exporting traces from Python lambda HOT 2
- Logging exporter does not log metrics or traces HOT 4
- node.js lambda -> aws-otel-lambda -> ADOT collector doesn't work HOT 10
- First set of counter value ignored after lambda cold boot
- Auto-instrumentation Agent only in Lambda HOT 5
- nodejs spans not exported when upgrading aws otel lambda layer to 1.15.0 HOT 7
- How to configure NodeJs auto-instrumentation to use tracecontext instead of xray? HOT 4
- Error invoking Lambda function after adding latest layer (1-28-1) for java HOT 5
- Steps to build and download a private Python lambda layer as a local .zip or .tar file? HOT 1
- Trace is broken in Lambda Java17 Runtime HOT 2
- Traces are not flushed to the server before the lambda terminates HOT 6
- Unable to access Lambda layer for Python with x86_64 architecture HOT 5
- docs: document of supported python version is old HOT 1
- 53612: bind: address already in use HOT 5
- [nodejs lambda layer] no metrics is exported to cloudwatch logs HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from aws-otel-lambda.