diff --git a/src/Span/Exporter/Pretty.php b/src/Span/Exporter/Pretty.php index 529dce9..f4f067a 100644 --- a/src/Span/Exporter/Pretty.php +++ b/src/Span/Exporter/Pretty.php @@ -62,6 +62,12 @@ public function export(Span $span): void } } + if (array_key_exists('level', $attributes)) { + $level = $attributes['level']; + unset($attributes['level']); + $attributes = ['level' => $level] + $attributes; + } + $maxKeyLen = 0; foreach (array_keys($attributes) as $key) { $maxKeyLen = max($maxKeyLen, strlen($key)); diff --git a/src/Span/Exporter/Stdout.php b/src/Span/Exporter/Stdout.php index 4aefa64..336b776 100644 --- a/src/Span/Exporter/Stdout.php +++ b/src/Span/Exporter/Stdout.php @@ -38,7 +38,15 @@ public function sample(Span $span): bool public function export(Span $span): void { - $data = ['action' => $span->getAction()] + $span->getAttributes(); + $attributes = $span->getAttributes(); + $ordered = []; + if (array_key_exists('level', $attributes)) { + $ordered['level'] = $attributes['level']; + unset($attributes['level']); + } + $ordered['action'] = $span->getAction(); + + $data = $ordered + $attributes; $error = $span->getError(); if ($error instanceof \Throwable) {