Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Aug 2, 2025

This PR adds support for exporting Resource attributes with each log record in the opentelemetry-etw-logs crate, following the same pattern implemented in PR #288 for opentelemetry-user-events-logs.

Background

Previously, the ETW logs exporter only automatically exported two specific resource attributes:

  • service.name → exported as cloud.roleName in PartA of Common Schema
  • service.instance.id → exported as cloud.roleInstance in PartA of Common Schema

All other resource attributes were ignored, limiting the ability to include additional context with log records.

Changes

New API

Added a with_resource_attributes() method to the ProcessorBuilder that allows users to specify which resource attributes should be exported with each log record:

use opentelemetry_etw_logs::Processor;
use opentelemetry_sdk::Resource;
use opentelemetry::KeyValue;

let processor = Processor::builder("MyApp")
    .with_resource_attributes(["deployment.environment", "application.version"])
    .build()
    .unwrap();

let logger_provider = SdkLoggerProvider::builder()
    .with_resource(
        Resource::builder()
            .with_service_name("my-service")
            .with_attribute(KeyValue::new("deployment.environment", "production"))
            .with_attribute(KeyValue::new("application.version", "1.0.0"))
            .with_attribute(KeyValue::new("ignored.attribute", "not-exported"))
            .build(),
    )
    .with_log_processor(processor)
    .build();

Implementation Details

  • Resource attributes are exported in PartC of the ETW event alongside other log record attributes
  • Only explicitly configured resource attributes are exported (opt-in behavior)
  • The existing behavior for service.name and service.instance.id is preserved
  • Proper type conversion from OpenTelemetry Value to AnyValue is handled

Performance Considerations

The implementation includes comprehensive documentation about performance implications, as resource attributes are serialized with every log record (unlike OTLP exporters where they're sent once per batch).

Documentation

Added extensive documentation with:

  • Usage examples
  • Performance considerations for ETW scenarios
  • Best practices for selecting which attributes to export
  • Clear explanation of default behavior

Testing

  • Added unit tests for the new functionality
  • Integration tests with tracing
  • Validation of resource attribute filtering
  • All existing tests continue to pass (29 total tests)

Backward Compatibility

This change is fully backward compatible. Existing code will continue to work unchanged, with only the default resource attributes (service.name and service.instance.id) being exported as before.

Fixes #409.


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

Copy link

linux-foundation-easycla bot commented Aug 2, 2025

CLA Signed

The committers listed above are authorized under a signed CLA.

@Copilot Copilot AI changed the title [WIP] Add support Resource attributes in eta-logs exporter feat: Add support for Resource attributes in ETW logs exporter Aug 2, 2025
@Copilot Copilot AI requested a review from cijothomas August 2, 2025 00:21
Copilot finished work on behalf of cijothomas August 2, 2025 00:21
Copy link

codecov bot commented Aug 2, 2025

Codecov Report

❌ Patch coverage is 96.58120% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 48.6%. Comparing base (46b18fb) to head (2356c5e).

Files with missing lines Patch % Lines
opentelemetry-etw-logs/src/exporter/mod.rs 92.8% 4 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##            main    #410     +/-   ##
=======================================
+ Coverage   48.1%   48.6%   +0.5%     
=======================================
  Files         69      69             
  Lines       9810    9919    +109     
=======================================
+ Hits        4719    4824    +105     
- Misses      5091    5095      +4     

☔ 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@cijothomas
Copy link
Member

/easycla

@cijothomas
Copy link
Member

@copilot There are lint failures. Analyze and fix them. You can run cargo fmt --all to fix most of them.

Copy link
Contributor Author

Copilot AI commented Aug 6, 2025

@copilot There are lint failures. Analyze and fix them. You can run cargo fmt --all to fix most of them.

Fixed all formatting issues by running cargo fmt --all. The changes included import ordering, removing trailing whitespace, and properly formatting long lines and method chains. All 29 tests continue to pass. Commit: 0a01dad

Copilot finished work on behalf of cijothomas August 6, 2025 16:16
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.

Add support Resource attributes in eta-logs exporter
3 participants