Skip to content

Commit f8f40cb

Browse files
committed
Fixed a bit of warnings and deprecations
1 parent 27a188b commit f8f40cb

File tree

13 files changed

+30
-27
lines changed

13 files changed

+30
-27
lines changed

src/Context/Swoole/src/SwooleContextStorage.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,21 @@ public function __construct(ContextStorageInterface $storage)
2626
$this->handler = new SwooleContextHandler($storage);
2727
}
2828

29-
public function fork($id): void
29+
public function fork(int|string $id): void
3030
{
3131
$this->handler->switchToActiveCoroutine();
3232

3333
$this->storage->fork($id);
3434
}
3535

36-
public function switch($id): void
36+
public function switch(int|string $id): void
3737
{
3838
$this->handler->switchToActiveCoroutine();
3939

4040
$this->storage->switch($id);
4141
}
4242

43-
public function destroy($id): void
43+
public function destroy(int|string $id): void
4444
{
4545
$this->handler->switchToActiveCoroutine();
4646

src/Instrumentation/ExtRdKafka/src/ExtRdKafkaInstrumentation.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,14 @@ private static function addProductionHooks($instrumentation)
7474
/** @var CachedInstrumentation $instrumentation */
7575
$builder = $instrumentation
7676
->tracer()
77-
->spanBuilder(sprintf('%s %s', $exchange->getName(), TraceAttributeValues::MESSAGING_OPERATION_PUBLISH))
77+
->spanBuilder(sprintf('%s %s', $exchange->getName(), TraceAttributeValues::MESSAGING_OPERATION_TYPE_PUBLISH))
7878
->setSpanKind(SpanKind::KIND_PRODUCER)
7979
->setAttribute(TraceAttributes::CODE_FUNCTION, $function)
8080
->setAttribute(TraceAttributes::CODE_NAMESPACE, $class)
8181
->setAttribute(TraceAttributes::CODE_FILEPATH, $filename)
8282
->setAttribute(TraceAttributes::CODE_LINENO, $lineno)
8383
->setAttribute(TraceAttributes::MESSAGING_SYSTEM, TraceAttributeValues::MESSAGING_SYSTEM_KAFKA)
84-
->setAttribute(TraceAttributes::MESSAGING_OPERATION, TraceAttributeValues::MESSAGING_OPERATION_PUBLISH)
84+
->setAttribute(TraceAttributes::MESSAGING_OPERATION_TYPE, TraceAttributeValues::MESSAGING_OPERATION_TYPE_PUBLISH)
8585
;
8686

8787
$parent = Context::getCurrent();
@@ -147,12 +147,12 @@ private static function addConsumeHooks($instrumentation)
147147
$builder = $instrumentation
148148
->tracer()
149149
// @phan-suppress-next-line PhanTypeMismatchArgumentInternal - Doesn't seem to know this has to be a string
150-
->spanBuilder(sprintf('%s %s', $message->topic_name, TraceAttributeValues::MESSAGING_OPERATION_DELIVER))
150+
->spanBuilder(sprintf('%s %s', $message->topic_name, TraceAttributeValues::MESSAGING_OPERATION_TYPE_PROCESS))
151151
->setSpanKind(SpanKind::KIND_CONSUMER)
152152
->setAttribute(TraceAttributes::MESSAGING_SYSTEM, TraceAttributeValues::MESSAGING_SYSTEM_KAFKA)
153-
->setAttribute(TraceAttributes::MESSAGING_OPERATION, TraceAttributeValues::MESSAGING_OPERATION_DELIVER)
153+
->setAttribute(TraceAttributes::MESSAGING_OPERATION_TYPE, TraceAttributeValues::MESSAGING_OPERATION_TYPE_PROCESS)
154154
->setAttribute(TraceAttributes::MESSAGING_KAFKA_MESSAGE_KEY, $message->key)
155-
->setAttribute(TraceAttributes::MESSAGING_KAFKA_MESSAGE_OFFSET, $message->offset)
155+
->setAttribute(TraceAttributes::MESSAGING_KAFKA_OFFSET, $message->offset)
156156
;
157157

158158
if (is_array($message->headers)) {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ protected function hookBulk(): bool
5151
->spanBuilder(vsprintf('%s %s', [
5252
/** @phan-suppress-next-line PhanUndeclaredMethod */
5353
method_exists($queue, 'getQueue') ? $queue->getQueue($params[2] ?? null) : $queue->getConnectionName(),
54-
TraceAttributeValues::MESSAGING_OPERATION_PUBLISH,
54+
TraceAttributeValues::MESSAGING_OPERATION_TYPE_PUBLISH,
5555
]))
5656
->setSpanKind(SpanKind::KIND_PRODUCER)
5757
->setAttributes($attributes)
@@ -125,7 +125,7 @@ protected function hookPushRaw(): bool
125125
->tracer()
126126
->spanBuilder(vsprintf('%s %s', [
127127
$attributes[TraceAttributes::MESSAGING_DESTINATION_NAME],
128-
TraceAttributeValues::MESSAGING_OPERATION_CREATE,
128+
TraceAttributeValues::MESSAGING_OPERATION_TYPE_CREATE,
129129
]))
130130
->setSpanKind(SpanKind::KIND_PRODUCER)
131131
->setAttributes($attributes)

src/Instrumentation/Laravel/src/Hooks/Illuminate/Queue/Worker.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ private function hookWorkerGetNextJob(): bool
9999
->tracer()
100100
->spanBuilder(vsprintf('%s %s', [
101101
$attributes[TraceAttributes::MESSAGING_DESTINATION_NAME],
102-
TraceAttributeValues::MESSAGING_OPERATION_RECEIVE,
102+
TraceAttributeValues::MESSAGING_OPERATION_TYPE_RECEIVE,
103103
]))
104104
->setSpanKind(SpanKind::KIND_CONSUMER)
105105
->setAttributes($attributes)

src/Instrumentation/Laravel/src/Watchers/LogWatcher.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
use Illuminate\Log\LogManager;
1010
use OpenTelemetry\API\Instrumentation\CachedInstrumentation;
1111
use OpenTelemetry\API\Logs\LogRecord;
12-
use OpenTelemetry\API\Logs\Map\Psr3;
12+
use OpenTelemetry\API\Logs\Severity;
1313
use TypeError;
1414

1515
class LogWatcher extends Watcher
@@ -58,7 +58,7 @@ public function recordLog(MessageLogged $log): void
5858

5959
$record = (new LogRecord($log->message))
6060
->setSeverityText($log->level)
61-
->setSeverityNumber(Psr3::severityNumber($log->level))
61+
->setSeverityNumber(Severity::fromPsr3($log->level))
6262
->setAttributes($attributes);
6363

6464
$logger->emit($record);

src/Instrumentation/Laravel/src/Watchers/QueryWatcher.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,13 @@ public function recordQuery(QueryExecuted $query): void
4545

4646
$attributes = [
4747
TraceAttributes::DB_SYSTEM => $query->connection->getDriverName(),
48-
TraceAttributes::DB_NAME => $query->connection->getDatabaseName(),
49-
TraceAttributes::DB_OPERATION => $operationName,
48+
TraceAttributes::DB_NAMESPACE => $query->connection->getDatabaseName(),
49+
TraceAttributes::DB_OPERATION_NAME => $operationName,
50+
/** @phan-suppress-next-line PhanDeprecatedClassConstant */
5051
TraceAttributes::DB_USER => $query->connection->getConfig('username'),
5152
];
5253

53-
$attributes[TraceAttributes::DB_STATEMENT] = $query->sql;
54+
$attributes[TraceAttributes::DB_QUERY_TEXT] = $query->sql;
5455
/** @psalm-suppress PossiblyInvalidArgument */
5556
$span->setAttributes($attributes);
5657
$span->end($nowInNs);

src/Instrumentation/Laravel/src/Watchers/RedisCommand/RedisCommandWatcher.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ public function recordRedisCommand(CommandExecuted $event): void
5555
// See https://opentelemetry.io/docs/specs/semconv/database/redis/
5656
$attributes = [
5757
TraceAttributes::DB_SYSTEM => TraceAttributeValues::DB_SYSTEM_REDIS,
58-
TraceAttributes::DB_NAME => $this->fetchDbIndex($event->connection),
59-
TraceAttributes::DB_OPERATION => $operationName,
60-
TraceAttributes::DB_STATEMENT => Serializer::serializeCommand($event->command, $event->parameters),
58+
TraceAttributes::DB_NAMESPACE => $this->fetchDbIndex($event->connection),
59+
TraceAttributes::DB_OPERATION_NAME => $operationName,
60+
TraceAttributes::DB_QUERY_TEXT => Serializer::serializeCommand($event->command, $event->parameters),
6161
TraceAttributes::SERVER_ADDRESS => $this->fetchDbHost($event->connection),
6262
];
6363

src/Instrumentation/Laravel/src/Watchers/RedisCommand/Serializer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public static function serializeCommand(string $command, array $params): string
7070
}
7171

7272
// In some cases (for example when using LUA scripts) arrays are valid parameters
73-
$paramsToSerialize = array_map(function($param) { return is_array($param) ? json_encode($param) : $param; }, $paramsToSerialize);
73+
$paramsToSerialize = array_map(function ($param) { return is_array($param) ? json_encode($param) : $param; }, $paramsToSerialize);
7474

7575
return $command . ' ' . implode(' ', $paramsToSerialize);
7676
}

