Skip to content

Conversation

@martincostello
Copy link
Member

@martincostello martincostello commented Oct 2, 2025

Changes

Found while working on #6463.

  • Avoid Uri.ToString() allocations when logging in OTLP export clients if the event source is not enabled at the relevant logging levels.
  • Log successful HTTP export for parity with gRPC.

Merge requirement checklist

  • CONTRIBUTING guidelines followed (license requirements, nullable enabled, static analysis, etc.)
  • Unit tests added/updated
  • Appropriate CHANGELOG.md files updated for non-trivial changes
  • Changes in public API reviewed (if applicable)

@github-actions github-actions bot added the pkg:OpenTelemetry.Exporter.OpenTelemetryProtocol Issues related to OpenTelemetry.Exporter.OpenTelemetryProtocol NuGet package label Oct 2, 2025
martincostello added a commit to martincostello/opentelemetry-dotnet that referenced this pull request Oct 2, 2025
Avoid allocations when logging in OTLP export clients.
Log successful HTTP export like we do for gRPC.
@martincostello martincostello force-pushed the otlp-logging-allocations branch from 8d6af25 to f264179 Compare October 2, 2025 16:54
@martincostello martincostello marked this pull request as ready for review October 2, 2025 16:54
@martincostello martincostello requested a review from a team as a code owner October 2, 2025 16:54
Copilot AI review requested due to automatic review settings October 2, 2025 16:54
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR optimizes OTLP export clients by avoiding redundant string allocations in logging and adds parity between HTTP and gRPC export clients by logging successful HTTP exports.

  • Avoids Uri.ToString() allocations when event source is not enabled at the relevant logging levels
  • Adds success logging for HTTP export to match existing gRPC behavior
  • Introduces helper methods with logging level checks to prevent unnecessary allocations

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
OpenTelemetryProtocolExporterEventSource.cs Added helper methods with event level checks to avoid Uri.ToString() allocations
OtlpHttpExportClient.cs Added success logging for HTTP export completion
OtlpGrpcExportClient.cs Updated to use new helper methods that avoid string allocations
CHANGELOG.md Updated to document performance improvements and feature parity

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@codecov
Copy link

codecov bot commented Oct 2, 2025

Codecov Report

❌ Patch coverage is 55.55556% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.62%. Comparing base (5f66728) to head (64181d8).
⚠️ Report is 2 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...tation/OpenTelemetryProtocolExporterEventSource.cs 50.00% 3 Missing ⚠️
...mplementation/ExportClient/OtlpGrpcExportClient.cs 50.00% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #6562      +/-   ##
==========================================
- Coverage   86.63%   86.62%   -0.01%     
==========================================
  Files         258      258              
  Lines       11888    11895       +7     
==========================================
+ Hits        10299    10304       +5     
- Misses       1589     1591       +2     
Flag Coverage Δ
unittests-Project-Experimental 86.61% <55.55%> (+0.27%) ⬆️
unittests-Project-Stable 86.60% <44.44%> (+0.04%) ⬆️

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

Files with missing lines Coverage Δ
...mplementation/ExportClient/OtlpHttpExportClient.cs 100.00% <100.00%> (ø)
...mplementation/ExportClient/OtlpGrpcExportClient.cs 75.28% <50.00%> (ø)
...tation/OpenTelemetryProtocolExporterEventSource.cs 84.52% <50.00%> (-2.66%) ⬇️

... and 1 file with indirect coverage changes


## Unreleased

* Avoid allocating strings when logging gRPC export events unless required.
Copy link
Member

Choose a reason for hiding this comment

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

No need to update changelog for this change as it is related to internal logging.

Copy link
Member

@rajkumar-rangaraj rajkumar-rangaraj left a comment

Choose a reason for hiding this comment

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

left a comment to remove updates to changelog


## Unreleased

* Log export success when exporting telemetry using `http/protobuf`.
Copy link
Member

Choose a reason for hiding this comment

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

We don't need to include this update in the changelog, as it doesn't have any relevance for the customer.

Copy link
Member Author

Choose a reason for hiding this comment

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

Is there no way for users to enable it by listening the event source themselves if they want to debug?

Copy link
Member

Choose a reason for hiding this comment

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

Including these kinds of updates in the changelog could quickly become too noisy. Since this isn’t something most customers will act on directly, I’d lean toward leaving it out and this is what earlier maintainers too followed as guidelines in this repo.

@rajkumar-rangaraj rajkumar-rangaraj merged commit 6a70665 into open-telemetry:main Oct 2, 2025
43 checks passed
@martincostello martincostello deleted the otlp-logging-allocations branch October 3, 2025 06:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pkg:OpenTelemetry.Exporter.OpenTelemetryProtocol Issues related to OpenTelemetry.Exporter.OpenTelemetryProtocol NuGet package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants