-
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.
[DI] Attach ddtags to probe results (#5042)
The following extra information is added to each probe result: - `env` - From the `DD_ENV` environment variable - `version` - From the `DD_VERSION` environment variable - `debugger_version` - The version of the tracing lib - `host_name` - The hostname that application is running on The `agent_version` is not added in this commit, but will be come later.
- Loading branch information
Showing
5 changed files
with
79 additions
and
15 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
'use strict' | ||
|
||
const os = require('os') | ||
|
||
const { assert } = require('chai') | ||
const { setup } = require('./utils') | ||
const { version } = require('../../package.json') | ||
|
||
describe('Dynamic Instrumentation', function () { | ||
describe('ddtags', function () { | ||
const t = setup({ | ||
env: { | ||
DD_ENV: 'test-env', | ||
DD_VERSION: 'test-version', | ||
DD_GIT_COMMIT_SHA: 'test-commit-sha', | ||
DD_GIT_REPOSITORY_URL: 'test-repository-url' | ||
}, | ||
testApp: 'target-app/basic.js' | ||
}) | ||
|
||
it('should add the expected ddtags as a query param to /debugger/v1/input', function (done) { | ||
t.triggerBreakpoint() | ||
|
||
t.agent.on('debugger-input', ({ query }) => { | ||
assert.property(query, 'ddtags') | ||
|
||
// Before: "a:b,c:d" | ||
// After: { a: 'b', c: 'd' } | ||
const ddtags = query.ddtags | ||
.split(',') | ||
.map((tag) => tag.split(':')) | ||
.reduce((acc, [k, v]) => { acc[k] = v; return acc }, {}) | ||
|
||
assert.hasAllKeys(ddtags, [ | ||
'env', | ||
'version', | ||
'debugger_version', | ||
'host_name', | ||
'git.commit.sha', | ||
'git.repository_url' | ||
]) | ||
|
||
assert.strictEqual(ddtags.env, 'test-env') | ||
assert.strictEqual(ddtags.version, 'test-version') | ||
assert.strictEqual(ddtags.debugger_version, version) | ||
assert.strictEqual(ddtags.host_name, os.hostname()) | ||
assert.strictEqual(ddtags['git.commit.sha'], 'test-commit-sha') | ||
assert.strictEqual(ddtags['git.repository_url'], 'test-repository-url') | ||
|
||
done() | ||
}) | ||
|
||
t.agent.addRemoteConfig(t.rcConfig) | ||
}) | ||
}) | ||
}) |
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