-
Notifications
You must be signed in to change notification settings - Fork 309
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
44 additions
and
53 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
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,20 @@ | ||
'use strict' | ||
|
||
const { entryTag } = require('./tags') | ||
const web = require('../../dd-trace/src/plugins/util/web') | ||
|
||
const kCodeOriginForSpansTagsSym = Symbol('datadog.codeOriginForSpansTags') | ||
|
||
module.exports = function (plugin) { | ||
plugin.addSub('apm:fastify:request:handle', ({ req, routeConfig }) => { | ||
const tags = routeConfig?.[kCodeOriginForSpansTagsSym] | ||
if (!tags) return | ||
const context = web.getContext(req) | ||
context.span?.addTags(tags) | ||
}) | ||
|
||
plugin.addSub('apm:fastify:route:added', ({ routeOptions, onRoute }) => { | ||
if (!routeOptions.config) routeOptions.config = {} | ||
routeOptions.config[kCodeOriginForSpansTagsSym] = entryTag(onRoute) | ||
}) | ||
} |
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,17 @@ | ||
'use strict' | ||
|
||
const fastify = require('./fastify') | ||
const RouterPlugin = require('../../datadog-plugin-router/src') | ||
|
||
class CodeOriginForSpansPlugin extends RouterPlugin { | ||
static get id () { | ||
return 'code-origin-for-spans' | ||
} | ||
|
||
constructor (...args) { | ||
super(...args) | ||
fastify(this) | ||
} | ||
} | ||
|
||
module.exports = CodeOriginForSpansPlugin |
2 changes: 1 addition & 1 deletion
2
packages/dd-trace/src/code_origin.js → ...es/datadog-plugin-code-origin/src/tags.js
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