-
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
This commit does two things: 1. It lays the groundwork for a new feature called "Code Origin for Spans". 2. To showcase this feature, it adds limited support for just Fastify entry-spans. To enable, set `DD_CODE_ORIGIN_FOR_SPANS_ENABLED=true`.
- Loading branch information
Showing
13 changed files
with
449 additions
and
27 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.