Skip to content

Commit 9d278d6

Browse files
committed
Fixed component tests assuming ast_process_enabled is true
1 parent 1ee49af commit 9d278d6

3 files changed

Lines changed: 7 additions & 3 deletions

File tree

agent/php/ElasticApm/Impl/Config/AllOptionsMetadata.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public static function get(): array
8282
/** @var array<string, OptionMetadata<mixed>> $value */
8383
$value = [
8484
OptionNames::API_KEY => new NullableStringOptionMetadata(),
85-
OptionNames::AST_PROCESS_ENABLED => new BoolOptionMetadata(/* defaultValue: */ true),
85+
OptionNames::AST_PROCESS_ENABLED => new BoolOptionMetadata(OptionDefaultValues::AST_PROCESS_ENABLED),
8686
OptionNames::AST_PROCESS_DEBUG_DUMP_CONVERTED_BACK_TO_SOURCE
8787
=> new BoolOptionMetadata(/* defaultValue: */ true),
8888
OptionNames::AST_PROCESS_DEBUG_DUMP_FOR_PATH_PREFIX => new NullableStringOptionMetadata(),

agent/php/ElasticApm/Impl/Config/OptionDefaultValues.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ final class OptionDefaultValues
3434
{
3535
use StaticClassTrait;
3636

37+
public const AST_PROCESS_ENABLED = false;
3738
public const SPAN_STACK_TRACE_MIN_DURATION = -1;
3839
public const STACK_TRACE_LIMIT = 50;
3940
public const TRANSACTION_MAX_SPANS = 500;

tests/ElasticApmTests/ComponentTests/Util/ComponentTestCaseBase.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
namespace ElasticApmTests\ComponentTests\Util;
2525

2626
use Elastic\Apm\Impl\AutoInstrument\AutoInstrumentationBase;
27+
use Elastic\Apm\Impl\Config\OptionDefaultValues;
2728
use Elastic\Apm\Impl\Config\OptionNames;
2829
use Elastic\Apm\Impl\GlobalTracerHolder;
2930
use 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

Comments
 (0)