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

Prevent concurrent ::export() calls in span processor #788

Merged
merged 6 commits into from
Aug 24, 2022

Conversation

Nevay
Copy link
Contributor

@Nevay Nevay commented Aug 2, 2022

Export() will never be called concurrently for the same exporter instance.

This PR calls ::export() in a synchronous loop to prevent concurrent calls to ::export().
Note that this might block the Span::end() call that triggered the export longer. The blocking autoflush behavior of BatchSpanProcessor::onEnd() can be disabled, spans will then only be flushed on explicit ::forceFlush() / ::shutdown() calls.

OnEnd() MUST be called synchronously within the Span.End() API, therefore it should not block or throw an exception.

Disallowing concurrent export calls means that we have to reintroduce support for concurrent exports by changing the return type of ::export() to a promise/future-like value - I plan on working on that after this PR is merged.

Alternative to #787, see also #787 (comment).

@codecov
Copy link

codecov bot commented Aug 2, 2022

Codecov Report

Merging #788 (8905837) into main (3ac64f6) will increase coverage by 0.25%.
The diff coverage is 97.65%.

❗ Current head 8905837 differs from pull request most recent head d309f83. Consider uploading reports for the commit d309f83 to get more accurate results

Impacted file tree graph

@@             Coverage Diff              @@
##               main     #788      +/-   ##
============================================
+ Coverage     80.40%   80.66%   +0.25%     
- Complexity     1765     1786      +21     
============================================
  Files           222      222              
  Lines          4516     4592      +76     
============================================
+ Hits           3631     3704      +73     
- Misses          885      888       +3     
Flag Coverage Δ
7.4 80.66% <97.65%> (+0.26%) ⬆️
8.0 80.69% <97.65%> (+0.25%) ⬆️
8.1 80.69% <97.65%> (+0.25%) ⬆️

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

Impacted Files Coverage Δ
...PI/Common/Instrumentation/InstrumentationTrait.php 94.73% <50.00%> (-5.27%) ⬇️
src/SDK/Trace/SpanProcessorFactory.php 92.85% <87.50%> (-7.15%) ⬇️
src/SDK/Trace/SpanProcessor/BatchSpanProcessor.php 100.00% <100.00%> (ø)
...rc/SDK/Trace/SpanProcessor/SimpleSpanProcessor.php 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

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

@Nevay Nevay force-pushed the fix/prevent-concurrent-exports branch from 77e02fc to af668ad Compare August 4, 2022 17:42
int $scheduledDelayMillis = self::DEFAULT_SCHEDULE_DELAY,
int $exportTimeoutMillis = self::DEFAULT_EXPORT_TIMEOUT,
int $maxExportBatchSize = self::DEFAULT_MAX_EXPORT_BATCH_SIZE,
bool $autoFlush = true
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should be changed to default false before beta to be consistent with async implementations that will only export once the event loop gains control. Using default true for now to keep the scope of the PR small / to not break examples etc.

src/SDK/Trace/SpanProcessor/BatchSpanProcessor.php Outdated Show resolved Hide resolved
@Nevay Nevay marked this pull request as ready for review August 4, 2022 20:53
@Nevay Nevay force-pushed the fix/prevent-concurrent-exports branch from de53b81 to 4a2b869 Compare August 10, 2022 15:00
@Nevay Nevay force-pushed the fix/prevent-concurrent-exports branch from 88e0a69 to d309f83 Compare August 17, 2022 20:10
@brettmc brettmc merged commit 2457c76 into open-telemetry:main Aug 24, 2022
@Nevay Nevay deleted the fix/prevent-concurrent-exports branch April 19, 2023 19:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants