Skip to content

Commit 0a9776f

Browse files
authored
Merge branch 'main' into cijothomas/tracing-error
2 parents ee0887d + 40effae commit 0a9776f

File tree

14 files changed

+104
-224
lines changed

14 files changed

+104
-224
lines changed

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ It's important to regularly review and remove the `otel_unstable` flag from the
172172

173173
The potential features include:
174174

175-
- Stable and non-experimental features that compliant to specification, and have a feature flag to minimize compilation size. Example: feature flags for signals (like `logs`, `traces`, `metrics`) and runtimes (`rt-tokio`, `rt-tokio-current-thread`, `rt-async-std`).
175+
- Stable and non-experimental features that are compliant with the specification and have a feature flag to minimize compilation size. Example: feature flags for signals (like `logs`, `traces`, `metrics`) and runtimes (`rt-tokio`, `rt-tokio-current-thread`).
176176
- Stable and non-experimental features, although not part of the specification, are crucial for enhancing the tracing/log crate's functionality or boosting performance. These features are also subject to discussion and approval by the OpenTelemetry Rust Maintainers.
177177

178178
All such features should adhere to naming convention `<signal>_<feature_name>`

docs/design/logs.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,13 @@ They get called in the order of registration. Log records are passed to the
195195
records, enrich them, filter them, and export to destinations by leveraging
196196
LogRecord Exporters.
197197

