Skip to content

Commit

Permalink
Require injected dd-trace/ext
Browse files Browse the repository at this point in the history
  • Loading branch information
nikostoulas committed Sep 6, 2024
1 parent 6140534 commit 5ac5d4a
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/initializers/datadog/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import requireInjected from '../../require-injected';
import { getLogger } from '../log4js';
import { formats } from 'dd-trace/ext';

let tracer;
export default config => {
Expand All @@ -25,8 +24,10 @@ export const isDatadogEnabled = () => {
return process.env.DD_SERVICE && process.env.DD_ENV;
};

let formats;
export const injectTrace = (event: any) => {
if (!isDatadogEnabled()) return;
formats = formats ?? requireInjected('dd-trace/ext').formats;
const span = tracer?.scope()?.active();
if (span) {
tracer.inject(span.context(), formats.LOG, event);
Expand Down

0 comments on commit 5ac5d4a

Please sign in to comment.