opentelemetry_etw_logs/lib.rs
1//! The ETW exporter will enable applications to use OpenTelemetry API
2//! to capture the telemetry events, and write them to the ETW subsystem.
3//!
4//! ## Resource Attribute Handling
5//!
6//! **Important**: By default, resource attributes are NOT exported with log records.
7//! The ETW exporter only automatically exports these specific resource attributes:
8//!
9//! - **`service.name`** → Exported as `cloud.roleName` in PartA of Common Schema
10//! - **`service.instance.id`** → Exported as `cloud.roleInstance` in PartA of Common Schema
11//!
12//! All other resource attributes are ignored unless explicitly specified.
13//!
14//! ### Opting in to Additional Resource Attributes
15//!
16//! To export additional resource attributes, use the `with_resource_attributes()` method:
17//!
18//! ```rust
19//! use opentelemetry_sdk::logs::SdkLoggerProvider;
20//! use opentelemetry_sdk::Resource;
21//! use opentelemetry_etw_logs::Processor;
22//! use opentelemetry::KeyValue;
23//!
24//! let etw_processor = Processor::builder("myprovider")
25//! // Only export specific resource attributes
26//! .with_resource_attributes(["custom_attribute1", "custom_attribute2"])
27//! .build()
28//! .unwrap();
29//!
30//! let provider = SdkLoggerProvider::builder()
31//! .with_resource(
32//! Resource::builder_empty()
33//! .with_service_name("example")
34//! .with_attribute(KeyValue::new("custom_attribute1", "value1"))
35//! .with_attribute(KeyValue::new("custom_attribute2", "value2"))
36//! .with_attribute(KeyValue::new("custom_attribute3", "value3")) // This won't be exported
37//! .build(),
38//! )
39//! .with_log_processor(etw_processor)
40//! .build();
41//! ```
42//!
43//! ### Performance Considerations for ETW
44//!
45//! **Warning**: Each specified resource attribute will be serialized and sent
46//! with EVERY log record. This is different from OTLP exporters where resource
47//! attributes are serialized once per batch. Consider the performance impact
48//! when selecting which attributes to export.
49//!
50//! **Recommendation**: Be selective about which resource attributes to export.
51//! Since ETW writes to a local kernel buffer and requires a local
52//! listener/agent, the agent can often deduce many resource attributes without
53//! requiring them to be sent with each log:
54//!
55//! - **Infrastructure attributes** (datacenter, region, availability zone) can
56//! be determined by the local agent.
57//! - **Host attributes** (hostname, IP address, OS version) are available locally.
58//! - **Deployment attributes** (environment, cluster) may be known to the agent.
59//!
60//! Focus on attributes that are truly specific to your application instance
61//! and cannot be easily determined by the local agent.
62
63#![warn(missing_debug_implementations, missing_docs)]
64
65#[cfg(feature = "serde_json")]
66mod converters;
67mod exporter;
68mod processor;
69
70pub use processor::Processor;
71pub use processor::ProcessorBuilder;