Skip to content

Commit 8b1c7f6

Browse files
committed
Add regression test for always off sampler
1 parent e753e4c commit 8b1c7f6

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

tests/integration/instrumentation/Symfony/OtelSdkBundle/DependencyInjection/OtelSdkExtensionTest.php

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,14 @@ public function testSamplers(): void
102102
{
103103
$this->loadTestData('sampler');
104104

105+
$sampler = $this->getDefinitionByClass(SDK\Trace\TracerProvider::class)
106+
->getArgument(1);
107+
108+
$this->assertReference(
109+
SDK\Trace\Sampler\ParentBased::class,
110+
$sampler
111+
);
112+
105113
$parent = $this->getDefinitionByClass(SDK\Trace\Sampler\ParentBased::class);
106114
$arguments = $parent->getArguments();
107115

@@ -132,6 +140,34 @@ public function testSamplers(): void
132140
);
133141
}
134142

143+
public function testAlwaysOffRootSamplerRegression(): void
144+
{
145+
$data = $this->retrieveTestData('simple');
146+
$data['trace']['sampler'] = 'always_off';
147+
148+
$this->load(
149+
self::wrapConfig(
150+
$data
151+
)
152+
);
153+
154+
$sampler = $this->getDefinitionByClass(SDK\Trace\TracerProvider::class)
155+
->getArgument(1);
156+
157+
$this->assertReference(
158+
SDK\Trace\Sampler\ParentBased::class,
159+
$sampler
160+
);
161+
162+
$parent = $this->getDefinitionByClass(SDK\Trace\Sampler\ParentBased::class);
163+
$arguments = $parent->getArguments();
164+
165+
$this->assertReference(
166+
SDK\Trace\Sampler\AlwaysOffSampler::class,
167+
$arguments[0]
168+
);
169+
}
170+
135171
/**
136172
* @throws Exception
137173
*/

0 commit comments

Comments
 (0)