-
Notifications
You must be signed in to change notification settings - Fork 109
add Doctrine span links and more SemConv #374
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
track doctrine prepared statements, and when they are executed create a span link back to the span that prepared. add some more SemConv to db spans, particularly db.operation.name align span names with how PDO does it (eg Doctrine::prepare)
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #374 +/- ##
============================================
+ Coverage 81.68% 83.16% +1.47%
- Complexity 1741 1957 +216
============================================
Files 133 143 +10
Lines 7307 8190 +883
============================================
+ Hits 5969 6811 +842
- Misses 1338 1379 +41 Flags with carried forward coverage won't be shown. Click here to find out more.
... and 19 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
@open-telemetry/php-approvers ping! |
|
||
public function trackStatement(Statement $statement, SpanContextInterface $context): void | ||
{ | ||
$this->statementToSpanContextMap[$statement] = WeakReference::create($context); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like it will return null
after the ::prepare()
span is flushed and exported? Should be testable by something like:
$stmt = $connection->prepare('SELECT * FROM `technology` WHERE name = :name');
$this->storage->exchangeArray([]);
$stmt->bindValue('name', 'PHP');
$stmt->executeQuery();
$execute = $this->storage->offsetGet(0);
$this->assertCount(1, $execute->getLinks());
$this->statementToSpanContextMap[$statement] = WeakReference::create($context); | |
$this->statementToSpanContextMap[$statement] = $context; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, you're right. I've used SplObjectStorage now, and added a test. It doesn't look like prepared statements can be destroyed easily, so I guess holding on to span context forever is okay...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should revert the WeakMap
->SplObjectStorage
change to avoid leaking memory; only the usage of WeakReference
was problematic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reverted to WeakMap
- tidy constructor - do not use a WeakMap to track prepared statements, as the SpanContext is lost when prepare span flushed/exported
Fixes: open-telemetry/opentelemetry-php#1578