Skip to content

Commit

Permalink
Add Support for DD_DOGSTATSD_HOST (#4989)
Browse files Browse the repository at this point in the history
* adding support for DD_DOGSTATSD_HOST

* fixing typo

* adding test
  • Loading branch information
mhlidd authored Dec 12, 2024
1 parent 04f3610 commit f2a3601
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/dd-trace/src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,7 @@ class Config {
DD_DATA_STREAMS_ENABLED,
DD_DBM_PROPAGATION_MODE,
DD_DOGSTATSD_HOSTNAME,
DD_DOGSTATSD_HOST,
DD_DOGSTATSD_PORT,
DD_DYNAMIC_INSTRUMENTATION_ENABLED,
DD_ENV,
Expand Down Expand Up @@ -739,7 +740,7 @@ class Config {
this._setBoolean(env, 'crashtracking.enabled', DD_CRASHTRACKING_ENABLED)
this._setBoolean(env, 'codeOriginForSpans.enabled', DD_CODE_ORIGIN_FOR_SPANS_ENABLED)
this._setString(env, 'dbmPropagationMode', DD_DBM_PROPAGATION_MODE)
this._setString(env, 'dogstatsd.hostname', DD_DOGSTATSD_HOSTNAME)
this._setString(env, 'dogstatsd.hostname', DD_DOGSTATSD_HOST || DD_DOGSTATSD_HOSTNAME)
this._setString(env, 'dogstatsd.port', DD_DOGSTATSD_PORT)
this._setBoolean(env, 'dsmEnabled', DD_DATA_STREAMS_ENABLED)
this._setBoolean(env, 'dynamicInstrumentationEnabled', DD_DYNAMIC_INSTRUMENTATION_ENABLED)
Expand Down
9 changes: 9 additions & 0 deletions packages/dd-trace/test/config.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1836,6 +1836,15 @@ describe('Config', () => {
expect(config.appsec.apiSecurity.enabled).to.be.true
})

it('should prioritize DD_DOGSTATSD_HOST over DD_DOGSTATSD_HOSTNAME', () => {
process.env.DD_DOGSTATSD_HOSTNAME = 'dsd-agent'
process.env.DD_DOGSTATSD_HOST = 'localhost'

const config = new Config()

expect(config).to.have.nested.property('dogstatsd.hostname', 'localhost')
})

context('auto configuration w/ unix domain sockets', () => {
context('on windows', () => {
it('should not be used', () => {
Expand Down

0 comments on commit f2a3601

Please sign in to comment.