Skip to content

Commit 5192fba

Browse files
authored
Move 3rd party propagators and merge exporter into sdk::export (open-telemetry#375)
1 parent a0ade71 commit 5192fba

File tree

75 files changed

+897
-867
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+897
-867
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ jobs:
5252
override: true
5353
- name: Run tests
5454
run: cargo --version &&
55-
cargo test --verbose --manifest-path=opentelemetry/Cargo.toml --features trace,metrics,serialize,tokio,serde,http,tonic,reqwest &&
55+
cargo test --verbose --manifest-path=opentelemetry/Cargo.toml --features trace,metrics,serialize,tokio,serde,http,tonic,reqwest,testing &&
5656
cargo test --manifest-path=opentelemetry-jaeger/Cargo.toml &&
5757
cargo test --manifest-path=opentelemetry-zipkin/Cargo.toml
5858
meta:

CONTRIBUTING.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,3 +129,7 @@ See the [code owners](CODEOWNERS) file.
129129

130130
See the [community membership document in OpenTelemetry community
131131
repo](https://github.com/open-telemetry/community/blob/master/community-membership.md).
132+
133+
## FAQ
134+
### Where should I put third party propagators/exporters, contrib or standalone crates?
135+
As of now, the specification classify the propagators into three categories: Fully opened standards, platform-specific standards, proprietary headers. The conclusion is only the fully opened standards should live in SDK packages/repos. So here, only fully opened standards should live as independent crate. For more detail and discussion, see [this pr](https://github.com/open-telemetry/opentelemetry-specification/pull/1144).

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ observability tools.
3333
## Getting Started
3434

3535
```rust
36-
use opentelemetry::{exporter::trace::stdout, trace::Tracer};
36+
use opentelemetry::{sdk::export::trace::stdout, trace::Tracer};
3737

3838
fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>> {
3939
// Create a new instrumentation pipeline

examples/aws-xray/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ path = "src/client.rs"
1717
hyper = "0.13"
1818
tokio = { version = "0.2", features = ["full"] }
1919
opentelemetry = { path = "../../opentelemetry", features = ["http"] }
20-
opentelemetry-contrib = { path = "../../opentelemetry-contrib" }
20+
opentelemetry-contrib = { path = "../../opentelemetry-contrib", features = ["aws-xray"] }

examples/aws-xray/src/client.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
use hyper::{body::Body, Client};
22
use opentelemetry::{
3-
exporter::trace::stdout,
43
global,
5-
sdk::{propagation::XrayPropagator, trace as sdktrace},
4+
sdk::export::trace::stdout,
5+
sdk::trace as sdktrace,
66
trace::{TraceContextExt, Tracer},
77
Context, KeyValue,
88
};
9+
use opentelemetry_contrib::trace::propagator::XrayPropagator;
910

1011
fn init_tracer() -> (sdktrace::Tracer, stdout::Uninstall) {
1112
global::set_text_map_propagator(XrayPropagator::new());

examples/aws-xray/src/server.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
use hyper::service::{make_service_fn, service_fn};
22
use hyper::{Body, Request, Response, Server};
33
use opentelemetry::{
4-
exporter::trace::stdout,
54
global,
6-
sdk::{propagation::XrayPropagator, trace as sdktrace},
5+
sdk::export::trace::stdout,
6+
sdk::trace as sdktrace,
77
trace::{Span, Tracer},
88
};
9+
use opentelemetry_contrib::trace::propagator::XrayPropagator;
910
use std::{convert::Infallible, net::SocketAddr};
1011

1112
async fn handle(req: Request<Body>) -> Result<Response<Body>, Infallible> {

examples/basic-otlp/src/main.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use futures::stream::{Stream, StreamExt};
2-
use opentelemetry::exporter;
32
use opentelemetry::sdk::metrics::PushController;
43
use opentelemetry::trace::TraceError;
54
use opentelemetry::{
@@ -22,7 +21,7 @@ fn delayed_interval(duration: Duration) -> impl Stream<Item = tokio::time::Insta
2221
}
2322

2423
fn init_meter() -> metrics::Result<PushController> {
25-
exporter::metrics::stdout(tokio::spawn, delayed_interval)
24+
opentelemetry::sdk::export::metrics::stdout(tokio::spawn, delayed_interval)
2625
.with_quantiles(vec![0.5, 0.9, 0.99])
2726
.with_formatter(|batch| {
2827
serde_json::to_value(batch)

examples/basic/src/main.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use futures::stream::{Stream, StreamExt};
2-
use opentelemetry::exporter;
32
use opentelemetry::global;
43
use opentelemetry::sdk::{metrics::PushController, trace as sdktrace};
54
use opentelemetry::trace::TraceError;
@@ -28,7 +27,7 @@ fn delayed_interval(duration: Duration) -> impl Stream<Item = tokio::time::Insta
2827
}
2928

3029
fn init_meter() -> metrics::Result<PushController> {
31-
exporter::metrics::stdout(tokio::spawn, delayed_interval)
30+
opentelemetry::sdk::export::metrics::stdout(tokio::spawn, delayed_interval)
3231
.with_quantiles(vec![0.5, 0.9, 0.99])
3332
.with_formatter(|batch| {
3433
serde_json::to_value(batch)

examples/http/src/client.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use hyper::{body::Body, Client};
2-
use opentelemetry::exporter::trace::stdout;
32
use opentelemetry::global;
3+
use opentelemetry::sdk::export::trace::stdout;
44
use opentelemetry::sdk::{
55
propagation::TraceContextPropagator,
66
trace::{Config, Sampler},

examples/http/src/server.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use hyper::service::{make_service_fn, service_fn};
22
use hyper::{Body, Request, Response, Server};
33
use opentelemetry::{
4-
exporter::trace::stdout,
54
global,
5+
sdk::export::trace::stdout,
66
sdk::{
77
propagation::TraceContextPropagator,
88
trace::{Config, Sampler},

examples/stdout.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use opentelemetry::{
2-
exporter::trace::stdout,
2+
sdk::export::trace::stdout,
33
sdk::trace::{self, Sampler},
44
trace::Tracer,
55
};

opentelemetry-contrib/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ datadog = ["indexmap", "rmp", "async-trait", "thiserror"]
2626
reqwest-blocking-client = ["reqwest/blocking", "opentelemetry/reqwest"]
2727
reqwest-client = ["reqwest", "opentelemetry/reqwest"]
2828
surf-client = ["surf", "opentelemetry/surf"]
29+
aws-xray = []
2930

3031
[dependencies]
3132
async-trait = { version = "0.1", optional = true }
@@ -42,3 +43,4 @@ thiserror = { version = "1.0", optional = true }
4243
[dev-dependencies]
4344
base64 = "0.13"
4445
isahc = "0.9"
46+
opentelemetry = { path = "../opentelemetry", features = ["trace", "http", "testing"] }

opentelemetry-contrib/src/trace/exporter/datadog/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@
7272
//! ```no_run
7373
//! use opentelemetry::{KeyValue, trace::Tracer};
7474
//! use opentelemetry::sdk::{trace::{self, IdGenerator, Sampler}, Resource};
75-
//! use opentelemetry::exporter::trace::ExportResult;
76-
//! use opentelemetry::exporter::trace::HttpClient;
75+
//! use opentelemetry::sdk::export::trace::ExportResult;
76+
//! use opentelemetry::sdk::export::trace::HttpClient;
7777
//! use opentelemetry_contrib::trace::exporter::datadog::{new_pipeline, ApiVersion};
7878
//! use async_trait::async_trait;
7979
//! use opentelemetry_contrib::trace::exporter::datadog::Error;
@@ -127,8 +127,8 @@ pub use model::Error;
127127

128128
use async_trait::async_trait;
129129
use http::{Method, Request, Uri};
130-
use opentelemetry::exporter::trace;
131-
use opentelemetry::exporter::trace::{HttpClient, SpanData};
130+
use opentelemetry::sdk::export::trace;
131+
use opentelemetry::sdk::export::trace::{HttpClient, SpanData};
132132
use opentelemetry::trace::TraceError;
133133
use opentelemetry::{global, sdk, trace::TracerProvider};
134134

opentelemetry-contrib/src/trace/exporter/datadog/model/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use opentelemetry::exporter::{trace, ExportError};
1+
use opentelemetry::sdk::export::{trace, ExportError};
22

33
mod v03;
44
mod v05;

opentelemetry-contrib/src/trace/exporter/datadog/model/v03.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::trace::exporter::datadog::model::Error;
2-
use opentelemetry::exporter::trace;
2+
use opentelemetry::sdk::export::trace;
33
use opentelemetry::{Key, Value};
44
use std::time::SystemTime;
55

opentelemetry-contrib/src/trace/exporter/datadog/model/v05.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::trace::exporter::datadog::intern::StringInterner;
2-
use crate::trace::exporter::datadog::model::Error;
3-
use opentelemetry::exporter::trace;
2+
use crate::trace::exporter::datadog::Error;
3+
use opentelemetry::sdk::export::trace;
44
use opentelemetry::{Key, Value};
55
use std::time::SystemTime;
66

opentelemetry/src/sdk/propagation/aws.rs renamed to opentelemetry-contrib/src/trace/propagator/aws.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::{
1+
use opentelemetry::{
22
propagation::{text_map_propagator::FieldIter, Extractor, Injector, TextMapPropagator},
33
trace::{
44
SpanContext, SpanId, TraceContextExt, TraceId, TraceState, TRACE_FLAG_DEFERRED,
@@ -32,7 +32,7 @@ lazy_static::lazy_static! {
3232
///
3333
/// ```
3434
/// use opentelemetry::global;
35-
/// use opentelemetry::sdk::propagation::XrayPropagator;
35+
/// use opentelemetry_contrib::trace::propagator::XrayPropagator;
3636
///
3737
/// global::set_text_map_propagator(XrayPropagator::default());
3838
/// ```
@@ -236,8 +236,8 @@ fn title_case(s: &str) -> String {
236236
#[cfg(test)]
237237
mod tests {
238238
use super::*;
239-
use crate::testing::trace::TestSpan;
240-
use crate::trace::TraceState;
239+
use opentelemetry::testing::trace::TestSpan;
240+
use opentelemetry::trace::TraceState;
241241
use std::collections::HashMap;
242242
use std::str::FromStr;
243243

opentelemetry-contrib/src/trace/propagator/mod.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,12 @@
66
//! Currently, the following propagators are supported:
77
//!
88
//! * `binary_propagator`, propagating trace context in the binary format.
9+
//! * `XrayPropagator`, propagating via AWS XRay protocol.
10+
//!
11+
//! This module also provides relative types for those propagators.
12+
#[cfg(feature = "aws-xray")]
13+
mod aws;
914
pub mod binary;
15+
16+
#[cfg(feature = "aws-xray")]
17+
pub use aws::XrayPropagator;

opentelemetry-jaeger/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ tokio = { version = "0.2", features = ["udp", "sync"], optional = true }
3434
wasm-bindgen = { version = "0.2", optional = true }
3535
wasm-bindgen-futures = { version = "0.4.18", optional = true }
3636
thiserror = "1.0"
37+
lazy_static = "1.4"
38+
39+
[dev-dependencies]
40+
opentelemetry = { version = "0.10", default-features = false, features = ["trace", "testing"], path = "../opentelemetry" }
3741

3842
[dependencies.web-sys]
3943
version = "0.3.4"

opentelemetry-jaeger/README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
# OpenTelemetry Jaeger
66

7-
[`Jaeger`] integration for applications instrumented with [`OpenTelemetry`].
7+
[`Jaeger`] integration for applications instrumented with [`OpenTelemetry`]. This includes a jaeger exporter and a jaeger propagator.
88

99
[![Crates.io: opentelemetry-jaeger](https://img.shields.io/crates/v/opentelemetry-jaeger.svg)](https://crates.io/crates/opentelemetry-jaeger)
1010
[![Documentation](https://docs.rs/opentelemetry-jaeger/badge.svg)](https://docs.rs/opentelemetry-jaeger)
@@ -43,8 +43,10 @@ exporting telemetry:
4343

4444
```rust
4545
use opentelemetry::tracer;
46+
use opentelemetry::global;
4647

4748
fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>> {
49+
global::set_text_map_propagator(opentelemetry_jaeger::Propagator::new());
4850
let (tracer, _uninstall) = opentelemetry_jaeger::new_pipeline().install()?;
4951

5052
tracer.in_span("doing_work", |cx| {
@@ -84,8 +86,10 @@ in the [jaeger variables spec].
8486

8587
```rust
8688
use opentelemetry::tracer;
89+
use opentelemetry::global;
8790

8891
fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>> {
92+
global::set_text_map_propagator(opentelemetry_jaeger::Propagator::new());
8993
// export OTEL_SERVICE_NAME=my-service-name
9094
let (tracer, _uninstall) = opentelemetry_jaeger::new_pipeline().from_env().install()?;
9195

@@ -142,8 +146,10 @@ Example showing how to override all configuration options. See the
142146
```rust
143147
use opentelemetry::{KeyValue, Tracer};
144148
use opentelemetry::sdk::{trace, IdGenerator, Resource, Sampler};
149+
use opentelemetry::global;
145150

146151
fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>> {
152+
global::set_text_map_propagator(opentelemetry_jaeger::Propagator::new());
147153
let (tracer, _uninstall) = opentelemetry_jaeger::new_pipeline()
148154
.from_env()
149155
.with_agent_endpoint("localhost:6831")

opentelemetry-jaeger/src/agent.rs renamed to opentelemetry-jaeger/src/exporter/agent.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
//! # UDP Jaeger Agent Client
2-
use crate::thrift::{
2+
use crate::exporter::thrift::{
33
agent::{self, TAgentSyncClient},
44
jaeger,
55
};
6-
use crate::transport::{TBufferChannel, TNoopChannel};
6+
use crate::exporter::transport::{TBufferChannel, TNoopChannel};
77
use std::fmt;
88
use std::net::{ToSocketAddrs, UdpSocket};
99
use thrift::{

opentelemetry-jaeger/src/collector.rs renamed to opentelemetry-jaeger/src/exporter/collector.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ struct WasmHttpClient {
2323
#[cfg(feature = "collector_client")]
2424
mod collector_client {
2525
use super::*;
26-
use crate::thrift::jaeger;
26+
use crate::exporter::thrift::jaeger;
2727
use http::{Request, Uri};
2828
use isahc::{
2929
auth::{Authentication, Credentials},
@@ -106,7 +106,7 @@ mod collector_client {
106106
#[cfg(all(feature = "wasm_collector_client", not(feature = "collector_client")))]
107107
mod wasm_collector_client {
108108
use super::*;
109-
use crate::thrift::jaeger;
109+
use crate::exporter::thrift::jaeger;
110110
use futures_util::future;
111111
use http::Uri;
112112
use js_sys::Uint8Array;

0 commit comments

Comments
 (0)