Skip to content

[EXPORTER] Handle OTLP partial success response#4104

Open
RaviTriv wants to merge 14 commits into
open-telemetry:mainfrom
RaviTriv:ravtrive/handle-oltp-partial-success-response
Open

[EXPORTER] Handle OTLP partial success response#4104
RaviTriv wants to merge 14 commits into
open-telemetry:mainfrom
RaviTriv:ravtrive/handle-oltp-partial-success-response

Conversation

@RaviTriv
Copy link
Copy Markdown
Contributor

@RaviTriv RaviTriv commented May 25, 2026

Fixes #1577

Changes

PR to handle partial success responses from OTLP collector. As per the spec it states explicitly to not retry, the proposed solution is to log the rejection count and message.

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

Comment thread exporters/otlp/test/otlp_grpc_exporter_test.cc Outdated
@codecov
Copy link
Copy Markdown

codecov Bot commented May 25, 2026

Codecov Report

❌ Patch coverage is 51.07914% with 68 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.97%. Comparing base (d1723be) to head (1135899).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
exporters/otlp/src/otlp_grpc_client.cc 0.00% 18 Missing ⚠️
exporters/otlp/src/otlp_http_client.cc 63.16% 14 Missing ⚠️
exporters/otlp/src/otlp_grpc_exporter.cc 26.67% 11 Missing ⚠️
...xporters/otlp/src/otlp_grpc_log_record_exporter.cc 28.58% 10 Missing ⚠️
exporters/otlp/src/otlp_grpc_metric_exporter.cc 28.58% 10 Missing ⚠️
...xporters/otlp/src/otlp_http_log_record_exporter.cc 84.62% 2 Missing ⚠️
exporters/otlp/src/otlp_http_metric_exporter.cc 83.34% 2 Missing ⚠️
exporters/otlp/src/otlp_http_exporter.cc 93.34% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #4104      +/-   ##
==========================================
- Coverage   82.01%   81.97%   -0.03%     
==========================================
  Files         385      385              
  Lines       16030    16135     +105     
==========================================
+ Hits        13145    13225      +80     
- Misses       2885     2910      +25     
Files with missing lines Coverage Δ
...de/opentelemetry/exporters/otlp/otlp_http_client.h 100.00% <ø> (ø)
exporters/otlp/src/otlp_http_exporter.cc 98.24% <93.34%> (-0.81%) ⬇️
...xporters/otlp/src/otlp_http_log_record_exporter.cc 96.59% <84.62%> (-1.54%) ⬇️
exporters/otlp/src/otlp_http_metric_exporter.cc 96.67% <83.34%> (-1.51%) ⬇️
...xporters/otlp/src/otlp_grpc_log_record_exporter.cc 80.19% <28.58%> (-6.90%) ⬇️
exporters/otlp/src/otlp_grpc_metric_exporter.cc 71.93% <28.58%> (+22.43%) ⬆️
exporters/otlp/src/otlp_grpc_exporter.cc 78.10% <26.67%> (-6.68%) ⬇️
exporters/otlp/src/otlp_http_client.cc 66.54% <63.16%> (-1.03%) ⬇️
exporters/otlp/src/otlp_grpc_client.cc 70.63% <0.00%> (-0.90%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

arena.get());
grpc::Status status = OtlpGrpcClient::DelegateExport(
trace_service_stub_.get(), std::move(context), std::move(arena), request, response);
grpc::Status status = trace_service_stub_->Export(context.get(), *request, response);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We should only call gRPC's APIs only in otlp_grpc_client.cc to avoid symbol conflicts.

More details can be found at #3435 #1891 #1520 #1603 #1606

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks for taking a look!

Got it. Updated DelegateExport to take an optional callback that runs before the arena destructs, and passed a callback that logs partial_success / success.

arena.get());
grpc::Status status = OtlpGrpcClient::DelegateExport(
log_service_stub_.get(), std::move(context), std::move(arena), request, response);
grpc::Status status = log_service_stub_->Export(context.get(), *request, response);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The same as otlp_grpc_exporter.cc‎:186


sdk::common::ExportResult OtlpHttpClient::Export(
const google::protobuf::Message &message,
google::protobuf::Message *response,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I noticed the callback currently captures shared_ptr of response but the method signature also passes pointer to response separately. It might be cleaner to package these together—perhaps as a CompletionContext—so the lifecycle is managed in one place.

And we should use arena to create response to reduce memory segment.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good idea, updated to move this into an arena in HttpSessionData.

http_client_->Export(*service_request, [metric_count](
opentelemetry::sdk::common::ExportResult result) {

std::shared_ptr<proto::collector::metrics::v1::ExportMetricsServiceResponse> response =
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We should use arena to create response to reduce memory segment. Maybe we can move arena into session to hold the lifetime, just like it in otlp_grpc_client

@RaviTriv RaviTriv marked this pull request as ready for review May 27, 2026 21:14
@RaviTriv RaviTriv requested a review from a team as a code owner May 27, 2026 21:14
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.

Handle partial success responses from OTLP export services

2 participants