diff --git a/src/Instrumentation/CodeIgniter/composer.json b/src/Instrumentation/CodeIgniter/composer.json index 11989ef0..919bcddc 100644 --- a/src/Instrumentation/CodeIgniter/composer.json +++ b/src/Instrumentation/CodeIgniter/composer.json @@ -12,7 +12,7 @@ "ext-opentelemetry": "*", "codeigniter4/framework": ">=4.0", "open-telemetry/api": "^1.0.0beta10", - "open-telemetry/sem-conv": "^1" + "open-telemetry/sem-conv": "^1.22" }, "require-dev": { "friendsofphp/php-cs-fixer": "^3", diff --git a/src/Instrumentation/CodeIgniter/src/CodeIgniterInstrumentation.php b/src/Instrumentation/CodeIgniter/src/CodeIgniterInstrumentation.php index c0d548a0..07724170 100644 --- a/src/Instrumentation/CodeIgniter/src/CodeIgniterInstrumentation.php +++ b/src/Instrumentation/CodeIgniter/src/CodeIgniterInstrumentation.php @@ -68,11 +68,11 @@ public static function register(): void /** @psalm-suppress DeprecatedMethod */ $spanBuilder = $spanBuilder->setParent($parent) - ->setAttribute(TraceAttributes::HTTP_URL, (string) $request->getUri()) + ->setAttribute(TraceAttributes::URL_FULL, (string) $request->getUri()) /** @phan-suppress-next-line PhanDeprecatedFunction */ - ->setAttribute(TraceAttributes::HTTP_METHOD, $request->getMethod(true)) - ->setAttribute(TraceAttributes::HTTP_REQUEST_CONTENT_LENGTH, $request->getHeaderLine('Content-Length')) - ->setAttribute(TraceAttributes::HTTP_SCHEME, $request->getUri()->getScheme()); + ->setAttribute(TraceAttributes::HTTP_REQUEST_METHOD, $request->getMethod(true)) + ->setAttribute(TraceAttributes::HTTP_REQUEST_BODY_SIZE, $request->getHeaderLine('Content-Length')) + ->setAttribute(TraceAttributes::URL_SCHEME, $request->getUri()->getScheme()); } $span = $spanBuilder->startSpan(); @@ -97,9 +97,9 @@ public static function register(): void /** @psalm-suppress DeprecatedMethod */ /** @phan-suppress-next-line PhanDeprecatedFunction */ $statusCode = $response->getStatusCode(); - $span->setAttribute(TraceAttributes::HTTP_STATUS_CODE, $statusCode); - $span->setAttribute(TraceAttributes::HTTP_FLAVOR, $response->getProtocolVersion()); - $span->setAttribute(TraceAttributes::HTTP_RESPONSE_CONTENT_LENGTH, CodeIgniterInstrumentation::getResponseLength($response)); + $span->setAttribute(TraceAttributes::HTTP_RESPONSE_STATUS_CODE, $statusCode); + $span->setAttribute(TraceAttributes::NETWORK_PROTOCOL_VERSION, $response->getProtocolVersion()); + $span->setAttribute(TraceAttributes::HTTP_RESPONSE_BODY_SIZE, CodeIgniterInstrumentation::getResponseLength($response)); foreach ((array) (get_cfg_var('otel.instrumentation.http.response_headers') ?: []) as $header) { if ($response->hasHeader($header)) { diff --git a/src/Instrumentation/CodeIgniter/tests/Integration/CodeIgniterInstrumentationTest.php b/src/Instrumentation/CodeIgniter/tests/Integration/CodeIgniterInstrumentationTest.php index 603ebd40..f5d44885 100644 --- a/src/Instrumentation/CodeIgniter/tests/Integration/CodeIgniterInstrumentationTest.php +++ b/src/Instrumentation/CodeIgniter/tests/Integration/CodeIgniterInstrumentationTest.php @@ -26,13 +26,13 @@ public function test_success() $attributes = $this->storage[0]->getAttributes(); $this->assertCount(1, $this->storage); $this->assertEquals('HTTP GET', $this->storage[0]->getName()); - $this->assertEquals('http://example.com/index.php/home', $attributes->get(TraceAttributes::HTTP_URL)); - $this->assertEquals('GET', $attributes->get(TraceAttributes::HTTP_METHOD)); - $this->assertEquals('http', $attributes->get(TraceAttributes::HTTP_SCHEME)); + $this->assertEquals('http://example.com/index.php/home', $attributes->get(TraceAttributes::URL_FULL)); + $this->assertEquals('GET', $attributes->get(TraceAttributes::HTTP_REQUEST_METHOD)); + $this->assertEquals('http', $attributes->get(TraceAttributes::URL_SCHEME)); $this->assertEquals('Home.index', $attributes->get(TraceAttributes::HTTP_ROUTE)); - $this->assertEquals(200, $attributes->get(TraceAttributes::HTTP_STATUS_CODE)); - $this->assertEquals('1.1', $attributes->get(TraceAttributes::HTTP_FLAVOR)); - $this->assertGreaterThan(0, $attributes->get(TraceAttributes::HTTP_RESPONSE_CONTENT_LENGTH)); + $this->assertEquals(200, $attributes->get(TraceAttributes::HTTP_RESPONSE_STATUS_CODE)); + $this->assertEquals('1.1', $attributes->get(TraceAttributes::NETWORK_PROTOCOL_VERSION)); + $this->assertGreaterThan(0, $attributes->get(TraceAttributes::HTTP_RESPONSE_BODY_SIZE)); } public function test_exception() @@ -56,13 +56,13 @@ public function test_exception() $attributes = $this->storage[0]->getAttributes(); $this->assertCount(1, $this->storage); $this->assertEquals('HTTP GET', $this->storage[0]->getName()); - $this->assertEquals('http://example.com/index.php/exception', $attributes->get(TraceAttributes::HTTP_URL)); - $this->assertEquals('GET', $attributes->get(TraceAttributes::HTTP_METHOD)); - $this->assertEquals('http', $attributes->get(TraceAttributes::HTTP_SCHEME)); + $this->assertEquals('http://example.com/index.php/exception', $attributes->get(TraceAttributes::URL_FULL)); + $this->assertEquals('GET', $attributes->get(TraceAttributes::HTTP_REQUEST_METHOD)); + $this->assertEquals('http', $attributes->get(TraceAttributes::URL_SCHEME)); $this->assertEquals('Closure.index', $attributes->get(TraceAttributes::HTTP_ROUTE)); - $this->assertNull($attributes->get(TraceAttributes::HTTP_STATUS_CODE)); - $this->assertNull($attributes->get(TraceAttributes::HTTP_FLAVOR)); - $this->assertNull($attributes->get(TraceAttributes::HTTP_RESPONSE_CONTENT_LENGTH)); + $this->assertNull($attributes->get(TraceAttributes::HTTP_RESPONSE_STATUS_CODE)); + $this->assertNull($attributes->get(TraceAttributes::NETWORK_PROTOCOL_VERSION)); + $this->assertNull($attributes->get(TraceAttributes::HTTP_RESPONSE_BODY_SIZE)); $status = $this->storage[0]->getStatus(); $this->assertEquals('Error', $status->getCode()); diff --git a/src/Instrumentation/HttpAsyncClient/composer.json b/src/Instrumentation/HttpAsyncClient/composer.json index becbfc12..675b4b58 100644 --- a/src/Instrumentation/HttpAsyncClient/composer.json +++ b/src/Instrumentation/HttpAsyncClient/composer.json @@ -12,7 +12,7 @@ "php": "^8.0", "ext-opentelemetry": "*", "open-telemetry/api": "^1.0.0beta10", - "open-telemetry/sem-conv": "^1", + "open-telemetry/sem-conv": "^1.22", "php-http/httplug": "^2" }, "autoload": { diff --git a/src/Instrumentation/HttpAsyncClient/src/HttpAsyncClientInstrumentation.php b/src/Instrumentation/HttpAsyncClient/src/HttpAsyncClientInstrumentation.php index d198242d..60d13ed0 100644 --- a/src/Instrumentation/HttpAsyncClient/src/HttpAsyncClientInstrumentation.php +++ b/src/Instrumentation/HttpAsyncClient/src/HttpAsyncClientInstrumentation.php @@ -46,13 +46,13 @@ public static function register(): void ->spanBuilder(sprintf('HTTP %s', $request->getMethod())) ->setParent($parentContext) ->setSpanKind(SpanKind::KIND_CLIENT) - ->setAttribute(TraceAttributes::HTTP_URL, (string) $request->getUri()) - ->setAttribute(TraceAttributes::HTTP_METHOD, $request->getMethod()) - ->setAttribute(TraceAttributes::HTTP_FLAVOR, $request->getProtocolVersion()) + ->setAttribute(TraceAttributes::URL_FULL, (string) $request->getUri()) + ->setAttribute(TraceAttributes::HTTP_REQUEST_METHOD, $request->getMethod()) + ->setAttribute(TraceAttributes::NETWORK_PROTOCOL_VERSION, $request->getProtocolVersion()) ->setAttribute(TraceAttributes::USER_AGENT_ORIGINAL, $request->getHeaderLine('User-Agent')) - ->setAttribute(TraceAttributes::HTTP_REQUEST_CONTENT_LENGTH, $request->getHeaderLine('Content-Length')) - ->setAttribute(TraceAttributes::NET_PEER_NAME, $request->getUri()->getHost()) - ->setAttribute(TraceAttributes::NET_PEER_PORT, $request->getUri()->getPort()) + ->setAttribute(TraceAttributes::HTTP_REQUEST_BODY_SIZE, $request->getHeaderLine('Content-Length')) + ->setAttribute(TraceAttributes::SERVER_ADDRESS, $request->getUri()->getHost()) + ->setAttribute(TraceAttributes::SERVER_PORT, $request->getUri()->getPort()) ->setAttribute(TraceAttributes::CODE_FUNCTION, $function) ->setAttribute(TraceAttributes::CODE_NAMESPACE, $class) ->setAttribute(TraceAttributes::CODE_FILEPATH, $filename) @@ -96,9 +96,9 @@ public static function register(): void $promise->then( onFulfilled: function (ResponseInterface $response) use ($span) { - $span->setAttribute(TraceAttributes::HTTP_STATUS_CODE, $response->getStatusCode()); - $span->setAttribute(TraceAttributes::HTTP_FLAVOR, $response->getProtocolVersion()); - $span->setAttribute(TraceAttributes::HTTP_RESPONSE_CONTENT_LENGTH, $response->getHeaderLine('Content-Length')); + $span->setAttribute(TraceAttributes::HTTP_RESPONSE_STATUS_CODE, $response->getStatusCode()); + $span->setAttribute(TraceAttributes::NETWORK_PROTOCOL_VERSION, $response->getProtocolVersion()); + $span->setAttribute(TraceAttributes::HTTP_RESPONSE_BODY_SIZE, $response->getHeaderLine('Content-Length')); if ($response->getStatusCode() >= 400 && $response->getStatusCode() < 600) { $span->setStatus(StatusCode::STATUS_ERROR); } diff --git a/src/Instrumentation/IO/composer.json b/src/Instrumentation/IO/composer.json index b28271fd..67683615 100644 --- a/src/Instrumentation/IO/composer.json +++ b/src/Instrumentation/IO/composer.json @@ -11,7 +11,7 @@ "php": "^8.2", "ext-opentelemetry": "*", "open-telemetry/api": "^1.0.0beta10", - "open-telemetry/sem-conv": "^1" + "open-telemetry/sem-conv": "^1.22" }, "require-dev": { "friendsofphp/php-cs-fixer": "^3", diff --git a/src/Instrumentation/Laravel/composer.json b/src/Instrumentation/Laravel/composer.json index 83efc240..b704b724 100644 --- a/src/Instrumentation/Laravel/composer.json +++ b/src/Instrumentation/Laravel/composer.json @@ -13,7 +13,7 @@ "ext-opentelemetry": "*", "laravel/framework": ">=6.0", "open-telemetry/api": "^1.0.0beta10", - "open-telemetry/sem-conv": "^1" + "open-telemetry/sem-conv": "^1.22" }, "require-dev": { "friendsofphp/php-cs-fixer": "^3", diff --git a/src/Instrumentation/Laravel/src/HttpInstrumentation.php b/src/Instrumentation/Laravel/src/HttpInstrumentation.php index 1d5e9291..33fbeb85 100644 --- a/src/Instrumentation/Laravel/src/HttpInstrumentation.php +++ b/src/Instrumentation/Laravel/src/HttpInstrumentation.php @@ -40,16 +40,16 @@ public static function register(CachedInstrumentation $instrumentation): void $parent = Globals::propagator()->extract($request, HeadersPropagator::instance()); $span = $builder ->setParent($parent) - ->setAttribute(TraceAttributes::HTTP_URL, $request->fullUrl()) - ->setAttribute(TraceAttributes::HTTP_METHOD, $request->method()) - ->setAttribute(TraceAttributes::HTTP_REQUEST_CONTENT_LENGTH, $request->header('Content-Length')) - ->setAttribute(TraceAttributes::HTTP_SCHEME, $request->getScheme()) - ->setAttribute(TraceAttributes::HTTP_FLAVOR, $request->getProtocolVersion()) - ->setAttribute(TraceAttributes::HTTP_CLIENT_IP, $request->ip()) - ->setAttribute(TraceAttributes::HTTP_TARGET, self::httpTarget($request)) - ->setAttribute(TraceAttributes::NET_HOST_NAME, self::httpHostName($request)) - ->setAttribute(TraceAttributes::NET_HOST_PORT, $request->getPort()) - ->setAttribute(TraceAttributes::NET_PEER_PORT, $request->server('REMOTE_PORT')) + ->setAttribute(TraceAttributes::URL_FULL, $request->fullUrl()) + ->setAttribute(TraceAttributes::HTTP_REQUEST_METHOD, $request->method()) + ->setAttribute(TraceAttributes::HTTP_REQUEST_BODY_SIZE, $request->header('Content-Length')) + ->setAttribute(TraceAttributes::URL_SCHEME, $request->getScheme()) + ->setAttribute(TraceAttributes::NETWORK_PROTOCOL_VERSION, $request->getProtocolVersion()) + ->setAttribute(TraceAttributes::NETWORK_PEER_ADDRESS, $request->ip()) + ->setAttribute(TraceAttributes::URL_PATH, self::httpTarget($request)) + ->setAttribute(TraceAttributes::SERVER_ADDRESS, self::httpHostName($request)) + ->setAttribute(TraceAttributes::SERVER_PORT, $request->getPort()) + ->setAttribute(TraceAttributes::CLIENT_PORT, $request->server('REMOTE_PORT')) ->setAttribute(TraceAttributes::USER_AGENT_ORIGINAL, $request->userAgent()) ->startSpan(); $request->attributes->set(SpanInterface::class, $span); @@ -75,9 +75,9 @@ public static function register(CachedInstrumentation $instrumentation): void if ($response->getStatusCode() >= 400) { $span->setStatus(StatusCode::STATUS_ERROR); } - $span->setAttribute(TraceAttributes::HTTP_STATUS_CODE, $response->getStatusCode()); - $span->setAttribute(TraceAttributes::HTTP_FLAVOR, $response->getProtocolVersion()); - $span->setAttribute(TraceAttributes::HTTP_RESPONSE_CONTENT_LENGTH, $response->headers->get('Content-Length')); + $span->setAttribute(TraceAttributes::HTTP_RESPONSE_STATUS_CODE, $response->getStatusCode()); + $span->setAttribute(TraceAttributes::NETWORK_PROTOCOL_VERSION, $response->getProtocolVersion()); + $span->setAttribute(TraceAttributes::HTTP_RESPONSE_BODY_SIZE, $response->headers->get('Content-Length')); } $span->end(); diff --git a/src/Instrumentation/Laravel/src/Watchers/ClientRequestWatcher.php b/src/Instrumentation/Laravel/src/Watchers/ClientRequestWatcher.php index 6e2226f5..73fa1714 100644 --- a/src/Instrumentation/Laravel/src/Watchers/ClientRequestWatcher.php +++ b/src/Instrumentation/Laravel/src/Watchers/ClientRequestWatcher.php @@ -47,13 +47,13 @@ public function recordRequest(RequestSending $request): void $span = $this->instrumentation->tracer()->spanBuilder('HTTP ' . $request->request->method()) ->setSpanKind(SpanKind::KIND_CLIENT) ->setAttributes([ - TraceAttributes::HTTP_METHOD => $request->request->method(), - TraceAttributes::HTTP_URL => $processedUrl, - TraceAttributes::HTTP_TARGET => $parsedUrl['path'] ?? '', + TraceAttributes::HTTP_REQUEST_METHOD => $request->request->method(), + TraceAttributes::URL_FULL => $processedUrl, + TraceAttributes::URL_PATH => $parsedUrl['path'] ?? '', TraceAttributes::HTTP_HOST => $parsedUrl['host'] ?? '', - TraceAttributes::HTTP_SCHEME => $parsedUrl['scheme'] ?? '', - TraceAttributes::NET_PEER_NAME => $parsedUrl['host'] ?? '', - TraceAttributes::NET_PEER_PORT => $parsedUrl['port'] ?? '', + TraceAttributes::URL_SCHEME => $parsedUrl['scheme'] ?? '', + TraceAttributes::SERVER_ADDRESS => $parsedUrl['host'] ?? '', + TraceAttributes::SERVER_PORT => $parsedUrl['port'] ?? '', ]) ->startSpan(); $this->spans[$this->createRequestComparisonHash($request->request)] = $span; @@ -84,8 +84,8 @@ public function recordResponse(ResponseReceived $request): void } $span->setAttributes([ - TraceAttributes::HTTP_STATUS_CODE => $request->response->status(), - TraceAttributes::HTTP_RESPONSE_CONTENT_LENGTH => $request->response->header('Content-Length'), + TraceAttributes::HTTP_RESPONSE_STATUS_CODE => $request->response->status(), + TraceAttributes::HTTP_RESPONSE_BODY_SIZE => $request->response->header('Content-Length'), ]); $this->maybeRecordError($span, $request->response); diff --git a/src/Instrumentation/Laravel/tests/Integration/LaravelInstrumentationTest.php b/src/Instrumentation/Laravel/tests/Integration/LaravelInstrumentationTest.php index 76dbdb89..f504938f 100644 --- a/src/Instrumentation/Laravel/tests/Integration/LaravelInstrumentationTest.php +++ b/src/Instrumentation/Laravel/tests/Integration/LaravelInstrumentationTest.php @@ -82,7 +82,7 @@ public function test_cache_log_db(): void $this->assertCount(2, $this->storage); $span = $this->storage->offsetGet(1); $this->assertSame('HTTP GET', $span->getName()); - $this->assertSame('http://localhost/hello', $span->getAttributes()->get(TraceAttributes::HTTP_URL)); + $this->assertSame('http://localhost/hello', $span->getAttributes()->get(TraceAttributes::URL_FULL)); $this->assertCount(5, $span->getEvents()); $this->assertSame('cache set', $span->getEvents()[0]->getName()); $this->assertSame('Log info', $span->getEvents()[1]->getName()); diff --git a/src/Instrumentation/MongoDB/composer.json b/src/Instrumentation/MongoDB/composer.json index 52e7e3d6..806cec24 100644 --- a/src/Instrumentation/MongoDB/composer.json +++ b/src/Instrumentation/MongoDB/composer.json @@ -13,7 +13,7 @@ "ext-json": "*", "mongodb/mongodb": "^1.15", "open-telemetry/api": "^1.0.0beta12", - "open-telemetry/sem-conv": "^1" + "open-telemetry/sem-conv": "^1.22" }, "require-dev": { "friendsofphp/php-cs-fixer": "^3", diff --git a/src/Instrumentation/MongoDB/src/MongoDBInstrumentationSubscriber.php b/src/Instrumentation/MongoDB/src/MongoDBInstrumentationSubscriber.php index 5dd5d7fe..700de8ff 100644 --- a/src/Instrumentation/MongoDB/src/MongoDBInstrumentationSubscriber.php +++ b/src/Instrumentation/MongoDB/src/MongoDBInstrumentationSubscriber.php @@ -61,9 +61,9 @@ public function commandStarted(CommandStartedEvent $event): void ->setAttribute(TraceAttributes::DB_NAME, $databaseName) ->setAttribute(TraceAttributes::DB_CONNECTION_STRING, $connectionString) ->setAttribute(TraceAttributes::DB_OPERATION, $commandName) - ->setAttribute(TraceAttributes::NET_PEER_NAME, $isSocket ? null : $host) - ->setAttribute(TraceAttributes::NET_PEER_PORT, $isSocket ? null : $port) - ->setAttribute(TraceAttributes::NET_TRANSPORT, $isSocket ? 'unix' : 'tcp') + ->setAttribute(TraceAttributes::SERVER_ADDRESS, $isSocket ? null : $host) + ->setAttribute(TraceAttributes::SERVER_PORT, $isSocket ? null : $port) + ->setAttribute(TraceAttributes::NETWORK_TRANSPORT, $isSocket ? 'unix' : 'tcp') ->setAttribute(TraceAttributes::DB_STATEMENT, ($this->commandSerializer)($command)) ->setAttribute(TraceAttributes::DB_MONGODB_COLLECTION, $collectionName) ->setAttribute(MongoDBTraceAttributes::DB_MONGODB_MASTER, $info['ismaster'] ?? null) diff --git a/src/Instrumentation/MongoDB/tests/Integration/MongoDBInstrumentationTest.php b/src/Instrumentation/MongoDB/tests/Integration/MongoDBInstrumentationTest.php index 5dfbd912..44b1f755 100644 --- a/src/Instrumentation/MongoDB/tests/Integration/MongoDBInstrumentationTest.php +++ b/src/Instrumentation/MongoDB/tests/Integration/MongoDBInstrumentationTest.php @@ -68,9 +68,9 @@ public function test_mongodb_find_one(): void self::assertSame('mongodb://127.0.0.1:27017/db', $attributes->get(TraceAttributes::DB_CONNECTION_STRING)); self::assertSame('find', $attributes->get(TraceAttributes::DB_OPERATION)); self::assertSame(self::COLLECTION_NAME, $attributes->get(TraceAttributes::DB_MONGODB_COLLECTION)); - self::assertSame('127.0.0.1', $attributes->get(TraceAttributes::NET_PEER_NAME)); - self::assertSame(27017, $attributes->get(TraceAttributes::NET_PEER_PORT)); - self::assertSame('tcp', $attributes->get(TraceAttributes::NET_TRANSPORT)); + self::assertSame('127.0.0.1', $attributes->get(TraceAttributes::SERVER_ADDRESS)); + self::assertSame(27017, $attributes->get(TraceAttributes::SERVER_PORT)); + self::assertSame('tcp', $attributes->get(TraceAttributes::NETWORK_TRANSPORT)); self::assertTrue($attributes->get(MongoDBTraceAttributes::DB_MONGODB_MASTER)); self::assertFalse($attributes->get(MongoDBTraceAttributes::DB_MONGODB_READ_ONLY)); self::assertIsNumeric($attributes->get(MongoDBTraceAttributes::DB_MONGODB_CONNECTION_ID)); diff --git a/src/Instrumentation/PDO/composer.json b/src/Instrumentation/PDO/composer.json index d897de87..e1bfe431 100644 --- a/src/Instrumentation/PDO/composer.json +++ b/src/Instrumentation/PDO/composer.json @@ -12,7 +12,7 @@ "ext-pdo": "*", "ext-opentelemetry": "*", "open-telemetry/api": "^1.0.0beta10", - "open-telemetry/sem-conv": "^1" + "open-telemetry/sem-conv": "^1.22" }, "require-dev": { "friendsofphp/php-cs-fixer": "^3", diff --git a/src/Instrumentation/Psr15/composer.json b/src/Instrumentation/Psr15/composer.json index d820d3aa..3150dc2b 100644 --- a/src/Instrumentation/Psr15/composer.json +++ b/src/Instrumentation/Psr15/composer.json @@ -12,7 +12,7 @@ "php": "^8.0", "ext-opentelemetry": "*", "open-telemetry/api": "^1.0.0beta10", - "open-telemetry/sem-conv": "^1", + "open-telemetry/sem-conv": "^1.22", "psr/http-server-middleware": "^1" }, "autoload": { diff --git a/src/Instrumentation/Psr15/src/Psr15Instrumentation.php b/src/Instrumentation/Psr15/src/Psr15Instrumentation.php index 9e3df4ca..4cf63632 100644 --- a/src/Instrumentation/Psr15/src/Psr15Instrumentation.php +++ b/src/Instrumentation/Psr15/src/Psr15Instrumentation.php @@ -89,10 +89,10 @@ public static function register(): void $parent = Globals::propagator()->extract($request->getHeaders()); $span = $builder ->setParent($parent) - ->setAttribute(TraceAttributes::HTTP_URL, $request->getUri()->__toString()) - ->setAttribute(TraceAttributes::HTTP_METHOD, $request->getMethod()) - ->setAttribute(TraceAttributes::HTTP_REQUEST_CONTENT_LENGTH, $request->getHeaderLine('Content-Length')) - ->setAttribute(TraceAttributes::HTTP_SCHEME, $request->getUri()->getScheme()) + ->setAttribute(TraceAttributes::URL_FULL, $request->getUri()->__toString()) + ->setAttribute(TraceAttributes::HTTP_REQUEST_METHOD, $request->getMethod()) + ->setAttribute(TraceAttributes::HTTP_REQUEST_BODY_SIZE, $request->getHeaderLine('Content-Length')) + ->setAttribute(TraceAttributes::URL_SCHEME, $request->getUri()->getScheme()) ->startSpan(); $request = $request->withAttribute(SpanInterface::class, $span); } else { @@ -117,9 +117,9 @@ public static function register(): void if ($response->getStatusCode() >= 400) { $span->setStatus(StatusCode::STATUS_ERROR); } - $span->setAttribute(TraceAttributes::HTTP_STATUS_CODE, $response->getStatusCode()); - $span->setAttribute(TraceAttributes::HTTP_FLAVOR, $response->getProtocolVersion()); - $span->setAttribute(TraceAttributes::HTTP_RESPONSE_CONTENT_LENGTH, $response->getHeaderLine('Content-Length')); + $span->setAttribute(TraceAttributes::HTTP_RESPONSE_STATUS_CODE, $response->getStatusCode()); + $span->setAttribute(TraceAttributes::NETWORK_PROTOCOL_VERSION, $response->getProtocolVersion()); + $span->setAttribute(TraceAttributes::HTTP_RESPONSE_BODY_SIZE, $response->getHeaderLine('Content-Length')); } $span->end(); diff --git a/src/Instrumentation/Psr18/composer.json b/src/Instrumentation/Psr18/composer.json index 262b21e8..9a7f54d2 100644 --- a/src/Instrumentation/Psr18/composer.json +++ b/src/Instrumentation/Psr18/composer.json @@ -12,7 +12,7 @@ "php": "^8.0", "ext-opentelemetry": "*", "open-telemetry/api": "^1.0.0beta10", - "open-telemetry/sem-conv": "^1", + "open-telemetry/sem-conv": "^1.22", "psr/http-client": "^1" }, "autoload": { diff --git a/src/Instrumentation/Psr18/src/Psr18Instrumentation.php b/src/Instrumentation/Psr18/src/Psr18Instrumentation.php index c0a9d9e1..2f73a636 100644 --- a/src/Instrumentation/Psr18/src/Psr18Instrumentation.php +++ b/src/Instrumentation/Psr18/src/Psr18Instrumentation.php @@ -49,13 +49,13 @@ public static function register(): void ->spanBuilder(sprintf('HTTP %s', $request->getMethod())) ->setParent($parentContext) ->setSpanKind(SpanKind::KIND_CLIENT) - ->setAttribute(TraceAttributes::HTTP_URL, (string) $request->getUri()) - ->setAttribute(TraceAttributes::HTTP_METHOD, $request->getMethod()) - ->setAttribute(TraceAttributes::HTTP_FLAVOR, $request->getProtocolVersion()) + ->setAttribute(TraceAttributes::URL_FULL, (string) $request->getUri()) + ->setAttribute(TraceAttributes::HTTP_REQUEST_METHOD, $request->getMethod()) + ->setAttribute(TraceAttributes::NETWORK_PROTOCOL_VERSION, $request->getProtocolVersion()) ->setAttribute(TraceAttributes::HTTP_USER_AGENT, $request->getHeaderLine('User-Agent')) - ->setAttribute(TraceAttributes::HTTP_REQUEST_CONTENT_LENGTH, $request->getHeaderLine('Content-Length')) - ->setAttribute(TraceAttributes::NET_PEER_NAME, $request->getUri()->getHost()) - ->setAttribute(TraceAttributes::NET_PEER_PORT, $request->getUri()->getPort()) + ->setAttribute(TraceAttributes::HTTP_REQUEST_BODY_SIZE, $request->getHeaderLine('Content-Length')) + ->setAttribute(TraceAttributes::SERVER_ADDRESS, $request->getUri()->getHost()) + ->setAttribute(TraceAttributes::SERVER_PORT, $request->getUri()->getPort()) ->setAttribute(TraceAttributes::CODE_FUNCTION, $function) ->setAttribute(TraceAttributes::CODE_NAMESPACE, $class) ->setAttribute(TraceAttributes::CODE_FILEPATH, $filename) @@ -95,9 +95,9 @@ public static function register(): void $span = Span::fromContext($scope->context()); if ($response) { - $span->setAttribute(TraceAttributes::HTTP_STATUS_CODE, $response->getStatusCode()); - $span->setAttribute(TraceAttributes::HTTP_FLAVOR, $response->getProtocolVersion()); - $span->setAttribute(TraceAttributes::HTTP_RESPONSE_CONTENT_LENGTH, $response->getHeaderLine('Content-Length')); + $span->setAttribute(TraceAttributes::HTTP_RESPONSE_STATUS_CODE, $response->getStatusCode()); + $span->setAttribute(TraceAttributes::NETWORK_PROTOCOL_VERSION, $response->getProtocolVersion()); + $span->setAttribute(TraceAttributes::HTTP_RESPONSE_BODY_SIZE, $response->getHeaderLine('Content-Length')); foreach ((array) (get_cfg_var('otel.instrumentation.http.response_headers') ?: []) as $header) { if ($response->hasHeader($header)) { diff --git a/src/Instrumentation/Psr18/tests/Integration/Psr18InstrumentationTest.php b/src/Instrumentation/Psr18/tests/Integration/Psr18InstrumentationTest.php index e66db9c4..f00e9d17 100644 --- a/src/Instrumentation/Psr18/tests/Integration/Psr18InstrumentationTest.php +++ b/src/Instrumentation/Psr18/tests/Integration/Psr18InstrumentationTest.php @@ -80,12 +80,12 @@ public function test_send_request(string $method, string $uri, int $statusCode): $span = $this->storage[0]; $this->assertStringContainsString($method, $span->getName()); - $this->assertTrue($span->getAttributes()->has(TraceAttributes::HTTP_URL)); - $this->assertSame($uri, $span->getAttributes()->get(TraceAttributes::HTTP_URL)); - $this->assertTrue($span->getAttributes()->has(TraceAttributes::HTTP_METHOD)); - $this->assertSame($method, $span->getAttributes()->get(TraceAttributes::HTTP_METHOD)); - $this->assertTrue($span->getAttributes()->has(TraceAttributes::HTTP_STATUS_CODE)); - $this->assertSame($statusCode, $span->getAttributes()->get(TraceAttributes::HTTP_STATUS_CODE)); + $this->assertTrue($span->getAttributes()->has(TraceAttributes::URL_FULL)); + $this->assertSame($uri, $span->getAttributes()->get(TraceAttributes::URL_FULL)); + $this->assertTrue($span->getAttributes()->has(TraceAttributes::HTTP_REQUEST_METHOD)); + $this->assertSame($method, $span->getAttributes()->get(TraceAttributes::HTTP_REQUEST_METHOD)); + $this->assertTrue($span->getAttributes()->has(TraceAttributes::HTTP_RESPONSE_STATUS_CODE)); + $this->assertSame($statusCode, $span->getAttributes()->get(TraceAttributes::HTTP_RESPONSE_STATUS_CODE)); } public function requestProvider(): array diff --git a/src/Instrumentation/Psr3/composer.json b/src/Instrumentation/Psr3/composer.json index 91325b80..68d7da87 100644 --- a/src/Instrumentation/Psr3/composer.json +++ b/src/Instrumentation/Psr3/composer.json @@ -19,7 +19,7 @@ "php": "^8.0", "ext-opentelemetry": "*", "open-telemetry/api": ">=1.0.0RC2", - "open-telemetry/sem-conv": "^1", + "open-telemetry/sem-conv": "^1.22", "psr/log": "^1 || ^2 || ^3" }, "autoload": { diff --git a/src/Instrumentation/Slim/composer.json b/src/Instrumentation/Slim/composer.json index dcf4f493..3c84d9e5 100644 --- a/src/Instrumentation/Slim/composer.json +++ b/src/Instrumentation/Slim/composer.json @@ -13,7 +13,7 @@ "ext-opentelemetry": "*", "ext-reflection": "*", "open-telemetry/api": "^1.0.0beta10", - "open-telemetry/sem-conv": "^1", + "open-telemetry/sem-conv": "^1.22", "slim/slim": "^4" }, "require-dev": { diff --git a/src/Instrumentation/Slim/src/SlimInstrumentation.php b/src/Instrumentation/Slim/src/SlimInstrumentation.php index 7c6d6686..2110f3e4 100644 --- a/src/Instrumentation/Slim/src/SlimInstrumentation.php +++ b/src/Instrumentation/Slim/src/SlimInstrumentation.php @@ -48,10 +48,10 @@ public static function register(): void $parent = Globals::propagator()->extract($request->getHeaders()); $span = $builder ->setParent($parent) - ->setAttribute(TraceAttributes::HTTP_URL, $request->getUri()->__toString()) - ->setAttribute(TraceAttributes::HTTP_METHOD, $request->getMethod()) - ->setAttribute(TraceAttributes::HTTP_REQUEST_CONTENT_LENGTH, $request->getHeaderLine('Content-Length')) - ->setAttribute(TraceAttributes::HTTP_SCHEME, $request->getUri()->getScheme()) + ->setAttribute(TraceAttributes::URL_FULL, $request->getUri()->__toString()) + ->setAttribute(TraceAttributes::HTTP_REQUEST_METHOD, $request->getMethod()) + ->setAttribute(TraceAttributes::HTTP_REQUEST_BODY_SIZE, $request->getHeaderLine('Content-Length')) + ->setAttribute(TraceAttributes::URL_SCHEME, $request->getUri()->getScheme()) ->startSpan(); $request = $request->withAttribute(SpanInterface::class, $span); } else { @@ -76,9 +76,9 @@ public static function register(): void if ($response->getStatusCode() >= 400) { $span->setStatus(StatusCode::STATUS_ERROR); } - $span->setAttribute(TraceAttributes::HTTP_STATUS_CODE, $response->getStatusCode()); - $span->setAttribute(TraceAttributes::HTTP_FLAVOR, $response->getProtocolVersion()); - $span->setAttribute(TraceAttributes::HTTP_RESPONSE_CONTENT_LENGTH, $response->getHeaderLine('Content-Length')); + $span->setAttribute(TraceAttributes::HTTP_RESPONSE_STATUS_CODE, $response->getStatusCode()); + $span->setAttribute(TraceAttributes::NETWORK_PROTOCOL_VERSION, $response->getProtocolVersion()); + $span->setAttribute(TraceAttributes::HTTP_RESPONSE_BODY_SIZE, $response->getHeaderLine('Content-Length')); } $span->end(); diff --git a/src/Instrumentation/Symfony/composer.json b/src/Instrumentation/Symfony/composer.json index ac4e04e2..27e99adb 100644 --- a/src/Instrumentation/Symfony/composer.json +++ b/src/Instrumentation/Symfony/composer.json @@ -11,7 +11,7 @@ "php": "^8.0", "ext-opentelemetry": "*", "open-telemetry/api": "^1.0.0beta10", - "open-telemetry/sem-conv": "^1", + "open-telemetry/sem-conv": "^1.22", "symfony/http-kernel": "*", "symfony/http-client-contracts": "*" }, diff --git a/src/Instrumentation/Symfony/src/HttpClientInstrumentation.php b/src/Instrumentation/Symfony/src/HttpClientInstrumentation.php index 5e0c2b0e..4fa610c4 100644 --- a/src/Instrumentation/Symfony/src/HttpClientInstrumentation.php +++ b/src/Instrumentation/Symfony/src/HttpClientInstrumentation.php @@ -38,8 +38,8 @@ public static function register(): void ->tracer() ->spanBuilder(\sprintf('HTTP %s', $params[0])) ->setSpanKind(SpanKind::KIND_CLIENT) - ->setAttribute(TraceAttributes::HTTP_URL, (string) $params[1]) - ->setAttribute(TraceAttributes::HTTP_METHOD, $params[0]) + ->setAttribute(TraceAttributes::URL_FULL, (string) $params[1]) + ->setAttribute(TraceAttributes::HTTP_REQUEST_METHOD, $params[0]) ->setAttribute(TraceAttributes::CODE_FUNCTION, $function) ->setAttribute(TraceAttributes::CODE_NAMESPACE, $class) ->setAttribute(TraceAttributes::CODE_FILEPATH, $filename) @@ -72,10 +72,10 @@ public static function register(): void $statusCode = $info['http_code']; if (0 !== $statusCode && null !== $statusCode && $span->isRecording()) { - $span->setAttribute(TraceAttributes::HTTP_STATUS_CODE, $statusCode); + $span->setAttribute(TraceAttributes::HTTP_RESPONSE_STATUS_CODE, $statusCode); if ($statusCode >= 400 && $statusCode < 600) { - $span->setAttribute(TraceAttributes::HTTP_STATUS_CODE, $statusCode); + $span->setAttribute(TraceAttributes::HTTP_RESPONSE_STATUS_CODE, $statusCode); $span->setStatus(StatusCode::STATUS_ERROR); } diff --git a/src/Instrumentation/Symfony/src/SymfonyInstrumentation.php b/src/Instrumentation/Symfony/src/SymfonyInstrumentation.php index 5074529a..06022a77 100644 --- a/src/Instrumentation/Symfony/src/SymfonyInstrumentation.php +++ b/src/Instrumentation/Symfony/src/SymfonyInstrumentation.php @@ -52,10 +52,10 @@ public static function register(): void $parent = Globals::propagator()->extract($request, RequestPropagationGetter::instance()); $span = $builder ->setParent($parent) - ->setAttribute(TraceAttributes::HTTP_URL, $request->getUri()) - ->setAttribute(TraceAttributes::HTTP_METHOD, $request->getMethod()) - ->setAttribute(TraceAttributes::HTTP_REQUEST_CONTENT_LENGTH, $request->headers->get('Content-Length')) - ->setAttribute(TraceAttributes::HTTP_SCHEME, $request->getScheme()) + ->setAttribute(TraceAttributes::URL_FULL, $request->getUri()) + ->setAttribute(TraceAttributes::HTTP_REQUEST_METHOD, $request->getMethod()) + ->setAttribute(TraceAttributes::HTTP_REQUEST_BODY_SIZE, $request->headers->get('Content-Length')) + ->setAttribute(TraceAttributes::URL_SCHEME, $request->getScheme()) ->startSpan(); $request->attributes->set(SpanInterface::class, $span); } else { @@ -103,15 +103,15 @@ public static function register(): void if ($response->getStatusCode() >= Response::HTTP_BAD_REQUEST) { $span->setStatus(StatusCode::STATUS_ERROR); } - $span->setAttribute(TraceAttributes::HTTP_STATUS_CODE, $response->getStatusCode()); - $span->setAttribute(TraceAttributes::HTTP_FLAVOR, $response->getProtocolVersion()); + $span->setAttribute(TraceAttributes::HTTP_RESPONSE_STATUS_CODE, $response->getStatusCode()); + $span->setAttribute(TraceAttributes::NETWORK_PROTOCOL_VERSION, $response->getProtocolVersion()); $contentLength = $response->headers->get('Content-Length'); /** @psalm-suppress PossiblyFalseArgument */ if (null === $contentLength && is_string($response->getContent())) { $contentLength = \strlen($response->getContent()); } - $span->setAttribute(TraceAttributes::HTTP_RESPONSE_CONTENT_LENGTH, $contentLength); + $span->setAttribute(TraceAttributes::HTTP_RESPONSE_BODY_SIZE, $contentLength); // Propagate traceresponse header to response, if TraceResponsePropagator is present if (class_exists('OpenTelemetry\Contrib\Propagation\TraceResponse\TraceResponsePropagator')) { diff --git a/src/Instrumentation/Symfony/tests/Integration/HttpClientInstrumentationTest.php b/src/Instrumentation/Symfony/tests/Integration/HttpClientInstrumentationTest.php index 8c7c1e1b..99522c61 100644 --- a/src/Instrumentation/Symfony/tests/Integration/HttpClientInstrumentationTest.php +++ b/src/Instrumentation/Symfony/tests/Integration/HttpClientInstrumentationTest.php @@ -48,13 +48,13 @@ public function test_send_request(string $method, string $uri, int $statusCode, $this->assertNotNull($requestHeaders['HTTP_TRACEPARENT']); } - $this->assertTrue($span->getAttributes()->has(TraceAttributes::HTTP_URL)); - $this->assertSame($uri, $span->getAttributes()->get(TraceAttributes::HTTP_URL)); - $this->assertTrue($span->getAttributes()->has(TraceAttributes::HTTP_METHOD)); - $this->assertSame($method, $span->getAttributes()->get(TraceAttributes::HTTP_METHOD)); - $this->assertTrue($span->getAttributes()->has(TraceAttributes::HTTP_STATUS_CODE)); + $this->assertTrue($span->getAttributes()->has(TraceAttributes::URL_FULL)); + $this->assertSame($uri, $span->getAttributes()->get(TraceAttributes::URL_FULL)); + $this->assertTrue($span->getAttributes()->has(TraceAttributes::HTTP_REQUEST_METHOD)); + $this->assertSame($method, $span->getAttributes()->get(TraceAttributes::HTTP_REQUEST_METHOD)); + $this->assertTrue($span->getAttributes()->has(TraceAttributes::HTTP_RESPONSE_STATUS_CODE)); $this->assertSame($spanStatus, $span->getStatus()->getCode()); - $this->assertSame($statusCode, $span->getAttributes()->get(TraceAttributes::HTTP_STATUS_CODE)); + $this->assertSame($statusCode, $span->getAttributes()->get(TraceAttributes::HTTP_RESPONSE_STATUS_CODE)); } public function test_throw_exception(): void @@ -77,8 +77,8 @@ public function test_throw_exception(): void /** @var EventInterface $event */ $event = $span->getEvents()[0]; - $this->assertTrue($span->getAttributes()->has(TraceAttributes::HTTP_URL)); - $this->assertTrue($span->getAttributes()->has(TraceAttributes::HTTP_METHOD)); + $this->assertTrue($span->getAttributes()->has(TraceAttributes::URL_FULL)); + $this->assertTrue($span->getAttributes()->has(TraceAttributes::HTTP_REQUEST_METHOD)); $this->assertSame(StatusCode::STATUS_ERROR, $span->getStatus()->getCode()); $this->assertSame(InvalidArgumentException::class, $event->getAttributes()->get('exception.type')); } diff --git a/src/Instrumentation/Symfony/tests/Integration/SymfonyInstrumentationTest.php b/src/Instrumentation/Symfony/tests/Integration/SymfonyInstrumentationTest.php index a6d4eeda..ad6dc1ce 100644 --- a/src/Instrumentation/Symfony/tests/Integration/SymfonyInstrumentationTest.php +++ b/src/Instrumentation/Symfony/tests/Integration/SymfonyInstrumentationTest.php @@ -49,13 +49,13 @@ public function test_http_kernel_handle_attributes(): void $attributes = $this->storage[0]->getAttributes(); $this->assertCount(1, $this->storage); $this->assertEquals('HTTP GET', $this->storage[0]->getName()); - $this->assertEquals('http://:/', $attributes->get(TraceAttributes::HTTP_URL)); - $this->assertEquals('GET', $attributes->get(TraceAttributes::HTTP_METHOD)); - $this->assertEquals('http', $attributes->get(TraceAttributes::HTTP_SCHEME)); + $this->assertEquals('http://:/', $attributes->get(TraceAttributes::URL_FULL)); + $this->assertEquals('GET', $attributes->get(TraceAttributes::HTTP_REQUEST_METHOD)); + $this->assertEquals('http', $attributes->get(TraceAttributes::URL_SCHEME)); $this->assertEquals('test_route', $attributes->get(TraceAttributes::HTTP_ROUTE)); - $this->assertEquals(200, $attributes->get(TraceAttributes::HTTP_STATUS_CODE)); - $this->assertEquals('1.0', $attributes->get(TraceAttributes::HTTP_FLAVOR)); - $this->assertEquals(5, $attributes->get(TraceAttributes::HTTP_RESPONSE_CONTENT_LENGTH)); + $this->assertEquals(200, $attributes->get(TraceAttributes::HTTP_RESPONSE_STATUS_CODE)); + $this->assertEquals('1.0', $attributes->get(TraceAttributes::NETWORK_PROTOCOL_VERSION)); + $this->assertEquals(5, $attributes->get(TraceAttributes::HTTP_RESPONSE_BODY_SIZE)); $this->assertArrayHasKey( TraceResponsePropagator::TRACERESPONSE, @@ -74,7 +74,7 @@ public function test_http_kernel_handle_stream_response(): void $response = $kernel->handle(new Request()); $this->assertCount(1, $this->storage); - $this->assertNull($this->storage[0]->getAttributes()->get(TraceAttributes::HTTP_RESPONSE_CONTENT_LENGTH)); + $this->assertNull($this->storage[0]->getAttributes()->get(TraceAttributes::HTTP_RESPONSE_BODY_SIZE)); $this->assertArrayHasKey( TraceResponsePropagator::TRACERESPONSE, @@ -90,7 +90,7 @@ public function test_http_kernel_handle_binary_file_response(): void $response = $kernel->handle(new Request()); $this->assertCount(1, $this->storage); - $this->assertNull($this->storage[0]->getAttributes()->get(TraceAttributes::HTTP_RESPONSE_CONTENT_LENGTH)); + $this->assertNull($this->storage[0]->getAttributes()->get(TraceAttributes::HTTP_RESPONSE_BODY_SIZE)); $this->assertArrayHasKey( TraceResponsePropagator::TRACERESPONSE, diff --git a/src/Instrumentation/Wordpress/composer.json b/src/Instrumentation/Wordpress/composer.json index 5b8dd523..08e5d45f 100644 --- a/src/Instrumentation/Wordpress/composer.json +++ b/src/Instrumentation/Wordpress/composer.json @@ -11,7 +11,7 @@ "php": "^8.0", "ext-opentelemetry": "*", "open-telemetry/api": "^1.0.0beta10", - "open-telemetry/sem-conv": "^1", + "open-telemetry/sem-conv": "^1.22", "nyholm/psr7": "^1", "nyholm/psr7-server": "^1" }, diff --git a/src/Instrumentation/Wordpress/src/WordpressInstrumentation.php b/src/Instrumentation/Wordpress/src/WordpressInstrumentation.php index 2f5dca64..bd3577dc 100644 --- a/src/Instrumentation/Wordpress/src/WordpressInstrumentation.php +++ b/src/Instrumentation/Wordpress/src/WordpressInstrumentation.php @@ -87,13 +87,13 @@ function: 'wp_initial_constants', ->spanBuilder(sprintf('HTTP %s', $request->getMethod())) ->setParent($parent) ->setSpanKind(SpanKind::KIND_SERVER) - ->setAttribute(TraceAttributes::HTTP_URL, (string) $request->getUri()) - ->setAttribute(TraceAttributes::HTTP_METHOD, $request->getMethod()) - ->setAttribute(TraceAttributes::HTTP_FLAVOR, $request->getProtocolVersion()) + ->setAttribute(TraceAttributes::URL_FULL, (string) $request->getUri()) + ->setAttribute(TraceAttributes::HTTP_REQUEST_METHOD, $request->getMethod()) + ->setAttribute(TraceAttributes::NETWORK_PROTOCOL_VERSION, $request->getProtocolVersion()) ->setAttribute(TraceAttributes::HTTP_USER_AGENT, $request->getHeaderLine('User-Agent')) - ->setAttribute(TraceAttributes::HTTP_REQUEST_CONTENT_LENGTH, $request->getHeaderLine('Content-Length')) - ->setAttribute(TraceAttributes::NET_PEER_NAME, $request->getUri()->getHost()) - ->setAttribute(TraceAttributes::NET_PEER_PORT, $request->getUri()->getPort()) + ->setAttribute(TraceAttributes::HTTP_REQUEST_BODY_SIZE, $request->getHeaderLine('Content-Length')) + ->setAttribute(TraceAttributes::CLIENT_ADDRESS, $request->getUri()->getHost()) + ->setAttribute(TraceAttributes::CLIENT_PORT, $request->getUri()->getPort()) ->startSpan(); Context::storage()->attach($span->storeInContext(Context::getCurrent())); @@ -103,7 +103,7 @@ function: 'wp_initial_constants', function_exists('is_admin') && $span->setAttribute('wp.is_admin', is_admin()); if (function_exists('is_404') && is_404()) { - $span->setAttribute(TraceAttributes::HTTP_STATUS_CODE, 404); + $span->setAttribute(TraceAttributes::HTTP_RESPONSE_STATUS_CODE, 404); $span->setStatus(StatusCode::STATUS_ERROR); } //@todo check for other errors? diff --git a/src/Symfony/composer.json b/src/Symfony/composer.json index 7f469d3f..44de8a8d 100644 --- a/src/Symfony/composer.json +++ b/src/Symfony/composer.json @@ -14,7 +14,7 @@ "open-telemetry/context": "^1", "open-telemetry/exporter-otlp": "^1", "open-telemetry/exporter-zipkin": "^1", - "open-telemetry/sem-conv": "^1", + "open-telemetry/sem-conv": "^1.22", "php-http/discovery": "^1.14", "php-http/message": "^1.12" }, diff --git a/src/Symfony/src/OtelBundle/HttpKernel/RequestListener.php b/src/Symfony/src/OtelBundle/HttpKernel/RequestListener.php index ef4d9ca3..1b2e27d8 100644 --- a/src/Symfony/src/OtelBundle/HttpKernel/RequestListener.php +++ b/src/Symfony/src/OtelBundle/HttpKernel/RequestListener.php @@ -160,8 +160,8 @@ public function recordResponse(ResponseEvent $event): void } $response = $event->getResponse(); - $span->setAttribute(TraceAttributes::HTTP_RESPONSE_CONTENT_LENGTH, $response->headers->get('Content-Length')); - $span->setAttribute(TraceAttributes::HTTP_STATUS_CODE, $response->getStatusCode()); + $span->setAttribute(TraceAttributes::HTTP_RESPONSE_BODY_SIZE, $response->headers->get('Content-Length')); + $span->setAttribute(TraceAttributes::HTTP_RESPONSE_STATUS_CODE, $response->getStatusCode()); if ($response->getStatusCode() >= 500 && $response->getStatusCode() < 600) { $span->setStatus(StatusCode::STATUS_ERROR); } @@ -233,23 +233,23 @@ private function fetchRequestAttribute(Request $request, string $key, string $ty private function requestAttributes(Request $request): iterable { return [ - TraceAttributes::HTTP_METHOD => $request->getMethod(), - TraceAttributes::HTTP_TARGET => $request->getRequestUri(), + TraceAttributes::HTTP_REQUEST_METHOD => $request->getMethod(), + TraceAttributes::URL_PATH => $request->getRequestUri(), self::TRACE_ATTRIBUTE_HTTP_HOST => $request->getHttpHost(), - TraceAttributes::HTTP_SCHEME => $request->getScheme(), - TraceAttributes::HTTP_FLAVOR => ($protocolVersion = $request->getProtocolVersion()) !== null + TraceAttributes::URL_SCHEME => $request->getScheme(), + TraceAttributes::NETWORK_PROTOCOL_VERSION => ($protocolVersion = $request->getProtocolVersion()) !== null ? strtr($protocolVersion, ['HTTP/' => '']) : null, self::TRACE_ATTRIBUTE_HTTP_USER_AGENT => $request->headers->get('User-Agent'), - TraceAttributes::HTTP_REQUEST_CONTENT_LENGTH => $request->headers->get('Content-Length'), - TraceAttributes::HTTP_CLIENT_IP => $request->getClientIp(), + TraceAttributes::HTTP_REQUEST_BODY_SIZE => $request->headers->get('Content-Length'), + TraceAttributes::NETWORK_PEER_ADDRESS => $request->getClientIp(), self::TRACE_ATTRIBUTE_NET_PEER_IP => $request->server->get('REMOTE_ADDR'), - TraceAttributes::NET_PEER_PORT => $request->server->get('REMOTE_PORT'), - TraceAttributes::NET_PEER_NAME => $request->server->get('REMOTE_HOST'), + TraceAttributes::CLIENT_PORT => $request->server->get('REMOTE_PORT'), + TraceAttributes::CLIENT_ADDRESS => $request->server->get('REMOTE_HOST'), self::TRACE_ATTRIBUTE_NET_HOST_IP => $request->server->get('SERVER_ADDR'), - TraceAttributes::NET_HOST_PORT => $request->server->get('SERVER_PORT'), - TraceAttributes::NET_HOST_NAME => $request->server->get('SERVER_NAME'), + TraceAttributes::SERVER_PORT => $request->server->get('SERVER_PORT'), + TraceAttributes::SERVER_ADDRESS => $request->server->get('SERVER_NAME'), ]; } diff --git a/src/Symfony/src/OtelBundle/composer.json b/src/Symfony/src/OtelBundle/composer.json index 90ef13cd..5d186e5d 100644 --- a/src/Symfony/src/OtelBundle/composer.json +++ b/src/Symfony/src/OtelBundle/composer.json @@ -9,7 +9,7 @@ "composer-runtime-api": "^2.0", "open-telemetry/api": "^0.0.14", "open-telemetry/context": "^0.0.14", - "open-telemetry/sem-conv": "^0.0.14", + "open-telemetry/sem-conv": "^1.22", "symfony/config": "^4.4 || ^5.4 || ^6.1", "symfony/dependency-injection": "^4.4 || ^5.4 || ^6.1" },