198+
Similar to [LoggerProvider](#sdkloggerprovider), methods on the `LogProcessor`
199+
trait also takes a immutable self (`&self`) only, forcing the need to use
200+
interior mutability, if any mutation is required. The exception to this is
201+
`set_resource`, which takes a `&mut self`. This is acceptable as `set_resource`
202+
is called by the `SdkLoggerProvider` during build() method only, and is not
203+
required after that.
204+
198205
Following built-in Log processors are provided in the Log SDK:
199206

200207
##### SimpleLogProcessor
@@ -232,8 +239,13 @@ other words, that many logs can be lost if the app crashes in the middle.
232239

233240
## LogExporters
234241

235-
LogExporters are responsible for exporting logs to a destination. Some of them
236-
include:
242+
LogExporters are responsible for exporting logs to a destination.
243+
`SdkLoggerProvider` does not have a direct knowledge of the `LogExporter`, as it
244+
only deals with `LogProcessors`. It is the `LogProcessor`s that invokes
245+
`LogExporter` methods. Most methods on `LogExporter` trait also only takes
246+
`&self`, following the same reasoning as [LogProcessors](#logrecord-processors)
247+
248+
Some of the exporters are:
237249

238250
1. **InMemoryExporter** - exports to an in-memory list, primarily for
239251
unit-testing. This is used extensively in the repo itself, and external users

examples/tracing-jaeger/Cargo.toml

Lines changed: 0 additions & 12 deletions
This file was deleted.

examples/tracing-jaeger/README.md

Lines changed: 0 additions & 21 deletions
This file was deleted.

examples/tracing-jaeger/jaeger.png

-165 KB
Binary file not shown.

examples/tracing-jaeger/src/main.rs

Lines changed: 0 additions & 50 deletions
This file was deleted.

opentelemetry-otlp/src/lib.rs

Lines changed: 80 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,68 @@
1-
//! The OTLP Exporter supports exporting logs, metrics and traces in the OTLP
2-
//! format to the OpenTelemetry collector or other compatible backend.
1+
//! # OpenTelemetry OTLP Exporter
32
//!
4-
//! The OpenTelemetry Collector offers a vendor-agnostic implementation on how
5-
//! to receive, process, and export telemetry data. In addition, it removes
6-
//! the need to run, operate, and maintain multiple agents/collectors in
7-
//! order to support open-source telemetry data formats (e.g. Jaeger,
8-
//! Prometheus, etc.) sending to multiple open-source or commercial back-ends.
3+
//! The OTLP Exporter enables exporting telemetry data (logs, metrics, and traces) in the
4+
//! OpenTelemetry Protocol (OTLP) format to compatible backends. These backends include:
95
//!
10-
//! Currently, this crate supports sending telemetry in OTLP
11-
//! via gRPC and http (binary and json).
6+
//! - OpenTelemetry Collector
7+
//! - Open-source observability tools (Prometheus, Jaeger, etc.)
8+
//! - Vendor-specific monitoring platforms
129
//!
13-
//! # Quickstart
10+
//! This crate supports sending OTLP data via:
11+
//! - gRPC
12+
//! - HTTP (binary protobuf or JSON)
1413
//!
15-
//! First make sure you have a running version of the opentelemetry collector
16-
//! you want to send data to:
14+
//! ## Quickstart with OpenTelemetry Collector
15+
//!
16+
//! ### HTTP Transport (Port 4318)
17+
//!
18+
//! Run the OpenTelemetry Collector:
1719
//!
1820
//! ```shell
19-
//! $ docker run -p 4317:4317 otel/opentelemetry-collector:latest
21+
//! $ docker run -p 4318:4318 otel/opentelemetry-collector:latest
22+
//! ```
23+
//!
24+
//! Configure your application to export traces via HTTP:
25+
//!
26+
//! ```no_run
27+
//! # #[cfg(all(feature = "trace", feature = "http-proto"))]
28+
//! # {
29+
//! use opentelemetry::global;
30+
//! use opentelemetry::trace::Tracer;
31+
//! use opentelemetry_otlp::Protocol;
32+
//! use opentelemetry_otlp::WithExportConfig;
33+
//!
34+
//! fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>> {
35+
//! // Initialize OTLP exporter using HTTP binary protocol
36+
//! let otlp_exporter = opentelemetry_otlp::SpanExporter::builder()
37+
//! .with_http()
38+
//! .with_protocol(Protocol::HttpBinary)
39+
//! .build()?;
40+
//!
41+
//! // Create a tracer provider with the exporter
42+
//! let _ = opentelemetry_sdk::trace::SdkTracerProvider::builder()
43+
//! .with_simple_exporter(otlp_exporter)
44+
//! .build();
45+
//!
46+
//! // Get a tracer and create spans
47+
//! let tracer = global::tracer("my_tracer");
48+
//! tracer.in_span("doing_work", |_cx| {
49+
//! // Your application logic here...
50+
//! });
51+
//!
52+
//! Ok(())
53+
//! # }
54+
//! }
2055
//! ```
2156
//!
22-
//! Then create a new `Exporter`, and `Provider` with the recommended defaults to start exporting
23-
//! telemetry.
57+
//! ### gRPC Transport (Port 4317)
58+
//!
59+
//! Run the OpenTelemetry Collector:
2460
//!
25-
//! You will have to build a OTLP exporter first. Create the correct exporter based on the signal
26-
//! you are looking to export `SpanExporter::builder()`, `MetricExporter::builder()`,
27-
//! `LogExporter::builder()` respectively for traces, metrics, and logs.
61+
//! ```shell
62+
//! $ docker run -p 4317:4317 otel/opentelemetry-collector:latest
63+
//! ```
2864
//!
29-
//! Once you have the exporter, you can create your `Provider` by starting with `TracerProvider::builder()`,
30-
//! `SdkMeterProvider::builder()`, and `LoggerProvider::builder()` respectively for traces, metrics, and logs.
65+
//! Configure your application to export traces via gRPC:
3166
//!
3267
//! ```no_run
3368
//! # #[cfg(all(feature = "trace", feature = "grpc-tonic"))]
@@ -36,22 +71,41 @@
3671
//! use opentelemetry::trace::Tracer;
3772
//!
3873
//! fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>> {
39-
//! // First, create a OTLP exporter builder. Configure it as you need.
40-
//! let otlp_exporter = opentelemetry_otlp::SpanExporter::builder().with_tonic().build()?;
41-
//! // Then pass it into provider builder
74+
//! // Initialize OTLP exporter using gRPC (Tonic)
75+
//! let otlp_exporter = opentelemetry_otlp::SpanExporter::builder()
76+
//! .with_tonic()
77+
//! .build()?;
78+
//!
79+
//! // Create a tracer provider with the exporter
4280
//! let _ = opentelemetry_sdk::trace::SdkTracerProvider::builder()
4381
//! .with_simple_exporter(otlp_exporter)
4482
//! .build();
83+
//!
84+
//! // Get a tracer and create spans
4585
//! let tracer = global::tracer("my_tracer");
46-
//! tracer.in_span("doing_work", |cx| {
47-
//! // Traced app logic here...
86+
//! tracer.in_span("doing_work", |_cx| {
87+
//! // Your application logic here...
4888
//! });
4989
//!
5090
//! Ok(())
51-
//! # }
91+
//! # }
5292
//! }
5393
//! ```
5494
//!
95+
//! ## Using with Jaeger
96+
//!
97+
//! Jaeger natively supports the OTLP protocol, making it easy to send traces directly:
98+
//!
99+
//! ```shell
100+
//! $ docker run -p 16686:16686 -p 4317:4317 -e COLLECTOR_OTLP_ENABLED=true jaegertracing/all-in-one:latest
101+
//! ```
102+
//!
103+
//! After running your application configured with the OTLP exporter, view traces at:
104+
//! `http://localhost:16686`
105+
//!
106+
//! ## Using with Prometheus (TODO)
107+
//! ## Show Logs, Metrics too (TODO)
108+
//!
55109
//! ## Performance
56110
//!
57111
//! For optimal performance, a batch exporting processor is recommended as the simple
@@ -87,7 +141,6 @@
87141
//! ```
88142
//!
89143
//! [`tokio`]: https://tokio.rs
90-
//! [`async-std`]: https://async.rs
91144
//!
92145
//! # Feature Flags
93146
//! The following feature flags can enable exporters for different telemetry signals:

opentelemetry-sdk/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
- **Breaking**: The `Runtime` trait has been simplified and refined. See the [#2641](https://github.com/open-telemetry/opentelemetry-rust/pull/2641)
66
for the changes.
7+
- Removed `async-std` support for `Runtime`, as [`async-std` crate is deprecated](https://crates.io/crates/async-std).
78
- Calls to `MeterProviderBuilder::with_resource`, `TracerProviderBuilder::with_resource`,
89
`LoggerProviderBuilder::with_resource` are now additive ([#2677](https://github.com/open-telemetry/opentelemetry-rust/pull/2677)).
910
- Moved `ExportError` trait from `opentelemetry::trace::ExportError` to `opentelemetry_sdk::export::ExportError`

opentelemetry-sdk/Cargo.toml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ rust-version = "1.75.0"
1212
[dependencies]
1313
opentelemetry = { version = "0.28", path = "../opentelemetry/" }
1414
opentelemetry-http = { version = "0.28", path = "../opentelemetry-http", optional = true }
15-
async-std = { workspace = true, features = ["unstable"], optional = true }
1615
futures-channel = { workspace = true }
1716
futures-executor = { workspace = true }
1817
futures-util = { workspace = true, features = ["std", "sink", "async-await-macro"] }
@@ -47,11 +46,10 @@ jaeger_remote_sampler = ["trace", "opentelemetry-http", "http", "serde", "serde_
4746
logs = ["opentelemetry/logs", "serde_json"]
4847
spec_unstable_logs_enabled = ["logs", "opentelemetry/spec_unstable_logs_enabled"]
4948
metrics = ["opentelemetry/metrics", "glob"]
50-
testing = ["opentelemetry/testing", "trace", "metrics", "logs", "rt-async-std", "rt-tokio", "rt-tokio-current-thread", "tokio/macros", "tokio/rt-multi-thread"]
49+
testing = ["opentelemetry/testing", "trace", "metrics", "logs", "rt-tokio", "rt-tokio-current-thread", "tokio/macros", "tokio/rt-multi-thread"]
5150
experimental_async_runtime = []
5251
rt-tokio = ["tokio", "tokio-stream", "experimental_async_runtime"]
5352
rt-tokio-current-thread = ["tokio", "tokio-stream", "experimental_async_runtime"]
54-
rt-async-std = ["async-std", "experimental_async_runtime"]
5553
internal-logs = ["tracing"]
5654
experimental_metrics_periodicreader_with_async_runtime = ["metrics"]
5755
spec_unstable_metrics_views = ["metrics"]

opentelemetry-sdk/src/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,8 @@
9494
//! * `experimental_async_runtime`: Enables the experimental `Runtime` trait and related functionality.
9595
//! * `rt-tokio`: Spawn telemetry tasks using [tokio]'s multi-thread runtime.
9696
//! * `rt-tokio-current-thread`: Spawn telemetry tasks on a separate runtime so that the main runtime won't be blocked.
97-
//! * `rt-async-std`: Spawn telemetry tasks using [async-std]'s runtime.
9897
//!
9998
//! [tokio]: https://crates.io/crates/tokio
100-
//! [async-std]: https://crates.io/crates/async-std
10199
#![warn(
102100
future_incompatible,
103101
missing_debug_implementations,

0 commit comments

Comments
 (0)