Version: 3.0.0-alpha.1
My previouse environment setting of:
AWS_XRAY_CONTEXT_MISSING=LOG_ERROR
doesn't work on this version.
Hi @Mangosteen-Yang,
I suspect this has to do with the removal of winston in the 3.0.0-alpha.1 update. Can you describe what you expected to happen vs. what is actually happening? Is the SDK raising a runtime error, failing to print the error, or something else entirely?
Hi @willarmiros
I expect I can ignore errors.
The error I met is:
2020-01-07 12:57:37.108 +11:00 [ERROR] Error: Failed to get the current sub/segment from the context.
at Object.contextMissingLogError [as contextMissing] (/Users/shuo/Documents/mii-api/node_modules/aws-xray-sdk-core/lib/context_utils.js:26:19)
at Object.getSegment (/Users/shuo/Documents/mii-api/node_modules/aws-xray-sdk-core/lib/context_utils.js:92:45)
at tryGetCurrentSegment (/Users/shuo/Documents/mii-api/node_modules/aws-xray-sdk-core/lib/patchers/promise_p.js:31:28)
at Promise.then (/Users/shuo/Documents/mii-api/node_modules/aws-xray-sdk-core/lib/patchers/promise_p.js:16:10)
at Function.init (/Users/shuo/Documents/mii-api/node_modules/mongoose/lib/model.js:1222:16)
at Mongoose.model (/Users/shuo/Documents/mii-api/node_modules/mongoose/lib/index.js:555:11)
at Object.<anonymous> (/Users/shuo/Documents/mii-api/app/models/brand.js:44:27)
at Module._compile (internal/modules/cjs/loader.js:868:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:879:10)
at Module.load (internal/modules/cjs/loader.js:731:32)
at Function.Module._load (internal/modules/cjs/loader.js:644:12)
at Module.require (internal/modules/cjs/loader.js:771:19)
at require (internal/modules/cjs/helpers.js:68:18)
at Object.<anonymous> (/Users/shuo/Documents/mii-api/app/api/brand.js:3:15)
at Module._compile (internal/modules/cjs/loader.js:868:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:879:10)
Please refer AWS support case ID 6310960771 for more detail.
Hi @Mangosteen-Yang,
This is the intended behavior of the SDK. Setting the context missing environment variable to LOG_ERROR does just what it says, it logs context missing error messages. If you'd like to not see anything logged from the SDK, you can set the AWS_XRAY_LOG_LEVEL environment variable to silent, which will suppress all logging output from the SDK.
Lastly, if you'd like to truly do nothing on context missing errors, you can unset AWS_XRAY_CONTEXT_MISSING and use our API to make the context missing strategy to a no-op:
AWSXRay.setContextMissingStrategy(() => {});
@willarmiros Thanks.
I still have a question. Base on my assumption, I should not get this error after version v3.0 because I app.use(AWSXRay.express.openSegment()); just after const app = express(); and app.use(AWSXRay.express.closeSegment()); at the last line of my code
Hmmm I would need to see a fuller snippet of your code to properly diagnose the issue. The most important thing with the express instrumentation is that you should not use other middlewares in between your declarations of openSegment() and closeSegment(), as I explained in this comment. Feel free to post more detailed example code and I can try to reproduce it.
@willarmiros
Thank you so much!
As futher discussion will out of the topic and post more code may contain sensitive information, I will create a ticket in AWS if I cannot solve it.
Pls feel free to close it.
Happy to help :)
Most helpful comment
Hi @Mangosteen-Yang,
This is the intended behavior of the SDK. Setting the context missing environment variable to
LOG_ERRORdoes just what it says, it logs context missing error messages. If you'd like to not see anything logged from the SDK, you can set theAWS_XRAY_LOG_LEVELenvironment variable tosilent, which will suppress all logging output from the SDK.Lastly, if you'd like to truly do nothing on context missing errors, you can unset
AWS_XRAY_CONTEXT_MISSINGand use our API to make the context missing strategy to a no-op: