From 93f2068d0bee0301c663d783d688d61911fdb6f4 Mon Sep 17 00:00:00 2001 From: znerol Date: Fri, 18 Oct 2024 23:01:35 +0200 Subject: [PATCH] fix start timestamp in auto root span (#1413) --- src/SDK/Trace/AutoRootSpan.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/SDK/Trace/AutoRootSpan.php b/src/SDK/Trace/AutoRootSpan.php index ed4f6eb7f..69790cd61 100644 --- a/src/SDK/Trace/AutoRootSpan.php +++ b/src/SDK/Trace/AutoRootSpan.php @@ -8,6 +8,7 @@ use Http\Discovery\Psr17FactoryDiscovery; use Nyholm\Psr7Server\ServerRequestCreator; use OpenTelemetry\API\Behavior\LogsMessagesTrait; +use OpenTelemetry\API\Common\Time\ClockInterface; use OpenTelemetry\API\Globals; use OpenTelemetry\API\Trace\Span; use OpenTelemetry\API\Trace\SpanKind; @@ -47,7 +48,7 @@ public static function create(ServerRequestInterface $request): void : (int) microtime(true); $span = $tracer->spanBuilder($request->getMethod()) ->setSpanKind(SpanKind::KIND_SERVER) - ->setStartTimestamp((int) ($startTime*1_000_000)) + ->setStartTimestamp((int) ($startTime*ClockInterface::NANOS_PER_SECOND)) ->setParent($parent) ->setAttribute(TraceAttributes::URL_FULL, (string) $request->getUri()) ->setAttribute(TraceAttributes::HTTP_REQUEST_METHOD, $request->getMethod())