Skip to content

Commit 2d17302

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 96f0d0c commit 2d17302

File tree

112 files changed

+4917
-448
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

112 files changed

+4917
-448
lines changed

.github/workflows/php.yml

Lines changed: 5 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
strategy:
1818
fail-fast: false
1919
matrix:
20-
php-version: ['7.4', '8.0', '8.1', '8.2', '8.3']
20+
php-version: ['8.0', '8.1', '8.2', '8.3']
2121
# Sorted alphabetically to ease finding the desired run in the GitHub Workflow UI.
2222
project: [
2323
'Aws',
@@ -55,34 +55,6 @@ jobs:
5555
'Symfony',
5656
]
5757
exclude:
58-
- project: 'Instrumentation/Guzzle'
59-
php-version: 7.4
60-
- project: 'Instrumentation/HttpAsyncClient'
61-
php-version: 7.4
62-
- project: 'Instrumentation/Slim'
63-
php-version: 7.4
64-
- project: 'Instrumentation/Psr3'
65-
php-version: 7.4
66-
- project: 'Instrumentation/Psr6'
67-
php-version: 7.4
68-
- project: 'Instrumentation/Psr14'
69-
php-version: 7.4
70-
- project: 'Instrumentation/Psr15'
71-
php-version: 7.4
72-
- project: 'Instrumentation/Psr16'
73-
php-version: 7.4
74-
- project: 'Instrumentation/Psr18'
75-
php-version: 7.4
76-
- project: 'Instrumentation/IO'
77-
php-version: 7.4
78-
- project: 'Instrumentation/Symfony'
79-
php-version: 7.4
80-
- project: 'Instrumentation/Laravel'
81-
php-version: 7.4
82-
- project: 'Instrumentation/CodeIgniter'
83-
php-version: 7.4
84-
- project: 'Instrumentation/Yii'
85-
php-version: 7.4
8658
- project: 'Instrumentation/IO'
8759
php-version: 8.0
8860
- project: 'Instrumentation/IO'
@@ -99,14 +71,12 @@ jobs:
9971
php-version: 8.0
10072
- project: 'Instrumentation/MySqli'
10173
php-version: 8.1
102-
- project: 'Instrumentation/PDO'
103-
php-version: 7.4
10474
- project: 'Instrumentation/PDO'
10575
php-version: 8.0
10676
- project: 'Instrumentation/PDO'
10777
php-version: 8.1
108-
- project: 'Instrumentation/ExtAmqp'
109-
php-version: 7.4
78+
- project: 'Instrumentation/Psr3'
79+
php-version: 8.0
11080
- project: 'Instrumentation/ExtAmqp'
11181
php-version: 8.0
11282
- project: 'Instrumentation/ExtAmqp'
@@ -117,22 +87,12 @@ jobs:
11787
php-version: 8.0
11888
- project: 'Instrumentation/ExtRdKafka'
11989
php-version: 8.1
120-
- project: 'Instrumentation/OpenAIPHP'
121-
php-version: 7.4
12290
- project: 'Instrumentation/OpenAIPHP'
12391
php-version: 8.0
124-
- project: 'Instrumentation/CakePHP'
125-
php-version: 7.4
126-
- project: 'Propagation/ServerTiming'
127-
php-version: 7.4
128-
- project: 'ResourceDetectors/Container'
129-
php-version: 7.4
130-
- project: 'Sampler/RuleBased'
131-
php-version: 7.4
92+
- project: 'Logs/Monolog'
93+
php-version: 8.0
13294
- project: 'Sampler/RuleBased'
13395
php-version: 8.0
134-
- project: 'Symfony'
135-
php-version: 7.4
13696
- project: 'Symfony'
13797
php-version: 8.0
13898
steps:

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ build: ## Build image
1919
install: ## Install dependencies
2020
$(DC_RUN_PHP) env XDEBUG_MODE=off composer install
2121
update: ## Update dependencies
22-
$(DC_RUN_PHP) env XDEBUG_MODE=off composer update
22+
$(DC_RUN_PHP) env XDEBUG_MODE=off composer update --no-plugins
2323
update-lowest: ## Update dependencies to lowest supported versions
24-
$(DC_RUN_PHP) env XDEBUG_MODE=off composer update --prefer-lowest
24+
$(DC_RUN_PHP) env XDEBUG_MODE=off composer update --no-plugins --prefer-lowest
2525
test: ## Run all tests
2626
$(DC_RUN_PHP) env XDEBUG_MODE=off vendor/bin/phpunit --testdox --colors=always
2727
test-unit: ## Run unit tests
@@ -39,7 +39,7 @@ psalm-info: ## Run psalm with info
3939
phpstan: ## Run phpstan
4040
$(DC_RUN_PHP) env XDEBUG_MODE=off vendor/bin/phpstan analyse --memory-limit=256M
4141
validate: ## Validate composer file
42-
$(DC_RUN_PHP) env XDEBUG_MODE=off composer validate
42+
$(DC_RUN_PHP) env XDEBUG_MODE=off composer validate --no-plugins
4343
packages-composer: ## Validate all composer packages
4444
$(DC_RUN) php env XDEBUG_MODE=off vendor/bin/otel packages:composer:validate
4545
bash: ## Bash shell

