Skip to content

Commit 37eb608

Browse files
committed
fixed: tracing working
1 parent 15a364a commit 37eb608

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/Elastic/Monolog/Formatter/ElasticCommonSchemaFormatter.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ protected function normalize($data, int $depth = 0)
6969
return $data->jsonSerialize();
7070
}
7171

72+
if ($data instanceof EcsTracing) {
73+
return $data->jsonSerialize();
74+
}
75+
7276
return parent::normalize($data, $depth);
7377
}
7478

@@ -104,7 +108,8 @@ public function format(array $record): string
104108

105109
// Add Tracing Context
106110
if (isset($inRecord['context']['tracing']['Elastic\Types\Tracing']) === true) {
107-
$outRecord += $inRecord['context']['tracing']['Elastic\Types\Tracing'];
111+
$outRecord['trace.id'] = $inRecord['context']['tracing']['Elastic\Types\Tracing']['trace.id'];
112+
$outRecord['span.id'] = $inRecord['context']['tracing']['Elastic\Types\Tracing']['span.id'];
108113
unset($inRecord['context']['tracing']);
109114
}
110115

0 commit comments

Comments
 (0)