Skip to content

Commit

Permalink
Add basic doc comments for opentelemetry-http (open-telemetry#1528)
Browse files Browse the repository at this point in the history
  • Loading branch information
cijothomas authored Feb 14, 2024
1 parent 64b11e0 commit 49f1be6
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@
**/*.rs.bk
Cargo.lock
/.idea/

.cosine
4 changes: 2 additions & 2 deletions opentelemetry-http/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[package]
name = "opentelemetry-http"
version = "0.10.0"
description = "Helper implementations for exchange of traces and metrics over HTTP"
description = "Helper implementations for sending HTTP requests. Uses include propagating and extracting context over http, exporting telemetry, requesting sampling strategies."
homepage = "https://github.com/open-telemetry/opentelemetry-rust"
repository = "https://github.com/open-telemetry/opentelemetry-rust"
keywords = ["opentelemetry", "tracing", "metrics"]
keywords = ["opentelemetry", "tracing", "context", "propagation"]
license = "Apache-2.0"
edition = "2021"
rust-version = "1.65"
Expand Down
12 changes: 11 additions & 1 deletion opentelemetry-http/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ pub use bytes::Bytes;
pub use http::{Request, Response};
use opentelemetry::propagation::{Extractor, Injector};

/// Helper for injecting headers into HTTP Requests. This is used for OpenTelemetry context
/// propagation over HTTP.
/// See [this](https://github.com/open-telemetry/opentelemetry-rust/blob/main/examples/tracing-http-propagator/README.md)
/// for example usage.
pub struct HeaderInjector<'a>(pub &'a mut http::HeaderMap);

impl<'a> Injector for HeaderInjector<'a> {
Expand All @@ -20,6 +24,10 @@ impl<'a> Injector for HeaderInjector<'a> {
}
}

/// Helper for extracting headers from HTTP Requests. This is used for OpenTelemetry context
/// propagation over HTTP.
/// See [this](https://github.com/open-telemetry/opentelemetry-rust/blob/main/examples/tracing-http-propagator/README.md)
/// for example usage.
pub struct HeaderExtractor<'a>(pub &'a http::HeaderMap);

impl<'a> Extractor for HeaderExtractor<'a> {
Expand All @@ -39,7 +47,9 @@ impl<'a> Extractor for HeaderExtractor<'a> {

pub type HttpError = Box<dyn std::error::Error + Send + Sync + 'static>;

/// A minimal interface necessary for export spans over HTTP.
/// A minimal interface necessary for sending requests over HTTP.
/// Used primarily for exporting telemetry over HTTP. Also used for fetching
/// sampling strategies for JaegerRemoteSampler
///
/// Users sometime choose HTTP clients that relay on a certain async runtime. This trait allows
/// users to bring their choice of HTTP client.
Expand Down

0 comments on commit 49f1be6

Please sign in to comment.