-
Notifications
You must be signed in to change notification settings - Fork 7.3k
Storing per-domain data #5242
Comments
See also #3733, which doesn't seem to have any conclusion |
On a related note, what is the best way to use domains for HTTP servers? I've found two different variants, and I'm not sure which one is more correct. https://github.com/isaacs/domain-http-server/blob/master/domain-http-server.js |
You saw the mailing list post. We won't go out of our way to break your application but we reserve the right to change the current implementation as the need arises.
Can you post that question to the mailing list? The issue tracker is not for support or 'how to?' questions. |
For future reference, There are a number of us who need this more generic context mechanism. @bnoordhuis, I got together with @isaacs this week to discuss what I need in Node for New Relic to be useful. @SLaks, I'm in the process of putting together a strawman API for something that looks an awful lot like MDC. My goal is to create something with generic and simple enough semantics that can be used as a substrate for domains as well as other kinds of (user-created) tooling. Right now the thought is to land something in 0.12, and I may also try to implement a version of it as a module, much as @isaacs did with streams2 (although that's tough to do efficiently, given how the domains code is scattered all over the place). @SLaks, you'll also want to take a look at the source of Finally, take a look at https://github.com/newrelic/node-newrelic/blob/master/lib/instrumentation/connect.js#L90-L101 for an example / set of warnings for how to deal with domains in connect, which more or less has its own idiomatic error-handling strategy. You have to engage in some shenanigans to keep connect from swallowing errors before they can get emitted on a domain. This may or may not apply to your use case. |
Is I'll certainly take a look at New Relic; what timeframe are you expecting? |
See also #5243. |
@SLaks Domains have gone from As far as New Relic is concerned, there's a beta version of New Relic's Node support available today, and depending on your use case, it may or may not be useful to you, as it's very much a work in progress. Writing a version of New Relic's transaction tracer for Node has proven to be very challenging, for the reasons discussed in this issue and #3733. |
I'm trying to write a logging system for a complex web application.
I'd like to be able to associate data with an HTTP request (eg, URL, user ID, IP address). I would then include that data with messages logged from components that aren't aware of HTTP at all (eg, data layer), without having to explicitly pass a context object with every function call.
In effect, I'm trying to duplicate Java's MDC.
After looking around on StackOverflow and mailgroups, it looks like I can do this using the undocumented properties
process.domain
(to get a reference to the current domain) anddomain.data
(to store arbitrary information).How likely are these features to change in the future?
(I'm targetting 0.8 right now, but I hope to move to 0.10)
Are there any alternatives?
I'm particularly concerned after reading this post.
The text was updated successfully, but these errors were encountered: