-
Notifications
You must be signed in to change notification settings - Fork 99
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Manual tracing for auto-instrumentation-enabled Lambda fuctions #672
Comments
This is the code I tried later, still doesn't work: const _traceExporter = new OTLPTraceExporter();
const _spanProcessor = new BatchSpanProcessor(_traceExporter);
const sdk = new NodeSDK({
textMapPropagator: new AWSXRayPropagator(),
resource: new Resource({
[SemanticResourceAttributes.SERVICE_NAME]: 'echo-handler',
[SemanticResourceAttributes.SERVICE_VERSION]: '1.0',
}),
instrumentations: [
new AwsLambdaInstrumentation({
requestHook: (span, { event, context }) => {
span.setAttribute('faas.name', context.functionName);
span.setAttribute('event', event);
},
responseHook: (span, { err, res }) => {
if (err instanceof Error) span.setAttribute('faas.error', err.message);
if (res) span.setAttribute('faas.res', res);
},
}),
new HttpInstrumentation(),
new AwsInstrumentation({
suppressInternalInstrumentation: true,
}),
],
traceExporter: _traceExporter,
spanProcessor: _spanProcessor,
idGenerator: new AWSXRayIdGenerator(),
});
sdk.start();
const tracer = api.trace.getTracer('echo-handler-tracer');
module.exports.handler = async (
event: APIGatewayProxyEvent,
context: Context,
callback: Callback<APIGatewayProxyResult>,
): Promise<APIGatewayProxyResult> => {
return tracer.startActiveSpan('echo API handler', async (span) => {
... some logics
span.end();
return {
statusCode: 200,
body: JSON.stringify({
message: requestBody.message,
tables: tables,
}),
};
});
}; When I turn the activate trace option on, only traces provided by the layer (from my perspective) is exported to the X-Ray, and the traces from the code is not. |
I took a log to check if the default URL is correct: import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http';
const _traceExporter = new OTLPTraceExporter({});
console.log(`using default OTLP TraceExporter URL: ${_traceExporter.getDefaultUrl({})}`); From ADOT document
This seems to be right. |
were you able to get this working? I am running into the same issue |
Are you also using the layer from the ADOT document? |
Yes -- I was able to get manual instrumentation working for other backends like New Relic, so been working with that. Could not get xray to pick up any of my spans/attributes |
I turned to use PowerTools instead of the ADOT layer FYI @ferdy-roz |
Could it be because you're not awaiting your async callback? |
I enabled the auto-instrumentation support by following the instructions on ADOT Lambda Support For JavaScript in my TypeScript Lambda functions. The auto-instrumentation is enabled successfully as follow:
However, when I manually create spans following instructions from here, the information seems not reported to the CloudWatch X-Ray.
My operations exactly
arn:aws:lambda:us-west-2:901920570463:layer:aws-otel-nodejs-amd64-ver-1-15-0:2
Question
I'm unable to find any information about this, is manually instrumenting not supported when the auto-instrumentation is enabled?
The text was updated successfully, but these errors were encountered: