Skip to content

fix: Improved logging for OTLP Tonic Exporter #3108

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

cijothomas
Copy link
Member

Improved logging

  1. Interceptor failures are logged separately from export failures. Built-in interceptor simply adds Metadata, and has no scope of failure, so if this fails, it indicates user has added custom interceptors which is failing.
  2. Log individual fields in the OTLP exporter, and then return Result contains just the minimal info about failure as OTLP's own log already has sufficient information, and no need to duplicate it by upstream component like batchexportprocessor/readers.

Related to #3021

@cijothomas cijothomas requested a review from a team as a code owner August 2, 2025 19:49
Copy link

codecov bot commented Aug 2, 2025

Codecov Report

❌ Patch coverage is 0% with 38 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.0%. Comparing base (0462369) to head (ee0d2bc).

Files with missing lines Patch % Lines
opentelemetry-otlp/src/exporter/tonic/metrics.rs 0.0% 14 Missing ⚠️
opentelemetry-otlp/src/exporter/tonic/logs.rs 0.0% 12 Missing ⚠️
opentelemetry-otlp/src/exporter/tonic/trace.rs 0.0% 12 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##            main   #3108     +/-   ##
=======================================
- Coverage   80.1%   80.0%   -0.1%     
=======================================
  Files        126     126             
  Lines      21957   21981     +24     
=======================================
  Hits       17603   17603             
- Misses      4354    4378     +24     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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

@cijothomas cijothomas requested a review from Copilot August 2, 2025 19:59
Copy link

@Copilot 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 improves logging for OTLP Tonic Exporter by separating interceptor failures from export failures and providing more detailed error information while simplifying error messages passed upstream.

  • Separates interceptor failure logging from export failure logging to better identify custom interceptor issues
  • Enhances debug logging to include individual gRPC error fields (code, message, details) instead of formatting the entire error object
  • Simplifies error messages returned to upstream components while maintaining detailed logging

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 12 comments.

File Description
opentelemetry-otlp/src/exporter/tonic/trace.rs Updates trace exporter with improved interceptor and export error logging
opentelemetry-otlp/src/exporter/tonic/metrics.rs Updates metrics exporter with improved interceptor and export error logging
opentelemetry-otlp/src/exporter/tonic/logs.rs Updates logs exporter with improved interceptor and export error logging

