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

[SDK] Add ForceFlush for all LogRecordExporters and SpanExporters. #2000

Merged
merged 9 commits into from
Mar 20, 2023

Conversation

owent
Copy link
Member

@owent owent commented Feb 23, 2023

Fixes #1623
Fixes #1955

Changes

  • Add ForceFlush for all LogRecordExporters and SpanExporters.
  • Call ForceFlush to prevent cancel in OTLP examples.
  • Optimize BatchSpanProcessor::ForceFlush and BatchLogRecordProcessor::ForceFlush. We will finish force flush more quickly when pass a large timeout .
  • Optimize OTLP HTTP log example

For significant contributions please make sure you have completed the following items:

  • CHANGELOG.md updated for non-trivial changes
  • Unit tests have been added
  • Changes in public API reviewed

@owent owent requested a review from a team February 23, 2023 12:31
@codecov
Copy link

codecov bot commented Feb 23, 2023

Codecov Report

Merging #2000 (8359014) into main (3a09d53) will decrease coverage by 0.12%.
The diff coverage is 68.58%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2000      +/-   ##
==========================================
- Coverage   87.30%   87.17%   -0.12%     
==========================================
  Files         166      166              
  Lines        4723     4746      +23     
==========================================
+ Hits         4123     4137      +14     
- Misses        600      609       +9     
Impacted Files Coverage Δ
...de/opentelemetry/exporters/ostream/span_exporter.h 100.00% <ø> (ø)
exporters/ostream/src/span_exporter.cc 88.12% <0.00%> (-2.69%) ⬇️
...k/include/opentelemetry/sdk/trace/tracer_context.h 100.00% <ø> (ø)
sdk/src/trace/tracer.cc 78.73% <0.00%> (-11.52%) ⬇️
sdk/src/trace/exporter.cc 50.00% <50.00%> (ø)
...include/opentelemetry/sdk/trace/simple_processor.h 100.00% <100.00%> (ø)
sdk/src/trace/batch_span_processor.cc 92.71% <100.00%> (+1.23%) ⬆️
sdk/src/trace/tracer_context.cc 81.82% <100.00%> (ø)

... and 1 file with indirect coverage changes

@owent owent changed the title [WIP] Add ForceFlush for all LogRecordExporters and SpanExporters. Add ForceFlush for all LogRecordExporters and SpanExporters. Feb 23, 2023
@esigo esigo added the size/XL Denotes a PR that changes 500-999 lines. label Feb 26, 2023
Copy link
Member

@lalitb lalitb left a comment

Choose a reason for hiding this comment

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

LGTM. With nit comments. Thanks.

CHANGELOG.md Outdated Show resolved Hide resolved
exporters/etw/CMakeLists.txt Show resolved Hide resolved
sdk/src/trace/batch_span_processor.cc Show resolved Hide resolved
@owent owent force-pushed the add_SpanExporter_ForceFlush branch 2 times, most recently from 0440c9e to a5be47f Compare March 16, 2023 06:35
@lalitb
Copy link
Member

lalitb commented Mar 17, 2023

@owent - Can you resolve conflict here too, we can merge it now.

break_condition);
}
result = true;
timeout_steady = std::chrono::steady_clock::duration::max();
Copy link
Member

@lalitb lalitb Mar 17, 2023

Choose a reason for hiding this comment

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

I am not able to understand this part of code. The AdjustWaitForTimeout call above will change timeout from duration::zero() to duration::max() and this line now will change it back to duration::zero().

Copy link
Member Author

Choose a reason for hiding this comment

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

AdjustWaitForTimeout just cahnge the timeout to meet the requirement of wait_for .It will return the second parameter when the timeout is greater than max available value.It will change timeout to duration::zero() here, not to duration::max().
Some old codes use zero for indefinite waiting. Maybe we can raise another PR to remove this implementation if we have cleanup all zero value usage. Maybe it is easier to understand to do not wait when we get zero here.
What's your suggestion?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, I think cleaning up the zero-value usage for indefinite waiting in a separate PR would be good. Thanks for the explanation.

