Skip to content
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

Sending data to another collector #58

Open
bhaskarbanerjee opened this issue Apr 3, 2024 · 11 comments
Open

Sending data to another collector #58

bhaskarbanerjee opened this issue Apr 3, 2024 · 11 comments

Comments

@bhaskarbanerjee
Copy link

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.

@Ankcorn
Copy link
Contributor

Ankcorn commented Apr 3, 2024

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

@bhaskarbanerjee
Copy link
Author

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 ()
at Ll (/opt/nodejs/node_modules/@baselime/lambda-node-opentelemetry/lambda-wrapper.cjs:6:24139)
at /opt/nodejs/node_modules/@baselime/lambda-node-opentelemetry/lambda-wrapper.cjs:6:24111
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
2024-04-03T16:31:13.437Z undefined DEBUG @opentelemetry/instrumentation-http Applying patch for http@18.19.1
START RequestId: 3b97ca55-2c50-4f37-a5e2-337a7eb2a867 Version: $LATEST
2024-04-03T16:31:13.448Z 3b97ca55-2c50-4f37-a5e2-337a7eb2a867 INFO Event is: [object Object]
2024-04-03T16:31:13.448Z 3b97ca55-2c50-4f37-a5e2-337a7eb2a867 INFO Post request made
END RequestId: 3b97ca55-2c50-4f37-a5e2-337a7eb2a867
REPORT RequestId: 3b97ca55-2c50-4f37-a5e2-337a7eb2a867 Duration: 4.14 ms Billed Duration: 5 ms Memory Size: 128 MB Max Memory Used: 75 MB Init Duration: 335.45 ms
XRAY TraceId: 1-660d8450-120015ca0cb0bc724cb23420 SegmentId: 5c5a4a220a49b238 Sampled: true

@Ankcorn
Copy link
Contributor

Ankcorn commented Apr 3, 2024

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

@bhaskarbanerjee
Copy link
Author

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!!'),
};
};`

@bhaskarbanerjee
Copy link
Author

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?

@bhaskarbanerjee
Copy link
Author

@Ankcorn
Copy link
Contributor

Ankcorn commented Apr 3, 2024

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

@bhaskarbanerjee
Copy link
Author

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 ()
at Ll (/opt/nodejs/node_modules/@baselime/lambda-node-opentelemetry/lambda-wrapper.cjs:6:24139)
at /opt/nodejs/node_modules/@baselime/lambda-node-opentelemetry/lambda-wrapper.cjs:6:24111
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
2024-04-03T17:39:02.964Z undefined DEBUG @opentelemetry/instrumentation-http Applying patch for http@18.19.1
2024-04-03T17:39:03.225Z undefined ERROR Uncaught Exception {"errorType":"TypeError","errorMessage":"withOpentelemetry is not a function","stack":["TypeError: withOpentelemetry is not a function"," at Object. (/var/task/app.js:3:19)"," at Module._compile (node:internal/modules/cjs/loader:1356:14)"," at Module._extensions..js (node:internal/modules/cjs/loader:1414:10)"," at Module.load (node:internal/modules/cjs/loader:1197:32)"," at Module._load (node:internal/modules/cjs/loader:1013:12)"," at Module.require (node:internal/modules/cjs/loader:1225:19)"," at Ii._require.Bt.require (/opt/nodejs/node_modules/@baselime/lambda-node-opentelemetry/lambda-wrapper.cjs:5:3846)"," at _require.n.require (/opt/nodejs/node_modules/@baselime/lambda-node-opentelemetry/lambda-wrapper.cjs:12:3951)"," at require (node:internal/modules/helpers:177:18)"," at _tryRequireFile (file:///var/runtime/index.mjs:1002:37)"]}
2024-04-03T17:39:03.362Z undefined DEBUG @opentelemetry/instrumentation-http http instrumentation outgoingRequest
2024-04-03T17:39:03.363Z undefined DEBUG @opentelemetry/instrumentation-http http.ClientRequest return request
2024-04-03T17:39:03.484Z undefined DEBUG @opentelemetry/instrumentation-http outgoingRequest on response()
2024-04-03T17:39:03.505Z undefined DEBUG @opentelemetry/instrumentation-http outgoingRequest on end()
2024-04-03T17:39:03.621Z undefined WARN Can not execute the operation on ended Span {traceId: 87e4ed36e228546b04f636c2d51c9867, spanId: 4ca4e6c7501f9141}
INIT_REPORT Init Duration: 4450.27 ms Phase: invoke Status: error Error Type: Runtime.ExitError
START RequestId: b5bc8aa0-2c69-408d-895a-01b92ec2ad24 Version: $LATEST
Unknown application error occurred
Runtime.Unknown
END RequestId: b5bc8aa0-2c69-408d-895a-01b92ec2ad24
REPORT RequestId: b5bc8aa0-2c69-408d-895a-01b92ec2ad24 Duration: 4451.30 ms Billed Duration: 4452 ms Memory Size: 128 MB Max Memory Used: 25 MB
XRAY TraceId: 1-660d9432-6b30fedd3946790a1bdbe2dc SegmentId: 4d1ff83857958335 Sampled: true
Screenshot 2024-04-03 at 12 43 18 PM

@bhaskarbanerjee
Copy link
Author

@Ankcorn

@bhaskarbanerjee
Copy link
Author

packed @baselime/node-opentelemetry in the node_modules

@bhaskarbanerjee
Copy link
Author

@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. (/var/task/app.js:3:28)",
" at Module._compile (node:internal/modules/cjs/loader:1356:14)",
" at Module._extensions..js (node:internal/modules/cjs/loader:1414:10)",
" at Module.load (node:internal/modules/cjs/loader:1197:32)",
" at Module._load (node:internal/modules/cjs/loader:1013:12)",
" at Module.require (node:internal/modules/cjs/loader:1225:19)",
" at require (node:internal/modules/helpers:177:18)",
" at _tryRequireFile (file:///var/runtime/index.mjs:1002:37)",
" at _tryRequire (file:///var/runtime/index.mjs:1052:25)",
" at _loadUserApp (file:///var/runtime/index.mjs:1081:22)"
]
}

Any suggestions?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants