opentelemetry-js: AWS lambda - process is killed before the span is being exported
This is a simple scenario of lambda function
exports.handler = ( async ( event, ctx ) => {
const span = tracer.startSpan('test');
span.end();
return 'done';
} );
The span is not exported correctly as lambda seems to kill the process before it gets exported When adding some timeout before the process get killed the span iss exported
exports.handler = ( async ( event, ctx ) => {
const span = tracer.startSpan('test');
span.end();
await new Promise((resolve)=> {
setTimeout(()=> {
resolve();
}, 500);
})
return 'done';
} );
So the idea is to implement some async method either on tracer or exporter or change the exporter method shutdown
to be a promise and to be resolved when the last exports is sent successfully
WDYT ?
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 17 (17 by maintainers)
I would open an issue on the contrib repo and ping @willarmiros or @anuraaga since they maintain that instrumentation
In an autoinstrumentation I would suggest you either:
For this issue, I think it is sufficient to give the user a way to manually flush and not worry about wrapping handler or patching anything.