Skip to content

Commit bea0aa5

Browse files
authored
Cleanup crate documentation (#1278)
* Cleanup crate documentation - mainly this removes circular dev-dependencies between the api, sdk, and stdout crates. * Some things need to be behind "trace" feature
1 parent f7684b0 commit bea0aa5

File tree

9 files changed

+52
-62
lines changed

9 files changed

+52
-62
lines changed

.cspell.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,13 @@
2525
// these are words that are always correct and can be thought of as our
2626
// workspace dictionary.
2727
"words": [
28+
"deque",
2829
"hasher",
30+
"msrv",
2931
"opentelemetry",
3032
"OTLP",
3133
"quantile",
34+
"rustc",
3235
"zipkin"
3336
],
3437
"enabledLanguageIds": [
@@ -63,4 +66,4 @@
6366
]
6467
}
6568
]
66-
}
69+
}

opentelemetry-sdk/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
- Return error earlier if readers are shut down (#1266)
2525
- Add `/` to valid characters for instrument names (#1269)
2626
- Increase instrument name maximum length from 63 to 255 (#1269)
27+
- Updated crate documentation and examples.
28+
[#1256](https://github.com/open-telemetry/opentelemetry-rust/issues/1256)
2729

2830
### Removed
2931

opentelemetry-sdk/src/lib.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1-
//! OpenTelemetry is a collection of tools, APIs, and SDKs. Use it to
2-
//! instrument, generate, collect, and export telemetry data (metrics, logs, and
3-
//! traces) to help you analyze your software's performance and behavior.
1+
//! Implements the [`SDK`] component of [OpenTelemetry].
2+
//!
3+
//! *Compiler support: [requires `rustc` 1.64+][msrv]*
4+
//!
5+
//! [`SDK`]: https://opentelemetry.io/docs/specs/otel/overview/#sdk
6+
//! [OpenTelemetry]: https://opentelemetry.io/docs/what-is-opentelemetry/
7+
//! [msrv]: #supported-rust-versions
48
//!
59
//! # Getting Started
610
//!

opentelemetry/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
- `opentelemetry` crate now only carries the API types #1186. Use the `opentelemetry_sdk` crate for the SDK types.
99
- `trace::noop::NoopSpan` no longer implements `Default` and instead exposes
1010
a `const DEFAULT` value. [#1270](https://github.com/open-telemetry/opentelemetry-rust/pull/1270)
11+
- Updated crate documentation and examples.
12+
[#1256](https://github.com/open-telemetry/opentelemetry-rust/issues/1256)
1113

1214
## [v0.20.0](https://github.com/open-telemetry/opentelemetry-rust/compare/v0.19.0...v0.20.0)
1315
This release should been seen as 1.0-rc3 following 1.0-rc2 in v0.19.0. Refer to CHANGELOG.md in individual creates for details on changes made in different creates.

opentelemetry/Cargo.toml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,6 @@ urlencoding = "2.1.2"
3232
[target.'cfg(all(target_arch = "wasm32", not(target_os = "wasi")))'.dependencies]
3333
js-sys = "0.3.63"
3434

35-
[dev-dependencies]
36-
opentelemetry_sdk = { version = "0.20", path = "../opentelemetry-sdk" }
37-
opentelemetry-stdout = { version = "0.1", path = "../opentelemetry-stdout", features = ["trace"] }
38-
3935
[features]
4036
default = ["trace"]
4137
trace = ["pin-project-lite"]

opentelemetry/src/context.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#[cfg(feature = "trace")]
12
use crate::trace::context::SynchronizedSpan;
23
use std::any::{Any, TypeId};
34
use std::cell::RefCell;
@@ -75,6 +76,7 @@ thread_local! {
7576
/// ```
7677
#[derive(Clone, Default)]
7778
pub struct Context {
79+
#[cfg(feature = "trace")]
7880
pub(super) span: Option<Arc<SynchronizedSpan>>,
7981
entries: HashMap<TypeId, Arc<dyn Any + Sync + Send>, BuildHasherDefault<IdHasher>>,
8082
}
@@ -306,13 +308,15 @@ impl Context {
306308
}
307309
}
308310

311+
#[cfg(feature = "trace")]
309312
pub(super) fn current_with_synchronized_span(value: SynchronizedSpan) -> Self {
310313
Context {
311314
span: Some(Arc::new(value)),
312315
entries: Context::map_current(|cx| cx.entries.clone()),
313316
}
314317
}
315318

319+
#[cfg(feature = "trace")]
316320
pub(super) fn with_synchronized_span(&self, value: SynchronizedSpan) -> Self {
317321
Context {
318322
span: Some(Arc::new(value)),

opentelemetry/src/lib.rs

Lines changed: 30 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,22 @@
1-
//! OpenTelemetry provides a single set of APIs, libraries, agents, and collector
2-
//! services to capture distributed traces and metrics from your application. You
3-
//! can analyze them using [Prometheus], [Jaeger], and other observability tools.
1+
//! Implements the [`API`] component of [OpenTelemetry].
42
//!
53
//! *Compiler support: [requires `rustc` 1.64+][msrv]*
64
//!
7-
//! [Prometheus]: https://prometheus.io
8-
//! [Jaeger]: https://www.jaegertracing.io
5+
//! [`API`]: https://opentelemetry.io/docs/specs/otel/overview/#api
6+
//! [OpenTelemetry]: https://opentelemetry.io/docs/what-is-opentelemetry/
97
//! [msrv]: #supported-rust-versions
108
//!
119
//! # Getting Started
1210
//!
1311
//! ```no_run
1412
//! # #[cfg(feature = "trace")]
1513
//! # {
16-
//! use opentelemetry::{
17-
//! global,
18-
//! trace::{Tracer, TracerProvider as _},
19-
//! };
20-
//! use opentelemetry_sdk::trace::TracerProvider;
21-
//!
22-
//! fn main() {
23-
//! // Create a new trace pipeline that prints to stdout
24-
//! let provider = TracerProvider::builder()
25-
//! .with_simple_exporter(opentelemetry_stdout::SpanExporter::default())
26-
//! .build();
27-
//! let tracer = provider.tracer("readme_example");
28-
//!
29-
//! tracer.in_span("doing_work", |cx| {
30-
//! // Traced app logic here...
31-
//! });
32-
//!
33-
//! // Shutdown trace pipeline
34-
//! global::shutdown_tracer_provider();
14+
//! use opentelemetry::{global, trace::{TraceContextExt, Tracer}, Context };
15+
//!
16+
//! fn do_something() {
17+
//! let tracer = global::tracer("my_component");
18+
//! let _guard = Context::current_with_span(tracer.start("my_span")).attach();
19+
//! // do work tracked by the now current span
3520
//! }
3621
//! # }
3722
//! ```
@@ -109,18 +94,9 @@
10994
//!
11095
//! The following core crate feature flags are available:
11196
//!
112-
//! * `trace`: Includes the trace API and SDK (enabled by default).
113-
//! * `metrics`: Includes the unstable metrics API and SDK.
114-
//!
115-
//! Support for recording and exporting telemetry asynchronously can be added
116-
//! via the following flags:
117-
//!
118-
//! * `rt-tokio`: Spawn telemetry tasks using [tokio]'s multi-thread runtime.
119-
//! * `rt-tokio-current-thread`: Spawn telemetry tasks on a separate runtime so that the main runtime won't be blocked.
120-
//! * `rt-async-std`: Spawn telemetry tasks using [async-std]'s runtime.
121-
//!
122-
//! [tokio]: https://crates.io/crates/tokio
123-
//! [async-std]: https://crates.io/crates/async-std
97+
//! * `trace`: Includes the trace API (enabled by default).
98+
//! * `metrics`: Includes the unstable metrics API.
99+
//! * `logs`: Includes the logs bridge API.
124100
//!
125101
//! ## Related Crates
126102
//!
@@ -133,6 +109,7 @@
133109
//!
134110
//! In particular, the following crates are likely to be of interest:
135111
//!
112+
//! - [`opentelemetry_sdk`] provides the SDK used to configure providers.
136113
//! - [`opentelemetry-http`] provides an interface for injecting and extracting
137114
//! trace information from [`http`] headers.
138115
//! - [`opentelemetry-jaeger`] provides a pipeline and exporter for sending
@@ -167,31 +144,31 @@
167144
//! If you're the maintainer of an `opentelemetry` ecosystem crate not listed
168145
//! above, please let us know! We'd love to add your project to the list!
169146
//!
170-
//! [`open-telemetry/opentelemetry-rust`]: https://github.com/open-telemetry/opentelemetry-rust
171-
//! [`opentelemetry-jaeger`]: https://crates.io/crates/opentelemetry-jaeger
147+
//! [`actix-web-opentelemetry`]: https://crates.io/crates/actix-web-opentelemetry
148+
//! [`actix-web`]: https://crates.io/crates/actix-web
149+
//! [`Datadog`]: https://www.datadoghq.com
150+
//! [`http`]: https://crates.io/crates/http
172151
//! [`Jaeger`]: https://www.jaegertracing.io
173-
//! [`opentelemetry-otlp`]: https://crates.io/crates/opentelemetry-otlp
174-
//! [`opentelemetry-http`]: https://crates.io/crates/opentelemetry-http
175-
//! [`opentelemetry-prometheus`]: https://crates.io/crates/opentelemetry-prometheus
152+
//! [`open-telemetry/opentelemetry-rust`]: https://github.com/open-telemetry/opentelemetry-rust
153+
//! [`opentelemetry_sdk`]: https://crates.io/crates/opentelemetry_sdk
154+
//! [`opentelemetry-application-insights`]: https://crates.io/crates/opentelemetry-application-insights
176155
//! [`opentelemetry-aws`]: https://crates.io/crates/opentelemetry-aws
177-
//! [`Prometheus`]: https://prometheus.io
178-
//! [`opentelemetry-zipkin`]: https://crates.io/crates/opentelemetry-zipkin
179-
//! [`http`]: https://crates.io/crates/http
180-
//! [`Zipkin`]: https://zipkin.io
181156
//! [`opentelemetry-contrib`]: https://crates.io/crates/opentelemetry-contrib
182157
//! [`opentelemetry-datadog`]: https://crates.io/crates/opentelemetry-datadog
183-
//! [`Datadog`]: https://www.datadoghq.com
158+
//! [`opentelemetry-http`]: https://crates.io/crates/opentelemetry-http
159+
//! [`opentelemetry-jaeger`]: https://crates.io/crates/opentelemetry-jaeger
160+
//! [`opentelemetry-otlp`]: https://crates.io/crates/opentelemetry-otlp
161+
//! [`opentelemetry-prometheus`]: https://crates.io/crates/opentelemetry-prometheus
184162
//! [`opentelemetry-semantic-conventions`]: https://crates.io/crates/opentelemetry-semantic-conventions
185-
//!
163+
//! [`opentelemetry-stackdriver`]: https://crates.io/crates/opentelemetry-stackdriver
164+
//! [`opentelemetry-tide`]: https://crates.io/crates/opentelemetry-tide
165+
//! [`opentelemetry-zipkin`]: https://crates.io/crates/opentelemetry-zipkin
166+
//! [`Prometheus`]: https://prometheus.io
167+
//! [`Tide`]: https://crates.io/crates/tide
186168
//! [`tracing-opentelemetry`]: https://crates.io/crates/tracing-opentelemetry
187169
//! [`tracing`]: https://crates.io/crates/tracing
188-
//! [`actix-web-opentelemetry`]: https://crates.io/crates/actix-web-opentelemetry
189-
//! [`actix-web`]: https://crates.io/crates/actix-web
190-
//! [`opentelemetry-application-insights`]: https://crates.io/crates/opentelemetry-application-insights
170+
//! [`Zipkin`]: https://zipkin.io
191171
//! [Azure Application Insights]: https://docs.microsoft.com/en-us/azure/azure-monitor/app/app-insights-overview
192-
//! [`opentelemetry-tide`]: https://crates.io/crates/opentelemetry-tide
193-
//! [`Tide`]: https://crates.io/crates/tide
194-
//! [`opentelemetry-stackdriver`]: https://crates.io/crates/opentelemetry-stackdriver
195172
//! [Cloud Trace]: https://cloud.google.com/trace/
196173
//!
197174
//! ## Supported Rust Versions

opentelemetry/src/testing/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1+
#[cfg(feature = "trace")]
2+
#[cfg_attr(docsrs, doc(cfg(feature = "trace")))]
13
pub mod trace;

opentelemetry/src/trace/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
//! through a system. This module implements the OpenTelemetry [trace
88
//! specification].
99
//!
10-
//! [trace specification]: https://github.com/open-telemetry/opentelemetry-specification/blob/v1.3.0/specification/trace/api.md
10+
//! [trace specification]: https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/api.md
1111
//!
1212
//! ## Getting Started
1313
//!

0 commit comments

Comments
 (0)