Skip to content

Commit

Permalink
ensuring that options tags will not send array that will break the sp…
Browse files Browse the repository at this point in the history
…an (#13)
  • Loading branch information
luizmanhani committed Jun 6, 2024
1 parent c1cca00 commit 71c3ddd
Showing 1 changed file with 22 additions and 7 deletions.
29 changes: 22 additions & 7 deletions src/Adapter/JaegerTracerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,21 @@ public function make(string $name): Tracer

private function parseConfig(): array
{
$options = $this->getConfig('options', [
'sampler' => [
'type' => SAMPLER_TYPE_CONST,
'param' => true,
],
'logging' => false
]);

if (isset($options['tags'])) {
$options['tags'] = $this->sanitizeTags($options['tags']);
}

return [
$this->getConfig('name', 'skeleton'),
$this->getConfig('options', [
'sampler' => [
'type' => SAMPLER_TYPE_CONST,
'param' => true,
],
'logging' => false,
]),
$options
];
}

Expand All @@ -67,4 +73,13 @@ private function getPrefix(): string
{
return rtrim($this->prefix . $this->name, '.') . '.';
}

private function sanitizeTags(array $tags = []): array
{
$tagsSanitized = [];
foreach ($tags as $key => $value) {
$tagsSanitized[$key] = (is_array($value)) ? $value[0] : $value;
}
return $tagsSanitized;
}
}

0 comments on commit 71c3ddd

Please sign in to comment.