+ Optimize `BatchSpanProcessor::ForceFlush` and `BatchLogRecordProcessor::ForceFlush`.
+ Optimize OTLP HTTP log example
+ Call `ForceFlush` to prevent cancel in OTLP examples.

Signed-off-by: owent <[email protected]>
…nd `LogRecordExporter::ForceFlush`.

Signed-off-by: owent <[email protected]>
@owent owent force-pushed the add_SpanExporter_ForceFlush branch from 9cfd097 to 8359014 Compare March 20, 2023 02:53
@owent
Copy link
Member Author

owent commented Mar 20, 2023

@owent - Can you resolve conflict here too, we can merge it now.

Done.

@lalitb lalitb enabled auto-merge (squash) March 20, 2023 03:08
@lalitb lalitb disabled auto-merge March 20, 2023 03:15
@lalitb lalitb merged commit 9b222f2 into open-telemetry:main Mar 20, 2023
@owent owent deleted the add_SpanExporter_ForceFlush branch March 20, 2023 06:49
@marcalff marcalff changed the title Add ForceFlush for all LogRecordExporters and SpanExporters. [SDK] Add ForceFlush for all LogRecordExporters and SpanExporters. Apr 12, 2023
@marcalff marcalff changed the title [SDK] Add ForceFlush for all LogRecordExporters and SpanExporters. [EXPORTER] Add ForceFlush for all LogRecordExporters and SpanExporters. Apr 12, 2023
@marcalff marcalff changed the title [EXPORTER] Add ForceFlush for all LogRecordExporters and SpanExporters. [SDK] Add ForceFlush for all LogRecordExporters and SpanExporters. Apr 12, 2023
ays7 added a commit to ays7/opentelemetry-cpp that referenced this pull request May 18, 2023
* commit '7887d32da60f54984a597abccbb0c883f3a51649': (82 commits)
  [RELEASE] Release version 1.9.0 (open-telemetry#2091)
  Use sdk_start_ts for MetricData start_ts for instruments having cumulative aggregation temporality. (open-telemetry#2086)
  [SEMANTIC CONVENTIONS] Upgrade to version 1.20.0 (open-telemetry#2088)
  [EXPORTER] Add OTLP HTTP SSL support (open-telemetry#1793)
  Make Windows build environment parallel (open-telemetry#2080)
  make some hints (open-telemetry#2078)
  Make some targets parallel in CI pipeline (open-telemetry#2076)
  [Metrics SDK] Implement Forceflush for Periodic Metric Reader (open-telemetry#2064)
  Upgraded semantic conventions to 1.19.0 (open-telemetry#2017)
  Bump actions/stale from 7 to 8 (open-telemetry#2070)
  Include directory path added for Zipkin exporter example (open-telemetry#2069)
  Ignore more warning of generated protobuf files than not included in `-Wall` and `-Wextra` (open-telemetry#2067)
  Add `ForceFlush` for all `LogRecordExporter`s and `SpanExporter`s. (open-telemetry#2000)
  Remove unused 'alerting' section from prometheus.yml in examples (open-telemetry#2055)
  Clean warnings in ETW exporters (open-telemetry#2063)
  Fix default value of `OPENTELEMETRY_INSTALL_default`. (open-telemetry#2062)
  [EXPORTER] GRPC endpoint scheme should take precedence over OTEL_EXPORTER_OTLP_TRACES_INSECURE (open-telemetry#2060)
  Fix view names in Prometheus example (open-telemetry#2034)
  Fix some docs typo (open-telemetry#2057)
  Checking indices before dereference (open-telemetry#2040)
  ...

# Conflicts:
#	exporters/ostream/CMakeLists.txt
#	sdk/src/metrics/state/metric_collector.cc
#	sdk/src/metrics/state/temporal_metric_storage.cc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size/XL Denotes a PR that changes 500-999 lines.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

OtlpHttpClient::Export() fails in ASYNC build [Trace SDK] - Add SpanExporter#ForceFlush as required method
3 participants