@@ -71,7 +71,6 @@ describe('config', () => {
7171
7272 assert . deepStrictEqual ( config . tags , {
7373 service : 'node' ,
74- host : os . hostname ( ) ,
7574 } )
7675
7776 assert . ok ( config . logger instanceof ConsoleLogger )
@@ -94,12 +93,13 @@ describe('config', () => {
9493 profilers : 'space,wall' ,
9594 url : 'http://localhost:1234/' ,
9695 codeHotspotsEnabled : false ,
96+ reportHostname : true ,
9797 }
9898
9999 const config = new Config ( options )
100100
101101 assert . strictEqual ( config . service , options . service )
102- assert . strictEqual ( typeof config . host , 'string' )
102+ assert . strictEqual ( typeof config . tags . host , 'string' )
103103 assert . strictEqual ( config . version , options . version )
104104 assert . ok ( typeof config . tags === 'object' && config . tags !== null )
105105 assert . strictEqual ( typeof config . tags . host , 'string' )
@@ -121,6 +121,28 @@ describe('config', () => {
121121 }
122122 } )
123123
124+ it ( 'should not include host tag when reportHostname is false' , ( ) => {
125+ const config = new Config ( { reportHostname : false } )
126+
127+ assert . strictEqual ( config . tags . host , undefined )
128+ assert . ok ( ! ( 'host' in config . tags ) )
129+ } )
130+
131+ it ( 'should not include host tag when reportHostname is not set' , ( ) => {
132+ const config = new Config ( { } )
133+
134+ assert . strictEqual ( config . tags . host , undefined )
135+ assert . ok ( ! ( 'host' in config . tags ) )
136+ } )
137+
138+ it ( 'should include host tag when reportHostname is true' , ( ) => {
139+ const config = new Config ( { reportHostname : true } )
140+
141+ assert . strictEqual ( typeof config . tags . host , 'string' )
142+ assert . ok ( config . tags . host . length > 0 )
143+ assert . strictEqual ( config . tags . host , os . hostname ( ) )
144+ } )
145+
124146 it ( 'should filter out invalid profilers' , ( ) => {
125147 const errors = [ ]
126148 const options = {
@@ -444,7 +466,7 @@ describe('config', () => {
444466 } )
445467
446468 it ( 'should enable OOM heap profiler by default and use process as default strategy' , ( ) => {
447- const config = new Config ( )
469+ const config = new Config ( { reportHostname : true } )
448470
449471 if ( oomMonitoringSupported ) {
450472 assert . deepStrictEqual ( config . oomMonitoring , {
@@ -456,7 +478,7 @@ describe('config', () => {
456478 process . execPath ,
457479 path . normalize ( path . join ( __dirname , '../../src/profiling' , 'exporter_cli.js' ) ) ,
458480 'http://127.0.0.1:8126/' ,
459- `host:${ config . host } ,service:node,snapshot:on_oom` ,
481+ `host:${ config . tags . host } ,service:node,snapshot:on_oom` ,
460482 'space' ,
461483 ] ,
462484 } )
@@ -513,7 +535,7 @@ describe('config', () => {
513535 DD_PROFILING_EXPERIMENTAL_OOM_EXPORT_STRATEGIES : 'process,async,process' ,
514536 }
515537
516- const config = new Config ( { } )
538+ const config = new Config ( { reportHostname : true } )
517539
518540 assert . deepStrictEqual ( config . oomMonitoring , {
519541 enabled : true ,
@@ -524,7 +546,7 @@ describe('config', () => {
524546 process . execPath ,
525547 path . normalize ( path . join ( __dirname , '../../src/profiling' , 'exporter_cli.js' ) ) ,
526548 'http://127.0.0.1:8126/' ,
527- `host:${ config . host } ,service:node,snapshot:on_oom` ,
549+ `host:${ config . tags . host } ,service:node,snapshot:on_oom` ,
528550 'space' ,
529551 ] ,
530552 } )
0 commit comments