2424namespace ElasticApmTests \ComponentTests \Util ;
2525
2626use Elastic \Apm \Impl \AutoInstrument \AutoInstrumentationBase ;
27+ use Elastic \Apm \Impl \Config \OptionDefaultValues ;
2728use Elastic \Apm \Impl \Config \OptionNames ;
2829use Elastic \Apm \Impl \GlobalTracerHolder ;
2930use Elastic \Apm \Impl \Log \Level as LogLevel ;
@@ -184,6 +185,7 @@ protected function verifyOneTransactionNoSpans(DataFromAgent $dataFromAgent): Tr
184185 /**
185186 * @param class-string<AutoInstrumentationBase> $instrClassName
186187 * @param string[] $expectedNames
188+ * @param bool $isEnabledByDefault
187189 *
188190 * @return void
189191 */
@@ -197,7 +199,8 @@ protected static function implTestIsAutoInstrumentationEnabled(string $instrClas
197199 $ actualNames = $ instr ->keywords ();
198200 $ actualNames [] = $ instr ->name ();
199201 self ::assertEqualAsSets ($ expectedNames , $ actualNames );
200- self ::assertTrue ($ instr ->isEnabled ());
202+ $ isEnabledByDefault = OptionDefaultValues::AST_PROCESS_ENABLED || (!$ instr ->requiresUserlandCodeInstrumentation ());
203+ self ::assertSame ($ isEnabledByDefault , $ instr ->isEnabled ());
201204
202205 /**
203206 * @param string $name
@@ -238,7 +241,7 @@ protected static function implTestIsAutoInstrumentationEnabled(string $instrClas
238241 $ dbgCtx ->clearCurrentSubScope (['disableInstrumentationsOptVal ' => $ disableInstrumentationsOptVal ]);
239242 $ tracer = self ::buildTracerForTests ()->withConfig (OptionNames::DISABLE_INSTRUMENTATIONS , $ disableInstrumentationsOptVal )->build ();
240243 $ instr = new $ instrClassName ($ tracer );
241- self ::assertTrue ( $ instr ->isEnabled ());
244+ self ::assertSame ( $ isEnabledByDefault , $ instr ->isEnabled ());
242245 }
243246 $ dbgCtx ->popSubScope ();
244247
0 commit comments