Skip to content

Commit

Permalink
feat(telemetry): adding instrumentation_config_id (#4283)
Browse files Browse the repository at this point in the history
* feat(telemetry): adding instrumentation_config_id

Similar to DataDog/dd-trace-py#8783
  • Loading branch information
stanistan authored May 9, 2024
1 parent f4adddc commit 52da415
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/dd-trace/src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,7 @@ class Config {
this._setValue(defaults, 'tracing', true)
this._setValue(defaults, 'url', undefined)
this._setValue(defaults, 'version', pkg.version)
this._setValue(defaults, 'instrumentation_config_id', undefined)
}

_applyEnvironment () {
Expand Down Expand Up @@ -549,6 +550,7 @@ class Config {
DD_IAST_REQUEST_SAMPLING,
DD_IAST_TELEMETRY_VERBOSITY,
DD_INSTRUMENTATION_TELEMETRY_ENABLED,
DD_INSTRUMENTATION_CONFIG_ID,
DD_LOGS_INJECTION,
DD_OPENAI_LOGS_ENABLED,
DD_OPENAI_SPAN_CHAR_LIMIT,
Expand Down Expand Up @@ -699,6 +701,7 @@ class Config {
DD_INSTRUMENTATION_TELEMETRY_ENABLED, // to comply with instrumentation telemetry specs
!(this._isInServerlessEnvironment() || JEST_WORKER_ID)
))
this._setString(env, 'instrumentation_config_id', DD_INSTRUMENTATION_CONFIG_ID)
this._setBoolean(env, 'telemetry.debug', DD_TELEMETRY_DEBUG)
this._setBoolean(env, 'telemetry.dependencyCollection', DD_TELEMETRY_DEPENDENCY_COLLECTION_ENABLED)
this._setValue(env, 'telemetry.heartbeatInterval', maybeInt(Math.floor(DD_TELEMETRY_HEARTBEAT_INTERVAL * 1000)))
Expand Down
4 changes: 4 additions & 0 deletions packages/dd-trace/test/config.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ describe('Config', () => {
expect(config).to.have.property('spanAttributeSchema', 'v0')
expect(config).to.have.property('spanComputePeerService', false)
expect(config).to.have.property('spanRemoveIntegrationFromService', false)
expect(config).to.have.property('instrumentation_config_id', undefined)
expect(config).to.have.deep.property('serviceMapping', {})
expect(config).to.have.nested.deep.property('tracePropagationStyle.inject', ['datadog', 'tracecontext'])
expect(config).to.have.nested.deep.property('tracePropagationStyle.extract', ['datadog', 'tracecontext'])
Expand Down Expand Up @@ -439,6 +440,7 @@ describe('Config', () => {
process.env.DD_INSTRUMENTATION_INSTALL_ID = '68e75c48-57ca-4a12-adfc-575c4b05fcbe'
process.env.DD_INSTRUMENTATION_INSTALL_TYPE = 'k8s_single_step'
process.env.DD_INSTRUMENTATION_INSTALL_TIME = '1703188212'
process.env.DD_INSTRUMENTATION_CONFIG_ID = 'abcdef123'

const config = new Config()

Expand All @@ -462,6 +464,7 @@ describe('Config', () => {
expect(config).to.have.property('spanAttributeSchema', 'v1')
expect(config).to.have.property('spanRemoveIntegrationFromService', true)
expect(config).to.have.property('spanComputePeerService', true)
expect(config).to.have.property('instrumentation_config_id', 'abcdef123')
expect(config.tags).to.include({ foo: 'bar', baz: 'qux' })
expect(config.tags).to.include({ service: 'service', version: '1.0.0', env: 'test' })
expect(config).to.have.deep.nested.property('sampler', {
Expand Down Expand Up @@ -554,6 +557,7 @@ describe('Config', () => {
{ name: 'iast.redactionValuePattern', value: 'REDACTION_VALUE_PATTERN', origin: 'env_var' },
{ name: 'iast.requestSampling', value: 40, origin: 'env_var' },
{ name: 'iast.telemetryVerbosity', value: 'DEBUG', origin: 'env_var' },
{ name: 'instrumentation_config_id', value: 'abcdef123', origin: 'env_var' },
{ name: 'isGCPFunction', value: false, origin: 'env_var' },
{ name: 'peerServiceMapping', value: { c: 'cc', d: 'dd' }, origin: 'env_var' },
{ name: 'port', value: '6218', origin: 'env_var' },
Expand Down

0 comments on commit 52da415

Please sign in to comment.