.map_err(|e| {
otel_debug!(
name: "TonicTracesClient.InterceptorFailed",
grpc_code = format!("{:?}", e.code()),
Copy link
Preview

Copilot AI Aug 2, 2025

Choose a reason for hiding this comment

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

Using format!("{:?}", e.code()) is unnecessary since e.code() already returns a displayable type. Consider using grpc_code = %e.code() or grpc_code = e.code() directly to avoid the formatting overhead.

Suggested change
grpc_code = format!("{:?}", e.code()),
grpc_code = e.code(),

Copilot uses AI. Check for mistakes.

name: "TonicTracesClient.InterceptorFailed",
grpc_code = format!("{:?}", e.code()),
grpc_message = e.message(),
grpc_details = format!("{:?}", e.details())
Copy link
Preview

Copilot AI Aug 2, 2025

Choose a reason for hiding this comment

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

Using format!("{:?}", e.details()) is unnecessary since e.details() should be directly displayable. Consider using grpc_details = %e.details() or similar to avoid the formatting overhead.

Suggested change
grpc_details = format!("{:?}", e.details())
grpc_details = e.details()

Copilot uses AI. Check for mistakes.

Err(OTelSdkError::InternalFailure(error))
otel_debug!(
name: "TonicTracesClient.ExportFailed",
grpc_code = format!("{:?}", e.code()),
Copy link
Preview

Copilot AI Aug 2, 2025

Choose a reason for hiding this comment

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

Using format!("{:?}", e.code()) is unnecessary since e.code() already returns a displayable type. Consider using grpc_code = %e.code() or grpc_code = e.code() directly to avoid the formatting overhead.

Suggested change
grpc_code = format!("{:?}", e.code()),
grpc_code = e.code(),

Copilot uses AI. Check for mistakes.

name: "TonicTracesClient.ExportFailed",
grpc_code = format!("{:?}", e.code()),
grpc_message = e.message(),
grpc_details = format!("{:?}", e.details())
Copy link
Preview

Copilot AI Aug 2, 2025

Choose a reason for hiding this comment

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

Using format!("{:?}", e.details()) is unnecessary since e.details() should be directly displayable. Consider using grpc_details = %e.details() or similar to avoid the formatting overhead.

Suggested change
grpc_details = format!("{:?}", e.details())
grpc_details = e.details()

Copilot uses AI. Check for mistakes.

))
otel_debug!(
name: "TonicMetricsClient.InterceptorFailed",
grpc_code = format!("{:?}", e.code()),
Copy link
Preview

Copilot AI Aug 2, 2025

Choose a reason for hiding this comment

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

Using format!("{:?}", e.code()) is unnecessary since e.code() already returns a displayable type. Consider using grpc_code = %e.code() or grpc_code = e.code() directly to avoid the formatting overhead.

Suggested change
grpc_code = format!("{:?}", e.code()),
grpc_code = e.code(),

Copilot uses AI. Check for mistakes.

name: "TonicMetricsClient.ExportFailed",
grpc_code = format!("{:?}", e.code()),
grpc_message = e.message(),
grpc_details = format!("{:?}", e.details())
Copy link
Preview

Copilot AI Aug 2, 2025

Choose a reason for hiding this comment

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

Using format!("{:?}", e.details()) is unnecessary since e.details() should be directly displayable. Consider using grpc_details = %e.details() or similar to avoid the formatting overhead.

Suggested change
grpc_details = format!("{:?}", e.details())
grpc_details = e.details()

Copilot uses AI. Check for mistakes.

.map_err(|e| {
otel_debug!(
name: "TonicLogsClient.InterceptorFailed",
grpc_code = format!("{:?}", e.code()),
Copy link
Preview

Copilot AI Aug 2, 2025

Choose a reason for hiding this comment

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

Using format!("{:?}", e.code()) is unnecessary since e.code() already returns a displayable type. Consider using grpc_code = %e.code() or grpc_code = e.code() directly to avoid the formatting overhead.

Suggested change
grpc_code = format!("{:?}", e.code()),
grpc_code = e.code(),

Copilot uses AI. Check for mistakes.

name: "TonicLogsClient.InterceptorFailed",
grpc_code = format!("{:?}", e.code()),
grpc_message = e.message(),
grpc_details = format!("{:?}", e.details())
Copy link
Preview

Copilot AI Aug 2, 2025

Choose a reason for hiding this comment

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

Using format!("{:?}", e.details()) is unnecessary since e.details() should be directly displayable. Consider using grpc_details = %e.details() or similar to avoid the formatting overhead.

Suggested change
grpc_details = format!("{:?}", e.details())
grpc_details = %e.details()

Copilot uses AI. Check for mistakes.

Err(OTelSdkError::InternalFailure(error))
otel_debug!(
name: "TonicLogsClient.ExportFailed",
grpc_code = format!("{:?}", e.code()),
Copy link
Preview

Copilot AI Aug 2, 2025

Choose a reason for hiding this comment

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

Using format!("{:?}", e.code()) is unnecessary since e.code() already returns a displayable type. Consider using grpc_code = %e.code() or grpc_code = e.code() directly to avoid the formatting overhead.

Suggested change
grpc_code = format!("{:?}", e.code()),
grpc_code = e.code(),

Copilot uses AI. Check for mistakes.

name: "TonicLogsClient.ExportFailed",
grpc_code = format!("{:?}", e.code()),
grpc_message = e.message(),
grpc_details = format!("{:?}", e.details())
Copy link
Preview

Copilot AI Aug 2, 2025

Choose a reason for hiding this comment

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

Using format!("{:?}", e.details()) is unnecessary since e.details() should be directly displayable. Consider using grpc_details = %e.details() or similar to avoid the formatting overhead.

Suggested change
grpc_details = format!("{:?}", e.details())
grpc_details = e.details()

Copilot uses AI. Check for mistakes.

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.

1 participant