Skip to content

Commit

Permalink
fix doc tests
Browse files Browse the repository at this point in the history
  • Loading branch information
shaun-cox committed Aug 10, 2023
1 parent 1a3c21f commit cde9019
Show file tree
Hide file tree
Showing 23 changed files with 64 additions and 61 deletions.
4 changes: 2 additions & 2 deletions opentelemetry-jaeger/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ hyper = { version = "0.14", default-features = false, features = ["client"], opt
hyper-tls = { version = "0.5.0", default-features = false, optional = true }
isahc = { version = "1.4", default-features = false, optional = true }
js-sys = { version = "0.3", optional = true }
opentelemetry_api = { version = "0.20", default-features = false, features = ["trace"], path = "../opentelemetry-api" }
opentelemetry = { version = "0.21", default-features = false, features = ["trace"], path = "../opentelemetry" }
opentelemetry_sdk = { version = "0.20", default-features = false, features = ["trace"], path = "../opentelemetry-sdk" }
opentelemetry-http = { version = "0.9", path = "../opentelemetry-http", optional = true }
opentelemetry-semantic-conventions = { version = "0.12", path = "../opentelemetry-semantic-conventions" }
Expand All @@ -54,7 +54,7 @@ futures-util = { version = "0.3", default-features = false, features = ["std", "
tokio = { version = "1.0", features = ["net", "sync"] }
bytes = "1"
futures-executor = "0.3"
opentelemetry_sdk = { default-features = false, features = ["trace", "testing"], path = "../opentelemetry-sdk" }
opentelemetry_sdk = { features = ["trace", "testing", "rt-tokio"], path = "../opentelemetry-sdk" }

[dependencies.web-sys]
version = "0.3.4"
Expand Down
22 changes: 11 additions & 11 deletions opentelemetry-jaeger/src/exporter/config/agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::exporter::config::{
};
use crate::exporter::uploader::{AsyncUploader, SyncUploader, Uploader};
use crate::{Error, Exporter, JaegerTraceRuntime};
use opentelemetry_api::trace::TraceError;
use opentelemetry::trace::TraceError;
use opentelemetry_sdk::trace::{BatchSpanProcessor, Tracer};
use opentelemetry_sdk::{
self,
Expand Down Expand Up @@ -46,21 +46,20 @@ const DEFAULT_AGENT_ENDPOINT_PORT: &str = "6831";
/// Set `auto_split_batch` to true will config the exporter to split the batch based on `max_packet_size`
/// automatically. Note that it has a performance overhead as every batch could require multiple requests to export.
///
///
/// For example, OSX UDP packet limit is 9216 by default. You can configure the pipeline as following
/// to avoid UDP packet breaches the limit.
///```no_run
/// # use opentelemetry::trace::TraceError;
/// # fn main() -> Result<(), TraceError>{
/// let tracer = opentelemetry_jaeger::new_agent_pipeline()
///
/// ```no_run
/// # use opentelemetry_sdk::runtime::Tokio;
/// # fn main() {
/// let tracer = opentelemetry_jaeger::new_agent_pipeline()
/// .with_endpoint("localhost:6831")
/// .with_service_name("my_app")
/// .with_max_packet_size(9_216)
/// .with_auto_split_batch(true)
/// .install_batch(opentelemetry_sdk::runtime::Tokio).unwrap();
/// # Ok(())
/// .install_batch(Tokio).unwrap();
/// # }
///```
/// ```
///
/// [`with_auto_split_batch`]: AgentPipeline::with_auto_split_batch
/// [`with_max_packet_size`]: AgentPipeline::with_max_packet_size
Expand Down Expand Up @@ -234,7 +233,8 @@ impl AgentPipeline {
/// # Examples
/// Set service name via resource.
/// ```rust
/// use opentelemetry::{sdk::{self, Resource}, KeyValue};
/// use opentelemetry::KeyValue;
/// use opentelemetry_sdk::{Resource, trace::Config};
///
/// let pipeline = opentelemetry_jaeger::new_agent_pipeline()
/// .with_trace_config(
Expand All @@ -256,7 +256,7 @@ impl AgentPipeline {
/// # Examples
/// Set max queue size.
/// ```rust
/// use opentelemetry::BatchConfig;
/// use opentelemetry_sdk::trace::BatchConfig;
///
/// let pipeline = opentelemetry_jaeger::new_agent_pipeline()
/// .with_batch_processor_config(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ mod collector_client_tests {
use crate::config::collector::http_client::test_http_client;
use crate::exporter::thrift::jaeger::Batch;
use crate::new_collector_pipeline;
use opentelemetry_api::trace::TraceError;
use opentelemetry::trace::TraceError;
use opentelemetry_sdk::runtime::Tokio;

#[test]
Expand Down
7 changes: 4 additions & 3 deletions opentelemetry-jaeger/src/exporter/config/collector/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::exporter::config::{
use crate::exporter::uploader::{AsyncUploader, Uploader};
use crate::{Exporter, JaegerTraceRuntime};
use http::Uri;
use opentelemetry_api::trace::TraceError;
use opentelemetry::trace::TraceError;
use opentelemetry_sdk::trace::{BatchConfig, BatchSpanProcessor, Config, Tracer, TracerProvider};
use std::borrow::BorrowMut;
use std::convert::TryFrom;
Expand Down Expand Up @@ -391,11 +391,12 @@ impl CollectorPipeline {
/// # Examples
/// Set service name via resource.
/// ```rust
/// use opentelemetry::{sdk::{self, Resource}, KeyValue};
/// use opentelemetry::KeyValue;
/// use opentelemetry_sdk::{Resource, trace::Config};
///
/// let pipeline = opentelemetry_jaeger::new_collector_pipeline()
/// .with_trace_config(
/// sdk::trace::Config::default()
/// Config::default()
/// .with_resource(Resource::new(vec![KeyValue::new("service.name", "my-service")]))
/// );
///
Expand Down
6 changes: 3 additions & 3 deletions opentelemetry-jaeger/src/exporter/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
//! [jaeger deployment guide]: https://www.jaegertracing.io/docs/1.31/deployment

use crate::Process;
use opentelemetry_api::{global, trace::TraceError, KeyValue};
use opentelemetry::{global, trace::TraceError, KeyValue};
use opentelemetry_sdk::trace::{BatchConfig, Config, Tracer, TracerProvider};
use opentelemetry_semantic_conventions as semcov;

Expand Down Expand Up @@ -86,7 +86,7 @@ fn build_config_and_process(
mod tests {
use crate::exporter::config::build_config_and_process;
use crate::new_agent_pipeline;
use opentelemetry_api::KeyValue;
use opentelemetry::KeyValue;
use opentelemetry_sdk::{trace::Config, Resource};
use std::env;

Expand Down Expand Up @@ -119,7 +119,7 @@ mod tests {
pub(crate) fn install_tracer_provider_and_get_tracer(
tracer_provider: TracerProvider,
) -> Result<Tracer, TraceError> {
let tracer = opentelemetry_api::trace::TracerProvider::versioned_tracer(
let tracer = opentelemetry::trace::TracerProvider::versioned_tracer(
&tracer_provider,

Check warning on line 123 in opentelemetry-jaeger/src/exporter/config/mod.rs

View check run for this annotation

Codecov / codecov/patch

opentelemetry-jaeger/src/exporter/config/mod.rs#L120-L123

Added lines #L120 - L123 were not covered by tests
"opentelemetry-jaeger",
Some(env!("CARGO_PKG_VERSION")),
Expand Down
4 changes: 2 additions & 2 deletions opentelemetry-jaeger/src/exporter/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use self::runtime::JaegerTraceRuntime;
use self::thrift::jaeger;
use crate::exporter::uploader::Uploader;
use futures_core::future::BoxFuture;
use opentelemetry_api::{
use opentelemetry::{
trace::{Event, Link, SpanKind, Status},
InstrumentationLibrary, Key, KeyValue,
};
Expand Down Expand Up @@ -357,7 +357,7 @@ mod tests {
use super::SPAN_KIND;
use crate::exporter::thrift::jaeger::Tag;
use crate::exporter::{build_span_tags, OTEL_STATUS_CODE, OTEL_STATUS_DESCRIPTION};
use opentelemetry_api::{
use opentelemetry::{
trace::{SpanKind, Status},
KeyValue,
};
Expand Down
2 changes: 1 addition & 1 deletion opentelemetry-jaeger/src/exporter/thrift/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//!
//! Definitions: <https://github.com/uber/jaeger-idl/blob/master/thrift/>

use opentelemetry_api::{trace::Event, Key, KeyValue, Value};
use opentelemetry::{trace::Event, Key, KeyValue, Value};
use std::time::{Duration, SystemTime};

pub(crate) mod agent;
Expand Down
26 changes: 13 additions & 13 deletions opentelemetry-jaeger/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,10 @@
//! exporting telemetry:
//!
//! ```no_run
//! use opentelemetry::trace::Tracer;
//! use opentelemetry::global;
//! use opentelemetry::{global, trace::{Tracer, TraceError}};
//!
//! #[tokio::main]
//! async fn main() -> Result<(), opentelemetry::trace::TraceError> {
//! async fn main() -> Result<(), TraceError> {
//! global::set_text_map_propagator(opentelemetry_jaeger::Propagator::new());
//! let tracer = opentelemetry_jaeger::new_agent_pipeline().install_simple()?;
//!
Expand All @@ -48,11 +47,10 @@
//!
//! Or if you are running on an async runtime like Tokio and want to report spans in batches
//! ```no_run
//! use opentelemetry::trace::Tracer;
//! use opentelemetry::global;
//! use opentelemetry::{global, trace::{Tracer, TraceError}};
//! use opentelemetry_sdk::runtime::Tokio;
//!
//! fn main() -> Result<(), opentelemetry::trace::TraceError> {
//! fn main() -> Result<(), TraceError> {
//! global::set_text_map_propagator(opentelemetry_jaeger::Propagator::new());
//! let tracer = opentelemetry_jaeger::new_agent_pipeline().install_batch(Tokio)?;
//!
Expand All @@ -75,7 +73,7 @@
//!
//! ```toml
//! [dependencies]
//! opentelemetry = { version = "*", features = ["rt-tokio"] }
//! opentelemetry_sdk = { version = "*", features = ["rt-tokio"] }
//! opentelemetry-jaeger = { version = "*", features = ["rt-tokio"] }
//! ```
//!
Expand Down Expand Up @@ -174,7 +172,8 @@
//!
//! ### Export to agents
//! ```no_run
//! use opentelemetry::{sdk::{trace::{self, RandomIdGenerator, Sampler}, Resource}, global, KeyValue, trace::{Tracer, TraceError}};
//! use opentelemetry::{global, KeyValue, trace::{Tracer, TraceError}};
//! use opentelemetry_sdk::{trace::{config, RandomIdGenerator, Sampler}, Resource};
//!
//! fn main() -> Result<(), TraceError> {
//! global::set_text_map_propagator(opentelemetry_jaeger::Propagator::new());
Expand All @@ -185,7 +184,7 @@
//! .with_auto_split_batch(true)
//! .with_instrumentation_library_tags(false)
//! .with_trace_config(
//! trace::config()
//! config()
//! .with_sampler(Sampler::AlwaysOn)
//! .with_id_generator(RandomIdGenerator::default())
//! .with_max_events_per_span(64)
Expand All @@ -210,15 +209,16 @@
//! ### Export to collectors
//! Note that this example requires `collecotr_client` and `isahc_collector_client` feature.
//! ```ignore
//! use opentelemetry::{sdk::{trace::{self, RandomIdGenerator, Sampler}, Resource}, global, KeyValue, trace::{Tracer, TraceError}};
//! use opentelemetry::{global, KeyValue, trace::{Tracer, TraceError}};
//! use opentelemetry_sdk{trace::{config, RandomIdGenerator, Sampler}, Resource};
//!
//! fn main() -> Result<(), TraceError> {
//! global::set_text_map_propagator(opentelemetry_jaeger::Propagator::new());
//! let tracer = opentelemetry_jaeger::new_collector_pipeline()
//! .with_endpoint("http://localhost:14250/api/trace") // set collector endpoint
//! .with_service_name("my_app") // the name of the application
//! .with_trace_config(
//! trace::config()
//! config()
//! .with_sampler(Sampler::AlwaysOn)
//! .with_id_generator(RandomIdGenerator::default())
//! .with_max_events_per_span(64)
Expand Down Expand Up @@ -331,7 +331,7 @@ mod exporter;
pub mod testing;

mod propagator {
use opentelemetry_api::{
use opentelemetry::{
global::{self, Error},
propagation::{text_map_propagator::FieldIter, Extractor, Injector, TextMapPropagator},
trace::{
Expand Down Expand Up @@ -583,7 +583,7 @@ mod propagator {
#[cfg(test)]
mod tests {
use super::*;
use opentelemetry_api::{
use opentelemetry::{
propagation::{Injector, TextMapPropagator},
testing::trace::TestSpan,
trace::{SpanContext, SpanId, TraceContextExt, TraceFlags, TraceId, TraceState},
Expand Down
2 changes: 1 addition & 1 deletion opentelemetry-jaeger/tests/integration_test.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#[cfg(feature = "integration_test")]
mod tests {
use opentelemetry_api::{
use opentelemetry::{
trace::{Status, TraceContextExt, Tracer},
KeyValue,
};
Expand Down
2 changes: 1 addition & 1 deletion opentelemetry-semantic-conventions/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ all-features = true
rustdoc-args = ["--cfg", "docsrs"]

[dependencies]
opentelemetry_api = { version = "0.20", default-features = false, path = "../opentelemetry-api" }
opentelemetry = { version = "0.21", default-features = false, path = "../opentelemetry" }
8 changes: 4 additions & 4 deletions opentelemetry-semantic-conventions/src/resource.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,18 @@
//! ## Usage
//!
//! ```
//! use opentelemetry::sdk;
//! use opentelemetry_sdk{trace::{config, TracerProvider}};
//! use opentelemetry_semantic_conventions as semconv;
//!
//! let _tracer = sdk::trace::TracerProvider::builder()
//! .with_config(sdk::trace::config().with_resource(sdk::Resource::new(vec![
//! let _tracer = TracerProvider::builder()
//! .with_config(config().with_resource(Resource::new(vec![
//! semconv::resource::SERVICE_NAME.string("my-service"),
//! semconv::resource::SERVICE_NAMESPACE.string("my-namespace"),
//! ])))
//! .build();
//! ```

use opentelemetry_api::Key;
use opentelemetry::Key;

/// Array of brand name and version separated by a space.
///
Expand Down
2 changes: 1 addition & 1 deletion opentelemetry-semantic-conventions/src/trace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
//! .start(&tracer);
//! ```

use opentelemetry_api::Key;
use opentelemetry::Key;

/// Client address - unix domain socket name, IPv4 or IPv6 address.
///
Expand Down
2 changes: 1 addition & 1 deletion opentelemetry-zipkin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ surf-client = ["surf", "opentelemetry-http/surf"]

[dependencies]
async-trait = "0.1"
opentelemetry_api = { version = "0.20", path = "../opentelemetry-api" }
opentelemetry = { version = "0.21", path = "../opentelemetry" }
opentelemetry_sdk = { version = "0.20", path = "../opentelemetry-sdk", features = ["trace"] }
opentelemetry-http = { version = "0.9", path = "../opentelemetry-http" }
opentelemetry-semantic-conventions = { version = "0.12", path = "../opentelemetry-semantic-conventions" }
Expand Down
2 changes: 1 addition & 1 deletion opentelemetry-zipkin/examples/zipkin.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use opentelemetry_api::{
use opentelemetry::{
global::{self, shutdown_tracer_provider},
trace::{Span, Tracer},
};
Expand Down
6 changes: 3 additions & 3 deletions opentelemetry-zipkin/src/exporter/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use async_trait::async_trait;
use futures_core::future::BoxFuture;
use http::Uri;
use model::endpoint::Endpoint;
use opentelemetry_api::{global, trace::TraceError, KeyValue};
use opentelemetry::{global, trace::TraceError, KeyValue};
use opentelemetry_http::HttpClient;
use opentelemetry_sdk::{
export::{trace, ExportError},
Expand Down Expand Up @@ -171,7 +171,7 @@ impl ZipkinPipelineBuilder {
let mut provider_builder = TracerProvider::builder().with_simple_exporter(exporter);

Check warning on line 171 in opentelemetry-zipkin/src/exporter/mod.rs

View check run for this annotation

Codecov / codecov/patch

opentelemetry-zipkin/src/exporter/mod.rs#L171

Added line #L171 was not covered by tests
provider_builder = provider_builder.with_config(config);
let provider = provider_builder.build();
let tracer = opentelemetry_api::trace::TracerProvider::versioned_tracer(
let tracer = opentelemetry::trace::TracerProvider::versioned_tracer(
&provider,

Check warning on line 175 in opentelemetry-zipkin/src/exporter/mod.rs

View check run for this annotation

Codecov / codecov/patch

opentelemetry-zipkin/src/exporter/mod.rs#L174-L175

Added lines #L174 - L175 were not covered by tests
"opentelemetry-zipkin",
Some(env!("CARGO_PKG_VERSION")),
Expand All @@ -193,7 +193,7 @@ impl ZipkinPipelineBuilder {
let mut provider_builder = TracerProvider::builder().with_batch_exporter(exporter, runtime);

Check warning on line 193 in opentelemetry-zipkin/src/exporter/mod.rs

View check run for this annotation

Codecov / codecov/patch

opentelemetry-zipkin/src/exporter/mod.rs#L193

Added line #L193 was not covered by tests
provider_builder = provider_builder.with_config(config);
let provider = provider_builder.build();
let tracer = opentelemetry_api::trace::TracerProvider::versioned_tracer(
let tracer = opentelemetry::trace::TracerProvider::versioned_tracer(
&provider,

Check warning on line 197 in opentelemetry-zipkin/src/exporter/mod.rs

View check run for this annotation

Codecov / codecov/patch

opentelemetry-zipkin/src/exporter/mod.rs#L196-L197

Added lines #L196 - L197 were not covered by tests
"opentelemetry-zipkin",
Some(env!("CARGO_PKG_VERSION")),
Expand Down
2 changes: 1 addition & 1 deletion opentelemetry-zipkin/src/exporter/model/annotation.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use opentelemetry_api::trace::Event;
use opentelemetry::trace::Event;
use serde::Serialize;
use std::time::{Duration, SystemTime};

Expand Down
2 changes: 1 addition & 1 deletion opentelemetry-zipkin/src/exporter/model/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use opentelemetry_api::{
use opentelemetry::{
trace::{SpanKind, Status},
Key, KeyValue,
};
Expand Down
2 changes: 1 addition & 1 deletion opentelemetry-zipkin/src/exporter/model/span.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ mod tests {
use crate::exporter::model::endpoint::Endpoint;
use crate::exporter::model::span::{Kind, Span};
use crate::exporter::model::{into_zipkin_span, OTEL_ERROR_DESCRIPTION, OTEL_STATUS_CODE};
use opentelemetry_api::trace::{SpanContext, SpanId, SpanKind, Status, TraceFlags, TraceId};
use opentelemetry::trace::{SpanContext, SpanId, SpanKind, Status, TraceFlags, TraceId};
use opentelemetry_sdk::{
export::trace::SpanData,
trace::{EvictedHashMap, EvictedQueue},
Expand Down
3 changes: 1 addition & 2 deletions opentelemetry-zipkin/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,9 @@
//!
//!
//! ```no_run
//! use opentelemetry::{KeyValue, trace::Tracer};
//! use opentelemetry::{global, KeyValue, trace::Tracer};
//! use opentelemetry_sdk::{trace::{self, RandomIdGenerator, Sampler}, Resource};
//! use opentelemetry_sdk::export::trace::ExportResult;
//! use opentelemetry::global;
//! use opentelemetry_http::{HttpClient, HttpError};
//! use async_trait::async_trait;
//! use bytes::Bytes;
Expand Down
4 changes: 2 additions & 2 deletions opentelemetry-zipkin/src/propagator/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
//! If `inject_encoding` is set to `B3Encoding::SingleHeader` then `b3` header is used to inject
//! and extract. Otherwise, separate headers are used to inject and extract.
use once_cell::sync::Lazy;
use opentelemetry_api::{
use opentelemetry::{
propagation::{text_map_propagator::FieldIter, Extractor, Injector, TextMapPropagator},
trace::{SpanContext, SpanId, TraceContextExt, TraceFlags, TraceId, TraceState},
Context,
Expand Down Expand Up @@ -316,7 +316,7 @@ impl TextMapPropagator for Propagator {
#[cfg(test)]
mod tests {
use super::*;
use opentelemetry_api::{
use opentelemetry::{
propagation::TextMapPropagator,
testing::trace::TestSpan,
trace::{SpanContext, SpanId, TraceFlags, TraceId},
Expand Down
Loading

0 comments on commit cde9019

Please sign in to comment.