Skip to content

Commit f31f91c

Browse files
authored
Update auto-instrumentation packages to SemConv 1.30 (#327)
* update auto-instrumentation packages to SemConv 1.30.0 * Curl semconv 1.30 * amqp noting semconv recommendations, try to stick to semconv 1.24. Where attributes have been removed, replace with a string * rdkafka * guzzle * HttpAsyncClient * io * laravel * mongodb * mysqli * openaiphp * pdo * psr3 * psr6 * psr14 * psr15 * psr16 * psr18 * slim * symfony * wordpress * yii * symfony * logs * hard-code schema url for 8.0-supporting packages on 8.0 these packages won't be able to use the SemConv::Version enum * no-plugins for composer make targets this avoids the annoying 'do you trust...' composer questions * drop 7.4 testing * fixing build errors - bump psr3 + monolog deps to php8.1 - fix azure detector semconv, add composer dependency * skip failing cake test on 8.0 * fix message span names in semconv 1.27 the order of operation+queue switched
1 parent 3f32c15 commit f31f91c

File tree

16 files changed

+41
-44
lines changed

16 files changed

+41
-44
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"ext-opentelemetry": "*",
1515
"laravel/framework": "^6.0 || ^7.0 || ^8.0 || ^9.0 || ^10.0 || ^11.0",
1616
"open-telemetry/api": "^1.0",
17-
"open-telemetry/sem-conv": "^1.24"
17+
"open-telemetry/sem-conv": "^1.30"
1818
},
1919
"require-dev": {
2020
"friendsofphp/php-cs-fixer": "^3.50",

src/Hooks/Illuminate/Console/Command.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ protected function hookExecute(): bool
3434
$builder = $this->instrumentation
3535
->tracer()
3636
->spanBuilder(sprintf('Command %s', $command->getName() ?: 'unknown'))
37-
->setAttribute(TraceAttributes::CODE_FUNCTION, $function)
37+
->setAttribute(TraceAttributes::CODE_FUNCTION_NAME, $function)
3838
->setAttribute(TraceAttributes::CODE_NAMESPACE, $class)
3939
->setAttribute(TraceAttributes::CODE_FILEPATH, $filename)
40-
->setAttribute(TraceAttributes::CODE_LINENO, $lineno);
40+
->setAttribute(TraceAttributes::CODE_LINE_NUMBER, $lineno);
4141

4242
$parent = Context::getCurrent();
4343
$span = $builder->startSpan();

src/Hooks/Illuminate/Contracts/Console/Kernel.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@ private function hookHandle(): bool
4343
->tracer()
4444
->spanBuilder('Artisan handler')
4545
->setSpanKind(SpanKind::KIND_PRODUCER)
46-
->setAttribute(TraceAttributes::CODE_FUNCTION, $function)
46+
->setAttribute(TraceAttributes::CODE_FUNCTION_NAME, $function)
4747
->setAttribute(TraceAttributes::CODE_NAMESPACE, $class)
4848
->setAttribute(TraceAttributes::CODE_FILEPATH, $filename)
49-
->setAttribute(TraceAttributes::CODE_LINENO, $lineno);
49+
->setAttribute(TraceAttributes::CODE_LINE_NUMBER, $lineno);
5050

5151
$parent = Context::getCurrent();
5252
$span = $builder->startSpan();

src/Hooks/Illuminate/Contracts/Http/Kernel.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@ protected function hookHandle(): bool
4545
->tracer()
4646
->spanBuilder(sprintf('%s', $request?->method() ?? 'unknown'))
4747
->setSpanKind(SpanKind::KIND_SERVER)
48-
->setAttribute(TraceAttributes::CODE_FUNCTION, $function)
48+
->setAttribute(TraceAttributes::CODE_FUNCTION_NAME, $function)
4949
->setAttribute(TraceAttributes::CODE_NAMESPACE, $class)
5050
->setAttribute(TraceAttributes::CODE_FILEPATH, $filename)
51-
->setAttribute(TraceAttributes::CODE_LINENO, $lineno);
51+
->setAttribute(TraceAttributes::CODE_LINE_NUMBER, $lineno);
5252
$parent = Context::getCurrent();
5353
if ($request) {
5454
/** @phan-suppress-next-line PhanAccessMethodInternal */

src/Hooks/Illuminate/Contracts/Queue/Queue.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,20 +38,20 @@ protected function hookBulk(): bool
3838
'bulk',
3939
pre: function (QueueContract $queue, array $params, string $class, string $function, ?string $filename, ?int $lineno) {
4040
$attributes = array_merge([
41-
TraceAttributes::CODE_FUNCTION => $function,
41+
TraceAttributes::CODE_FUNCTION_NAME => $function,
4242
TraceAttributes::CODE_NAMESPACE => $class,
4343
TraceAttributes::CODE_FILEPATH => $filename,
44-
TraceAttributes::CODE_LINENO => $lineno,
44+
TraceAttributes::CODE_LINE_NUMBER => $lineno,
4545
TraceAttributes::MESSAGING_BATCH_MESSAGE_COUNT => count($params[0] ?? []),
4646
], $this->contextualMessageSystemAttributes($queue, []));
4747

4848
/** @psalm-suppress ArgumentTypeCoercion */
4949
$span = $this->instrumentation
5050
->tracer()
5151
->spanBuilder(vsprintf('%s %s', [
52+
TraceAttributeValues::MESSAGING_OPERATION_TYPE_SEND,
5253
/** @phan-suppress-next-line PhanUndeclaredMethod */
5354
method_exists($queue, 'getQueue') ? $queue->getQueue($params[2] ?? null) : $queue->getConnectionName(),
54-
TraceAttributeValues::MESSAGING_OPERATION_PUBLISH,
5555
]))
5656
->setSpanKind(SpanKind::KIND_PRODUCER)
5757
->setAttributes($attributes)
@@ -81,20 +81,20 @@ protected function hookLater(): bool
8181
};
8282

8383
$attributes = [
84-
TraceAttributes::CODE_FUNCTION => $function,
84+
TraceAttributes::CODE_FUNCTION_NAME => $function,
8585
TraceAttributes::CODE_NAMESPACE => $class,
8686
TraceAttributes::CODE_FILEPATH => $filename,
87-
TraceAttributes::CODE_LINENO => $lineno,
87+
TraceAttributes::CODE_LINE_NUMBER => $lineno,
8888
'messaging.message.delivery_timestamp' => $estimateDeliveryTimestamp,
8989
];
9090

9191
/** @psalm-suppress ArgumentTypeCoercion */
9292
$span = $this->instrumentation
9393
->tracer()
9494
->spanBuilder(vsprintf('%s %s', [
95+
TraceAttributeValues::MESSAGING_OPERATION_TYPE_CREATE,
9596
/** @phan-suppress-next-line PhanUndeclaredMethod */
9697
method_exists($queue, 'getQueue') ? $queue->getQueue($params[2] ?? null) : $queue->getConnectionName(),
97-
'create',
9898
]))
9999
->setSpanKind(SpanKind::KIND_PRODUCER)
100100
->setAttributes($attributes)
@@ -124,8 +124,8 @@ protected function hookPushRaw(): bool
124124
$span = $this->instrumentation
125125
->tracer()
126126
->spanBuilder(vsprintf('%s %s', [
127+
TraceAttributeValues::MESSAGING_OPERATION_TYPE_CREATE,
127128
$attributes[TraceAttributes::MESSAGING_DESTINATION_NAME],
128-
TraceAttributeValues::MESSAGING_OPERATION_CREATE,
129129
]))
130130
->setSpanKind(SpanKind::KIND_PRODUCER)
131131
->setAttributes($attributes)

src/Hooks/Illuminate/Queue/SyncQueue.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ protected function hookPush(): bool
4040
]))
4141
->setSpanKind(SpanKind::KIND_INTERNAL)
4242
->setAttributes([
43-
TraceAttributes::CODE_FUNCTION => $function,
43+
TraceAttributes::CODE_FUNCTION_NAME => $function,
4444
TraceAttributes::CODE_NAMESPACE => $class,
4545
TraceAttributes::CODE_FILEPATH => $filename,
46-
TraceAttributes::CODE_LINENO => $lineno,
46+
TraceAttributes::CODE_LINE_NUMBER => $lineno,
4747
])
4848
->startSpan();
4949