src/Instrumentation/CakePHP/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"ext-opentelemetry": "*",
1414
"cakephp/cakephp": "^4 || ^5",
1515
"open-telemetry/api": "^1.0",
16-
"open-telemetry/sem-conv": "^1.24"
16+
"open-telemetry/sem-conv": "^1.30"
1717
},
1818
"require-dev": {
1919
"friendsofphp/php-cs-fixer": "^3",

src/Instrumentation/CakePHP/src/CakePHPInstrumentation.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public static function register(): void
1818
$instrumentation = new CachedInstrumentation(
1919
'io.opentelemetry.contrib.php.cakephp',
2020
null,
21-
'https://opentelemetry.io/schemas/1.24.0'
21+
'https://opentelemetry.io/schemas/1.30.0',
2222
);
2323
Server::hook($instrumentation);
2424
Controller::hook($instrumentation);

src/Instrumentation/CakePHP/src/Hooks/Cake/Command/Command.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ public function instrument(): void
2626
$builder = $this->instrumentation
2727
->tracer()
2828
->spanBuilder(sprintf('Command %s', $command->getName() ?: 'unknown'))
29-
->setAttribute(TraceAttributes::CODE_FUNCTION, $function)
29+
->setAttribute(TraceAttributes::CODE_FUNCTION_NAME, $function)
3030
->setAttribute(TraceAttributes::CODE_NAMESPACE, $class)
3131
->setAttribute(TraceAttributes::CODE_FILEPATH, $filename)
32-
->setAttribute(TraceAttributes::CODE_LINENO, $lineno);
32+
->setAttribute(TraceAttributes::CODE_LINE_NUMBER, $lineno);
3333

3434
$parent = Context::getCurrent();
3535
$span = $builder->startSpan();
@@ -52,9 +52,7 @@ public function instrument(): void
5252
$span = Span::fromContext($scope->context());
5353

5454
if ($exception) {
55-
$span->recordException($exception, [
56-
TraceAttributes::EXCEPTION_ESCAPED => true,
57-
]);
55+
$span->recordException($exception);
5856
$span->setStatus(StatusCode::STATUS_ERROR, $exception->getMessage());
5957
}
6058

src/Instrumentation/CakePHP/src/Hooks/Cake/Controller/Controller.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function instrument(): void
3535
$scope->detach();
3636
$span = \OpenTelemetry\API\Trace\Span::fromContext($scope->context());
3737
if ($exception) {
38-
$span->recordException($exception, [TraceAttributes::EXCEPTION_ESCAPED => true]);
38+
$span->recordException($exception);
3939
$span->setStatus(StatusCode::STATUS_ERROR, $exception->getMessage());
4040
}
4141
$response = $app->getResponse();

src/Instrumentation/CakePHP/src/Hooks/Cake/Http/Server.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function instrument(): void
4949
$span->setAttribute(TraceAttributes::HTTP_ROUTE, $route);
5050
}
5151
if ($exception) {
52-
$span->recordException($exception, [TraceAttributes::EXCEPTION_ESCAPED => true]);
52+
$span->recordException($exception);
5353
$span->setStatus(StatusCode::STATUS_ERROR, $exception->getMessage());
5454
}
5555
if ($response) {

src/Instrumentation/CakePHP/src/Hooks/CakeHookTrait.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,10 @@ protected function buildSpan(?ServerRequestInterface $request, string $class, st
5757
: sprintf('%s', $request?->getMethod() ?? 'unknown')
5858
)
5959
->setSpanKind(SpanKind::KIND_SERVER)
60-
->setAttribute(TraceAttributes::CODE_FUNCTION, $function)
60+
->setAttribute(TraceAttributes::CODE_FUNCTION_NAME, $function)
6161
->setAttribute(TraceAttributes::CODE_NAMESPACE, $class)
6262
->setAttribute(TraceAttributes::CODE_FILEPATH, $filename)
63-
->setAttribute(TraceAttributes::CODE_LINENO, $lineno);
63+
->setAttribute(TraceAttributes::CODE_LINE_NUMBER, $lineno);
6464
$parent = Context::getCurrent();
6565
if (!$root && $request) {
6666
$this->isRoot = true;

src/Instrumentation/CakePHP/tests/Integration/CakePHPInstrumentationTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function test_index(): void
4545
$this->assertSame(SpanKind::KIND_SERVER, $serverSpan->getKind());
4646
$this->assertGreaterThan(0, $serverSpan->getAttributes()->count());
4747
$attributes = $serverSpan->getAttributes()->toArray();
48-
$this->assertSame('run', $attributes['code.function']);
48+
$this->assertSame('run', $attributes['code.function.name']);
4949
$this->assertSame('GET', $attributes['http.request.method']);
5050
$this->assertSame(200, $attributes['http.response.status_code']);
5151
$this->assertSame(self::TRACE_ID, $serverSpan->getParentContext()->getTraceId());
@@ -58,7 +58,7 @@ public function test_index(): void
5858
$this->assertSame(SpanKind::KIND_INTERNAL, $controllerSpan->getKind());
5959
$this->assertGreaterThan(0, $controllerSpan->getAttributes()->count());
6060
$attributes = $controllerSpan->getAttributes()->toArray();
61-
$this->assertSame('invokeAction', $attributes['code.function']);
61+
$this->assertSame('invokeAction', $attributes['code.function.name']);
6262
$this->assertSame($serverSpan->getTraceId(), $controllerSpan->getParentContext()->getTraceId());
6363
$this->assertSame($serverSpan->getSpanId(), $controllerSpan->getParentContext()->getSpanId());
6464
}

src/Instrumentation/CakePHP/tests/Integration/CommandTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ class CommandTest extends TestCase
1212

1313
public function test_command_tracing(): void
1414
{
15+
if (PHP_VERSION_ID < 80100) {
16+
$this->markTestSkipped();
17+
}
1518
$this->assertCount(0, $this->storage);
1619

1720
$this->exec('dummy');

0 commit comments

Comments
 (0)