Skip to content

Commit d779b00

Browse files
authored
Add new strictTracePropagation option (#1834)
1 parent 795006b commit d779b00

4 files changed

Lines changed: 35 additions & 0 deletions

File tree

phpstan-baseline.neon

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,11 @@ parameters:
265265
count: 1
266266
path: src/Options.php
267267

268+
-
269+
message: "#^Method Sentry\\\\Options\\:\\:isStrictTracePropagationEnabled\\(\\) should return bool but returns mixed\\.$#"
270+
count: 1
271+
path: src/Options.php
272+
268273
-
269274
message: "#^Method Sentry\\\\Options\\:\\:shouldAttachMetricCodeLocations\\(\\) should return bool but returns mixed\\.$#"
270275
count: 1

src/Options.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -668,6 +668,26 @@ public function setTracePropagationTargets(array $tracePropagationTargets): self
668668
return $this;
669669
}
670670

671+
/**
672+
* Returns whether strict trace propagation is enabled or not.
673+
*/
674+
public function isStrictTracePropagationEnabled(): bool
675+
{
676+
return $this->options['strict_trace_propagation'];
677+
}
678+
679+
/**
680+
* Sets if strict trace propagation should be enabled or not.
681+
*/
682+
public function enableStrictTracePropagation(bool $strictTracePropagation): self
683+
{
684+
$options = array_merge($this->options, ['strict_trace_propagation' => $strictTracePropagation]);
685+
686+
$this->options = $this->resolver->resolve($options);
687+
688+
return $this;
689+
}
690+
671691
/**
672692
* Gets a list of default tags for events.
673693
*
@@ -1186,6 +1206,7 @@ private function configureOptions(OptionsResolver $resolver): void
11861206
return null;
11871207
},
11881208
'trace_propagation_targets' => null,
1209+
'strict_trace_propagation' => false,
11891210
'tags' => [],
11901211
'error_types' => null,
11911212
'max_breadcrumbs' => self::DEFAULT_MAX_BREADCRUMBS,
@@ -1234,6 +1255,7 @@ private function configureOptions(OptionsResolver $resolver): void
12341255
$resolver->setAllowedTypes('ignore_exceptions', 'string[]');
12351256
$resolver->setAllowedTypes('ignore_transactions', 'string[]');
12361257
$resolver->setAllowedTypes('trace_propagation_targets', ['null', 'string[]']);
1258+
$resolver->setAllowedTypes('strict_trace_propagation', 'bool');
12371259
$resolver->setAllowedTypes('tags', 'string[]');
12381260
$resolver->setAllowedTypes('error_types', ['null', 'int']);
12391261
$resolver->setAllowedTypes('max_breadcrumbs', 'int');

src/functions.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
* server_name?: string,
5858
* spotlight?: bool,
5959
* spotlight_url?: string,
60+
* strict_trace_propagation?: bool,
6061
* tags?: array<string>,
6162
* trace_propagation_targets?: array<string>|null,
6263
* traces_sample_rate?: float|int|null,

tests/OptionsTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,13 @@ static function (): void {},
278278
'setTracePropagationTargets',
279279
];
280280

281+
yield [
282+
'strict_trace_propagation',
283+
true,
284+
'isStrictTracePropagationEnabled',
285+
'enableStrictTracePropagation',
286+
];
287+
281288
yield [
282289
'before_breadcrumb',
283290
static function (): void {},

0 commit comments

Comments
 (0)