File tree Expand file tree Collapse file tree
instrumentation/buildtool/+matlab/+buildtool/+plugins Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -132,6 +132,12 @@ function runTask(plugin, pluginData)
132132
133133% Use the same configuration as PADV
134134function extcontextscope = configureOTel()
135+
136+ % Skip configuration if NO_MBT_OTEL_CONFIG set
137+ if (getenv(" NO_MBT_OTEL_CONFIG" ))
138+ return ;
139+ end
140+
135141% populate resource attributes
136142otelservicename = " buildtool" ;
137143otelresource = dictionary(" service.name" , otelservicename );
@@ -174,6 +180,11 @@ function runTask(plugin, pluginData)
174180% Use the same cleanup as PADV
175181function cleanupOTel(span )
176182
183+ % Skip cleanup if NO_MBT_OTEL_CONFIG set
184+ if (getenv(" NO_MBT_OTEL_CONFIG" ))
185+ return ;
186+ end
187+
177188timeout = 5 ;
178189
179190% end the input span before cleaning up
Original file line number Diff line number Diff line change @@ -522,6 +522,29 @@ function runningSeveralTasksProducesCorrectMetrics(testCase)
522522 testCase .verifyEqual(metrics(5 ).name, ' buildtool.tasks.successful' );
523523 testCase .verifyEqual(metrics(5 ).sum.dataPoints.asDouble, 3 );
524524 end
525+
526+ function buildToolDoesNotConfigureOTelWhenEnvVariableSet(testCase )
527+ testCase .assumeFalse(isMATLABReleaseOlderThan(" R2026a" ));
528+
529+ % Restore environment variable
530+ testCase .addTeardown(@()setenv(" NO_MBT_OTEL_CONFIG" , " " ));
531+
532+ % Set environment variable
533+ setenv(" NO_MBT_OTEL_CONFIG" , " 1" );
534+
535+ % Create plan with 1 successful task
536+ plan = buildplan();
537+ plan(" task" ) = matlab .buildtool .Task();
538+
539+ % Run build
540+ testCase .BuildRunner .run(plan , " task" );
541+
542+ % Get results
543+ results = readJsonResults(testCase );
544+
545+ % Verify results are empty since we never set up any providers
546+ testCase .verifyEmpty(results );
547+ end
525548 end
526549end
527550
You can’t perform that action at this time.
0 commit comments