|
| 1 | +'use strict' |
| 2 | + |
| 3 | +const os = require('os') |
| 4 | + |
| 5 | +const { assert } = require('chai') |
| 6 | +const { setup } = require('./utils') |
| 7 | +const { version } = require('../../package.json') |
| 8 | + |
| 9 | +describe('Dynamic Instrumentation', function () { |
| 10 | + describe('ddtags', function () { |
| 11 | + const t = setup({ |
| 12 | + env: { |
| 13 | + DD_ENV: 'test-env', |
| 14 | + DD_VERSION: 'test-version', |
| 15 | + DD_GIT_COMMIT_SHA: 'test-commit-sha', |
| 16 | + DD_GIT_REPOSITORY_URL: 'test-repository-url' |
| 17 | + }, |
| 18 | + testApp: 'target-app/basic.js' |
| 19 | + }) |
| 20 | + |
| 21 | + it('should add the expected ddtags as a query param to /debugger/v1/input', function (done) { |
| 22 | + t.triggerBreakpoint() |
| 23 | + |
| 24 | + t.agent.on('debugger-input', ({ query }) => { |
| 25 | + assert.property(query, 'ddtags') |
| 26 | + |
| 27 | + // Before: "a:b,c:d" |
| 28 | + // After: { a: 'b', c: 'd' } |
| 29 | + const ddtags = query.ddtags |
| 30 | + .split(',') |
| 31 | + .map((tag) => tag.split(':')) |
| 32 | + .reduce((acc, [k, v]) => { acc[k] = v; return acc }, {}) |
| 33 | + |
| 34 | + assert.hasAllKeys(ddtags, [ |
| 35 | + 'env', |
| 36 | + 'version', |
| 37 | + 'debugger_version', |
| 38 | + 'host_name', |
| 39 | + 'git.commit.sha', |
| 40 | + 'git.repository_url' |
| 41 | + ]) |
| 42 | + |
| 43 | + assert.strictEqual(ddtags.env, 'test-env') |
| 44 | + assert.strictEqual(ddtags.version, 'test-version') |
| 45 | + assert.strictEqual(ddtags.debugger_version, version) |
| 46 | + assert.strictEqual(ddtags.host_name, os.hostname()) |
| 47 | + assert.strictEqual(ddtags['git.commit.sha'], 'test-commit-sha') |
| 48 | + assert.strictEqual(ddtags['git.repository_url'], 'test-repository-url') |
| 49 | + |
| 50 | + done() |
| 51 | + }) |
| 52 | + |
| 53 | + t.agent.addRemoteConfig(t.rcConfig) |
| 54 | + }) |
| 55 | + }) |
| 56 | +}) |
0 commit comments