Skip to content

Commit

Permalink
fix(sdk): fix incorrect doc (#1499)
Browse files Browse the repository at this point in the history
Co-authored-by: Cijo Thomas <[email protected]>
  • Loading branch information
TommyCpp and cijothomas authored Feb 2, 2024
1 parent 270c857 commit dd4c13b
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 64 deletions.
5 changes: 1 addition & 4 deletions opentelemetry-sdk/src/metrics/meter_provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,7 @@ impl Default for SdkMeterProvider {
}

impl SdkMeterProvider {
/// Flushes all pending telemetry.
///
/// There is no guaranteed that all telemetry be flushed or all resources have
/// been released on error.
/// Return default [MeterProviderBuilder]
pub fn builder() -> MeterProviderBuilder {
MeterProviderBuilder::default()
}
Expand Down
42 changes: 0 additions & 42 deletions opentelemetry-sdk/src/propagation/baggage.rs
Original file line number Diff line number Diff line change
@@ -1,45 +1,3 @@
//! # OpenTelemetry Baggage API
//!
//! Baggage is used to annotate telemetry, adding context and
//! information to metrics, traces, and logs. It is an abstract data type
//! represented by a set of name-value pairs describing user-defined properties.
//! Each name in a [`Baggage`] is associated with exactly one value.
//! `Baggage`s are serialized according to the editor's draft of
//! the [W3C Baggage] specification.
//!
//! [`Baggage`]: opentelemetry::baggage::Baggage
//! [W3C Baggage]: https://w3c.github.io/baggage/
//!
//! # Examples
//!
//! ```
//! use opentelemetry::{baggage::BaggageExt, Key, propagation::TextMapPropagator};
//! use opentelemetry_sdk::propagation::BaggagePropagator;
//! use std::collections::HashMap;
//!
//! // Example baggage value passed in externally via http headers
//! let mut headers = HashMap::new();
//! headers.insert("baggage".to_string(), "user_id=1".to_string());
//!
//! let propagator = BaggagePropagator::new();
//! // can extract from any type that impls `Extractor`, usually an HTTP header map
//! let cx = propagator.extract(&headers);
//!
//! // Iterate over extracted name-value pairs
//! for (name, value) in cx.baggage() {
//! // ...
//! }
//!
//! // Add new baggage
//! let cx_with_additions = cx.with_baggage(vec![Key::new("server_id").i64(42)]);
//!
//! // Inject baggage into http request
//! propagator.inject_context(&cx_with_additions, &mut headers);
//!
//! let header_value = headers.get("baggage").expect("header is injected");
//! assert!(header_value.contains("user_id=1"), "still contains previous name-value");
//! assert!(header_value.contains("server_id=42"), "contains new name-value pair");
//! ```
use once_cell::sync::Lazy;
use opentelemetry::{
baggage::{BaggageExt, KeyValueMetadata},
Expand Down
43 changes: 25 additions & 18 deletions opentelemetry-sdk/src/propagation/trace_context.rs
Original file line number Diff line number Diff line change
@@ -1,22 +1,6 @@
//! # W3C Trace Context Propagator
//!
//! The `traceparent` header represents the incoming request in a
//! tracing system in a common format, understood by all vendors.
//! Here’s an example of a `traceparent` header.
//!
//! `traceparent: 00-0af7651916cd43dd8448eb211c80319c-b7ad6b7169203331-01`
//!
//! The `traceparent` HTTP header field identifies the incoming request in a
//! tracing system. It has four fields:
//!
//! - version
//! - trace-id
//! - parent-id
//! - trace-flags
//!
//! See the [w3c trace-context docs] for more details.
//!
//! [w3c trace-context docs]: https://w3c.github.io/trace-context/
use once_cell::sync::Lazy;
use opentelemetry::{
propagation::{text_map_propagator::FieldIter, Extractor, Injector, TextMapPropagator},
Expand All @@ -33,8 +17,31 @@ const TRACESTATE_HEADER: &str = "tracestate";
static TRACE_CONTEXT_HEADER_FIELDS: Lazy<[String; 2]> =
Lazy::new(|| [TRACEPARENT_HEADER.to_owned(), TRACESTATE_HEADER.to_owned()]);

/// Propagates `SpanContext`s in [W3C TraceContext] format.
/// Propagates `SpanContext`s in [W3C TraceContext] format under `traceparent` and `tracestate` header.
///
/// The `traceparent` header represents the incoming request in a
/// tracing system in a common format, understood by all vendors.
/// Here’s an example of a `traceparent` header.
///
/// `traceparent: 00-0af7651916cd43dd8448eb211c80319c-b7ad6b7169203331-01`
///
/// The `traceparent` HTTP header field identifies the incoming request in a
/// tracing system. It has four fields:
///
/// - version
/// - trace-id
/// - parent-id
/// - trace-flags
///
/// The `tracestate` header provides additional vendor-specific trace
/// identification information across different distributed tracing systems.
/// Here's an example of a `tracestate` header
///
/// `tracestate: vendorname1=opaqueValue1,vendorname2=opaqueValue2`
///
/// See the [w3c trace-context docs] for more details.
///
/// [w3c trace-context docs]: https://w3c.github.io/trace-context/
/// [W3C TraceContext]: https://www.w3.org/TR/trace-context/
#[derive(Clone, Debug, Default)]
pub struct TraceContextPropagator {
Expand Down

0 comments on commit dd4c13b

Please sign in to comment.