src/Instrumentation/Laravel/tests/Integration/LaravelInstrumentationTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ public function test_cache_log_db(): void
5858

5959
$span = $this->storage[1];
6060
$this->assertSame('sql SELECT', $span->getName());
61-
$this->assertSame('SELECT', $span->getAttributes()->get('db.operation'));
62-
$this->assertSame(':memory:', $span->getAttributes()->get('db.name'));
63-
$this->assertSame('select 1', $span->getAttributes()->get('db.statement'));
61+
$this->assertSame('SELECT', $span->getAttributes()->get('db.operation.name'));
62+
$this->assertSame(':memory:', $span->getAttributes()->get('db.namespace'));
63+
$this->assertSame('select 1', $span->getAttributes()->get('db.query.text'));
6464
$this->assertSame('sqlite', $span->getAttributes()->get('db.system'));
6565

6666
/** @var \OpenTelemetry\SDK\Logs\ReadWriteLogRecord $logRecord */

src/Instrumentation/Psr3/src/Psr3Instrumentation.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use OpenTelemetry\API\Instrumentation\CachedInstrumentation;
88
use OpenTelemetry\API\Instrumentation\ConfigurationResolver;
99
use OpenTelemetry\API\Logs as API;
10+
use OpenTelemetry\API\Logs\Severity;
1011
use OpenTelemetry\API\Trace\Span;
1112
use OpenTelemetry\Context\Context;
1213
use function OpenTelemetry\Instrumentation\hook;
@@ -76,7 +77,7 @@ public static function register(): void
7677
}
7778

7879
$record = (new API\LogRecord($body))
79-
->setSeverityNumber(API\Map\Psr3::severityNumber($level));
80+
->setSeverityNumber(Severity::fromPsr3($level));
8081
foreach (Formatter::format($context) as $key => $value) {
8182
$record->setAttribute((string) $key, $value);
8283
}

0 commit comments

Comments
 (0)