Skip to content

Commit 71c3ddd

Browse files
authored
ensuring that options tags will not send array that will break the span (#13)
1 parent c1cca00 commit 71c3ddd

File tree

1 file changed

+22
-7
lines changed

1 file changed

+22
-7
lines changed

src/Adapter/JaegerTracerFactory.php

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,21 @@ public function make(string $name): Tracer
4646

4747
private function parseConfig(): array
4848
{
49+
$options = $this->getConfig('options', [
50+
'sampler' => [
51+
'type' => SAMPLER_TYPE_CONST,
52+
'param' => true,
53+
],
54+
'logging' => false
55+
]);
56+
57+
if (isset($options['tags'])) {
58+
$options['tags'] = $this->sanitizeTags($options['tags']);
59+
}
60+
4961
return [
5062
$this->getConfig('name', 'skeleton'),
51-
$this->getConfig('options', [
52-
'sampler' => [
53-
'type' => SAMPLER_TYPE_CONST,
54-
'param' => true,
55-
],
56-
'logging' => false,
57-
]),
63+
$options
5864
];
5965
}
6066

@@ -67,4 +73,13 @@ private function getPrefix(): string
6773
{
6874
return rtrim($this->prefix . $this->name, '.') . '.';
6975
}
76+
77+
private function sanitizeTags(array $tags = []): array
78+
{
79+
$tagsSanitized = [];
80+
foreach ($tags as $key => $value) {
81+
$tagsSanitized[$key] = (is_array($value)) ? $value[0] : $value;
82+
}
83+
return $tagsSanitized;
84+
}
7085
}

0 commit comments

Comments
 (0)