diff --git a/src/Instrumentation/CakePHP/composer.json b/src/Instrumentation/CakePHP/composer.json index 75ca45542..5c041b9b0 100644 --- a/src/Instrumentation/CakePHP/composer.json +++ b/src/Instrumentation/CakePHP/composer.json @@ -13,7 +13,7 @@ "ext-opentelemetry": "*", "cakephp/cakephp": "^4 || ^5", "open-telemetry/api": "^1.0", - "open-telemetry/sem-conv": "^1.30" + "open-telemetry/sem-conv": "^1.32" }, "require-dev": { "friendsofphp/php-cs-fixer": "^3", diff --git a/src/Instrumentation/CakePHP/src/CakePHPInstrumentation.php b/src/Instrumentation/CakePHP/src/CakePHPInstrumentation.php index 6442723f5..45bea88cf 100644 --- a/src/Instrumentation/CakePHP/src/CakePHPInstrumentation.php +++ b/src/Instrumentation/CakePHP/src/CakePHPInstrumentation.php @@ -18,7 +18,7 @@ public static function register(): void $instrumentation = new CachedInstrumentation( 'io.opentelemetry.contrib.php.cakephp', null, - 'https://opentelemetry.io/schemas/1.30.0', + 'https://opentelemetry.io/schemas/1.32.0', ); Server::hook($instrumentation); Controller::hook($instrumentation); diff --git a/src/Instrumentation/CakePHP/src/Hooks/CakeHookTrait.php b/src/Instrumentation/CakePHP/src/Hooks/CakeHookTrait.php index cbbb9eb44..faaf989ff 100644 --- a/src/Instrumentation/CakePHP/src/Hooks/CakeHookTrait.php +++ b/src/Instrumentation/CakePHP/src/Hooks/CakeHookTrait.php @@ -57,9 +57,8 @@ protected function buildSpan(?ServerRequestInterface $request, string $class, st : sprintf('%s', $request?->getMethod() ?? 'unknown') ) ->setSpanKind(SpanKind::KIND_SERVER) - ->setAttribute(TraceAttributes::CODE_FUNCTION_NAME, $function) - ->setAttribute(TraceAttributes::CODE_NAMESPACE, $class) - ->setAttribute(TraceAttributes::CODE_FILEPATH, $filename) + ->setAttribute(TraceAttributes::CODE_FUNCTION_NAME, sprintf('%s::%s', $class, $function)) + ->setAttribute(TraceAttributes::CODE_FILE_PATH, $filename) ->setAttribute(TraceAttributes::CODE_LINE_NUMBER, $lineno); $parent = Context::getCurrent(); if (!$root && $request) { diff --git a/src/Instrumentation/CakePHP/tests/Integration/CakePHPInstrumentationTest.php b/src/Instrumentation/CakePHP/tests/Integration/CakePHPInstrumentationTest.php index c64f39fb8..4d3d51e01 100644 --- a/src/Instrumentation/CakePHP/tests/Integration/CakePHPInstrumentationTest.php +++ b/src/Instrumentation/CakePHP/tests/Integration/CakePHPInstrumentationTest.php @@ -45,7 +45,7 @@ public function test_index(): void $this->assertSame(SpanKind::KIND_SERVER, $serverSpan->getKind()); $this->assertGreaterThan(0, $serverSpan->getAttributes()->count()); $attributes = $serverSpan->getAttributes()->toArray(); - $this->assertSame('run', $attributes['code.function.name']); + $this->assertSame('Cake\Http\Server::run', $attributes['code.function.name']); $this->assertSame('GET', $attributes['http.request.method']); $this->assertSame(200, $attributes['http.response.status_code']); $this->assertSame(self::TRACE_ID, $serverSpan->getParentContext()->getTraceId()); @@ -58,7 +58,7 @@ public function test_index(): void $this->assertSame(SpanKind::KIND_INTERNAL, $controllerSpan->getKind()); $this->assertGreaterThan(0, $controllerSpan->getAttributes()->count()); $attributes = $controllerSpan->getAttributes()->toArray(); - $this->assertSame('invokeAction', $attributes['code.function.name']); + $this->assertSame('Cake\Controller\Controller::invokeAction', $attributes['code.function.name']); $this->assertSame($serverSpan->getTraceId(), $controllerSpan->getParentContext()->getTraceId()); $this->assertSame($serverSpan->getSpanId(), $controllerSpan->getParentContext()->getSpanId()); } diff --git a/src/Instrumentation/CodeIgniter/composer.json b/src/Instrumentation/CodeIgniter/composer.json index 2628401c2..5e5ff2ecc 100644 --- a/src/Instrumentation/CodeIgniter/composer.json +++ b/src/Instrumentation/CodeIgniter/composer.json @@ -13,7 +13,7 @@ "ext-opentelemetry": "*", "codeigniter4/framework": "^4.3", "open-telemetry/api": "^1.0", - "open-telemetry/sem-conv": "^1.30" + "open-telemetry/sem-conv": "^1.32" }, "require-dev": { "friendsofphp/php-cs-fixer": "^3.50", diff --git a/src/Instrumentation/CodeIgniter/src/CodeIgniterInstrumentation.php b/src/Instrumentation/CodeIgniter/src/CodeIgniterInstrumentation.php index 02519cec8..5508ae0d0 100644 --- a/src/Instrumentation/CodeIgniter/src/CodeIgniterInstrumentation.php +++ b/src/Instrumentation/CodeIgniter/src/CodeIgniterInstrumentation.php @@ -27,7 +27,7 @@ public static function register(): void $instrumentation = new CachedInstrumentation( 'io.opentelemetry.contrib.php.codeigniter', null, - 'https://opentelemetry.io/schemas/1.30.0', + 'https://opentelemetry.io/schemas/1.32.0', ); // The method that creates request/response/controller objects is in the same class as the method @@ -65,9 +65,8 @@ public static function register(): void /** @phan-suppress-next-line PhanDeprecatedFunction */ ->spanBuilder(\sprintf('%s', $request?->getMethod() ?? 'unknown')) ->setSpanKind(SpanKind::KIND_SERVER) - ->setAttribute(TraceAttributes::CODE_FUNCTION_NAME, $function) - ->setAttribute(TraceAttributes::CODE_NAMESPACE, $class) - ->setAttribute(TraceAttributes::CODE_FILEPATH, $filename) + ->setAttribute(TraceAttributes::CODE_FUNCTION_NAME, sprintf('%s::%s', $class, $function)) + ->setAttribute(TraceAttributes::CODE_FILE_PATH, $filename) ->setAttribute(TraceAttributes::CODE_LINE_NUMBER, $lineno); $parent = Context::getCurrent(); diff --git a/src/Instrumentation/Curl/composer.json b/src/Instrumentation/Curl/composer.json index 673832f20..7d9ed3d27 100644 --- a/src/Instrumentation/Curl/composer.json +++ b/src/Instrumentation/Curl/composer.json @@ -20,7 +20,7 @@ "ext-curl": "*", "ext-opentelemetry": "*", "open-telemetry/api": "^1.0", - "open-telemetry/sem-conv": "^1.30" + "open-telemetry/sem-conv": "^1.32" }, "require-dev": { "friendsofphp/php-cs-fixer": "^3", diff --git a/src/Instrumentation/Curl/src/CurlInstrumentation.php b/src/Instrumentation/Curl/src/CurlInstrumentation.php index 7d0c3f78f..7e04d120e 100644 --- a/src/Instrumentation/Curl/src/CurlInstrumentation.php +++ b/src/Instrumentation/Curl/src/CurlInstrumentation.php @@ -46,7 +46,7 @@ public static function register(): void $instrumentation = new CachedInstrumentation( 'io.opentelemetry.contrib.php.curl', null, - Version::VERSION_1_30_0->url(), + Version::VERSION_1_32_0->url(), ); hook( @@ -156,7 +156,7 @@ public static function register(): void ->setParent($parent) ->setSpanKind(SpanKind::KIND_CLIENT) ->setAttribute(TraceAttributes::CODE_FUNCTION_NAME, $function) - ->setAttribute(TraceAttributes::CODE_FILEPATH, $filename) + ->setAttribute(TraceAttributes::CODE_FILE_PATH, $filename) ->setAttribute(TraceAttributes::CODE_LINE_NUMBER, $lineno) ->setAttributes($curlHandleToAttributes[$params[0]]->getAttributes()); diff --git a/src/Instrumentation/Doctrine/.phan/config.php b/src/Instrumentation/Doctrine/.phan/config.php new file mode 100644 index 000000000..6bf6f35c4 --- /dev/null +++ b/src/Instrumentation/Doctrine/.phan/config.php @@ -0,0 +1,371 @@ + '8.2', + + // If enabled, missing properties will be created when + // they are first seen. If false, we'll report an + // error message if there is an attempt to write + // to a class property that wasn't explicitly + // defined. + 'allow_missing_properties' => false, + + // If enabled, null can be cast to any type and any + // type can be cast to null. Setting this to true + // will cut down on false positives. + 'null_casts_as_any_type' => false, + + // If enabled, allow null to be cast as any array-like type. + // + // This is an incremental step in migrating away from `null_casts_as_any_type`. + // If `null_casts_as_any_type` is true, this has no effect. + 'null_casts_as_array' => true, + + // If enabled, allow any array-like type to be cast to null. + // This is an incremental step in migrating away from `null_casts_as_any_type`. + // If `null_casts_as_any_type` is true, this has no effect. + 'array_casts_as_null' => true, + + // If enabled, scalars (int, float, bool, string, null) + // are treated as if they can cast to each other. + // This does not affect checks of array keys. See `scalar_array_key_cast`. + 'scalar_implicit_cast' => false, + + // If enabled, any scalar array keys (int, string) + // are treated as if they can cast to each other. + // E.g. `array` can cast to `array` and vice versa. + // Normally, a scalar type such as int could only cast to/from int and mixed. + 'scalar_array_key_cast' => true, + + // If this has entries, scalars (int, float, bool, string, null) + // are allowed to perform the casts listed. + // + // E.g. `['int' => ['float', 'string'], 'float' => ['int'], 'string' => ['int'], 'null' => ['string']]` + // allows casting null to a string, but not vice versa. + // (subset of `scalar_implicit_cast`) + 'scalar_implicit_partial' => [], + + // If enabled, Phan will warn if **any** type in a method invocation's object + // is definitely not an object, + // or if **any** type in an invoked expression is not a callable. + // Setting this to true will introduce numerous false positives + // (and reveal some bugs). + 'strict_method_checking' => false, + + // If enabled, Phan will warn if **any** type of the object expression for a property access + // does not contain that property. + 'strict_object_checking' => false, + + // If enabled, Phan will warn if **any** type in the argument's union type + // cannot be cast to a type in the parameter's expected union type. + // Setting this to true will introduce numerous false positives + // (and reveal some bugs). + 'strict_param_checking' => false, + + // If enabled, Phan will warn if **any** type in a property assignment's union type + // cannot be cast to a type in the property's declared union type. + // Setting this to true will introduce numerous false positives + // (and reveal some bugs). + 'strict_property_checking' => false, + + // If enabled, Phan will warn if **any** type in a returned value's union type + // cannot be cast to the declared return type. + // Setting this to true will introduce numerous false positives + // (and reveal some bugs). + 'strict_return_checking' => false, + + // If true, seemingly undeclared variables in the global + // scope will be ignored. + // + // This is useful for projects with complicated cross-file + // globals that you have no hope of fixing. + 'ignore_undeclared_variables_in_global_scope' => true, + + // Set this to false to emit `PhanUndeclaredFunction` issues for internal functions that Phan has signatures for, + // but aren't available in the codebase, or from Reflection. + // (may lead to false positives if an extension isn't loaded) + // + // If this is true(default), then Phan will not warn. + // + // Even when this is false, Phan will still infer return values and check parameters of internal functions + // if Phan has the signatures. + 'ignore_undeclared_functions_with_known_signatures' => true, + + // Backwards Compatibility Checking. This is slow + // and expensive, but you should consider running + // it before upgrading your version of PHP to a + // new version that has backward compatibility + // breaks. + // + // If you are migrating from PHP 5 to PHP 7, + // you should also look into using + // [php7cc (no longer maintained)](https://github.com/sstalle/php7cc) + // and [php7mar](https://github.com/Alexia/php7mar), + // which have different backwards compatibility checks. + 'backward_compatibility_checks' => false, + + // If true, check to make sure the return type declared + // in the doc-block (if any) matches the return type + // declared in the method signature. + 'check_docblock_signature_return_type_match' => false, + + // If true, make narrowed types from phpdoc params override + // the real types from the signature, when real types exist. + // (E.g. allows specifying desired lists of subclasses, + // or to indicate a preference for non-nullable types over nullable types) + // + // Affects analysis of the body of the method and the param types passed in by callers. + // + // (*Requires `check_docblock_signature_param_type_match` to be true*) + 'prefer_narrowed_phpdoc_param_type' => true, + + // (*Requires `check_docblock_signature_return_type_match` to be true*) + // + // If true, make narrowed types from phpdoc returns override + // the real types from the signature, when real types exist. + // + // (E.g. allows specifying desired lists of subclasses, + // or to indicate a preference for non-nullable types over nullable types) + // + // This setting affects the analysis of return statements in the body of the method and the return types passed in by callers. + 'prefer_narrowed_phpdoc_return_type' => true, + + // If enabled, check all methods that override a + // parent method to make sure its signature is + // compatible with the parent's. + // + // This check can add quite a bit of time to the analysis. + // + // This will also check if final methods are overridden, etc. + 'analyze_signature_compatibility' => true, + + // This setting maps case-insensitive strings to union types. + // + // This is useful if a project uses phpdoc that differs from the phpdoc2 standard. + // + // If the corresponding value is the empty string, + // then Phan will ignore that union type (E.g. can ignore 'the' in `@return the value`) + // + // If the corresponding value is not empty, + // then Phan will act as though it saw the corresponding UnionTypes(s) + // when the keys show up in a UnionType of `@param`, `@return`, `@var`, `@property`, etc. + // + // This matches the **entire string**, not parts of the string. + // (E.g. `@return the|null` will still look for a class with the name `the`, but `@return the` will be ignored with the below setting) + // + // (These are not aliases, this setting is ignored outside of doc comments). + // (Phan does not check if classes with these names exist) + // + // Example setting: `['unknown' => '', 'number' => 'int|float', 'char' => 'string', 'long' => 'int', 'the' => '']` + 'phpdoc_type_mapping' => [], + + // Set to true in order to attempt to detect dead + // (unreferenced) code. Keep in mind that the + // results will only be a guess given that classes, + // properties, constants and methods can be referenced + // as variables (like `$class->$property` or + // `$class->$method()`) in ways that we're unable + // to make sense of. + 'dead_code_detection' => false, + + // Set to true in order to attempt to detect unused variables. + // `dead_code_detection` will also enable unused variable detection. + // + // This has a few known false positives, e.g. for loops or branches. + 'unused_variable_detection' => false, + + // Set to true in order to attempt to detect redundant and impossible conditions. + // + // This has some false positives involving loops, + // variables set in branches of loops, and global variables. + 'redundant_condition_detection' => false, + + // If enabled, Phan will act as though it's certain of real return types of a subset of internal functions, + // even if those return types aren't available in reflection (real types were taken from php 7.3 or 8.0-dev, depending on target_php_version). + // + // Note that with php 7 and earlier, php would return null or false for many internal functions if the argument types or counts were incorrect. + // As a result, enabling this setting with target_php_version 8.0 may result in false positives for `--redundant-condition-detection` when codebases also support php 7.x. + 'assume_real_types_for_internal_functions' => false, + + // If true, this runs a quick version of checks that takes less + // time at the cost of not running as thorough + // of an analysis. You should consider setting this + // to true only when you wish you had more **undiagnosed** issues + // to fix in your code base. + // + // In quick-mode the scanner doesn't rescan a function + // or a method's code block every time a call is seen. + // This means that the problem here won't be detected: + // + // ```php + // false, + + // Enable or disable support for generic templated + // class types. + 'generic_types_enabled' => true, + + // Override to hardcode existence and types of (non-builtin) globals in the global scope. + // Class names should be prefixed with `\`. + // + // (E.g. `['_FOO' => '\FooClass', 'page' => '\PageClass', 'userId' => 'int']`) + 'globals_type_map' => [], + + // The minimum severity level to report on. This can be + // set to `Issue::SEVERITY_LOW`, `Issue::SEVERITY_NORMAL` or + // `Issue::SEVERITY_CRITICAL`. Setting it to only + // critical issues is a good place to start on a big + // sloppy mature code base. + 'minimum_severity' => Issue::SEVERITY_LOW, + + // Add any issue types (such as `'PhanUndeclaredMethod'`) + // to this deny-list to inhibit them from being reported. + 'suppress_issue_types' => [], + + // A regular expression to match files to be excluded + // from parsing and analysis and will not be read at all. + // + // This is useful for excluding groups of test or example + // directories/files, unanalyzable files, or files that + // can't be removed for whatever reason. + // (e.g. `'@Test\.php$@'`, or `'@vendor/.*/(tests|Tests)/@'`) + 'exclude_file_regex' => '@^vendor/.*/(tests?|Tests?)/@', + + // A list of files that will be excluded from parsing and analysis + // and will not be read at all. + // + // This is useful for excluding hopelessly unanalyzable + // files that can't be removed for whatever reason. + 'exclude_file_list' => [ + 'vendor/composer/composer/src/Composer/InstalledVersions.php' + ], + + // A directory list that defines files that will be excluded + // from static analysis, but whose class and method + // information should be included. + // + // Generally, you'll want to include the directories for + // third-party code (such as "vendor/") in this list. + // + // n.b.: If you'd like to parse but not analyze 3rd + // party code, directories containing that code + // should be added to the `directory_list` as well as + // to `exclude_analysis_directory_list`. + 'exclude_analysis_directory_list' => [ + 'vendor/', + 'proto/', + 'thrift/' + ], + + // Enable this to enable checks of require/include statements referring to valid paths. + 'enable_include_path_checks' => true, + + // The number of processes to fork off during the analysis + // phase. + 'processes' => 1, + + // List of case-insensitive file extensions supported by Phan. + // (e.g. `['php', 'html', 'htm']`) + 'analyzed_file_extensions' => [ + 'php', + ], + + // You can put paths to stubs of internal extensions in this config option. + // If the corresponding extension is **not** loaded, then Phan will use the stubs instead. + // Phan will continue using its detailed type annotations, + // but load the constants, classes, functions, and classes (and their Reflection types) + // from these stub files (doubling as valid php files). + // Use a different extension from php to avoid accidentally loading these. + // The `tools/make_stubs` script can be used to generate your own stubs (compatible with php 7.0+ right now) + // + // (e.g. `['xdebug' => '.phan/internal_stubs/xdebug.phan_php']`) + 'autoload_internal_extension_signatures' => [], + + // A list of plugin files to execute. + // + // Plugins which are bundled with Phan can be added here by providing their name (e.g. `'AlwaysReturnPlugin'`) + // + // Documentation about available bundled plugins can be found [here](https://github.com/phan/phan/tree/master/.phan/plugins). + // + // Alternately, you can pass in the full path to a PHP file with the plugin's implementation (e.g. `'vendor/phan/phan/.phan/plugins/AlwaysReturnPlugin.php'`) + 'plugins' => [ + 'AlwaysReturnPlugin', + 'PregRegexCheckerPlugin', + 'UnreachableCodePlugin', + ], + + // A list of directories that should be parsed for class and + // method information. After excluding the directories + // defined in `exclude_analysis_directory_list`, the remaining + // files will be statically analyzed for errors. + // + // Thus, both first-party and third-party code being used by + // your application should be included in this list. + 'directory_list' => [ + 'src', + 'vendor' + ], + + // A list of individual files to include in analysis + // with a path relative to the root directory of the + // project. + 'file_list' => [], +]; diff --git a/src/Instrumentation/Doctrine/composer.json b/src/Instrumentation/Doctrine/composer.json index 352fe07d3..f32f2568e 100644 --- a/src/Instrumentation/Doctrine/composer.json +++ b/src/Instrumentation/Doctrine/composer.json @@ -20,7 +20,7 @@ "ext-opentelemetry": "*", "doctrine/dbal": "^3 || ^4 || ^5", "open-telemetry/api": "^1.0", - "open-telemetry/sem-conv": "^1.24" + "open-telemetry/sem-conv": "^1.32" }, "require-dev": { "friendsofphp/php-cs-fixer": "^3", diff --git a/src/Instrumentation/Doctrine/src/AttributesResolver.php b/src/Instrumentation/Doctrine/src/AttributesResolver.php index 6ca182fc2..de7a6e261 100644 --- a/src/Instrumentation/Doctrine/src/AttributesResolver.php +++ b/src/Instrumentation/Doctrine/src/AttributesResolver.php @@ -74,9 +74,9 @@ private static function getServerPort(array $params): ?int } /** - * Resolve attribute `db.system` + * Resolve attribute `db.system.name` */ - private static function getDbSystem(array $params) + private static function getDbSystemName(array $params) { $dbSystem = $params[1][0]['driver'] ?? null; diff --git a/src/Instrumentation/Doctrine/src/DoctrineInstrumentation.php b/src/Instrumentation/Doctrine/src/DoctrineInstrumentation.php index 5534c6100..c37003850 100644 --- a/src/Instrumentation/Doctrine/src/DoctrineInstrumentation.php +++ b/src/Instrumentation/Doctrine/src/DoctrineInstrumentation.php @@ -33,7 +33,7 @@ public static function register(): void ->setSpanKind(SpanKind::KIND_CLIENT) ->setAttribute(TraceAttributes::SERVER_ADDRESS, AttributesResolver::get(TraceAttributes::SERVER_ADDRESS, func_get_args())) ->setAttribute(TraceAttributes::SERVER_PORT, AttributesResolver::get(TraceAttributes::SERVER_PORT, func_get_args())) - ->setAttribute(TraceAttributes::DB_SYSTEM, AttributesResolver::get(TraceAttributes::DB_SYSTEM, func_get_args())) + ->setAttribute(TraceAttributes::DB_SYSTEM_NAME, AttributesResolver::get(TraceAttributes::DB_SYSTEM_NAME, func_get_args())) ->setAttribute(TraceAttributes::DB_NAMESPACE, AttributesResolver::get(TraceAttributes::DB_NAMESPACE, func_get_args())); $parent = Context::getCurrent(); $span = $builder->startSpan(); @@ -158,10 +158,9 @@ private static function makeBuilder( /** @psalm-suppress ArgumentTypeCoercion */ return $instrumentation->tracer() ->spanBuilder($name) - ->setAttribute(TraceAttributes::CODE_FUNCTION, $function) - ->setAttribute(TraceAttributes::CODE_NAMESPACE, $class) - ->setAttribute(TraceAttributes::CODE_FILEPATH, $filename) - ->setAttribute(TraceAttributes::CODE_LINENO, $lineno); + ->setAttribute(TraceAttributes::CODE_FUNCTION_NAME, sprintf('%s::%s', $class, $function)) + ->setAttribute(TraceAttributes::CODE_FILE_PATH, $filename) + ->setAttribute(TraceAttributes::CODE_LINE_NUMBER, $lineno); } private static function end(?Throwable $exception): void { @@ -172,7 +171,7 @@ private static function end(?Throwable $exception): void $scope->detach(); $span = Span::fromContext($scope->context()); if ($exception) { - $span->recordException($exception, [TraceAttributes::EXCEPTION_ESCAPED => true]); + $span->recordException($exception); $span->setStatus(StatusCode::STATUS_ERROR, $exception->getMessage()); } diff --git a/src/Instrumentation/Doctrine/tests/Integration/DoctrineInstrumentationTest.php b/src/Instrumentation/Doctrine/tests/Integration/DoctrineInstrumentationTest.php index 36219490c..d4aa4feef 100644 --- a/src/Instrumentation/Doctrine/tests/Integration/DoctrineInstrumentationTest.php +++ b/src/Instrumentation/Doctrine/tests/Integration/DoctrineInstrumentationTest.php @@ -79,7 +79,7 @@ public function test_connection(): void $this->assertTrue($conn->isConnected()); $span = $this->storage->offsetGet(0); $this->assertSame('Doctrine\DBAL\Driver::connect', $span->getName()); - $this->assertEquals('sqlite', $span->getAttributes()->get(TraceAttributes::DB_SYSTEM)); + $this->assertEquals('sqlite', $span->getAttributes()->get(TraceAttributes::DB_SYSTEM_NAME)); } public function test_connection_exception(): void diff --git a/src/Instrumentation/ExtAmqp/composer.json b/src/Instrumentation/ExtAmqp/composer.json index d50ecb503..d51778a1c 100644 --- a/src/Instrumentation/ExtAmqp/composer.json +++ b/src/Instrumentation/ExtAmqp/composer.json @@ -7,13 +7,14 @@ "readme": "./README.md", "license": "Apache-2.0", "minimum-stability": "dev", + "prefer-stable": true, "require": { "php": "^8.2", "composer-runtime-api": "^2.0", "ext-amqp": "*", "ext-opentelemetry": "*", "open-telemetry/api": "^1", - "open-telemetry/sem-conv": "^1.30" + "open-telemetry/sem-conv": "^1.32" }, "require-dev": { "friendsofphp/php-cs-fixer": "^3", diff --git a/src/Instrumentation/ExtAmqp/src/ExtAmqpInstrumentation.php b/src/Instrumentation/ExtAmqp/src/ExtAmqpInstrumentation.php index b929c767d..79283038c 100644 --- a/src/Instrumentation/ExtAmqp/src/ExtAmqpInstrumentation.php +++ b/src/Instrumentation/ExtAmqp/src/ExtAmqpInstrumentation.php @@ -33,7 +33,7 @@ public static function register(): void $instrumentation = new CachedInstrumentation( 'io.opentelemetry.contrib.php.ext_amqp', InstalledVersions::getVersion('open-telemetry/opentelemetry-auto-ext-amqp'), - 'https://opentelemetry.io/schemas/1.24.0', + 'https://opentelemetry.io/schemas/1.32.0', ); /** @psalm-suppress UnusedFunctionCall */ @@ -56,13 +56,12 @@ public static function register(): void ->spanBuilder(sprintf('%s%s', $exchange->getName() != '' ? $exchange->getName() . ' ': '', $routingKey) . ' publish') ->setSpanKind(SpanKind::KIND_PRODUCER) // code - ->setAttribute(TraceAttributes::CODE_FUNCTION_NAME, $function) - ->setAttribute(TraceAttributes::CODE_NAMESPACE, $class) - ->setAttribute(TraceAttributes::CODE_FILEPATH, $filename) + ->setAttribute(TraceAttributes::CODE_FUNCTION_NAME, sprintf('%s::%s', $class, $function)) + ->setAttribute(TraceAttributes::CODE_FILE_PATH, $filename) ->setAttribute(TraceAttributes::CODE_LINE_NUMBER, $lineno) // messaging ->setAttribute(TraceAttributes::MESSAGING_SYSTEM, 'amqp') - ->setAttribute(TraceAttributes::MESSAGING_OPERATION, 'publish') + ->setAttribute(TraceAttributes::MESSAGING_OPERATION_TYPE, 'publish') ->setAttribute('messaging.destination', $routingKey) ->setAttribute(TraceAttributes::MESSAGING_DESTINATION_NAME, $routingKey) @@ -74,14 +73,10 @@ public static function register(): void ->setAttribute('messaging.rabbitmq.destination.routing.key', $routingKey) // network - ->setAttribute(TraceAttributes::NET_PROTOCOL_NAME, 'amqp') ->setAttribute(TraceAttributes::NETWORK_PROTOCOL_NAME, 'amqp') - ->setAttribute(TraceAttributes::NET_TRANSPORT, 'tcp') ->setAttribute(TraceAttributes::NETWORK_TRANSPORT, 'tcp') - ->setAttribute(TraceAttributes::NET_PEER_NAME, $exchange->getConnection()->getHost()) ->setAttribute(TraceAttributes::NETWORK_PEER_ADDRESS, $exchange->getConnection()->getHost()) - ->setAttribute(TraceAttributes::NET_PEER_PORT, $exchange->getConnection()->getPort()) ->setAttribute(TraceAttributes::NETWORK_PEER_PORT, $exchange->getConnection()->getPort()) ; @@ -170,13 +165,12 @@ protected static function createInteractionWithQueueSpan(CachedInstrumentation $ ->spanBuilder($queueName . ' ' . $method) ->setSpanKind(SpanKind::KIND_CLIENT) // code - ->setAttribute(TraceAttributes::CODE_FUNCTION_NAME, $function) - ->setAttribute(TraceAttributes::CODE_NAMESPACE, $class) - ->setAttribute(TraceAttributes::CODE_FILEPATH, $filename) + ->setAttribute(TraceAttributes::CODE_FUNCTION_NAME, sprintf('%s::%s', $class, $function)) + ->setAttribute(TraceAttributes::CODE_FILE_PATH, $filename) ->setAttribute(TraceAttributes::CODE_LINE_NUMBER, $lineno) // messaging ->setAttribute(TraceAttributes::MESSAGING_SYSTEM, 'amqp') - ->setAttribute(TraceAttributes::MESSAGING_OPERATION, $method) + ->setAttribute(TraceAttributes::MESSAGING_OPERATION_TYPE, $method) ->setAttribute('messaging.destination.kind', 'queue') @@ -186,14 +180,10 @@ protected static function createInteractionWithQueueSpan(CachedInstrumentation $ ->setAttribute(TraceAttributes::MESSAGING_CLIENT_ID, $queue->getConsumerTag()) - ->setAttribute(TraceAttributes::NET_PROTOCOL_NAME, 'amqp') ->setAttribute(TraceAttributes::NETWORK_PROTOCOL_NAME, 'amqp') - ->setAttribute(TraceAttributes::NET_TRANSPORT, 'tcp') ->setAttribute(TraceAttributes::NETWORK_TRANSPORT, 'tcp') - ->setAttribute(TraceAttributes::NET_PEER_NAME, $queue->getChannel()->getConnection()->getHost()) ->setAttribute(TraceAttributes::NETWORK_PEER_ADDRESS, $queue->getChannel()->getConnection()->getHost()) - ->setAttribute(TraceAttributes::NET_PEER_PORT, $queue->getChannel()->getConnection()->getPort()) ->setAttribute(TraceAttributes::NETWORK_PEER_PORT, $queue->getChannel()->getConnection()->getPort()) ; diff --git a/src/Instrumentation/ExtRdKafka/composer.json b/src/Instrumentation/ExtRdKafka/composer.json index 13c2c6c22..bb6f8e29c 100644 --- a/src/Instrumentation/ExtRdKafka/composer.json +++ b/src/Instrumentation/ExtRdKafka/composer.json @@ -13,7 +13,7 @@ "ext-rdkafka": "*", "ext-opentelemetry": "*", "open-telemetry/api": "^1.0", - "open-telemetry/sem-conv": "^1.30", + "open-telemetry/sem-conv": "^1.32", "composer-runtime-api": "^2.0" }, "require-dev": { diff --git a/src/Instrumentation/ExtRdKafka/src/ExtRdKafkaInstrumentation.php b/src/Instrumentation/ExtRdKafka/src/ExtRdKafkaInstrumentation.php index 981399ef5..15383b95d 100644 --- a/src/Instrumentation/ExtRdKafka/src/ExtRdKafkaInstrumentation.php +++ b/src/Instrumentation/ExtRdKafka/src/ExtRdKafkaInstrumentation.php @@ -32,7 +32,7 @@ public static function register(): void $instrumentation = new CachedInstrumentation( 'io.opentelemetry.contrib.php.ext_rdkafka', InstalledVersions::getVersion('open-telemetry/opentelemetry-auto-ext-rdkafka'), - Version::VERSION_1_30_0->url(), + Version::VERSION_1_32_0->url(), ); // Start root span and propagate parent if it exists in headers, for each message consumed @@ -81,9 +81,8 @@ private static function addProductionHooks($instrumentation) ->tracer() ->spanBuilder(sprintf('%s %s', TraceAttributeValues::MESSAGING_OPERATION_TYPE_SEND, $exchange->getName())) ->setSpanKind(SpanKind::KIND_PRODUCER) - ->setAttribute(TraceAttributes::CODE_FUNCTION_NAME, $function) - ->setAttribute(TraceAttributes::CODE_NAMESPACE, $class) - ->setAttribute(TraceAttributes::CODE_FILEPATH, $filename) + ->setAttribute(TraceAttributes::CODE_FUNCTION_NAME, sprintf('%s::%s', $class, $function)) + ->setAttribute(TraceAttributes::CODE_FILE_PATH, $filename) ->setAttribute(TraceAttributes::CODE_LINE_NUMBER, $lineno) ->setAttribute(TraceAttributes::MESSAGING_SYSTEM, TraceAttributeValues::MESSAGING_SYSTEM_KAFKA) ->setAttribute(TraceAttributes::MESSAGING_OPERATION_TYPE, TraceAttributeValues::MESSAGING_OPERATION_TYPE_SEND) diff --git a/src/Instrumentation/Guzzle/composer.json b/src/Instrumentation/Guzzle/composer.json index 095260c34..3944f2e65 100644 --- a/src/Instrumentation/Guzzle/composer.json +++ b/src/Instrumentation/Guzzle/composer.json @@ -12,7 +12,7 @@ "php": "^8.1", "ext-opentelemetry": "*", "open-telemetry/api": "^1.0", - "open-telemetry/sem-conv": "^1.30", + "open-telemetry/sem-conv": "^1.32", "guzzlehttp/guzzle": "^7" }, "require-dev": { diff --git a/src/Instrumentation/Guzzle/src/GuzzleInstrumentation.php b/src/Instrumentation/Guzzle/src/GuzzleInstrumentation.php index 62722e850..ace1c622b 100644 --- a/src/Instrumentation/Guzzle/src/GuzzleInstrumentation.php +++ b/src/Instrumentation/Guzzle/src/GuzzleInstrumentation.php @@ -32,7 +32,7 @@ public static function register(): void $instrumentation = new CachedInstrumentation( 'io.opentelemetry.contrib.php.guzzle', null, - 'https://opentelemetry.io/schemas/1.30.0', + 'https://opentelemetry.io/schemas/1.32.0', ); /** @psalm-suppress UnusedFunctionCall */ @@ -60,9 +60,8 @@ public static function register(): void ->setAttribute(TraceAttributes::SERVER_ADDRESS, $request->getUri()->getHost()) ->setAttribute(TraceAttributes::SERVER_PORT, $request->getUri()->getPort()) ->setAttribute(TraceAttributes::URL_PATH, $request->getUri()->getPath()) - ->setAttribute(TraceAttributes::CODE_FUNCTION_NAME, $function) - ->setAttribute(TraceAttributes::CODE_NAMESPACE, $class) - ->setAttribute(TraceAttributes::CODE_FILEPATH, $filename) + ->setAttribute(TraceAttributes::CODE_FUNCTION_NAME, sprintf('%s::%s', $class, $function)) + ->setAttribute(TraceAttributes::CODE_FILE_PATH, $filename) ->setAttribute(TraceAttributes::CODE_LINE_NUMBER, $lineno) ; diff --git a/src/Instrumentation/HttpAsyncClient/composer.json b/src/Instrumentation/HttpAsyncClient/composer.json index 7222bc0be..6a75b088b 100644 --- a/src/Instrumentation/HttpAsyncClient/composer.json +++ b/src/Instrumentation/HttpAsyncClient/composer.json @@ -12,7 +12,7 @@ "php": "^8.1", "ext-opentelemetry": "*", "open-telemetry/api": "^1.0", - "open-telemetry/sem-conv": "^1.30", + "open-telemetry/sem-conv": "^1.32", "php-http/httplug": "^2" }, "autoload": { diff --git a/src/Instrumentation/HttpAsyncClient/src/HttpAsyncClientInstrumentation.php b/src/Instrumentation/HttpAsyncClient/src/HttpAsyncClientInstrumentation.php index 4ffb61614..a92bd22a3 100644 --- a/src/Instrumentation/HttpAsyncClient/src/HttpAsyncClientInstrumentation.php +++ b/src/Instrumentation/HttpAsyncClient/src/HttpAsyncClientInstrumentation.php @@ -27,7 +27,7 @@ public static function register(): void { $instrumentation = new CachedInstrumentation( 'io.opentelemetry.contrib.php.http-async-client', - schemaUrl: 'https://opentelemetry.io/schemas/1.30.0', + schemaUrl: 'https://opentelemetry.io/schemas/1.32.0', ); /** @psalm-suppress UnusedFunctionCall */ @@ -58,9 +58,8 @@ public static function register(): void ->setAttribute(TraceAttributes::HTTP_REQUEST_BODY_SIZE, $request->getHeaderLine('Content-Length')) ->setAttribute(TraceAttributes::SERVER_ADDRESS, $request->getUri()->getHost()) ->setAttribute(TraceAttributes::SERVER_PORT, $request->getUri()->getPort()) - ->setAttribute(TraceAttributes::CODE_FUNCTION_NAME, $function) - ->setAttribute(TraceAttributes::CODE_NAMESPACE, $class) - ->setAttribute(TraceAttributes::CODE_FILEPATH, $filename) + ->setAttribute(TraceAttributes::CODE_FUNCTION_NAME, sprintf('%s::%s', $class, $function)) + ->setAttribute(TraceAttributes::CODE_FILE_PATH, $filename) ->setAttribute(TraceAttributes::CODE_LINE_NUMBER, $lineno) ; diff --git a/src/Instrumentation/IO/composer.json b/src/Instrumentation/IO/composer.json index 493b260d2..5e2aa26af 100644 --- a/src/Instrumentation/IO/composer.json +++ b/src/Instrumentation/IO/composer.json @@ -12,7 +12,7 @@ "php": "^8.2", "ext-opentelemetry": "*", "open-telemetry/api": "^1.0", - "open-telemetry/sem-conv": "^1.30" + "open-telemetry/sem-conv": "^1.32" }, "require-dev": { "friendsofphp/php-cs-fixer": "^3", diff --git a/src/Instrumentation/IO/src/IOInstrumentation.php b/src/Instrumentation/IO/src/IOInstrumentation.php index ca39c7104..0582960f7 100644 --- a/src/Instrumentation/IO/src/IOInstrumentation.php +++ b/src/Instrumentation/IO/src/IOInstrumentation.php @@ -24,7 +24,7 @@ public static function register(): void $instrumentation = new CachedInstrumentation( 'io.opentelemetry.contrib.php.io', null, - Version::VERSION_1_30_0->url(), + Version::VERSION_1_32_0->url(), ); self::_hook($instrumentation, null, 'fopen', 'fopen'); @@ -71,7 +71,7 @@ private static function makeBuilder( return $instrumentation->tracer() ->spanBuilder($name) ->setAttribute(TraceAttributes::CODE_FUNCTION_NAME, $function) - ->setAttribute(TraceAttributes::CODE_FILEPATH, $filename) + ->setAttribute(TraceAttributes::CODE_FILE_PATH, $filename) ->setAttribute(TraceAttributes::CODE_LINE_NUMBER, $lineno); } private static function end(?Throwable $exception): void diff --git a/src/Instrumentation/Laravel/composer.json b/src/Instrumentation/Laravel/composer.json index dad8597bf..f5a188aad 100644 --- a/src/Instrumentation/Laravel/composer.json +++ b/src/Instrumentation/Laravel/composer.json @@ -14,7 +14,7 @@ "ext-opentelemetry": "*", "laravel/framework": "^6.0 || ^7.0 || ^8.0 || ^9.0 || ^10.0 || ^11.0 || ^12.0", "open-telemetry/api": "^1.0", - "open-telemetry/sem-conv": "^1.30" + "open-telemetry/sem-conv": "^1.32" }, "require-dev": { "friendsofphp/php-cs-fixer": "^3.50", diff --git a/src/Instrumentation/Laravel/src/Hooks/Illuminate/Console/Command.php b/src/Instrumentation/Laravel/src/Hooks/Illuminate/Console/Command.php index 48b23d516..2b2bbc867 100644 --- a/src/Instrumentation/Laravel/src/Hooks/Illuminate/Console/Command.php +++ b/src/Instrumentation/Laravel/src/Hooks/Illuminate/Console/Command.php @@ -35,9 +35,8 @@ protected function hookExecute(): bool $builder = $this->instrumentation ->tracer() ->spanBuilder(sprintf('Command %s', $command->getName() ?: 'unknown')) - ->setAttribute(TraceAttributes::CODE_FUNCTION_NAME, $function) - ->setAttribute(TraceAttributes::CODE_NAMESPACE, $class) - ->setAttribute(TraceAttributes::CODE_FILEPATH, $filename) + ->setAttribute(TraceAttributes::CODE_FUNCTION_NAME, sprintf('%s::%s', $class, $function)) + ->setAttribute(TraceAttributes::CODE_FILE_PATH, $filename) ->setAttribute(TraceAttributes::CODE_LINE_NUMBER, $lineno); $parent = Context::getCurrent(); diff --git a/src/Instrumentation/Laravel/src/Hooks/Illuminate/Contracts/Console/Kernel.php b/src/Instrumentation/Laravel/src/Hooks/Illuminate/Contracts/Console/Kernel.php index 8afa2947a..2a1c9e29c 100644 --- a/src/Instrumentation/Laravel/src/Hooks/Illuminate/Contracts/Console/Kernel.php +++ b/src/Instrumentation/Laravel/src/Hooks/Illuminate/Contracts/Console/Kernel.php @@ -44,9 +44,8 @@ private function hookHandle(): bool ->tracer() ->spanBuilder('Artisan handler') ->setSpanKind(SpanKind::KIND_PRODUCER) - ->setAttribute(TraceAttributes::CODE_FUNCTION_NAME, $function) - ->setAttribute(TraceAttributes::CODE_NAMESPACE, $class) - ->setAttribute(TraceAttributes::CODE_FILEPATH, $filename) + ->setAttribute(TraceAttributes::CODE_FUNCTION_NAME, sprintf('%s::%s', $class, $function)) + ->setAttribute(TraceAttributes::CODE_FILE_PATH, $filename) ->setAttribute(TraceAttributes::CODE_LINE_NUMBER, $lineno); $parent = Context::getCurrent(); diff --git a/src/Instrumentation/Laravel/src/Hooks/Illuminate/Contracts/Http/Kernel.php b/src/Instrumentation/Laravel/src/Hooks/Illuminate/Contracts/Http/Kernel.php index b0c0eb931..bd564a9c6 100644 --- a/src/Instrumentation/Laravel/src/Hooks/Illuminate/Contracts/Http/Kernel.php +++ b/src/Instrumentation/Laravel/src/Hooks/Illuminate/Contracts/Http/Kernel.php @@ -46,9 +46,8 @@ protected function hookHandle(): bool ->tracer() ->spanBuilder(sprintf('%s', $request?->method() ?? 'unknown')) ->setSpanKind(SpanKind::KIND_SERVER) - ->setAttribute(TraceAttributes::CODE_FUNCTION_NAME, $function) - ->setAttribute(TraceAttributes::CODE_NAMESPACE, $class) - ->setAttribute(TraceAttributes::CODE_FILEPATH, $filename) + ->setAttribute(TraceAttributes::CODE_FUNCTION_NAME, sprintf('%s::%s', $class, $function)) + ->setAttribute(TraceAttributes::CODE_FILE_PATH, $filename) ->setAttribute(TraceAttributes::CODE_LINE_NUMBER, $lineno); $parent = Context::getCurrent(); if ($request) { diff --git a/src/Instrumentation/Laravel/src/Hooks/Illuminate/Contracts/Queue/Queue.php b/src/Instrumentation/Laravel/src/Hooks/Illuminate/Contracts/Queue/Queue.php index 96ec455e1..403cab68b 100644 --- a/src/Instrumentation/Laravel/src/Hooks/Illuminate/Contracts/Queue/Queue.php +++ b/src/Instrumentation/Laravel/src/Hooks/Illuminate/Contracts/Queue/Queue.php @@ -39,9 +39,8 @@ protected function hookBulk(): bool 'bulk', pre: function (QueueContract $queue, array $params, string $class, string $function, ?string $filename, ?int $lineno) { $attributes = array_merge([ - TraceAttributes::CODE_FUNCTION_NAME => $function, - TraceAttributes::CODE_NAMESPACE => $class, - TraceAttributes::CODE_FILEPATH => $filename, + TraceAttributes::CODE_FUNCTION_NAME => sprintf('%s::%s', $class, $function), + TraceAttributes::CODE_FILE_PATH => $filename, TraceAttributes::CODE_LINE_NUMBER => $lineno, TraceAttributes::MESSAGING_BATCH_MESSAGE_COUNT => count($params[0] ?? []), ], $this->contextualMessageSystemAttributes($queue, [])); @@ -83,9 +82,8 @@ protected function hookLater(): bool }; $attributes = [ - TraceAttributes::CODE_FUNCTION_NAME => $function, - TraceAttributes::CODE_NAMESPACE => $class, - TraceAttributes::CODE_FILEPATH => $filename, + TraceAttributes::CODE_FUNCTION_NAME => sprintf('%s::%s', $class, $function), + TraceAttributes::CODE_FILE_PATH => $filename, TraceAttributes::CODE_LINE_NUMBER => $lineno, 'messaging.message.delivery_timestamp' => $estimateDeliveryTimestamp, ]; diff --git a/src/Instrumentation/Laravel/src/Hooks/Illuminate/Database/Eloquent/Model.php b/src/Instrumentation/Laravel/src/Hooks/Illuminate/Database/Eloquent/Model.php index 70de1bfa3..610cdb8ab 100644 --- a/src/Instrumentation/Laravel/src/Hooks/Illuminate/Database/Eloquent/Model.php +++ b/src/Instrumentation/Laravel/src/Hooks/Illuminate/Database/Eloquent/Model.php @@ -42,9 +42,8 @@ private function hookFind(): void ->tracer() ->spanBuilder($model::class . '::find') ->setSpanKind(SpanKind::KIND_INTERNAL) - ->setAttribute(TraceAttributes::CODE_FUNCTION_NAME, $function) - ->setAttribute(TraceAttributes::CODE_NAMESPACE, $class) - ->setAttribute(TraceAttributes::CODE_FILEPATH, $filename) + ->setAttribute(TraceAttributes::CODE_FUNCTION_NAME, sprintf('%s::%s', $class, $function)) + ->setAttribute(TraceAttributes::CODE_FILE_PATH, $filename) ->setAttribute(TraceAttributes::CODE_LINE_NUMBER, $lineno) ->setAttribute('laravel.eloquent.model', $model::class) ->setAttribute('laravel.eloquent.table', $model->getTable()) @@ -73,9 +72,8 @@ private function hookPerformUpdate(): void ->tracer() ->spanBuilder($model::class . '::update') ->setSpanKind(SpanKind::KIND_INTERNAL) - ->setAttribute(TraceAttributes::CODE_FUNCTION_NAME, $function) - ->setAttribute(TraceAttributes::CODE_NAMESPACE, $class) - ->setAttribute(TraceAttributes::CODE_FILEPATH, $filename) + ->setAttribute(TraceAttributes::CODE_FUNCTION_NAME, sprintf('%s::%s', $class, $function)) + ->setAttribute(TraceAttributes::CODE_FILE_PATH, $filename) ->setAttribute(TraceAttributes::CODE_LINE_NUMBER, $lineno) ->setAttribute('laravel.eloquent.model', $model::class) ->setAttribute('laravel.eloquent.table', $model->getTable()) @@ -104,9 +102,8 @@ private function hookPerformInsert(): void ->tracer() ->spanBuilder($model::class . '::create') ->setSpanKind(SpanKind::KIND_INTERNAL) - ->setAttribute(TraceAttributes::CODE_FUNCTION_NAME, $function) - ->setAttribute(TraceAttributes::CODE_NAMESPACE, $class) - ->setAttribute(TraceAttributes::CODE_FILEPATH, $filename) + ->setAttribute(TraceAttributes::CODE_FUNCTION_NAME, sprintf('%s::%s', $class, $function)) + ->setAttribute(TraceAttributes::CODE_FILE_PATH, $filename) ->setAttribute(TraceAttributes::CODE_LINE_NUMBER, $lineno) ->setAttribute('laravel.eloquent.model', $model::class) ->setAttribute('laravel.eloquent.table', $model->getTable()) @@ -135,9 +132,8 @@ private function hookDelete(): void ->tracer() ->spanBuilder($model::class . '::delete') ->setSpanKind(SpanKind::KIND_INTERNAL) - ->setAttribute(TraceAttributes::CODE_FUNCTION_NAME, $function) - ->setAttribute(TraceAttributes::CODE_NAMESPACE, $class) - ->setAttribute(TraceAttributes::CODE_FILEPATH, $filename) + ->setAttribute(TraceAttributes::CODE_FUNCTION_NAME, sprintf('%s::%s', $class, $function)) + ->setAttribute(TraceAttributes::CODE_FILE_PATH, $filename) ->setAttribute(TraceAttributes::CODE_LINE_NUMBER, $lineno) ->setAttribute('laravel.eloquent.model', $model::class) ->setAttribute('laravel.eloquent.table', $model->getTable()) @@ -167,9 +163,8 @@ private function hookGetModels(): void ->tracer() ->spanBuilder($model::class . '::get') ->setSpanKind(SpanKind::KIND_INTERNAL) - ->setAttribute(TraceAttributes::CODE_FUNCTION_NAME, $function) - ->setAttribute(TraceAttributes::CODE_NAMESPACE, $class) - ->setAttribute(TraceAttributes::CODE_FILEPATH, $filename) + ->setAttribute(TraceAttributes::CODE_FUNCTION_NAME, sprintf('%s::%s', $class, $function)) + ->setAttribute(TraceAttributes::CODE_FILE_PATH, $filename) ->setAttribute(TraceAttributes::CODE_LINE_NUMBER, $lineno) ->setAttribute('laravel.eloquent.model', $model::class) ->setAttribute('laravel.eloquent.table', $model->getTable()) @@ -199,9 +194,8 @@ private function hookDestroy(): void ->tracer() ->spanBuilder($model::class . '::destroy') ->setSpanKind(SpanKind::KIND_INTERNAL) - ->setAttribute(TraceAttributes::CODE_FUNCTION_NAME, $function) - ->setAttribute(TraceAttributes::CODE_NAMESPACE, $class) - ->setAttribute(TraceAttributes::CODE_FILEPATH, $filename) + ->setAttribute(TraceAttributes::CODE_FUNCTION_NAME, sprintf('%s::%s', $class, $function)) + ->setAttribute(TraceAttributes::CODE_FILE_PATH, $filename) ->setAttribute(TraceAttributes::CODE_LINE_NUMBER, $lineno) ->setAttribute('laravel.eloquent.model', $model::class) ->setAttribute('laravel.eloquent.table', $model->getTable()) @@ -230,9 +224,8 @@ private function hookRefresh(): void ->tracer() ->spanBuilder($model::class . '::refresh') ->setSpanKind(SpanKind::KIND_INTERNAL) - ->setAttribute(TraceAttributes::CODE_FUNCTION_NAME, $function) - ->setAttribute(TraceAttributes::CODE_NAMESPACE, $class) - ->setAttribute(TraceAttributes::CODE_FILEPATH, $filename) + ->setAttribute(TraceAttributes::CODE_FUNCTION_NAME, sprintf('%s::%s', $class, $function)) + ->setAttribute(TraceAttributes::CODE_FILE_PATH, $filename) ->setAttribute(TraceAttributes::CODE_LINE_NUMBER, $lineno) ->setAttribute('laravel.eloquent.model', $model::class) ->setAttribute('laravel.eloquent.table', $model->getTable()) diff --git a/src/Instrumentation/Laravel/src/Hooks/Illuminate/Queue/SyncQueue.php b/src/Instrumentation/Laravel/src/Hooks/Illuminate/Queue/SyncQueue.php index 2845f253d..2934b2750 100644 --- a/src/Instrumentation/Laravel/src/Hooks/Illuminate/Queue/SyncQueue.php +++ b/src/Instrumentation/Laravel/src/Hooks/Illuminate/Queue/SyncQueue.php @@ -41,9 +41,8 @@ protected function hookPush(): bool ])) ->setSpanKind(SpanKind::KIND_INTERNAL) ->setAttributes([ - TraceAttributes::CODE_FUNCTION_NAME => $function, - TraceAttributes::CODE_NAMESPACE => $class, - TraceAttributes::CODE_FILEPATH => $filename, + TraceAttributes::CODE_FUNCTION_NAME => sprintf('%s::%s', $class, $function), + TraceAttributes::CODE_FILE_PATH => $filename, TraceAttributes::CODE_LINE_NUMBER => $lineno, ]) ->startSpan(); diff --git a/src/Instrumentation/Laravel/src/LaravelInstrumentation.php b/src/Instrumentation/Laravel/src/LaravelInstrumentation.php index efd32ed99..e3c210ba8 100644 --- a/src/Instrumentation/Laravel/src/LaravelInstrumentation.php +++ b/src/Instrumentation/Laravel/src/LaravelInstrumentation.php @@ -17,7 +17,7 @@ public static function register(): void $instrumentation = new CachedInstrumentation( 'io.opentelemetry.contrib.php.laravel', null, - 'https://opentelemetry.io/schemas/1.30.0', + 'https://opentelemetry.io/schemas/1.32.0', ); Hooks\Illuminate\Console\Command::hook($instrumentation); diff --git a/src/Instrumentation/MongoDB/composer.json b/src/Instrumentation/MongoDB/composer.json index 4f8a9d72e..2ce2065c5 100644 --- a/src/Instrumentation/MongoDB/composer.json +++ b/src/Instrumentation/MongoDB/composer.json @@ -12,7 +12,7 @@ "ext-json": "*", "mongodb/mongodb": "^1.15 || ^2.0", "open-telemetry/api": "^1.0", - "open-telemetry/sem-conv": "^1.30" + "open-telemetry/sem-conv": "^1.32" }, "require-dev": { "friendsofphp/php-cs-fixer": "^3", diff --git a/src/Instrumentation/MongoDB/src/MongoDBInstrumentation.php b/src/Instrumentation/MongoDB/src/MongoDBInstrumentation.php index 148acc8d1..6f00ba840 100644 --- a/src/Instrumentation/MongoDB/src/MongoDBInstrumentation.php +++ b/src/Instrumentation/MongoDB/src/MongoDBInstrumentation.php @@ -19,7 +19,7 @@ public static function register(?callable $commandSerializer = null): void $instrumentation = new CachedInstrumentation( 'io.opentelemetry.contrib.php.mongodb', null, - 'https://opentelemetry.io/schemas/1.30.0', + 'https://opentelemetry.io/schemas/1.32.0', ); $commandSerializer ??= self::defaultCommandSerializer(); /** @psalm-suppress UnusedFunctionCall */ diff --git a/src/Instrumentation/MySqli/composer.json b/src/Instrumentation/MySqli/composer.json index 608678aed..fd581723d 100644 --- a/src/Instrumentation/MySqli/composer.json +++ b/src/Instrumentation/MySqli/composer.json @@ -21,7 +21,7 @@ "ext-mysqli": "*", "ext-opentelemetry": "*", "open-telemetry/api": "^1.0", - "open-telemetry/sem-conv": "^1.30", + "open-telemetry/sem-conv": "^1.32", "symfony/polyfill-mbstring": "^1.31" }, "suggest": { diff --git a/src/Instrumentation/MySqli/src/MySqliInstrumentation.php b/src/Instrumentation/MySqli/src/MySqliInstrumentation.php index 30bc32352..51ec05692 100644 --- a/src/Instrumentation/MySqli/src/MySqliInstrumentation.php +++ b/src/Instrumentation/MySqli/src/MySqliInstrumentation.php @@ -37,7 +37,7 @@ public static function register(): void $instrumentation = new CachedInstrumentation( 'io.opentelemetry.contrib.php.mysqli', null, - Version::VERSION_1_30_0->url(), + Version::VERSION_1_32_0->url(), ); $tracker = new MySqliTracker(); @@ -408,7 +408,7 @@ public static function register(): void } /** @param non-empty-string $spanName */ - private static function constructPreHook(string $spanName, int $paramsOffset, CachedInstrumentation $instrumentation, MySqliTracker $tracker, $obj, array $params, ?string $class, ?string $function, ?string $filename, ?int $lineno): void + private static function constructPreHook(string $spanName, int $paramsOffset, CachedInstrumentation $instrumentation, MySqliTracker $tracker, $obj, array $params, ?string $class, string $function, ?string $filename, ?int $lineno): void { $attributes = []; $attributes[TraceAttributes::SERVER_ADDRESS] = $params[$paramsOffset + 0] ?? get_cfg_var('mysqli.default_host'); @@ -440,7 +440,7 @@ private static function constructPostHook(int $paramsOffset, CachedInstrumentati } /** @param non-empty-string $spanName */ - private static function queryPreHook(string $spanName, CachedInstrumentation $instrumentation, MySqliTracker $tracker, $obj, array $params, ?string $class, ?string $function, ?string $filename, ?int $lineno): void + private static function queryPreHook(string $spanName, CachedInstrumentation $instrumentation, MySqliTracker $tracker, $obj, array $params, ?string $class, string $function, ?string $filename, ?int $lineno): void { $span = self::startSpan($spanName, $instrumentation, $class, $function, $filename, $lineno, []); $mysqli = $obj ? $obj : $params[0]; @@ -492,7 +492,7 @@ private static function multiQueryPostHook(CachedInstrumentation $instrumentatio } /** @param non-empty-string $spanName */ - private static function nextResultPreHook(string $spanName, CachedInstrumentation $instrumentation, MySqliTracker $tracker, $obj, array $params, ?string $class, ?string $function, ?string $filename, ?int $lineno): void + private static function nextResultPreHook(string $spanName, CachedInstrumentation $instrumentation, MySqliTracker $tracker, $obj, array $params, ?string $class, string $function, ?string $filename, ?int $lineno): void { $span = self::startSpan($spanName, $instrumentation, $class, $function, $filename, $lineno, []); $mysqli = $obj ? $obj : $params[0]; @@ -558,7 +558,7 @@ private static function selectDbPostHook(CachedInstrumentation $instrumentation, } /** @param non-empty-string $spanName */ - private static function preparePreHook(string $spanName, CachedInstrumentation $instrumentation, MySqliTracker $tracker, $obj, array $params, ?string $class, ?string $function, ?string $filename, ?int $lineno): void + private static function preparePreHook(string $spanName, CachedInstrumentation $instrumentation, MySqliTracker $tracker, $obj, array $params, ?string $class, string $function, ?string $filename, ?int $lineno): void { $span = self::startSpan($spanName, $instrumentation, $class, $function, $filename, $lineno, []); $mysqli = $obj ? $obj : $params[0]; @@ -593,7 +593,7 @@ private static function preparePostHook(CachedInstrumentation $instrumentation, } /** @param non-empty-string $spanName */ - private static function beginTransactionPreHook(string $spanName, CachedInstrumentation $instrumentation, MySqliTracker $tracker, $obj, array $params, ?string $class, ?string $function, ?string $filename, ?int $lineno): void + private static function beginTransactionPreHook(string $spanName, CachedInstrumentation $instrumentation, MySqliTracker $tracker, $obj, array $params, ?string $class, string $function, ?string $filename, ?int $lineno): void { self::startSpan($spanName, $instrumentation, $class, $function, $filename, $lineno, []); } @@ -620,7 +620,7 @@ private static function beginTransactionPostHook(CachedInstrumentation $instrume } /** @param non-empty-string $spanName */ - private static function transactionPreHook(string $spanName, CachedInstrumentation $instrumentation, MySqliTracker $tracker, $obj, array $params, ?string $class, ?string $function, ?string $filename, ?int $lineno): void + private static function transactionPreHook(string $spanName, CachedInstrumentation $instrumentation, MySqliTracker $tracker, $obj, array $params, ?string $class, string $function, ?string $filename, ?int $lineno): void { $span = self::startSpan($spanName, $instrumentation, $class, $function, $filename, $lineno, []); $mysqli = $obj ? $obj : $params[0]; @@ -687,7 +687,7 @@ private static function stmtConstructPostHook(CachedInstrumentation $instrumenta } /** @param non-empty-string $spanName */ - private static function stmtExecutePreHook(string $spanName, CachedInstrumentation $instrumentation, MySqliTracker $tracker, $obj, array $params, ?string $class, ?string $function, ?string $filename, ?int $lineno): void + private static function stmtExecutePreHook(string $spanName, CachedInstrumentation $instrumentation, MySqliTracker $tracker, $obj, array $params, ?string $class, string $function, ?string $filename, ?int $lineno): void { $span = self::startSpan($spanName, $instrumentation, $class, $function, $filename, $lineno, []); self::addTransactionLink($tracker, $span, $obj ? $obj : $params[0]); @@ -711,7 +711,7 @@ private static function stmtExecutePostHook(CachedInstrumentation $instrumentati } /** @param non-empty-string $spanName */ - private static function stmtNextResultPreHook(string $spanName, CachedInstrumentation $instrumentation, MySqliTracker $tracker, $obj, array $params, ?string $class, ?string $function, ?string $filename, ?int $lineno): void + private static function stmtNextResultPreHook(string $spanName, CachedInstrumentation $instrumentation, MySqliTracker $tracker, $obj, array $params, ?string $class, string $function, ?string $filename, ?int $lineno): void { $span = self::startSpan($spanName, $instrumentation, $class, $function, $filename, $lineno, []); @@ -746,16 +746,16 @@ private static function stmtNextResultPostHook(CachedInstrumentation $instrument } /** @param non-empty-string $spanName */ - private static function startSpan(string $spanName, CachedInstrumentation $instrumentation, ?string $class, ?string $function, ?string $filename, ?int $lineno, iterable $attributes) : SpanInterface + private static function startSpan(string $spanName, CachedInstrumentation $instrumentation, ?string $class, string $function, ?string $filename, ?int $lineno, iterable $attributes) : SpanInterface { + $fqn = ($class !== null) ? sprintf('%s::%s', $class, $function) : $function; $parent = Context::getCurrent(); $builder = $instrumentation->tracer() ->spanBuilder($spanName) ->setParent($parent) ->setSpanKind(SpanKind::KIND_CLIENT) - ->setAttribute(TraceAttributes::CODE_FUNCTION_NAME, $function) - ->setAttribute(TraceAttributes::CODE_NAMESPACE, $class) - ->setAttribute(TraceAttributes::CODE_FILEPATH, $filename) + ->setAttribute(TraceAttributes::CODE_FUNCTION_NAME, $fqn) + ->setAttribute(TraceAttributes::CODE_FILE_PATH, $filename) ->setAttribute(TraceAttributes::CODE_LINE_NUMBER, $lineno) ->setAttributes($attributes); diff --git a/src/Instrumentation/OpenAIPHP/composer.json b/src/Instrumentation/OpenAIPHP/composer.json index a1346d231..01fffc758 100644 --- a/src/Instrumentation/OpenAIPHP/composer.json +++ b/src/Instrumentation/OpenAIPHP/composer.json @@ -14,7 +14,7 @@ "ext-opentelemetry": "*", "openai-php/client": "*", "open-telemetry/api": "^1", - "open-telemetry/sem-conv": "^1.30" + "open-telemetry/sem-conv": "^1.32" }, "require-dev": { "friendsofphp/php-cs-fixer": "^3", diff --git a/src/Instrumentation/OpenAIPHP/src/OpenAIPHPInstrumentation.php b/src/Instrumentation/OpenAIPHP/src/OpenAIPHPInstrumentation.php index 2218b6aaf..8be64d0db 100644 --- a/src/Instrumentation/OpenAIPHP/src/OpenAIPHPInstrumentation.php +++ b/src/Instrumentation/OpenAIPHP/src/OpenAIPHPInstrumentation.php @@ -40,7 +40,7 @@ public static function register(): void $instrumentation = new CachedInstrumentation( 'io.opentelemetry.contrib.php.openaiphp', InstalledVersions::getVersion('open-telemetry/opentelemetry-auto-openai-php'), - Version::VERSION_1_30_0->url(), + Version::VERSION_1_32_0->url(), ); self::$totalTokensCounter = $instrumentation->meter()->createCounter( @@ -93,9 +93,8 @@ private static function hookApi(CachedInstrumentation $instrumentation, $class, ->spanBuilder(sprintf('openai %s', $resource . '/' . $operation)) ->setSpanKind(SpanKind::KIND_INTERNAL) // code - ->setAttribute(TraceAttributes::CODE_FUNCTION_NAME, $function) - ->setAttribute(TraceAttributes::CODE_NAMESPACE, $class) - ->setAttribute(TraceAttributes::CODE_FILEPATH, $filename) + ->setAttribute(TraceAttributes::CODE_FUNCTION_NAME, sprintf('%s::%s', $class, $function)) + ->setAttribute(TraceAttributes::CODE_FILE_PATH, $filename) ->setAttribute(TraceAttributes::CODE_LINE_NUMBER, $lineno) // openai ->setAttribute(OpenAIAttributes::OPENAI_RESOURCE, $resource . '/' . $operation) diff --git a/src/Instrumentation/PDO/composer.json b/src/Instrumentation/PDO/composer.json index 442b64f49..7f6c9a682 100644 --- a/src/Instrumentation/PDO/composer.json +++ b/src/Instrumentation/PDO/composer.json @@ -13,7 +13,7 @@ "ext-pdo": "*", "ext-opentelemetry": "*", "open-telemetry/api": "^1.0", - "open-telemetry/sem-conv": "^1.30", + "open-telemetry/sem-conv": "^1.32", "symfony/polyfill-mbstring": "^1.31" }, "suggest": { diff --git a/src/Instrumentation/PDO/src/PDOInstrumentation.php b/src/Instrumentation/PDO/src/PDOInstrumentation.php index d4d9574cb..ddf81c91e 100644 --- a/src/Instrumentation/PDO/src/PDOInstrumentation.php +++ b/src/Instrumentation/PDO/src/PDOInstrumentation.php @@ -27,7 +27,7 @@ public static function register(): void $instrumentation = new CachedInstrumentation( 'io.opentelemetry.contrib.php.pdo', null, - Version::VERSION_1_30_0->url(), + Version::VERSION_1_32_0->url(), ); $pdoTracker = new PDOTracker(); @@ -301,9 +301,8 @@ private static function makeBuilder( /** @psalm-suppress ArgumentTypeCoercion */ return $instrumentation->tracer() ->spanBuilder($name) - ->setAttribute(TraceAttributes::CODE_FUNCTION_NAME, $function) - ->setAttribute(TraceAttributes::CODE_NAMESPACE, $class) - ->setAttribute(TraceAttributes::CODE_FILEPATH, $filename) + ->setAttribute(TraceAttributes::CODE_FUNCTION_NAME, sprintf('%s::%s', $class, $function)) + ->setAttribute(TraceAttributes::CODE_FILE_PATH, $filename) ->setAttribute(TraceAttributes::CODE_LINE_NUMBER, $lineno); } private static function end(?Throwable $exception): void diff --git a/src/Instrumentation/Psr14/composer.json b/src/Instrumentation/Psr14/composer.json index 42f65335e..1fa04ea17 100644 --- a/src/Instrumentation/Psr14/composer.json +++ b/src/Instrumentation/Psr14/composer.json @@ -12,7 +12,7 @@ "php": "^8.1", "ext-opentelemetry": "*", "open-telemetry/api": "^1.0", - "open-telemetry/sem-conv": "^1.30", + "open-telemetry/sem-conv": "^1.32", "psr/event-dispatcher": "^1", "composer-runtime-api": "^2.0" }, diff --git a/src/Instrumentation/Psr14/src/Psr14Instrumentation.php b/src/Instrumentation/Psr14/src/Psr14Instrumentation.php index 4db4cc39b..0804c6699 100644 --- a/src/Instrumentation/Psr14/src/Psr14Instrumentation.php +++ b/src/Instrumentation/Psr14/src/Psr14Instrumentation.php @@ -11,6 +11,7 @@ use OpenTelemetry\Context\Context; use function OpenTelemetry\Instrumentation\hook; use OpenTelemetry\SemConv\TraceAttributes; +use OpenTelemetry\SemConv\Version; use Psr\EventDispatcher\EventDispatcherInterface; use Throwable; @@ -28,7 +29,7 @@ public static function register(): void $instrumentation = new CachedInstrumentation( 'io.opentelemetry.contrib.php.psr14', InstalledVersions::getVersion('open-telemetry/opentelemetry-auto-psr14'), - 'https://opentelemetry.io/schemas/1.30.0', + Version::VERSION_1_32_0->url(), ); /** @@ -42,9 +43,8 @@ public static function register(): void $event = is_object($params[0]) ? $params[0] : null; $builder = $instrumentation->tracer() ->spanBuilder(sprintf('event %s', $event ? $event::class : 'unknown')) - ->setAttribute(TraceAttributes::CODE_FUNCTION_NAME, $function) - ->setAttribute(TraceAttributes::CODE_NAMESPACE, $class) - ->setAttribute(TraceAttributes::CODE_FILEPATH, $filename) + ->setAttribute(TraceAttributes::CODE_FUNCTION_NAME, sprintf('%s::%s', $class, $function)) + ->setAttribute(TraceAttributes::CODE_FILE_PATH, $filename) ->setAttribute(TraceAttributes::CODE_LINE_NUMBER, $lineno); if ($event) { diff --git a/src/Instrumentation/Psr15/composer.json b/src/Instrumentation/Psr15/composer.json index a3ed9dd8a..eda5af6d2 100644 --- a/src/Instrumentation/Psr15/composer.json +++ b/src/Instrumentation/Psr15/composer.json @@ -12,7 +12,7 @@ "php": "^8.1", "ext-opentelemetry": "*", "open-telemetry/api": "^1.0", - "open-telemetry/sem-conv": "^1.30", + "open-telemetry/sem-conv": "^1.32", "psr/http-server-middleware": "^1" }, "autoload": { diff --git a/src/Instrumentation/Psr15/src/Psr15Instrumentation.php b/src/Instrumentation/Psr15/src/Psr15Instrumentation.php index ddad4f4b9..898803d4d 100644 --- a/src/Instrumentation/Psr15/src/Psr15Instrumentation.php +++ b/src/Instrumentation/Psr15/src/Psr15Instrumentation.php @@ -13,6 +13,7 @@ use OpenTelemetry\Context\Context; use function OpenTelemetry\Instrumentation\hook; use OpenTelemetry\SemConv\TraceAttributes; +use OpenTelemetry\SemConv\Version; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; use Psr\Http\Server\MiddlewareInterface; @@ -32,7 +33,7 @@ public static function register(): void $instrumentation = new CachedInstrumentation( 'io.opentelemetry.contrib.php.psr15', null, - 'https://opentelemetry.io/schemas/1.30.0', + Version::VERSION_1_32_0->url(), ); /** @@ -44,9 +45,8 @@ public static function register(): void 'process', pre: static function (MiddlewareInterface $middleware, array $params, string $class, string $function, ?string $filename, ?int $lineno) use ($instrumentation) { $span = $instrumentation->tracer()->spanBuilder(sprintf('%s::%s', $class, $function)) - ->setAttribute(TraceAttributes::CODE_FUNCTION_NAME, $function) - ->setAttribute(TraceAttributes::CODE_NAMESPACE, $class) - ->setAttribute(TraceAttributes::CODE_FILEPATH, $filename) + ->setAttribute(TraceAttributes::CODE_FUNCTION_NAME, sprintf('%s::%s', $class, $function)) + ->setAttribute(TraceAttributes::CODE_FILE_PATH, $filename) ->setAttribute(TraceAttributes::CODE_LINE_NUMBER, $lineno) ->startSpan(); @@ -86,9 +86,8 @@ public static function register(): void : sprintf('%s', $request?->getMethod() ?? 'unknown') ) ->setSpanKind(SpanKind::KIND_SERVER) - ->setAttribute(TraceAttributes::CODE_FUNCTION_NAME, $function) - ->setAttribute(TraceAttributes::CODE_NAMESPACE, $class) - ->setAttribute(TraceAttributes::CODE_FILEPATH, $filename) + ->setAttribute(TraceAttributes::CODE_FUNCTION_NAME, sprintf('%s::%s', $class, $function)) + ->setAttribute(TraceAttributes::CODE_FILE_PATH, $filename) ->setAttribute(TraceAttributes::CODE_LINE_NUMBER, $lineno); $parent = Context::getCurrent(); if (!$root && $request) { diff --git a/src/Instrumentation/Psr16/composer.json b/src/Instrumentation/Psr16/composer.json index a642260be..39e57c3f2 100644 --- a/src/Instrumentation/Psr16/composer.json +++ b/src/Instrumentation/Psr16/composer.json @@ -12,7 +12,7 @@ "php": "^8.1", "ext-opentelemetry": "*", "open-telemetry/api": "^1.0", - "open-telemetry/sem-conv": "^1.30", + "open-telemetry/sem-conv": "^1.32", "psr/simple-cache": "^1 || ^2 || ^3", "composer-runtime-api": "^2.0" }, diff --git a/src/Instrumentation/Psr16/src/Psr16Instrumentation.php b/src/Instrumentation/Psr16/src/Psr16Instrumentation.php index b16baf093..7a119b022 100644 --- a/src/Instrumentation/Psr16/src/Psr16Instrumentation.php +++ b/src/Instrumentation/Psr16/src/Psr16Instrumentation.php @@ -13,6 +13,7 @@ use OpenTelemetry\Context\Context; use function OpenTelemetry\Instrumentation\hook; use OpenTelemetry\SemConv\TraceAttributes; +use OpenTelemetry\SemConv\Version; use Psr\SimpleCache\CacheInterface; use Throwable; @@ -28,7 +29,7 @@ public static function register(): void $instrumentation = new CachedInstrumentation( 'io.opentelemetry.contrib.php.psr16', InstalledVersions::getVersion('open-telemetry/opentelemetry-auto-psr16'), - 'https://opentelemetry.io/schemas/1.30.0', + Version::VERSION_1_32_0->url(), ); $pre = static function (CacheInterface $cacheItem, array $params, string $class, string $function, ?string $filename, ?int $lineno) use ($instrumentation) { @@ -69,9 +70,8 @@ private static function makeSpanBuilder( return $instrumentation->tracer() ->spanBuilder($name) ->setSpanKind(SpanKind::KIND_INTERNAL) - ->setAttribute(TraceAttributes::CODE_FUNCTION_NAME, $function) - ->setAttribute(TraceAttributes::CODE_NAMESPACE, $class) - ->setAttribute(TraceAttributes::CODE_FILEPATH, $filename) + ->setAttribute(TraceAttributes::CODE_FUNCTION_NAME, sprintf('%s::%s', $class, $function)) + ->setAttribute(TraceAttributes::CODE_FILE_PATH, $filename) ->setAttribute(TraceAttributes::CODE_LINE_NUMBER, $lineno) ->setAttribute('cache.operation', $name); } diff --git a/src/Instrumentation/Psr18/composer.json b/src/Instrumentation/Psr18/composer.json index 19320cf7b..e9255083d 100644 --- a/src/Instrumentation/Psr18/composer.json +++ b/src/Instrumentation/Psr18/composer.json @@ -12,7 +12,7 @@ "php": "^8.1", "ext-opentelemetry": "*", "open-telemetry/api": "^1.0", - "open-telemetry/sem-conv": "^1.30", + "open-telemetry/sem-conv": "^1.32", "psr/http-client": "^1" }, "autoload": { diff --git a/src/Instrumentation/Psr18/src/Psr18Instrumentation.php b/src/Instrumentation/Psr18/src/Psr18Instrumentation.php index e8ba3092f..7e1ff90f6 100644 --- a/src/Instrumentation/Psr18/src/Psr18Instrumentation.php +++ b/src/Instrumentation/Psr18/src/Psr18Instrumentation.php @@ -13,6 +13,7 @@ use OpenTelemetry\Context\Context; use function OpenTelemetry\Instrumentation\hook; use OpenTelemetry\SemConv\TraceAttributes; +use OpenTelemetry\SemConv\Version; use Psr\Http\Client\ClientInterface; use Psr\Http\Message\RequestInterface; use Psr\Http\Message\ResponseInterface; @@ -30,7 +31,7 @@ public static function register(): void { $instrumentation = new CachedInstrumentation( 'io.opentelemetry.contrib.php.psr18', - 'https://opentelemetry.io/schemas/1.30.0', + schemaUrl: Version::VERSION_1_32_0->url(), ); /** @psalm-suppress UnusedFunctionCall */ @@ -61,9 +62,8 @@ public static function register(): void ->setAttribute(TraceAttributes::HTTP_REQUEST_BODY_SIZE, $request->getHeaderLine('Content-Length')) ->setAttribute(TraceAttributes::SERVER_ADDRESS, $request->getUri()->getHost()) ->setAttribute(TraceAttributes::SERVER_PORT, $request->getUri()->getPort()) - ->setAttribute(TraceAttributes::CODE_FUNCTION_NAME, $function) - ->setAttribute(TraceAttributes::CODE_NAMESPACE, $class) - ->setAttribute(TraceAttributes::CODE_FILEPATH, $filename) + ->setAttribute(TraceAttributes::CODE_FUNCTION_NAME, sprintf('%s::%s', $class, $function)) + ->setAttribute(TraceAttributes::CODE_FILE_PATH, $filename) ->setAttribute(TraceAttributes::CODE_LINE_NUMBER, $lineno) ; diff --git a/src/Instrumentation/Psr3/composer.json b/src/Instrumentation/Psr3/composer.json index c8a390de0..a20fbd799 100644 --- a/src/Instrumentation/Psr3/composer.json +++ b/src/Instrumentation/Psr3/composer.json @@ -19,7 +19,7 @@ "php": "^8.1", "ext-opentelemetry": "*", "open-telemetry/api": "^1.0", - "open-telemetry/sem-conv": "^1.30", + "open-telemetry/sem-conv": "^1.32", "psr/log": "^1 || ^2 || ^3" }, "autoload": { diff --git a/src/Instrumentation/Psr3/src/Psr3Instrumentation.php b/src/Instrumentation/Psr3/src/Psr3Instrumentation.php index 93258e6eb..5d94b581e 100644 --- a/src/Instrumentation/Psr3/src/Psr3Instrumentation.php +++ b/src/Instrumentation/Psr3/src/Psr3Instrumentation.php @@ -63,7 +63,7 @@ public static function register(): void $instrumentation ??= new CachedInstrumentation( 'io.opentelemetry.contrib.php.psr3', null, - 'https://opentelemetry.io/schemas/1.30.0', + 'https://opentelemetry.io/schemas/1.32.0', ); if ($function === 'log') { $level = $params[0]; diff --git a/src/Instrumentation/Psr3/tests/phpt/export_apix.phpt b/src/Instrumentation/Psr3/tests/phpt/export_apix.phpt index 26b9970a5..a386f1038 100644 --- a/src/Instrumentation/Psr3/tests/phpt/export_apix.phpt +++ b/src/Instrumentation/Psr3/tests/phpt/export_apix.phpt @@ -35,7 +35,7 @@ $span->end(); { "resource": { - "attributes": [], + "attributes": %A "dropped_attributes_count": 0 }, "scopes": [ diff --git a/src/Instrumentation/Psr3/tests/phpt/export_cake.phpt b/src/Instrumentation/Psr3/tests/phpt/export_cake.phpt index 73c3cdc3a..4af5b7070 100644 --- a/src/Instrumentation/Psr3/tests/phpt/export_cake.phpt +++ b/src/Instrumentation/Psr3/tests/phpt/export_cake.phpt @@ -36,7 +36,7 @@ $span->end(); { "resource": { - "attributes": [], + "attributes": %A "dropped_attributes_count": 0 }, "scopes": [ diff --git a/src/Instrumentation/Psr3/tests/phpt/export_context.phpt b/src/Instrumentation/Psr3/tests/phpt/export_context.phpt index 6224b362f..cb10a2cf3 100644 --- a/src/Instrumentation/Psr3/tests/phpt/export_context.phpt +++ b/src/Instrumentation/Psr3/tests/phpt/export_context.phpt @@ -57,7 +57,7 @@ $span->end(); --EXPECTF-- { "resource": { - "attributes": [], + "attributes": %A "dropped_attributes_count": 0 }, "scopes": [ diff --git a/src/Instrumentation/Psr3/tests/phpt/export_monolog.phpt b/src/Instrumentation/Psr3/tests/phpt/export_monolog.phpt index 9506318e1..86be5197c 100644 --- a/src/Instrumentation/Psr3/tests/phpt/export_monolog.phpt +++ b/src/Instrumentation/Psr3/tests/phpt/export_monolog.phpt @@ -30,7 +30,7 @@ $span->end(); --EXPECTF-- { "resource": { - "attributes": [], + "attributes": %A "dropped_attributes_count": 0 }, "scopes": [ diff --git a/src/Instrumentation/Psr3/tests/phpt/export_multi.phpt b/src/Instrumentation/Psr3/tests/phpt/export_multi.phpt index 18a7b1af0..a63414afc 100644 --- a/src/Instrumentation/Psr3/tests/phpt/export_multi.phpt +++ b/src/Instrumentation/Psr3/tests/phpt/export_multi.phpt @@ -47,7 +47,7 @@ Message context: { "resource": { - "attributes": [], + "attributes": %A "dropped_attributes_count": 0 }, "scopes": [ diff --git a/src/Instrumentation/Psr3/tests/phpt/export_symfony.phpt b/src/Instrumentation/Psr3/tests/phpt/export_symfony.phpt index 34205fca4..ca5666501 100644 --- a/src/Instrumentation/Psr3/tests/phpt/export_symfony.phpt +++ b/src/Instrumentation/Psr3/tests/phpt/export_symfony.phpt @@ -32,7 +32,7 @@ $span->end(); { "resource": { - "attributes": [], + "attributes": %A "dropped_attributes_count": 0 }, "scopes": [ diff --git a/src/Instrumentation/Psr3/tests/phpt/export_yii.phpt b/src/Instrumentation/Psr3/tests/phpt/export_yii.phpt index 2c50f845b..abd6ad519 100644 --- a/src/Instrumentation/Psr3/tests/phpt/export_yii.phpt +++ b/src/Instrumentation/Psr3/tests/phpt/export_yii.phpt @@ -52,7 +52,7 @@ Stack trace: %A { "resource": { - "attributes": [], + "attributes": %A "dropped_attributes_count": 0 }, "scopes": [ diff --git a/src/Instrumentation/Psr6/composer.json b/src/Instrumentation/Psr6/composer.json index 75de72774..64de4e56c 100644 --- a/src/Instrumentation/Psr6/composer.json +++ b/src/Instrumentation/Psr6/composer.json @@ -12,7 +12,7 @@ "php": "^8.1", "ext-opentelemetry": "*", "open-telemetry/api": "^1.0", - "open-telemetry/sem-conv": "^1.30", + "open-telemetry/sem-conv": "^1.32", "psr/cache": "^1 || ^2 || ^3", "composer-runtime-api": "^2.0" }, diff --git a/src/Instrumentation/Psr6/src/Psr6Instrumentation.php b/src/Instrumentation/Psr6/src/Psr6Instrumentation.php index 146b75d0a..c45a468ec 100644 --- a/src/Instrumentation/Psr6/src/Psr6Instrumentation.php +++ b/src/Instrumentation/Psr6/src/Psr6Instrumentation.php @@ -29,7 +29,7 @@ public static function register(): void $instrumentation = new CachedInstrumentation( 'io.opentelemetry.contrib.php.psr6', InstalledVersions::getVersion('open-telemetry/opentelemetry-auto-psr6'), - 'https://opentelemetry.io/schemas/1.30.0', + 'https://opentelemetry.io/schemas/1.32.0', ); $pre = static function (CacheItemPoolInterface $pool, array $params, string $class, string $function, ?string $filename, ?int $lineno) use ($instrumentation) { @@ -74,9 +74,8 @@ private static function makeSpanBuilder( return $instrumentation->tracer() ->spanBuilder($function) ->setSpanKind(SpanKind::KIND_INTERNAL) - ->setAttribute(TraceAttributes::CODE_FUNCTION_NAME, $function) - ->setAttribute(TraceAttributes::CODE_NAMESPACE, $class) - ->setAttribute(TraceAttributes::CODE_FILEPATH, $filename) + ->setAttribute(TraceAttributes::CODE_FUNCTION_NAME, sprintf('%s::%s', $class, $function)) + ->setAttribute(TraceAttributes::CODE_FILE_PATH, $filename) ->setAttribute(TraceAttributes::CODE_LINE_NUMBER, $lineno) ->setAttribute('cache.operation', $name); } diff --git a/src/Instrumentation/Slim/composer.json b/src/Instrumentation/Slim/composer.json index d54e2d116..8850d55ab 100644 --- a/src/Instrumentation/Slim/composer.json +++ b/src/Instrumentation/Slim/composer.json @@ -13,7 +13,7 @@ "ext-opentelemetry": "*", "ext-reflection": "*", "open-telemetry/api": "^1.0", - "open-telemetry/sem-conv": "^1.30", + "open-telemetry/sem-conv": "^1.32", "slim/slim": "^4" }, "require-dev": { diff --git a/src/Instrumentation/Slim/src/SlimInstrumentation.php b/src/Instrumentation/Slim/src/SlimInstrumentation.php index 2d6a5c22c..025ab8aec 100644 --- a/src/Instrumentation/Slim/src/SlimInstrumentation.php +++ b/src/Instrumentation/Slim/src/SlimInstrumentation.php @@ -33,7 +33,7 @@ public static function register(): void $instrumentation = new CachedInstrumentation( 'io.opentelemetry.contrib.php.slim', null, - 'https://opentelemetry.io/schemas/1.30.0', + 'https://opentelemetry.io/schemas/1.32.0', ); /** @@ -53,9 +53,8 @@ public static function register(): void $builder = $instrumentation->tracer() ->spanBuilder(sprintf('%s', $request?->getMethod() ?? 'unknown')) ->setSpanKind(SpanKind::KIND_SERVER) - ->setAttribute(TraceAttributes::CODE_FUNCTION_NAME, $function) - ->setAttribute(TraceAttributes::CODE_NAMESPACE, $class) - ->setAttribute(TraceAttributes::CODE_FILEPATH, $filename) + ->setAttribute(TraceAttributes::CODE_FUNCTION_NAME, sprintf('%s::%s', $class, $function)) + ->setAttribute(TraceAttributes::CODE_FILE_PATH, $filename) ->setAttribute(TraceAttributes::CODE_LINE_NUMBER, $lineno); $parent = Context::getCurrent(); if ($request) { @@ -124,6 +123,8 @@ public static function register(): void * and type SpanInterface which represents the root span, having been previously set * If routing fails (eg 404/not found), then the root span name will not be updated. * + * @todo this can use LocalRootSpan (available since API 1.1.0) + * * @psalm-suppress ArgumentTypeCoercion * @psalm-suppress UnusedFunctionCall */ @@ -161,9 +162,8 @@ public static function register(): void $callable = $params[0]; $name = CallableFormatter::format($callable); $builder = $instrumentation->tracer()->spanBuilder($name) - ->setAttribute(TraceAttributes::CODE_FUNCTION_NAME, $function) - ->setAttribute(TraceAttributes::CODE_NAMESPACE, $class) - ->setAttribute(TraceAttributes::CODE_FILEPATH, $filename) + ->setAttribute(TraceAttributes::CODE_FUNCTION_NAME, sprintf('%s::%s', $class, $function)) + ->setAttribute(TraceAttributes::CODE_FILE_PATH, $filename) ->setAttribute(TraceAttributes::CODE_LINE_NUMBER, $lineno); $span = $builder->startSpan(); Context::storage()->attach($span->storeInContext(Context::getCurrent())); diff --git a/src/Instrumentation/Symfony/composer.json b/src/Instrumentation/Symfony/composer.json index dcc126c99..5e15435ad 100644 --- a/src/Instrumentation/Symfony/composer.json +++ b/src/Instrumentation/Symfony/composer.json @@ -12,7 +12,7 @@ "php": "^8.1", "ext-opentelemetry": "*", "open-telemetry/api": "^1.0", - "open-telemetry/sem-conv": "^1.30", + "open-telemetry/sem-conv": "^1.32", "symfony/http-kernel": "*", "symfony/http-client-contracts": "*" }, diff --git a/src/Instrumentation/Symfony/src/HttpClientInstrumentation.php b/src/Instrumentation/Symfony/src/HttpClientInstrumentation.php index f9233412c..d550abac3 100644 --- a/src/Instrumentation/Symfony/src/HttpClientInstrumentation.php +++ b/src/Instrumentation/Symfony/src/HttpClientInstrumentation.php @@ -13,6 +13,7 @@ use OpenTelemetry\Context\Propagation\ArrayAccessGetterSetter; use function OpenTelemetry\Instrumentation\hook; use OpenTelemetry\SemConv\TraceAttributes; +use OpenTelemetry\SemConv\Version; use Symfony\Contracts\HttpClient\HttpClientInterface; use Symfony\Contracts\HttpClient\ResponseInterface; @@ -41,7 +42,7 @@ public static function register(): void $instrumentation = new CachedInstrumentation( 'io.opentelemetry.contrib.php.symfony_http', null, - 'https://opentelemetry.io/schemas/1.30.0', + Version::VERSION_1_32_0->url(), ); /** @psalm-suppress UnusedFunctionCall */ @@ -64,9 +65,8 @@ public static function register(): void ->setAttribute(TraceAttributes::PEER_SERVICE, parse_url((string) $params[1])['host'] ?? null) ->setAttribute(TraceAttributes::URL_FULL, (string) $params[1]) ->setAttribute(TraceAttributes::HTTP_REQUEST_METHOD, $params[0]) - ->setAttribute(TraceAttributes::CODE_FUNCTION_NAME, $function) - ->setAttribute(TraceAttributes::CODE_NAMESPACE, $class) - ->setAttribute(TraceAttributes::CODE_FILEPATH, $filename) + ->setAttribute(TraceAttributes::CODE_FUNCTION_NAME, sprintf('%s::%s', $class, $function)) + ->setAttribute(TraceAttributes::CODE_FILE_PATH, $filename) ->setAttribute(TraceAttributes::CODE_LINE_NUMBER, $lineno); $propagator = Globals::propagator(); diff --git a/src/Instrumentation/Symfony/src/MessengerInstrumentation.php b/src/Instrumentation/Symfony/src/MessengerInstrumentation.php index fe8e22347..521c4a3ac 100644 --- a/src/Instrumentation/Symfony/src/MessengerInstrumentation.php +++ b/src/Instrumentation/Symfony/src/MessengerInstrumentation.php @@ -11,6 +11,7 @@ use OpenTelemetry\Context\Context; use function OpenTelemetry\Instrumentation\hook; use OpenTelemetry\SemConv\TraceAttributes; +use OpenTelemetry\SemConv\Version; use Symfony\Component\Messenger\Envelope; use Symfony\Component\Messenger\MessageBusInterface; use Symfony\Component\Messenger\Transport\Sender\SenderInterface; @@ -38,7 +39,7 @@ public static function register(): void $instrumentation = new CachedInstrumentation( 'io.opentelemetry.contrib.php.symfony_messenger', null, - 'https://opentelemetry.io/schemas/1.30.0', + Version::VERSION_1_32_0->url(), ); /** @@ -66,9 +67,8 @@ public static function register(): void ->tracer() ->spanBuilder(\sprintf('DISPATCH %s', $messageClass)) ->setSpanKind(SpanKind::KIND_PRODUCER) - ->setAttribute(TraceAttributes::CODE_FUNCTION_NAME, $function) - ->setAttribute(TraceAttributes::CODE_NAMESPACE, $class) - ->setAttribute(TraceAttributes::CODE_FILEPATH, $filename) + ->setAttribute(TraceAttributes::CODE_FUNCTION_NAME, sprintf('%s::%s', $class, $function)) + ->setAttribute(TraceAttributes::CODE_FILE_PATH, $filename) ->setAttribute(TraceAttributes::CODE_LINE_NUMBER, $lineno) ->setAttribute(self::ATTRIBUTE_MESSENGER_BUS, $class) @@ -133,9 +133,8 @@ public static function register(): void ->tracer() ->spanBuilder(\sprintf('SEND %s', $messageClass)) ->setSpanKind(SpanKind::KIND_PRODUCER) - ->setAttribute(TraceAttributes::CODE_FUNCTION_NAME, $function) - ->setAttribute(TraceAttributes::CODE_NAMESPACE, $class) - ->setAttribute(TraceAttributes::CODE_FILEPATH, $filename) + ->setAttribute(TraceAttributes::CODE_FUNCTION_NAME, sprintf('%s::%s', $class, $function)) + ->setAttribute(TraceAttributes::CODE_FILE_PATH, $filename) ->setAttribute(TraceAttributes::CODE_LINE_NUMBER, $lineno) ->setAttribute(self::ATTRIBUTE_MESSENGER_TRANSPORT, $class) diff --git a/src/Instrumentation/Symfony/src/SymfonyInstrumentation.php b/src/Instrumentation/Symfony/src/SymfonyInstrumentation.php index 73478f7bc..d74a14263 100644 --- a/src/Instrumentation/Symfony/src/SymfonyInstrumentation.php +++ b/src/Instrumentation/Symfony/src/SymfonyInstrumentation.php @@ -13,6 +13,7 @@ use OpenTelemetry\Context\Context; use function OpenTelemetry\Instrumentation\hook; use OpenTelemetry\SemConv\TraceAttributes; +use OpenTelemetry\SemConv\Version; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\HttpKernel; @@ -28,7 +29,7 @@ public static function register(): void $instrumentation = new CachedInstrumentation( 'io.opentelemetry.contrib.php.symfony', null, - 'https://opentelemetry.io/schemas/1.30.0', + Version::VERSION_1_32_0->url(), ); /** @psalm-suppress UnusedFunctionCall */ @@ -54,9 +55,8 @@ public static function register(): void ->tracer() ->spanBuilder($name) ->setSpanKind(($type === HttpKernelInterface::SUB_REQUEST) ? SpanKind::KIND_INTERNAL : SpanKind::KIND_SERVER) - ->setAttribute(TraceAttributes::CODE_FUNCTION_NAME, $function) - ->setAttribute(TraceAttributes::CODE_NAMESPACE, $class) - ->setAttribute(TraceAttributes::CODE_FILEPATH, $filename) + ->setAttribute(TraceAttributes::CODE_FUNCTION_NAME, sprintf('%s::%s', $class, $function)) + ->setAttribute(TraceAttributes::CODE_FILE_PATH, $filename) ->setAttribute(TraceAttributes::CODE_LINE_NUMBER, $lineno); $parent = Context::getCurrent(); diff --git a/src/Instrumentation/Wordpress/composer.json b/src/Instrumentation/Wordpress/composer.json index 350de2343..886877602 100644 --- a/src/Instrumentation/Wordpress/composer.json +++ b/src/Instrumentation/Wordpress/composer.json @@ -12,7 +12,7 @@ "php": "^8.1", "ext-opentelemetry": "*", "open-telemetry/api": "^1.0", - "open-telemetry/sem-conv": "^1.30", + "open-telemetry/sem-conv": "^1.32", "nyholm/psr7": "^1", "nyholm/psr7-server": "^1" }, diff --git a/src/Instrumentation/Wordpress/psalm.xml.dist b/src/Instrumentation/Wordpress/psalm.xml.dist index c9c51229e..f4f424b1c 100644 --- a/src/Instrumentation/Wordpress/psalm.xml.dist +++ b/src/Instrumentation/Wordpress/psalm.xml.dist @@ -18,5 +18,15 @@ + + + + + + + + + + diff --git a/src/Instrumentation/Wordpress/src/WordpressInstrumentation.php b/src/Instrumentation/Wordpress/src/WordpressInstrumentation.php index d23198249..96d79deba 100644 --- a/src/Instrumentation/Wordpress/src/WordpressInstrumentation.php +++ b/src/Instrumentation/Wordpress/src/WordpressInstrumentation.php @@ -15,6 +15,7 @@ use OpenTelemetry\Context\Context; use function OpenTelemetry\Instrumentation\hook; use OpenTelemetry\SemConv\TraceAttributes; +use OpenTelemetry\SemConv\Version; use Throwable; /** @@ -29,7 +30,7 @@ public static function register(): void $instrumentation = new CachedInstrumentation( 'io.opentelemetry.contrib.php.wordpress', null, - 'https://opentelemetry.io/schemas/1.30.0' + Version::VERSION_1_32_0->url(), ); self::_hook($instrumentation, 'WP', 'main', 'WP.main'); @@ -49,8 +50,8 @@ public static function register(): void hook( class: 'wpdb', function: '__construct', - pre: static function ($object, ?array $params, ?string $class, ?string $function, ?string $filename, ?int $lineno) use ($instrumentation) { - $span = self::builder($instrumentation, 'wpdb.__connect', $function, $class, $filename, $lineno) + pre: static function ($object, ?array $params, ?string $class, string $function, ?string $filename, ?int $lineno) use ($instrumentation) { + $span = self::builder($instrumentation, 'wpdb.__construct', $function, $class, $filename, $lineno) //->setAttribute(TraceAttributes::DB_USER, $params[0] ?? 'unknown') //deprecated, no replacement ->setAttribute(TraceAttributes::DB_NAMESPACE, $params[2] ?? 'unknown') ->setAttribute(TraceAttributes::DB_SYSTEM_NAME, 'mysql') @@ -68,7 +69,7 @@ function: '__construct', hook( class: 'wpdb', function: 'query', - pre: static function ($object, ?array $params, ?string $class, ?string $function, ?string $filename, ?int $lineno) use ($instrumentation) { + pre: static function ($object, ?array $params, ?string $class, string $function, ?string $filename, ?int $lineno) use ($instrumentation) { $span = self::builder($instrumentation, 'wpdb.query', $function, $class, $filename, $lineno) ->setSpanKind(SpanKind::KIND_CLIENT) ->setAttribute(TraceAttributes::DB_QUERY_TEXT, $params[0] ?? 'undefined') @@ -137,7 +138,7 @@ private static function _hook(CachedInstrumentation $instrumentation, ?string $c hook( class: $class, function: $function, - pre: static function ($object, ?array $params, ?string $class, ?string $function, ?string $filename, ?int $lineno) use ($instrumentation, $name, $spanKind) { + pre: static function ($object, ?array $params, ?string $class, string $function, ?string $filename, ?int $lineno) use ($instrumentation, $name, $spanKind) { $span = self::builder($instrumentation, $name, $function, $class, $filename, $lineno) ->setSpanKind($spanKind) ->startSpan(); @@ -152,17 +153,18 @@ function: $function, private static function builder( CachedInstrumentation $instrumentation, string $name, - ?string $function, + string $function, ?string $class, ?string $filename, ?int $lineno, ): SpanBuilderInterface { + $fqn = ($class !== null) ? sprintf('%s::%s', $class, $function) : $function; + /** @psalm-suppress ArgumentTypeCoercion */ return $instrumentation->tracer() ->spanBuilder($name) - ->setAttribute(TraceAttributes::CODE_FUNCTION_NAME, $function) - ->setAttribute(TraceAttributes::CODE_NAMESPACE, $class) - ->setAttribute(TraceAttributes::CODE_FILEPATH, $filename) + ->setAttribute(TraceAttributes::CODE_FUNCTION_NAME, $fqn) + ->setAttribute(TraceAttributes::CODE_FILE_PATH, $filename) ->setAttribute(TraceAttributes::CODE_LINE_NUMBER, $lineno); } diff --git a/src/Instrumentation/Yii/composer.json b/src/Instrumentation/Yii/composer.json index 8a43835b8..5eeb9af7f 100644 --- a/src/Instrumentation/Yii/composer.json +++ b/src/Instrumentation/Yii/composer.json @@ -11,7 +11,7 @@ "ext-opentelemetry": "*", "yiisoft/yii2": "^2.0.13", "open-telemetry/api": "^1", - "open-telemetry/sem-conv": "^1.30" + "open-telemetry/sem-conv": "^1.32" }, "require-dev": { "friendsofphp/php-cs-fixer": "^3", diff --git a/src/Instrumentation/Yii/src/YiiInstrumentation.php b/src/Instrumentation/Yii/src/YiiInstrumentation.php index 96494a34d..4e85b428f 100644 --- a/src/Instrumentation/Yii/src/YiiInstrumentation.php +++ b/src/Instrumentation/Yii/src/YiiInstrumentation.php @@ -26,7 +26,7 @@ public static function register(): void $instrumentation = new CachedInstrumentation( 'io.opentelemetry.contrib.php.yii', null, - 'https://opentelemetry.io/schemas/1.30.0' + 'https://opentelemetry.io/schemas/1.32.0' ); hook( @@ -49,9 +49,8 @@ public static function register(): void ->spanBuilder(sprintf('%s', $request->getMethod())) ->setParent($parent) ->setSpanKind(SpanKind::KIND_SERVER) - ->setAttribute(TraceAttributes::CODE_FUNCTION_NAME, $function) - ->setAttribute(TraceAttributes::CODE_NAMESPACE, $class) - ->setAttribute(TraceAttributes::CODE_FILEPATH, $filename) + ->setAttribute(TraceAttributes::CODE_FUNCTION_NAME, sprintf('%s::%s', $class, $function)) + ->setAttribute(TraceAttributes::CODE_FILE_PATH, $filename) ->setAttribute(TraceAttributes::CODE_LINE_NUMBER, $lineno) ->setAttribute(TraceAttributes::URL_FULL, $request->getAbsoluteUrl()) ->setAttribute(TraceAttributes::HTTP_REQUEST_METHOD, $request->getMethod()) diff --git a/src/Symfony/composer.json b/src/Symfony/composer.json index 7705d845f..fb9fe2f9d 100644 --- a/src/Symfony/composer.json +++ b/src/Symfony/composer.json @@ -13,7 +13,7 @@ "open-telemetry/context": "^1", "open-telemetry/exporter-otlp": "^1", "open-telemetry/exporter-zipkin": "^1", - "open-telemetry/sem-conv": "^1.30", + "open-telemetry/sem-conv": "^1.32", "php-http/discovery": "^1.14", "php-http/message": "^1.12" }, diff --git a/src/Symfony/src/OtelBundle/Console/ConsoleListener.php b/src/Symfony/src/OtelBundle/Console/ConsoleListener.php index 74aa4af64..ecdcb6d7b 100644 --- a/src/Symfony/src/OtelBundle/Console/ConsoleListener.php +++ b/src/Symfony/src/OtelBundle/Console/ConsoleListener.php @@ -28,7 +28,7 @@ public function __construct( $this->tracer = $tracerProvider->getTracer( OtelBundle::instrumentationName(), OtelBundle::instrumentationVersion(), - 'https://opentelemetry.io/schemas/1.30.0', + 'https://opentelemetry.io/schemas/1.32.0', ); } @@ -54,14 +54,14 @@ public function startCommand(ConsoleCommandEvent $event): void $name = $command ? $command->getName() : null; - $class = $command - ? get_class($command) + $fqn = $command + ? sprintf('%s::%s', get_class($command), 'run') : null; + $fqn = $span = $this->tracer ->spanBuilder($name ?? 'command') - ->setAttribute(TraceAttributes::CODE_FUNCTION_NAME, 'run') - ->setAttribute(TraceAttributes::CODE_NAMESPACE, $class) + ->setAttribute(TraceAttributes::CODE_FUNCTION_NAME, $fqn) ->startSpan(); Context::storage()->attach($span->storeInContext(Context::getCurrent()));