Skip to content

Commit ac47e4a

Browse files
authored
update instrumentations to semconv 1.32 (#369)
SemConv 1.32 deprecates a couple of attributes which we use extensively: - code.function.name is now an FQN (including class name) - code.namespace is deprecated (included in code.function.name) - code.linenumber is deprecated and replaced with code.line.number Updated all packages to conform, updated min semconv to 1.32, and made a couple of minor changes"
1 parent 30ab666 commit ac47e4a

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"php": "^8.1",
1313
"ext-opentelemetry": "*",
1414
"open-telemetry/api": "^1.0",
15-
"open-telemetry/sem-conv": "^1.30",
15+
"open-telemetry/sem-conv": "^1.32",
1616
"psr/http-client": "^1"
1717
},
1818
"autoload": {

src/Psr18Instrumentation.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use OpenTelemetry\Context\Context;
1414
use function OpenTelemetry\Instrumentation\hook;
1515
use OpenTelemetry\SemConv\TraceAttributes;
16+
use OpenTelemetry\SemConv\Version;
1617
use Psr\Http\Client\ClientInterface;
1718
use Psr\Http\Message\RequestInterface;
1819
use Psr\Http\Message\ResponseInterface;
@@ -30,7 +31,7 @@ public static function register(): void
3031
{
3132
$instrumentation = new CachedInstrumentation(
3233
'io.opentelemetry.contrib.php.psr18',
33-
'https://opentelemetry.io/schemas/1.30.0',
34+
schemaUrl: Version::VERSION_1_32_0->url(),
3435
);
3536

3637
/** @psalm-suppress UnusedFunctionCall */
@@ -61,9 +62,8 @@ public static function register(): void
6162
->setAttribute(TraceAttributes::HTTP_REQUEST_BODY_SIZE, $request->getHeaderLine('Content-Length'))
6263
->setAttribute(TraceAttributes::SERVER_ADDRESS, $request->getUri()->getHost())
6364
->setAttribute(TraceAttributes::SERVER_PORT, $request->getUri()->getPort())
64-
->setAttribute(TraceAttributes::CODE_FUNCTION_NAME, $function)
65-
->setAttribute(TraceAttributes::CODE_NAMESPACE, $class)
66-
->setAttribute(TraceAttributes::CODE_FILEPATH, $filename)
65+
->setAttribute(TraceAttributes::CODE_FUNCTION_NAME, sprintf('%s::%s', $class, $function))
66+
->setAttribute(TraceAttributes::CODE_FILE_PATH, $filename)
6767
->setAttribute(TraceAttributes::CODE_LINE_NUMBER, $lineno)
6868
;
6969

0 commit comments

Comments
 (0)