|
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]. |
4 | 2 | //!
|
5 | 3 | //! *Compiler support: [requires `rustc` 1.64+][msrv]*
|
6 | 4 | //!
|
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/ |
9 | 7 | //! [msrv]: #supported-rust-versions
|
10 | 8 | //!
|
11 | 9 | //! # Getting Started
|
12 | 10 | //!
|
13 | 11 | //! ```no_run
|
14 | 12 | //! # #[cfg(feature = "trace")]
|
15 | 13 | //! # {
|
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 |
35 | 20 | //! }
|
36 | 21 | //! # }
|
37 | 22 | //! ```
|
|
109 | 94 | //!
|
110 | 95 | //! The following core crate feature flags are available:
|
111 | 96 | //!
|
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. |
124 | 100 | //!
|
125 | 101 | //! ## Related Crates
|
126 | 102 | //!
|
|
133 | 109 | //!
|
134 | 110 | //! In particular, the following crates are likely to be of interest:
|
135 | 111 | //!
|
| 112 | +//! - [`opentelemetry_sdk`] provides the SDK used to configure providers. |
136 | 113 | //! - [`opentelemetry-http`] provides an interface for injecting and extracting
|
137 | 114 | //! trace information from [`http`] headers.
|
138 | 115 | //! - [`opentelemetry-jaeger`] provides a pipeline and exporter for sending
|
|
167 | 144 | //! If you're the maintainer of an `opentelemetry` ecosystem crate not listed
|
168 | 145 | //! above, please let us know! We'd love to add your project to the list!
|
169 | 146 | //!
|
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 |
172 | 151 | //! [`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 |
176 | 155 | //! [`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 |
181 | 156 | //! [`opentelemetry-contrib`]: https://crates.io/crates/opentelemetry-contrib
|
182 | 157 | //! [`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 |
184 | 162 | //! [`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 |
186 | 168 | //! [`tracing-opentelemetry`]: https://crates.io/crates/tracing-opentelemetry
|
187 | 169 | //! [`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 |
191 | 171 | //! [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 |
195 | 172 | //! [Cloud Trace]: https://cloud.google.com/trace/
|
196 | 173 | //!
|
197 | 174 | //! ## Supported Rust Versions
|
|
0 commit comments