src/Hooks/Illuminate/Queue/Worker.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ private function hookWorkerProcess(): bool
5151
$span = $this->instrumentation
5252
->tracer()
5353
->spanBuilder(vsprintf('%s %s', [
54+
TraceAttributeValues::MESSAGING_OPERATION_TYPE_PROCESS,
5455
$attributes[TraceAttributes::MESSAGING_DESTINATION_NAME],
55-
'process',
5656
]))
5757
->setSpanKind(SpanKind::KIND_CONSUMER)
5858
->setParent($parent)
@@ -98,8 +98,8 @@ private function hookWorkerGetNextJob(): bool
9898
$span = $this->instrumentation
9999
->tracer()
100100
->spanBuilder(vsprintf('%s %s', [
101+
TraceAttributeValues::MESSAGING_OPERATION_TYPE_RECEIVE,
101102
$attributes[TraceAttributes::MESSAGING_DESTINATION_NAME],
102-
TraceAttributeValues::MESSAGING_OPERATION_RECEIVE,
103103
]))
104104
->setSpanKind(SpanKind::KIND_CONSUMER)
105105
->setAttributes($attributes)

src/Hooks/PostHookTrait.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
use OpenTelemetry\API\Trace\Span;
88
use OpenTelemetry\API\Trace\StatusCode;
99
use OpenTelemetry\Context\Context;
10-
use OpenTelemetry\SemConv\TraceAttributes;
1110
use Throwable;
1211

1312
trait PostHookTrait
@@ -23,9 +22,7 @@ private function endSpan(?Throwable $exception = null): void
2322
$span = Span::fromContext($scope->context());
2423

2524
if ($exception) {
26-
$span->recordException($exception, [
27-
TraceAttributes::EXCEPTION_ESCAPED => true,
28-
]);
25+
$span->recordException($exception);
2926
$span->setStatus(StatusCode::STATUS_ERROR, $exception->getMessage());
3027
}
3128

src/LaravelInstrumentation.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public static function register(): void
1616
$instrumentation = new CachedInstrumentation(
1717
'io.opentelemetry.contrib.php.laravel',
1818
null,
19-
'https://opentelemetry.io/schemas/1.24.0'
19+
'https://opentelemetry.io/schemas/1.30.0',
2020
);
2121

2222
Hooks\Illuminate\Console\Command::hook($instrumentation);

src/Watchers/ExceptionWatcher.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
use OpenTelemetry\API\Trace\Span;
1010
use OpenTelemetry\API\Trace\StatusCode;
1111
use OpenTelemetry\Context\Context;
12-
use OpenTelemetry\SemConv\TraceAttributes;
1312
use Throwable;
1413

1514
class ExceptionWatcher extends Watcher
@@ -37,7 +36,7 @@ public function recordException(MessageLogged $log): void
3736
return;
3837
}
3938
$span = Span::fromContext($scope->context());
40-
$span->recordException($exception, [TraceAttributes::EXCEPTION_ESCAPED => true]);
39+
$span->recordException($exception);
4140
$span->setStatus(StatusCode::STATUS_ERROR, $exception->getMessage());
4241
}
4342
}

0 commit comments

Comments
 (0)