Skip to content

Commit

Permalink
Change opentelemetry crate to contain only the API, not the SDK #1186
Browse files Browse the repository at this point in the history
  • Loading branch information
shaun-cox committed Aug 22, 2023
1 parent 495330f commit 52ee479
Show file tree
Hide file tree
Showing 108 changed files with 510 additions and 550 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ jobs:
run: ./scripts/patch_dependencies.sh
- name: Run tests
run: cargo --version &&
cargo test --manifest-path=opentelemetry/Cargo.toml --features trace,metrics,rt-tokio,testing &&
cargo test --manifest-path=opentelemetry/Cargo.toml --features trace,metrics,testing &&
cargo test --manifest-path=opentelemetry-jaeger/Cargo.toml --features rt-tokio &&
cargo test --manifest-path=opentelemetry-zipkin/Cargo.toml
cargo-deny:
Expand Down
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ members = [
"opentelemetry-user-events-logs",
"opentelemetry-user-events-metrics",
"opentelemetry-zipkin",
"opentelemetry-zpages",
"opentelemetry-otlp/examples/basic-otlp",
"opentelemetry-otlp/examples/basic-otlp-http",
"opentelemetry-otlp/examples/external-otlp-grpcio-async-std",
Expand Down
2 changes: 1 addition & 1 deletion examples/logs-basic/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ license = "Apache-2.0"
publish = false

[dependencies]
opentelemetry_api = { path = "../../opentelemetry-api", features = ["logs"] }
opentelemetry = { path = "../../opentelemetry", features = ["logs"] }
opentelemetry_sdk = { path = "../../opentelemetry-sdk", features = ["logs"] }
opentelemetry-stdout = { path = "../../opentelemetry-stdout", features = ["logs"]}
opentelemetry-appender-log = { path = "../../opentelemetry-appender-log", default-features = false}
Expand Down
2 changes: 1 addition & 1 deletion examples/logs-basic/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use log::{error, Level};
use opentelemetry_api::KeyValue;
use opentelemetry::KeyValue;
use opentelemetry_appender_log::OpenTelemetryLogBridge;
use opentelemetry_sdk::logs::{Config, LoggerProvider};
use opentelemetry_sdk::Resource;
Expand Down
2 changes: 1 addition & 1 deletion examples/metrics-advanced/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ license = "Apache-2.0"
publish = false

[dependencies]
opentelemetry_api = { path = "../../opentelemetry-api", features = ["metrics"] }
opentelemetry = { path = "../../opentelemetry", features = ["metrics"] }
opentelemetry_sdk = { path = "../../opentelemetry-sdk", features = ["metrics", "rt-tokio"] }
opentelemetry-stdout = { path = "../../opentelemetry-stdout", features = ["metrics"]}
tokio = { version = "1.0", features = ["full"] }
6 changes: 3 additions & 3 deletions examples/metrics-advanced/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use opentelemetry_api::metrics::Unit;
use opentelemetry_api::Key;
use opentelemetry_api::{metrics::MeterProvider as _, KeyValue};
use opentelemetry::metrics::Unit;
use opentelemetry::Key;
use opentelemetry::{metrics::MeterProvider as _, KeyValue};
use opentelemetry_sdk::metrics::{Instrument, MeterProvider, PeriodicReader, Stream};
use opentelemetry_sdk::{runtime, Resource};
use std::error::Error;
Expand Down
2 changes: 1 addition & 1 deletion examples/metrics-basic/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ license = "Apache-2.0"
publish = false

[dependencies]
opentelemetry_api = { path = "../../opentelemetry-api", features = ["metrics"] }
opentelemetry = { path = "../../opentelemetry", features = ["metrics"] }
opentelemetry_sdk = { path = "../../opentelemetry-sdk", features = ["metrics", "rt-tokio"] }
opentelemetry-stdout = { path = "../../opentelemetry-stdout", features = ["metrics"]}
tokio = { version = "1.0", features = ["full"] }
4 changes: 2 additions & 2 deletions examples/metrics-basic/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use opentelemetry_api::metrics::Unit;
use opentelemetry_api::{metrics::MeterProvider as _, KeyValue};
use opentelemetry::metrics::Unit;
use opentelemetry::{metrics::MeterProvider as _, KeyValue};
use opentelemetry_sdk::metrics::{MeterProvider, PeriodicReader};
use opentelemetry_sdk::{runtime, Resource};
use std::error::Error;
Expand Down
1 change: 1 addition & 0 deletions examples/traceresponse/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ doc = false
hyper = { version = "0.14", features = ["full"] }
tokio = { version = "1.0", features = ["full"] }
opentelemetry = { path = "../../opentelemetry" }
opentelemetry_sdk = { path = "../../opentelemetry-sdk" }
opentelemetry-http = { path = "../../opentelemetry-http" }
opentelemetry-contrib = { path = "../../opentelemetry-contrib" }
opentelemetry-stdout = { path = "../../opentelemetry-stdout", features = ["trace"] }
10 changes: 4 additions & 6 deletions examples/traceresponse/src/client.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
use hyper::http::HeaderValue;
use hyper::{body::Body, Client};
use opentelemetry::global;
use opentelemetry::propagation::TextMapPropagator;
use opentelemetry::sdk::propagation::TraceContextPropagator;
use opentelemetry::sdk::trace::TracerProvider;
use opentelemetry::trace::SpanKind;
use opentelemetry::{
trace::{TraceContextExt, Tracer},
global,
propagation::TextMapPropagator,
trace::{SpanKind, TraceContextExt, Tracer},
Context, KeyValue,
};
use opentelemetry_contrib::trace::propagator::trace_context_response::TraceContextResponsePropagator;
use opentelemetry_http::{HeaderExtractor, HeaderInjector};
use opentelemetry_sdk::{propagation::TraceContextPropagator, trace::TracerProvider};
use opentelemetry_stdout::SpanExporter;

fn init_tracer() {
Expand Down
18 changes: 11 additions & 7 deletions examples/traceresponse/src/server.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
use hyper::service::{make_service_fn, service_fn};
use hyper::{Body, Request, Response, Server};
use opentelemetry::propagation::TextMapPropagator;
use opentelemetry::sdk::trace::TracerProvider;
use opentelemetry::trace::{SpanKind, TraceContextExt};
use opentelemetry::Context;
use opentelemetry::{global, sdk::propagation::TraceContextPropagator, trace::Tracer};
use hyper::{
service::{make_service_fn, service_fn},
Body, Request, Response, Server,
};
use opentelemetry::{
global,
propagation::TextMapPropagator,
trace::{SpanKind, TraceContextExt, Tracer},
Context,
};
use opentelemetry_contrib::trace::propagator::trace_context_response::TraceContextResponsePropagator;
use opentelemetry_http::{HeaderExtractor, HeaderInjector};
use opentelemetry_sdk::{propagation::TraceContextPropagator, trace::TracerProvider};
use opentelemetry_stdout::SpanExporter;
use std::{convert::Infallible, net::SocketAddr};

Expand Down
7 changes: 4 additions & 3 deletions examples/tracing-grpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@ name = "grpc-client"
path = "src/client.rs"

[dependencies]
opentelemetry = { version = "0.19", features = ["rt-tokio"] }
opentelemetry-jaeger = { version = "0.18", features = ["rt-tokio"] }
opentelemetry = { version = "0.20" }
opentelemetry_sdk = { version = "0.20", features = ["rt-tokio"] }
opentelemetry-jaeger = { version = "0.19", features = ["rt-tokio"] }
prost = "0.11"
tokio = { version = "1.28", features = ["full"] }
tonic = "0.9.2"
tracing = "0.1"
tracing-futures = "0.2"
tracing-opentelemetry = "0.19"
tracing-opentelemetry = "0.20"
tracing-subscriber = { version = "0.3", features = ["env-filter"] }

[build-dependencies]
Expand Down
2 changes: 1 addition & 1 deletion examples/tracing-grpc/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>
global::set_text_map_propagator(opentelemetry_jaeger::Propagator::new());
let tracer = opentelemetry_jaeger::new_agent_pipeline()
.with_service_name("grpc-server")
.install_batch(opentelemetry::runtime::Tokio)?;
.install_batch(opentelemetry_sdk::runtime::Tokio)?;
tracing_subscriber::registry()
.with(tracing_subscriber::EnvFilter::new("INFO"))
.with(tracing_opentelemetry::layer().with_tracer(tracer))
Expand Down
4 changes: 2 additions & 2 deletions opentelemetry-appender-log/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ rust-version = "1.64"
edition = "2021"

[dependencies]
opentelemetry_api = { version = "0.20", path = "../opentelemetry-api", features = ["logs"]}
opentelemetry = { version = "0.21", path = "../opentelemetry", features = ["logs"]}
log = {version = "0.4.17", features = ["kv_unstable", "std"]}

[features]
logs_level_enabled = ["opentelemetry_api/logs_level_enabled"]
logs_level_enabled = ["opentelemetry/logs_level_enabled"]
default = ["logs_level_enabled"]
2 changes: 1 addition & 1 deletion opentelemetry-appender-log/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use log::{Level, Metadata, Record};
use opentelemetry_api::logs::{AnyValue, LogRecordBuilder, Logger, LoggerProvider, Severity};
use opentelemetry::logs::{AnyValue, LogRecordBuilder, Logger, LoggerProvider, Severity};
use std::borrow::Cow;

pub struct OpenTelemetryLogBridge<P, L>
Expand Down
4 changes: 2 additions & 2 deletions opentelemetry-appender-tracing/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ license = "Apache-2.0"
rust-version = "1.64"

[dependencies]
opentelemetry_api = { version = "0.20", path = "../opentelemetry-api", features = ["logs"] }
opentelemetry = { version = "0.21", path = "../opentelemetry", features = ["logs"] }
opentelemetry_sdk = { version = "0.20", path = "../opentelemetry-sdk", features = ["logs"] }
tracing = {version = "0.1.37", default-features = false, features = ["std"]}
tracing-core = "0.1.31"
Expand All @@ -22,5 +22,5 @@ once_cell = "1.13.0"
opentelemetry-stdout = { path = "../opentelemetry-stdout", features = ["logs"] }

[features]
logs_level_enabled = ["opentelemetry_api/logs_level_enabled", "opentelemetry_sdk/logs_level_enabled"]
logs_level_enabled = ["opentelemetry/logs_level_enabled", "opentelemetry_sdk/logs_level_enabled"]
default = ["logs_level_enabled"]
2 changes: 1 addition & 1 deletion opentelemetry-appender-tracing/examples/basic.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! run with `$ cargo run --example basic

use opentelemetry_api::KeyValue;
use opentelemetry::KeyValue;
use opentelemetry_appender_tracing::layer;
use opentelemetry_sdk::{
logs::{Config, LoggerProvider},
Expand Down
4 changes: 1 addition & 3 deletions opentelemetry-appender-tracing/src/layer.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
use opentelemetry::logs::{LogRecord, Logger, LoggerProvider, Severity};
use std::borrow::Cow;

use opentelemetry_api::logs::{LogRecord, Logger, LoggerProvider, Severity};

use tracing_subscriber::Layer;

const INSTRUMENTATION_LIBRARY_NAME: &str = "opentelemetry-appender-tracing";
Expand Down
5 changes: 2 additions & 3 deletions opentelemetry-aws/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,13 @@ rustdoc-args = ["--cfg", "docsrs"]

[features]
default = ["trace"]
trace = ["opentelemetry_api/trace"]
trace = ["opentelemetry/trace"]

[dependencies]
once_cell = "1.12"
opentelemetry_api = { version = "0.20", path = "../opentelemetry-api" }
opentelemetry = { version = "0.21", path = "../opentelemetry" }

[dev-dependencies]
opentelemetry_api = { path = "../opentelemetry-api", features = ["trace"] }
opentelemetry_sdk = { path = "../opentelemetry-sdk", features = ["trace", "testing"] }
opentelemetry-http = { path = "../opentelemetry-http" }
opentelemetry-stdout = { path = "../opentelemetry-stdout", features = ["trace"] }
Expand Down
8 changes: 4 additions & 4 deletions opentelemetry-aws/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
//!
//! ### Quick start
//! ```no_run
//! use opentelemetry_api::{global, trace::{Tracer, TracerProvider as _}};
//! use opentelemetry::{global, trace::{Tracer, TracerProvider as _}};
//! use opentelemetry_aws::trace::XrayPropagator;
//! use opentelemetry_sdk::trace::TracerProvider;
//! use opentelemetry_stdout::SpanExporter;
Expand Down Expand Up @@ -45,7 +45,7 @@ pub use trace::XrayPropagator;
#[cfg(feature = "trace")]
pub mod trace {
use once_cell::sync::Lazy;
use opentelemetry_api::{
use opentelemetry::{
global::{self, Error},
propagation::{text_map_propagator::FieldIter, Extractor, Injector, TextMapPropagator},
trace::{
Expand Down Expand Up @@ -81,7 +81,7 @@ pub mod trace {
/// ## Example
///
/// ```
/// use opentelemetry_api::global;
/// use opentelemetry::global;
/// use opentelemetry_aws::trace::XrayPropagator;
///
/// global::set_text_map_propagator(XrayPropagator::default());
Expand Down Expand Up @@ -310,7 +310,7 @@ pub mod trace {
#[cfg(test)]
mod tests {
use super::*;
use opentelemetry_api::trace::TraceState;
use opentelemetry::trace::TraceState;
use opentelemetry_sdk::testing::trace::TestSpan;
use std::collections::HashMap;
use std::str::FromStr;
Expand Down
12 changes: 6 additions & 6 deletions opentelemetry-contrib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,17 @@ default = []
base64_format = ["base64", "binary_propagator"]
binary_propagator = []
jaeger_json_exporter = ["serde_json", "futures-core", "futures-util", "async-trait", "opentelemetry-semantic-conventions"]
rt-tokio = ["tokio", "opentelemetry/rt-tokio"]
rt-tokio-current-thread = ["tokio", "opentelemetry/rt-tokio-current-thread"]
rt-async-std = ["async-std", "opentelemetry/rt-async-std"]
rt-tokio = ["tokio", "opentelemetry_sdk/rt-tokio"]
rt-tokio-current-thread = ["tokio", "opentelemetry_sdk/rt-tokio-current-thread"]
rt-async-std = ["async-std", "opentelemetry_sdk/rt-async-std"]

[dependencies]
async-std = { version = "1.10", optional = true }
async-trait = { version = "0.1", optional = true }
base64 = { version = "0.13", optional = true }
once_cell = "1.17.1"
opentelemetry = { version = "0.20", path = "../opentelemetry", features = ["trace"] }
opentelemetry_api = { version = "0.20", path = "../opentelemetry-api" }
opentelemetry = { version = "0.21", path = "../opentelemetry" }
opentelemetry_sdk = { version = "0.20", path = "../opentelemetry-sdk" }
opentelemetry-semantic-conventions = { version = "0.12", path = "../opentelemetry-semantic-conventions", optional = true }
serde_json = { version = "1", optional = true }
tokio = { version = "1.0", features = ["fs", "io-util"], optional = true }
Expand All @@ -44,4 +44,4 @@ futures-util = { version = "0.3", optional = true }

[dev-dependencies]
base64 = "0.13"
opentelemetry = { path = "../opentelemetry", features = ["trace", "testing"] }
opentelemetry_sdk = { path = "../opentelemetry-sdk", features = ["trace", "testing"] }
30 changes: 13 additions & 17 deletions opentelemetry-contrib/src/trace/exporter/jaeger_json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
use async_trait::async_trait;
use futures_core::future::BoxFuture;
use futures_util::FutureExt;
use opentelemetry::runtime::RuntimeChannel;
use opentelemetry::sdk::export::trace::{ExportResult, SpanData, SpanExporter};
use opentelemetry::sdk::trace::{BatchMessage, Tracer};
use opentelemetry::trace::{SpanId, TraceError};
use opentelemetry_sdk::{
export::trace::{ExportResult, SpanData, SpanExporter},
runtime::RuntimeChannel,
trace::{BatchMessage, Tracer, TracerProvider},
};
use opentelemetry_semantic_conventions::SCHEMA_URL;
use std::collections::HashMap;
use std::path::{Path, PathBuf};
Expand Down Expand Up @@ -40,15 +42,11 @@ impl<R: JaegerJsonRuntime> JaegerJsonExporter<R> {

/// Install the exporter using the internal provided runtime
pub fn install_batch(self) -> Tracer {
use opentelemetry::trace::TracerProvider;

let runtime = self.runtime.clone();
let provider_builder =
opentelemetry::sdk::trace::TracerProvider::builder().with_batch_exporter(self, runtime);

let provider_builder = TracerProvider::builder().with_batch_exporter(self, runtime);

Check warning on line 46 in opentelemetry-contrib/src/trace/exporter/jaeger_json.rs

View check run for this annotation

Codecov / codecov/patch

opentelemetry-contrib/src/trace/exporter/jaeger_json.rs#L46

Added line #L46 was not covered by tests
let provider = provider_builder.build();

let tracer = provider.versioned_tracer(
let tracer = opentelemetry::trace::TracerProvider::versioned_tracer(
&provider,

Check warning on line 49 in opentelemetry-contrib/src/trace/exporter/jaeger_json.rs

View check run for this annotation

Codecov / codecov/patch

opentelemetry-contrib/src/trace/exporter/jaeger_json.rs#L48-L49

Added lines #L48 - L49 were not covered by tests
"opentelemetry",
Some(env!("CARGO_PKG_VERSION")),
Some(SCHEMA_URL),
Expand Down Expand Up @@ -120,9 +118,7 @@ impl<R: JaegerJsonRuntime> SpanExporter for JaegerJsonExporter<R> {
}
}

fn span_data_to_jaeger_json(
span: opentelemetry::sdk::export::trace::SpanData,
) -> serde_json::Value {
fn span_data_to_jaeger_json(span: SpanData) -> serde_json::Value {

Check warning on line 121 in opentelemetry-contrib/src/trace/exporter/jaeger_json.rs

View check run for this annotation

Codecov / codecov/patch

opentelemetry-contrib/src/trace/exporter/jaeger_json.rs#L121

Added line #L121 was not covered by tests
let events = span
.events
.iter()
Expand Down Expand Up @@ -215,7 +211,7 @@ fn opentelemetry_value_to_json(value: &opentelemetry::Value) -> (&str, serde_jso

/// Jaeger Json Runtime is an extension to [`RuntimeChannel`].
///
/// [`RuntimeChannel`]: opentelemetry::sdk::runtime::RuntimeChannel
/// [`RuntimeChannel`]: opentelemetry_sdk::runtime::RuntimeChannel
#[async_trait]
pub trait JaegerJsonRuntime: RuntimeChannel<BatchMessage> + std::fmt::Debug {
/// Create a new directory if the given path does not exist yet
Expand All @@ -226,7 +222,7 @@ pub trait JaegerJsonRuntime: RuntimeChannel<BatchMessage> + std::fmt::Debug {

#[cfg(feature = "rt-tokio")]
#[async_trait]
impl JaegerJsonRuntime for opentelemetry::runtime::Tokio {
impl JaegerJsonRuntime for opentelemetry_sdk::runtime::Tokio {
async fn create_dir(&self, path: &Path) -> ExportResult {
if tokio::fs::metadata(path).await.is_err() {
tokio::fs::create_dir_all(path)
Expand Down Expand Up @@ -256,7 +252,7 @@ impl JaegerJsonRuntime for opentelemetry::runtime::Tokio {

#[cfg(feature = "rt-tokio-current-thread")]
#[async_trait]
impl JaegerJsonRuntime for opentelemetry::runtime::TokioCurrentThread {
impl JaegerJsonRuntime for opentelemetry_sdk::runtime::TokioCurrentThread {
async fn create_dir(&self, path: &Path) -> ExportResult {
if tokio::fs::metadata(path).await.is_err() {
tokio::fs::create_dir_all(path)
Expand Down Expand Up @@ -286,7 +282,7 @@ impl JaegerJsonRuntime for opentelemetry::runtime::TokioCurrentThread {

#[cfg(feature = "rt-async-std")]
#[async_trait]
impl JaegerJsonRuntime for opentelemetry::runtime::AsyncStd {
impl JaegerJsonRuntime for opentelemetry_sdk::runtime::AsyncStd {
async fn create_dir(&self, path: &Path) -> ExportResult {
if async_std::fs::metadata(path).await.is_err() {
async_std::fs::create_dir_all(path)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@
//!
//! [w3c trace-context docs]: https://w3c.github.io/trace-context/#traceresponse-header
use once_cell::sync::Lazy;
use opentelemetry::trace::{SpanContext, SpanId, TraceId, TraceState};
use opentelemetry_api::{
use opentelemetry::{
propagation::{text_map_propagator::FieldIter, Extractor, Injector, TextMapPropagator},
trace::{TraceContextExt, TraceFlags},
trace::{SpanContext, SpanId, TraceContextExt, TraceFlags, TraceId, TraceState},
Context,
};

Expand Down Expand Up @@ -132,10 +131,10 @@ impl TextMapPropagator for TraceContextResponsePropagator {
#[cfg(test)]
mod tests {
use super::*;
use opentelemetry::{testing::trace::TestSpan, trace::TraceState};
use opentelemetry_api::{
use opentelemetry::{
propagation::{Extractor, TextMapPropagator},
trace::{SpanContext, SpanId, TraceId},
testing::trace::TestSpan,
trace::{SpanContext, SpanId, TraceId, TraceState},
};
use std::{collections::HashMap, str::FromStr};

Expand Down
Loading

0 comments on commit 52ee479

Please sign in to comment.