-
Notifications
You must be signed in to change notification settings - Fork 317
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add initial support for Code Origin for Spans (Fastify only)
To enable, set `DD_CODE_ORIGIN_FOR_SPANS_ENABLED=true`. By default span origin is only set for spans whos callstack contains user land stack frames. To support span origin on entry spans (e.g. the span automatically created when an incoming HTTP request is being instrumented), one would need to add this to the router instrumentation for each web framework. This commit includes support for span origin on Fastify entry spans only.
- Loading branch information
Showing
15 changed files
with
454 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
'use strict' | ||
|
||
const { getUserLandFrames } = require('./plugins/util/stacktrace') | ||
|
||
const limit = Number(process.env._DD_CODE_ORIGIN_MAX_USER_FRAMES) || 8 | ||
|
||
module.exports = { | ||
entryTag, | ||
exitTag | ||
} | ||
|
||
function entryTag (topOfStackFunc) { | ||
return tag('entry', topOfStackFunc) | ||
} | ||
|
||
function exitTag (topOfStackFunc) { | ||
return tag('exit', topOfStackFunc) | ||
} | ||
|
||
function tag (type, topOfStackFunc) { | ||
const frames = getUserLandFrames(topOfStackFunc, limit) | ||
const tags = { | ||
'_dd.code_origin.type': type | ||
} | ||
for (let i = 0; i < frames.length; i++) { | ||
const frame = frames[i] | ||
tags[`_dd.code_origin.frames.${i}.file`] = frame.file | ||
tags[`_dd.code_origin.frames.${i}.line`] = String(frame.line) | ||
if (frame.method) { | ||
tags[`_dd.code_origin.frames.${i}.method`] = frame.method | ||
} | ||
if (frame.type) { | ||
tags[`_dd.code_origin.frames.${i}.type`] = frame.type | ||
} | ||
} | ||
return tags | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.