Skip to content
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

log discarded span attributes, events, links #1336

Merged
merged 7 commits into from
Jun 26, 2024

Conversation

brettmc
Copy link
Collaborator

@brettmc brettmc commented Jun 15, 2024

The SDK should log once if there are any dropped span attributes, links or events.
The SDK should log once if there are any dropped LogRecord attributes.

Fixes: #1323

@brettmc brettmc requested a review from a team June 15, 2024 07:56
Copy link

codecov bot commented Jun 15, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 74.58%. Comparing base (6bf422c) to head (f655748).
Report is 2 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##               main    #1336      +/-   ##
============================================
+ Coverage     74.38%   74.58%   +0.19%     
- Complexity     2493     2504      +11     
============================================
  Files           354      355       +1     
  Lines          7144     7180      +36     
============================================
+ Hits           5314     5355      +41     
+ Misses         1830     1825       -5     
Flag Coverage Δ
8.1 74.30% <100.00%> (+0.28%) ⬆️
8.2 74.47% <100.00%> (+0.24%) ⬆️
8.3 74.52% <100.00%> (+0.22%) ⬆️
8.4 74.52% <100.00%> (+0.33%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
src/SDK/Logs/LogRecordLimits.php 100.00% <ø> (ø)
src/SDK/Logs/Logger.php 100.00% <100.00%> (ø)
src/SDK/Trace/Span.php 94.52% <100.00%> (+10.78%) ⬆️

... and 10 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6bf422c...f655748. Read the comment docs.

src/SDK/Trace/Span.php Outdated Show resolved Hide resolved
src/SDK/Trace/Span.php Outdated Show resolved Hide resolved
moving the warning removes an extra call to toSpanData, thus some overhead. Outside of tests, this function
is only called from span processors once
Copy link
Contributor

@Nevay Nevay left a comment

Choose a reason for hiding this comment

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

Would it perhaps make sense to skip logging for not sampled spans?

IMO we should log discarded data for all recorded spans, not only for sampled spans. Usage of a sampler that records a span indicates that a user is interested in the span data (the built-in samplers return DROP or RECORD_AND_SAMPLE, not RECORD_ONLY).

Outside of tests, this function is only called from span processors once

Every span processor calls ::toSpanData() -> currently would be logged multiple times if multiple span processors are registered.

(We'll need the same for LogRecord attributes spec)

@@ -290,6 +292,18 @@ public function toSpanData(): SpanDataInterface
$this->endEpochNanos,
$this->hasEnded
);

if ($spanData->getTotalDroppedLinks() || $spanData->getTotalDroppedEvents() || $spanData->getAttributes()->getDroppedAttributesCount()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should also check for dropped event or link attributes.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updated to check+log on LogRecord dropped attributes, span event+link dropped attributes.

Moved the check into span's onEnd, so that it is called once per span. This does add an extra call to toSpanData. I didn't profile the difference, but it looks like a computationally light function...

@brettmc brettmc merged commit b6f9afb into open-telemetry:main Jun 26, 2024
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants