-
Notifications
You must be signed in to change notification settings - Fork 2
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
Add datadog tracing support #4
Conversation
import {BuffLog} from './bufflog'; | ||
|
||
tracer.init({ | ||
hostname: "dd-agent-hostname", | ||
logInjection: false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @erickhun,
Curious to know what differences you found between using logInjection: true
which supports pino and doing the injection manually like we are doing in this PR. Is the injected data different?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@esclapes good one, i've tried to add the traceID with switching the logInjection
to true
as you said, but it didn't work out of the box 🤔. It's why i've ended up with the manual tracing.
I'm not too sure how we can make it detect by the dd-trace plugin out of the box. but if you have any idea to make that work that'd be awesome.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@erickhun 🤔 my hunch is that it's an issue with the order of the imports. I believe the .init
call needs to happen before anything else is imported so that dd-trace
has time to monkey patch the supported libraries.
We usually place all the init code in a separate file and then import that file at the top of the index. This is a recent example
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@esclapes oh thanks! i'll try this in an other branch. Sorry if that might look obvious, still trying to get up to speed with js 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Glad to know that it works! It feels nice to use the dd-trace
feature for this, as it will probably be updated with newer features and bug fixes that may not be obvious to us.
💯
Append
trace_id
andspan_id
to the logs.We use the
mixin()
function of pino to append traces to the logs.Pre-Requirement:
The service using the lib will need to also have the
dd-trace
library installed. If not, nothing will be appended to the logs.How to initialise the tracer in a service:
Results:
cc @esclapes @colinscape if you have any comments :) ( I also tried to add tests with #3 , but I couldn't figure out yet how to properly test what's sent to
stdout
)