Sending data to another collector
Question - I am trying to use this opensource and send data to another collector. I am assuming that does not require the prerequisite of connecting my aws account with Baselime. I have built the layer using scripts/publish.sh and created a layer out of that. I have attached the layer to my lambda and am setting up the following ENV vars
AWS_LAMBDA_EXEC_WRAPPER /opt/baselime BASELIME_ACTUAL_HANDLER app.handler BASELIME_API_KEY 0123456789 (a ficticious key) COLLECTOR_URL my_collector_url:port OTEL_LOG_LEVEL DEBUG
My lamnbda's logs show no errors but the collectior doesn't receive any data either. Additionally, I do not see any console out from this layer. Seeking your suggestions on how to proceed with this.
My lambda handler is also set to app.handler.
Hey @bhaskarbanerjee
Do you see any debug logs from the sdk you should see a lot with the OTEL_LOG_LEVEL set to "debug"
just fyi the log level needs to be all lower case.
You can find the code for the tracer here https://github.com/baselime/node-opentelemetry/blob/main/src/baselime.ts
Thanks @Ankcorn Here are the logs.
@opentelemetry/api: Registered a global for diag v1.7.0.
@opentelemetry/api: Registered a global for trace v1.7.0.
@opentelemetry/api: Registered a global for context v1.7.0.
@opentelemetry/api: Registered a global for propagation v1.7.0.
Mq found resource. t {
_attributes: {},
asyncAttributesPending: false,
_syncAttributes: {},
_asyncAttributesPromise: undefined
}
wk found resource. t {
_attributes: {},
asyncAttributesPending: false,
_syncAttributes: {},
_asyncAttributesPromise: undefined
}
Uk found resource. t {
_attributes: {},
asyncAttributesPending: false,
_syncAttributes: {},
_asyncAttributesPromise: undefined
}
n found resource. t {
_attributes: {
'cloud.provider': 'aws',
'cloud.platform': 'aws_lambda',
'cloud.region': 'us-east-1',
'faas.name': 'otel-nodeSample',
'faas.version': '$LATEST'
},
asyncAttributesPending: false,
_syncAttributes: {},
_asyncAttributesPromise: Promise {
{
'cloud.provider': 'aws',
'cloud.platform': 'aws_lambda',
'cloud.region': 'us-east-1',
'faas.name': 'otel-nodeSample',
'faas.version': '$LATEST'
}
}
}
Trace: {
"cloud.provider": "aws",
"cloud.platform": "aws_lambda",
"cloud.region": "us-east-1",
"faas.name": "otel-nodeSample",
"faas.version": "$LATEST"
}
at t.verbose (/opt/nodejs/node_modules/@baselime/lambda-node-opentelemetry/lambda-wrapper.cjs:5:37558)
at t.verbose (/opt/nodejs/node_modules/@baselime/lambda-node-opentelemetry/lambda-wrapper.cjs:5:33690)
at /opt/nodejs/node_modules/@baselime/lambda-node-opentelemetry/lambda-wrapper.cjs:6:24242
at Array.forEach (
It doesn't look like you are creating any spans.
I'd recommend installing our node-opentelemetry package and using the withOpentelemetry middleware for lambda from it to trace your lambda function
I am trying a simple hello world app. Do I need to explicitly create spans?
`'use strict';
exports.handler = async (event) => {
console.log("Hello World") return { statusCode: 200, body: JSON.stringify('Hello from Lambda!!'), }; };`
Doesn't the layer work out of the box i.e. adding the layer and setting ENV VARs? Or is a code change in the lambda MUST to invoke/utilize this layer?
@Ankcorn similar to https://baselime.io/docs/sending-data/lambda-extension/
You need to change the code.
Would look something like this
const { withOpentelemetry } = require('@baselime/node-opentelemetry/lambda');
exports.handler = withOpentelemetry((event) => {
return {
statusCode: 200,
body: JSON.stringify('Hello from Lambda!!'),
};
});
If you are using the tag system and are signed up to baselime you can do it without code changes but otherwise you need to import the middleware
OK, Tried but it ended in an error. Have removed the layer too.
e2d08ccda27c802025d6b0c, spanId: 629b8370bd6ed632}
INIT_REPORT Init Duration: 365.59 ms Phase: init Status: error Error Type: Runtime.ExitError
@opentelemetry/api: Registered a global for diag v1.7.0.
@opentelemetry/api: Registered a global for trace v1.7.0.
@opentelemetry/api: Registered a global for context v1.7.0.
@opentelemetry/api: Registered a global for propagation v1.7.0.
Mq found resource. t {
_attributes: {},
asyncAttributesPending: false,
_syncAttributes: {},
_asyncAttributesPromise: undefined
}
wk found resource. t {
_attributes: {},
asyncAttributesPending: false,
_syncAttributes: {},
_asyncAttributesPromise: undefined
}
Uk found resource. t {
_attributes: {},
asyncAttributesPending: false,
_syncAttributes: {},
_asyncAttributesPromise: undefined
}
n found resource. t {
_attributes: {
'cloud.provider': 'aws',
'cloud.platform': 'aws_lambda',
'cloud.region': 'us-east-1',
'faas.name': 'otel-nodeSample',
'faas.version': '$LATEST'
},
asyncAttributesPending: false,
_syncAttributes: {},
_asyncAttributesPromise: Promise {
{
'cloud.provider': 'aws',
'cloud.platform': 'aws_lambda',
'cloud.region': 'us-east-1',
'faas.name': 'otel-nodeSample',
'faas.version': '$LATEST'
}
}
}
Trace: {
"cloud.provider": "aws",
"cloud.platform": "aws_lambda",
"cloud.region": "us-east-1",
"faas.name": "otel-nodeSample",
"faas.version": "$LATEST"
}
at t.verbose (/opt/nodejs/node_modules/@baselime/lambda-node-opentelemetry/lambda-wrapper.cjs:5:37558)
at t.verbose (/opt/nodejs/node_modules/@baselime/lambda-node-opentelemetry/lambda-wrapper.cjs:5:33690)
at /opt/nodejs/node_modules/@baselime/lambda-node-opentelemetry/lambda-wrapper.cjs:6:24242
at Array.forEach (
@Ankcorn
packed @baselime/node-opentelemetry in the node_modules
@Ankcorn slight change to the code but now a different error
`const { baselime } = require('@baselime/node-opentelemetry');
exports.handler = baselime.withOpentelemetry((event) => { return { statusCode: 200, body: JSON.stringify('Hello from Lambda!!'), }; }); `
{
"errorType": "TypeError",
"errorMessage": "Cannot read properties of undefined (reading 'withOpentelemetry')",
"trace": [
"TypeError: Cannot read properties of undefined (reading 'withOpentelemetry')",
" at Object.
Any suggestions?