Skip to content

[EXPORTER] add OTLP HTTP metric exporter benchmark#3801

Merged
lalitb merged 1 commit intoopen-telemetry:mainfrom
ishan0803:otlp-html-exporter-BM
Jan 9, 2026
Merged

[EXPORTER] add OTLP HTTP metric exporter benchmark#3801
lalitb merged 1 commit intoopen-telemetry:mainfrom
ishan0803:otlp-html-exporter-BM

Conversation

@ishan0803
Copy link
Copy Markdown
Contributor

@ishan0803 ishan0803 commented Jan 7, 2026

Introduce a Google Benchmark-based performance benchmark for the OTLP HTTP metric exporter, covering both binary (protobuf) and JSON encodings.

Key changes:

  • Add otlp_http_metric_exporter_benchmark target under WITH_BENCHMARK && WITH_OTLP_HTTP.
  • Benchmark OtlpHttpMetricExporter::Export() across increasing numbers of metric data points (1 → 10,000).
  • Measure export cost for both binary and JSON content types.
  • Disable retries and logging to reduce noise and isolate exporter overhead.

This benchmark provides a baseline for evaluating export performance and future optimizations in the OTLP HTTP metric exporter.

Fixes # (issue)

Changes

Please provide a brief description of the changes here.

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

@ishan0803 ishan0803 requested a review from a team as a code owner January 7, 2026 14:24
@linux-foundation-easycla
Copy link
Copy Markdown

linux-foundation-easycla Bot commented Jan 7, 2026

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: ishan0803 / name: Ishan Ashish Agrawal (769f87d)

@marcalff marcalff added pr:waiting-on-cla Waiting on CLA and removed pr:waiting-on-cla Waiting on CLA labels Jan 7, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Jan 7, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.93%. Comparing base (47d0351) to head (769f87d).
⚠️ Report is 6 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3801      +/-   ##
==========================================
+ Coverage   89.91%   89.93%   +0.02%     
==========================================
  Files         225      225              
  Lines        7163     7163              
==========================================
+ Hits         6440     6441       +1     
+ Misses        723      722       -1     

see 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ishan0803 ishan0803 force-pushed the otlp-html-exporter-BM branch 2 times, most recently from 49306b3 to c21ea2a Compare January 8, 2026 19:13
@ishan0803
Copy link
Copy Markdown
Contributor Author

@marcalff I’ve fixed the formatting / IWYU issues flagged by CI.
Could you please rerun CI when you get a chance?

Introduce a Google Benchmark-based performance benchmark for the OTLP HTTP
metric exporter, covering both binary (protobuf) and JSON encodings.

Key changes:
- Add `otlp_http_metric_exporter_benchmark` target under
  `WITH_BENCHMARK && WITH_OTLP_HTTP`.
- Benchmark `OtlpHttpMetricExporter::Export()` across increasing numbers of
  metric data points (1 → 10,000).
- Measure export cost for both binary and JSON content types.
- Disable retries and logging to reduce noise and isolate exporter overhead.

This benchmark provides a baseline for evaluating export performance and
future optimizations in the OTLP HTTP metric exporter.

Fix resource lifetime in OTLP HTTP metric exporter benchmark

fix CI build errors in HTTP metric exporter benchmark
@ishan0803 ishan0803 force-pushed the otlp-html-exporter-BM branch from c21ea2a to 769f87d Compare January 9, 2026 04:48
static void BM_OtlpHttpMetricExporter_Export_Binary(benchmark::State &state)
{
OtlpHttpMetricExporterOptions opts;
opts.url = "http://localhost:4318/v1/metrics";
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.

Seems this benchmark attempts real HTTP calls that fail immediately with connection refused. Even a failed connection attempt adds ~10-100μs of overhead, which becomes significant when serialization itself takes only nanoseconds (especially for small payloads).

See how gRPC benchmark avoid this be mocking the network layer entirely. Something we can try here ?

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.

Agreed, even a failed HTTP attempt adds non-trivial overhead for smaller payload sizes, where serialization itself is very cheap.

Unlike gRPC, the HTTP metric exporter doesn’t currently expose a public way to inject a no-send transport. The only existing injection path goes through test-only peers, and I avoided reusing that here since this is a benchmark target and not built with test permissions.

Longer term, possible options could be (1) making the HTTP client injectable via a public API, (2) reusing the existing test peer, or (3) introducing a dedicated benchmark peer. But all of these require changes to exporter headers or test/benchmark boundaries and felt out of scope for this PR. For now, this benchmark measures Export() through the public API with retries and logging disabled.

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.

Thanks for clarifying. Agree with the constraints. For future, reusing the existing test peer infrastructure might be the most practical option, but that's not necessary for this PR to be valuable. I’m okay with landing this as a first baseline and revisiting injection options in a follow-up.

@ishan0803 ishan0803 requested a review from lalitb January 9, 2026 06:15
@marcalff
Copy link
Copy Markdown
Member

marcalff commented Jan 9, 2026

Not tested, but if I understand correctly, one can:

  • deploy locally a peer (opentelemetry-collector for example) on port 4318
  • use this benchmark to send traffic to the peer

so this is useful already in a dev environment, independently of CI, with zero code changes.

Ok to merge.

Copy link
Copy Markdown
Member

@marcalff marcalff left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for the contribution.

@lalitb lalitb merged commit f33dcc0 into open-telemetry:main Jan 9, 2026
113 of 114 checks passed
malkia added a commit to malkia/opentelemetry-cpp that referenced this pull request Jan 9, 2026
exporters/otlp: add HTTP metric exporter benchmark (open-telemetry#3801)
@ishan0803 ishan0803 deleted the otlp-html-exporter-BM branch January 10, 2026 04:12
@marcalff marcalff changed the title exporters/otlp: add HTTP metric exporter benchmark [EXPORTER] add OTLP HTTP metric exporter benchmark Feb 6, 2026
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.

3 participants