Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Aug 1, 2025

The logs feature in the OpenTelemetry Rust SDK incorrectly required the trace feature, preventing users from using only logging functionality without bringing in tracing dependencies.

Problem

Previously, enabling only the logs feature would fail to compile because:

  1. The SDK's logs feature explicitly depended on opentelemetry/trace in Cargo.toml
  2. The logs implementation unconditionally used trace-specific APIs like TraceContextExt

This violated the principle of feature independence and forced users to include tracing dependencies even when only using logs.

Solution

Made trace context retrieval conditional while preserving existing functionality:

  • Removed hard dependency: Updated opentelemetry-sdk/Cargo.toml to remove "opentelemetry/trace" from the logs feature
  • Conditional trace context: Made span context retrieval conditional with #[cfg(feature = "trace")]
  • Preserved compatibility: When both features are enabled, logs automatically pick up trace context from active spans

Behavior Changes

Before: Logs feature required trace feature

# This would fail to compile
opentelemetry_sdk = { features = ["logs"] }  # Error: missing trace feature

After: Logs feature works independently

# Logs only - works without trace dependencies
opentelemetry_sdk = { features = ["logs"] }

# Logs + trace - automatic trace context integration  
opentelemetry_sdk = { features = ["logs", "trace"] }

Verification

  • ✅ Logs-only builds and tests pass without trace feature
  • ✅ Combined logs+trace features work with automatic trace context pickup
  • ✅ Backward compatibility maintained for existing code using both features
  • ✅ Created integration tests demonstrating both scenarios

Fixes #3096.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Aug 1, 2025

CLA Signed

The committers listed above are authorized under a signed CLA.

Copilot AI changed the title [WIP] Logs feature requires Trace feature Fix logs feature dependency on trace feature Aug 1, 2025
Copilot AI requested a review from cijothomas August 1, 2025 21:31
Copilot finished work on behalf of cijothomas August 1, 2025 21:31
@codecov
Copy link

codecov bot commented Aug 1, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.4%. Comparing base (0462369) to head (e01f857).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##            main   #3102     +/-   ##
=======================================
+ Coverage   80.1%   80.4%   +0.3%     
=======================================
  Files        126     126             
  Lines      21957   22218    +261     
=======================================
+ Hits       17603   17885    +282     
+ Misses      4354    4333     -21     

☔ 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 marked this pull request as ready for review August 1, 2025 23:47
@cijothomas cijothomas requested a review from a team as a code owner August 1, 2025 23:47
@cijothomas cijothomas changed the title Fix logs feature dependency on trace feature Fix: log sdk no longer enables trace feature Aug 1, 2025
@cijothomas cijothomas changed the title Fix: log sdk no longer enables trace feature fix: log sdk no longer enables trace feature Aug 2, 2025
Copy link
Member

@scottgerring scottgerring left a comment

Choose a reason for hiding this comment

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

Great to properly tease the signals apart!

@cijothomas cijothomas closed this Aug 4, 2025
@cijothomas cijothomas reopened this Aug 4, 2025
@cijothomas cijothomas merged commit bbb1821 into main Aug 4, 2025
27 checks passed
@cijothomas cijothomas deleted the copilot/fix-3096-2 branch August 4, 2025 16:27
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.

Logs feature requires Trace feature

3 participants