Skip to content

Commit 3da3ad9

Browse files
authored
ssi: fix reporting for services instrumented via SSI (#6048)
1 parent faee414 commit 3da3ad9

File tree

6 files changed

+16
-21
lines changed

6 files changed

+16
-21
lines changed

init.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,5 @@
55
var guard = require('./packages/dd-trace/src/guardrails')
66

77
module.exports = guard(function () {
8-
var INSTRUMENTED_BY_SSI = require('./packages/dd-trace/src/constants').INSTRUMENTED_BY_SSI
9-
var obj = {}
10-
obj[INSTRUMENTED_BY_SSI] = 'ssi'
11-
return require('.').init(obj)
8+
return require('.').init()
129
})

integration-tests/init.spec.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ function testInjectionScenarios (arg, filename, esmWorks = false) {
3636

3737
if (currentVersionIsSupported) {
3838
context('without DD_INJECTION_ENABLED', () => {
39-
it('should initialize the tracer', () => doTest('init/trace.js', 'true\n', [], 'ssi'))
40-
it('should initialize instrumentation', () => doTest('init/instrument.js', 'true\n', [], 'ssi'))
39+
it('should initialize the tracer', () => doTest('init/trace.js', 'true\n', [], 'manual'))
40+
it('should initialize instrumentation', () => doTest('init/instrument.js', 'true\n', [], 'manual'))
4141
it(`should ${esmWorks ? '' : 'not '}initialize ESM instrumentation`, () =>
42-
doTest('init/instrument.mjs', `${esmWorks}\n`, []))
42+
doTest('init/instrument.mjs', `${esmWorks}\n`, [], 'manual'))
4343
})
4444
}
4545
context('with DD_INJECTION_ENABLED', () => {
@@ -55,10 +55,10 @@ function testInjectionScenarios (arg, filename, esmWorks = false) {
5555
useEnv({ NODE_OPTIONS })
5656

5757
context('without DD_INJECTION_ENABLED', () => {
58-
it('should initialize the tracer', () => doTest('init/trace.js', 'true\n', [], 'ssi'))
59-
it('should initialize instrumentation', () => doTest('init/instrument.js', 'true\n', [], 'ssi'))
58+
it('should initialize the tracer', () => doTest('init/trace.js', 'true\n', [], 'manual'))
59+
it('should initialize instrumentation', () => doTest('init/instrument.js', 'true\n', [], 'manual'))
6060
it(`should ${esmWorks ? '' : 'not '}initialize ESM instrumentation`, () =>
61-
doTest('init/instrument.mjs', `${esmWorks}\n`, []))
61+
doTest('init/instrument.mjs', `${esmWorks}\n`, [], 'manual'))
6262
})
6363
context('with DD_INJECTION_ENABLED', () => {
6464
useEnv({ DD_INJECTION_ENABLED, DD_TRACE_DEBUG })
@@ -122,7 +122,7 @@ true
122122
context('when node version is more than engines field', () => {
123123
useEnv({ NODE_OPTIONS })
124124

125-
it('should initialize the tracer, if no DD_INJECTION_ENABLED', () => doTest('true\n', [], 'ssi'))
125+
it('should initialize the tracer, if no DD_INJECTION_ENABLED', () => doTest('true\n', [], 'manual'))
126126
context('with DD_INJECTION_ENABLED', () => {
127127
useEnv({ DD_INJECTION_ENABLED })
128128

integration-tests/package-guardrails.spec.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,24 +50,24 @@ false
5050
context('when package is in range', () => {
5151
context('when bluebird is 2.9.0', () => {
5252
useSandbox(['bluebird@2.9.0'])
53-
it('should instrument the package', () => runTest('true\n', [], 'ssi'))
53+
it('should instrument the package', () => runTest('true\n', [], 'manual'))
5454
})
5555
context('when bluebird is 3.7.2', () => {
5656
useSandbox(['bluebird@3.7.2'])
57-
it('should instrument the package', () => runTest('true\n', [], 'ssi'))
57+
it('should instrument the package', () => runTest('true\n', [], 'manual'))
5858
})
5959
})
6060

6161
context('when package is in range (fastify)', () => {
6262
context('when fastify is latest', () => {
6363
useSandbox(['fastify'])
64-
it('should instrument the package', () => runTest('true\n', [], 'ssi'))
64+
it('should instrument the package', () => runTest('true\n', [], 'manual'))
6565
})
6666
context('when fastify is latest and logging enabled', () => {
6767
useSandbox(['fastify'])
6868
useEnv({ DD_TRACE_DEBUG })
6969
it('should instrument the package', () =>
70-
runTest('Application instrumentation bootstrapping complete\ntrue\n', [], 'ssi'))
70+
runTest('Application instrumentation bootstrapping complete\ntrue\n', [], 'manual'))
7171
})
7272
})
7373

packages/dd-trace/src/config.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const { updateConfig } = require('./telemetry')
1616
const telemetryMetrics = require('./telemetry/metrics')
1717
const { isInServerlessEnvironment, getIsGCPFunction, getIsAzureFunction } = require('./serverless')
1818
const {
19-
ORIGIN_KEY, GRPC_CLIENT_ERROR_STATUSES, GRPC_SERVER_ERROR_STATUSES, INSTRUMENTED_BY_SSI
19+
ORIGIN_KEY, GRPC_CLIENT_ERROR_STATUSES, GRPC_SERVER_ERROR_STATUSES
2020
} = require('./constants')
2121
const { appendRules } = require('./payload-tagging/config')
2222
const { getEnvironmentVariable, getEnvironmentVariables } = require('./config-helper')
@@ -925,6 +925,7 @@ class Config {
925925
this._setString(env, 'iast.telemetryVerbosity', DD_IAST_TELEMETRY_VERBOSITY)
926926
this._setBoolean(env, 'iast.stackTrace.enabled', DD_IAST_STACK_TRACE_ENABLED)
927927
this._setArray(env, 'injectionEnabled', DD_INJECTION_ENABLED)
928+
this._setString(env, 'instrumentationSource', DD_INJECTION_ENABLED ? 'ssi' : 'manual')
928929
this._setBoolean(env, 'injectForce', DD_INJECT_FORCE)
929930
this._setBoolean(env, 'isAzureFunction', getIsAzureFunction())
930931
this._setBoolean(env, 'isGCPFunction', getIsGCPFunction())
@@ -1150,9 +1151,6 @@ class Config {
11501151
opts['iast.securityControlsConfiguration'] = options.iast?.securityControlsConfiguration
11511152
this._setBoolean(opts, 'iast.stackTrace.enabled', options.iast?.stackTrace?.enabled)
11521153
this._setString(opts, 'iast.telemetryVerbosity', options.iast && options.iast.telemetryVerbosity)
1153-
if (options[INSTRUMENTED_BY_SSI]) {
1154-
this._setString(opts, 'instrumentationSource', options[INSTRUMENTED_BY_SSI])
1155-
}
11561154
this._setBoolean(opts, 'isCiVisibility', options.isCiVisibility)
11571155
this._setBoolean(opts, 'legacyBaggageEnabled', options.legacyBaggageEnabled)
11581156
this._setBoolean(opts, 'llmobs.agentlessEnabled', options.llmobs?.agentlessEnabled)

packages/dd-trace/src/constants.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,5 @@ module.exports = {
5353
SPAN_POINTER_DIRECTION: Object.freeze({
5454
UPSTREAM: 'u',
5555
DOWNSTREAM: 'd'
56-
}),
57-
INSTRUMENTED_BY_SSI: Symbol('_dd.instrumented.by.ssi')
56+
})
5857
}

packages/dd-trace/test/config.spec.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -802,6 +802,7 @@ describe('Config', () => {
802802
{ name: 'injectForce', value: false, origin: 'env_var' },
803803
{ name: 'injectionEnabled', value: ['tracer'], origin: 'env_var' },
804804
{ name: 'instrumentation_config_id', value: 'abcdef123', origin: 'env_var' },
805+
{ name: 'instrumentationSource', value: 'ssi', origin: 'env_var' },
805806
{ name: 'isGCPFunction', value: false, origin: 'env_var' },
806807
{ name: 'langchain.spanCharLimit', value: 50, origin: 'env_var' },
807808
{ name: 'langchain.spanPromptCompletionSampleRate', value: 0.5, origin: 'env_var' },

0 commit comments

Comments
 (0)