Skip to content

Commit 252cd48

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 a4ff214 commit 252cd48

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"ext-opentelemetry": "*",
1414
"ext-reflection": "*",
1515
"open-telemetry/api": "^1.0",
16-
"open-telemetry/sem-conv": "^1.30",
16+
"open-telemetry/sem-conv": "^1.32",
1717
"slim/slim": "^4"
1818
},
1919
"require-dev": {

src/SlimInstrumentation.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public static function register(): void
3333
$instrumentation = new CachedInstrumentation(
3434
'io.opentelemetry.contrib.php.slim',
3535
null,
36-
'https://opentelemetry.io/schemas/1.30.0',
36+
'https://opentelemetry.io/schemas/1.32.0',
3737
);
3838

3939
/**
@@ -53,9 +53,8 @@ public static function register(): void
5353
$builder = $instrumentation->tracer()
5454
->spanBuilder(sprintf('%s', $request?->getMethod() ?? 'unknown'))
5555
->setSpanKind(SpanKind::KIND_SERVER)
56-
->setAttribute(TraceAttributes::CODE_FUNCTION_NAME, $function)
57-
->setAttribute(TraceAttributes::CODE_NAMESPACE, $class)
58-
->setAttribute(TraceAttributes::CODE_FILEPATH, $filename)
56+
->setAttribute(TraceAttributes::CODE_FUNCTION_NAME, sprintf('%s::%s', $class, $function))
57+
->setAttribute(TraceAttributes::CODE_FILE_PATH, $filename)
5958
->setAttribute(TraceAttributes::CODE_LINE_NUMBER, $lineno);
6059
$parent = Context::getCurrent();
6160
if ($request) {
@@ -124,6 +123,8 @@ public static function register(): void
124123
* and type SpanInterface which represents the root span, having been previously set
125124
* If routing fails (eg 404/not found), then the root span name will not be updated.
126125
*
126+
* @todo this can use LocalRootSpan (available since API 1.1.0)
127+
*
127128
* @psalm-suppress ArgumentTypeCoercion
128129
* @psalm-suppress UnusedFunctionCall
129130
*/
@@ -161,9 +162,8 @@ public static function register(): void
161162
$callable = $params[0];
162163
$name = CallableFormatter::format($callable);
163164
$builder = $instrumentation->tracer()->spanBuilder($name)
164-
->setAttribute(TraceAttributes::CODE_FUNCTION_NAME, $function)
165-
->setAttribute(TraceAttributes::CODE_NAMESPACE, $class)
166-
->setAttribute(TraceAttributes::CODE_FILEPATH, $filename)
165+
->setAttribute(TraceAttributes::CODE_FUNCTION_NAME, sprintf('%s::%s', $class, $function))
166+
->setAttribute(TraceAttributes::CODE_FILE_PATH, $filename)
167167
->setAttribute(TraceAttributes::CODE_LINE_NUMBER, $lineno);
168168
$span = $builder->startSpan();
169169
Context::storage()->attach($span->storeInContext(Context::getCurrent()));

0 commit comments

Comments
 (0)