Comments (2)
It's not really a context loss here. This is a limitation of how request attributes are attached to a trace.
As of now request attributes can be only attached to an open request. Once you send the 202 response the web request trace entry is ended and as a result the request attribute can't be attached anymore.
In contrast to request attributes other children like DB, HTTP or messaging requests (even when done via SDK) create a new linked entry in the trace but that's currently not supported for request attributes.
However, request attributes can be attached to this children and they are propagated up to the web request. But again they have to be added when the request is still ongoing.
Here is a small sample to illustrate this:
import * as http from "http";
import { createInstance } from "@dynatrace/oneagent-sdk";
const sdk = createInstance();
sdk.setLoggingCallbacks({
error(msg) { console.log("sdk error:", msg) },
warning(msg) { console.log("sdk warn:", msg) }
});
http.createServer((req, res) => {
sdk.addCustomRequestAttribute("onRequest", "works");
res.statusCode = 202;
res.end();
sdk.addCustomRequestAttribute("afterEnd sync in handler", "works");
setImmediate(() => {
sdk.addCustomRequestAttribute("afterEnd async", "works not");
http.get("http://example.org", (cltRsp) => {
cltRsp.resume();
sdk.addCustomRequestAttribute("inCltCb", "works again as in a sync callback");
});
});
}).listen(8100);
The SDK log attribute <afterEnd async> not added because no active trace context found
is a bit misleading here. A better wording would be probably attribute <afterEnd async> not added because no transaction is active
.
fyi @z1c0
from oneagent-sdk-for-nodejs.
I will close this issue. Feel free to reopen in case you have more questions regarding this.
from oneagent-sdk-for-nodejs.
Related Issues (14)
- Required parameter channelType not required in typing information HOT 8
- Custom Alerts in NodeJS application HOT 2
- Can we use this SDK for Angular? (client-side) HOT 1
- Custom Metrics HOT 1
- Auto initialize tracing of requests and database access HOT 4
- Missing Custom services HOT 3
- Readme references old Community HOT 1
- SDK is not active when used with oneagent lambda layer HOT 2
- Custom Metrics HOT 5
- Deno & Deno Deploy support HOT 2
- Custom service tracing HOT 2
- Wrong instantiation on README.md HOT 2
- traceIncomingMessage throw invalid vendorName error HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from oneagent-sdk-for-nodejs.