@@ -11,6 +11,8 @@ const WallProfiler = require('../../src/profiling/profilers/wall')
11
11
const SpaceProfiler = require ( '../../src/profiling/profilers/space' )
12
12
const { ConsoleLogger } = require ( '../../src/profiling/loggers/console' )
13
13
14
+ const samplingContextsAvailable = process . platform !== 'win32'
15
+
14
16
describe ( 'config' , ( ) => {
15
17
let Config
16
18
let env
@@ -48,7 +50,7 @@ describe('config', () => {
48
50
expect ( config . logger ) . to . be . an . instanceof ( ConsoleLogger )
49
51
expect ( config . exporters [ 0 ] ) . to . be . an . instanceof ( AgentExporter )
50
52
expect ( config . profilers [ 0 ] ) . to . be . an . instanceof ( WallProfiler )
51
- expect ( config . profilers [ 0 ] . codeHotspotsEnabled ( ) ) . true
53
+ expect ( config . profilers [ 0 ] . codeHotspotsEnabled ( ) ) . to . equal ( samplingContextsAvailable )
52
54
expect ( config . profilers [ 1 ] ) . to . be . an . instanceof ( SpaceProfiler )
53
55
expect ( config . v8ProfilerBugWorkaroundEnabled ) . true
54
56
expect ( config . cpuProfilingEnabled ) . false
@@ -142,7 +144,7 @@ describe('config', () => {
142
144
expect ( config . profilers ) . to . be . an ( 'array' )
143
145
expect ( config . profilers . length ) . to . equal ( 1 )
144
146
expect ( config . profilers [ 0 ] ) . to . be . an . instanceOf ( WallProfiler )
145
- expect ( config . profilers [ 0 ] . codeHotspotsEnabled ( ) ) . true
147
+ expect ( config . profilers [ 0 ] . codeHotspotsEnabled ( ) ) . to . equal ( samplingContextsAvailable )
146
148
expect ( config . v8ProfilerBugWorkaroundEnabled ) . false
147
149
expect ( config . cpuProfilingEnabled ) . true
148
150
} )
@@ -181,6 +183,10 @@ describe('config', () => {
181
183
} )
182
184
183
185
it ( 'should prioritize options over env variables' , ( ) => {
186
+ if ( ! samplingContextsAvailable ) {
187
+ return
188
+ }
189
+
184
190
process . env = {
185
191
DD_PROFILING_PROFILERS : 'space' ,
186
192
DD_PROFILING_ENDPOINT_COLLECTION_ENABLED : '1'
@@ -202,6 +208,10 @@ describe('config', () => {
202
208
} )
203
209
204
210
it ( 'should prioritize non-experimental env variables and warn about experimental ones' , ( ) => {
211
+ if ( ! samplingContextsAvailable ) {
212
+ return
213
+ }
214
+
205
215
process . env = {
206
216
DD_PROFILING_PROFILERS : 'wall' ,
207
217
DD_PROFILING_CODEHOTSPOTS_ENABLED : '0' ,
@@ -238,6 +248,30 @@ describe('config', () => {
238
248
expect ( config . profilers [ 0 ] . endpointCollectionEnabled ( ) ) . false
239
249
} )
240
250
251
+ it ( 'should prevent accidentally enabling code hotspots' , ( ) => {
252
+ if ( samplingContextsAvailable ) {
253
+ return
254
+ }
255
+
256
+ const options = {
257
+ codeHotspotsEnabled : true
258
+ }
259
+ // eslint-disable-next-line no-new
260
+ expect ( ( ) => { new Config ( options ) } ) . to . throw ( 'Code hotspots not supported on ' )
261
+ } )
262
+
263
+ it ( 'should prevent accidentally enabling endpoint collection' , ( ) => {
264
+ if ( samplingContextsAvailable ) {
265
+ return
266
+ }
267
+
268
+ const options = {
269
+ endpointCollection : true
270
+ }
271
+ // eslint-disable-next-line no-new
272
+ expect ( ( ) => { new Config ( options ) } ) . to . throw ( 'Endpoint collection not supported on ' )
273
+ } )
274
+
241
275
it ( 'should support tags' , ( ) => {
242
276
const tags = {
243
277
env : 'dev'
0 commit comments