Skip to content
Open
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/API/Instrumentation/WithSpanHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class WithSpanHandler
public static function pre(mixed $target, array $params, ?string $class, string $function, ?string $filename, ?int $lineno, ?array $span_args = [], ?array $attributes = []): void
{
static $instrumentation;
$instrumentation ??= new CachedInstrumentation(name: 'io.opentelemetry.php.with-span', schemaUrl: 'https://opentelemetry.io/schemas/1.25.0');
$instrumentation ??= new CachedInstrumentation(name: 'io.opentelemetry.php.with-span', schemaUrl: 'https://opentelemetry.io/schemas/1.40.0');

$name = $span_args['name'] ?? null;
if ($name === null) {
Expand All @@ -36,10 +36,10 @@ public static function pre(mixed $target, array $params, ?string $class, string
->tracer()
->spanBuilder($name)
->setSpanKind($kind)
->setAttribute('code.function', $function)
->setAttribute('code.namespace', $class)
->setAttribute('code.filepath', $filename)
->setAttribute('code.lineno', $lineno)
->setAttribute('code.function.name', $class !== null ? $class . '::' . $function : $function)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could unify this with the span $name logic above:

$functionName = $class !== null ? $class . '::' . $function : $function;
$name = $span_args['name'] ?? $functionName;

->setAttribute('code.file.path', $filename)
->setAttribute('code.line.number', $lineno)
->setAttribute('code.column.number', $lineno)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't look right. I don't think we should use the line number as column number.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Fixed.

->setAttributes($attributes ?? [])
->startSpan();
$context = $span->storeInContext(Context::getCurrent());
Expand Down