Skip to content

Commit 5b68216

Browse files
authored
Merge branch 'main' into doc-inmemory-exporters
2 parents 89c3419 + 0b2c703 commit 5b68216

File tree

100 files changed

+3364
-1270
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

100 files changed

+3364
-1270
lines changed

.cspell.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242
"Lalit",
4343
"msrv",
4444
"Ochtman",
45-
"openetelemetry",
4645
"opentelemetry",
4746
"OTLP",
4847
"protoc",
@@ -51,6 +50,7 @@
5150
"reqwest",
5251
"rustc",
5352
"Tescher",
53+
"tracerprovider",
5454
"Zhongyang",
5555
"zipkin"
5656
],

.github/codecov.yaml

+4-4
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ ignore:
2222
- "opentelemetry-jaeger/examples"
2323
- "opentelemetry-zipkin/examples"
2424
- "opentelemetry-otlp/examples"
25-
- "opentelemetry-aws/examples"
26-
- "opentelemetry-datadog/examples"
27-
- "opentelemetry-dynatrace/examples"
2825
- "opentelemetry-http/examples"
2926
- "opentelemetry-prometheus/examples"
30-
- "opentelemetry-zpages/examples"
27+
- "opentelemetry-appender-tracing/examples"
28+
- "opentelemetry-appender-log/examples"
29+
# stress test
30+
- "stress"

CONTRIBUTING.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ For a deeper discussion, see:
126126

127127
Currently, the Opentelemetry Rust SDK has two ways to handle errors. In the situation where errors are not allowed to return. One should call global error handler to process the errors. Otherwise, one should return the errors.
128128

129-
The Opentelemetry Rust SDK comes with an error type `openetelemetry::Error`. For different function, one error has been defined. All error returned by trace module MUST be wrapped in `opentelemetry::trace::TraceError`. All errors returned by metrics module MUST be wrapped in `opentelemetry::metrics::MetricsError`.
129+
The Opentelemetry Rust SDK comes with an error type `opentelemetry::Error`. For different function, one error has been defined. All error returned by trace module MUST be wrapped in `opentelemetry::trace::TraceError`. All errors returned by metrics module MUST be wrapped in `opentelemetry::metrics::MetricsError`. All errors returned by logs module MUST be wrapped in `opentelemetry::logs::LogsError`.
130130

131131
For users that want to implement their own exporters. It's RECOMMENDED to wrap all errors from the exporter into a crate-level error type, and implement `ExporterError` trait.
132132

Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ members = [
55
"opentelemetry-jaeger",
66
"opentelemetry-jaeger/examples/actix-udp",
77
"opentelemetry-jaeger/examples/remote-sampler",
8+
"opentelemetry-jaeger-propagator",
89
"opentelemetry-appender-log",
910
"opentelemetry-appender-tracing",
1011
"opentelemetry-otlp",

README.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,6 @@ above, please let us know! We'd love to add your project to the list!
137137

138138
[`open-telemetry/opentelemetry-rust`]: https://github.com/open-telemetry/opentelemetry-rust
139139
[`opentelemetry-jaeger`]: https://crates.io/crates/opentelemetry-jaeger
140-
[`Jaeger`]: https://www.jaegertracing.io
141140
[`opentelemetry-otlp`]: https://crates.io/crates/opentelemetry-otlp
142141
[`opentelemetry-http`]: https://crates.io/crates/opentelemetry-http
143142
[`opentelemetry-prometheus`]: https://crates.io/crates/opentelemetry-prometheus
@@ -157,7 +156,7 @@ above, please let us know! We'd love to add your project to the list!
157156
[`actix-web-opentelemetry`]: https://crates.io/crates/actix-web-opentelemetry
158157
[`actix-web`]: https://crates.io/crates/actix-web
159158
[`opentelemetry-application-insights`]: https://crates.io/crates/opentelemetry-application-insights
160-
[Azure Application Insights]: https://docs.microsoft.com/en-us/azure/azure-monitor/app/app-insights-overview
159+
[Azure Application Insights]: https://docs.microsoft.com/azure/azure-monitor/app/app-insights-overview
161160
[`opentelemetry-tide`]: https://crates.io/crates/opentelemetry-tide
162161
[`Tide`]: https://crates.io/crates/tide
163162
[`opentelemetry-stackdriver`]: https://crates.io/crates/opentelemetry-stackdriver

examples/README.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Examples
2-
This folder contains some examples that should help you get start crates from `opentelemetry-rust`.
2+
This directory contains some examples that should help you get start crates from `opentelemetry-rust`.
33

44
## log-basic
55
**Logs**
@@ -32,9 +32,10 @@ This example uses following crates from this repo:
3232
**Tracing**
3333

3434
This example uses following crates from this repo:
35+
3536
- opentelemetry(tracing)
36-
- opentelemetry-jaeger
37+
- opentelemetry-stdout
3738

3839
The application is built using `tokio`.
3940

40-
Check this example if you want to understand *how to integrate tracing with opentelemetry*.
41+
Check this example if you want to understand *how to create spans and propagate/restore context in OpenTelemetry*.

examples/metrics-basic/src/main.rs

+7-9
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use opentelemetry::metrics::Unit;
2+
use opentelemetry::AttributeSet;
23
use opentelemetry::{metrics::MeterProvider as _, KeyValue};
34
use opentelemetry_sdk::metrics::{PeriodicReader, SdkMeterProvider};
45
use opentelemetry_sdk::{runtime, Resource};
@@ -52,11 +53,10 @@ async fn main() -> Result<(), Box<dyn Error + Send + Sync + 'static>> {
5253
observer.observe_u64(
5354
&observable_counter,
5455
100,
55-
[
56+
AttributeSet::from(&[
5657
KeyValue::new("mykey1", "myvalue1"),
5758
KeyValue::new("mykey2", "myvalue2"),
58-
]
59-
.as_ref(),
59+
]),
6060
)
6161
})?;
6262

@@ -84,11 +84,10 @@ async fn main() -> Result<(), Box<dyn Error + Send + Sync + 'static>> {
8484
observer.observe_i64(
8585
&observable_up_down_counter,
8686
100,
87-
[
87+
AttributeSet::from(&[
8888
KeyValue::new("mykey1", "myvalue1"),
8989
KeyValue::new("mykey2", "myvalue2"),
90-
]
91-
.as_ref(),
90+
]),
9291
)
9392
})?;
9493

@@ -142,11 +141,10 @@ async fn main() -> Result<(), Box<dyn Error + Send + Sync + 'static>> {
142141
observer.observe_f64(
143142
&observable_gauge,
144143
1.0,
145-
[
144+
AttributeSet::from(&[
146145
KeyValue::new("mykey1", "myvalue1"),
147146
KeyValue::new("mykey2", "myvalue2"),
148-
]
149-
.as_ref(),
147+
]),
150148
)
151149
})?;
152150

examples/tracing-grpc/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ opentelemetry-stdout = { path = "../../opentelemetry-stdout", features = ["trace
2020
prost = { workspace = true }
2121
tokio = { workspace = true, features = ["full"] }
2222
tonic = { workspace = true }
23+
serde_json = { workspace = true }
2324

2425
[build-dependencies]
2526
tonic-build = "0.9.2"

examples/tracing-grpc/README.md

+12-11
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,25 @@
11
# GRPC example
22

3-
Example showing [Tonic] client and server interaction with OpenTelemetry context propagation. [tracing_opentelemetry](https://docs.rs/tracing-opentelemetry/0.4.0/tracing_opentelemetry/) is used to hook into the [tracing](https://github.com/tokio-rs/tracing) ecosystem, which enables drop-in replacements for [log](https://github.com/rust-lang/log) macros and an `#[instrument]` macro that will automatically add spans to your functions.
3+
Example showing [Tonic] client and server interaction with OpenTelemetry context
4+
propagation. Traces are exported to stdout.
45

56
[Tonic]: https://github.com/hyperium/tonic
67

7-
Examples
8-
--------
8+
## Running the example
99

1010
```shell
11-
# Run jaeger in background
12-
$ docker run -d -p6831:6831/udp -p6832:6832/udp -p16686:16686 jaegertracing/all-in-one:latest
13-
14-
# Run the server
11+
# Run the server first
1512
$ cargo run --bin grpc-server
1613

1714
# Now run the client to make a request to the server
1815
$ cargo run --bin grpc-client
19-
20-
# View spans (see the image below)
21-
$ firefox http://localhost:16686/
2216
```
2317

24-
![Jaeger UI](trace.png)
18+
Observe that the traces are exported to stdout, and that they share the same
19+
TraceId. Also, the server span would be parented to the client span. The example
20+
demonstrates how to propagate and restore OpenTelemetry context when making
21+
out-of-process calls, so as to ensure the same trace is continued in the next
22+
process. The client here initiates the trace by creating the root client span,
23+
and it propagates its context to the server. The server, extracts the context,
24+
and creates its own server span using the extracted context, ensuring both spans
25+
are correlated.

examples/tracing-grpc/src/client.rs

+10-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use opentelemetry::{global, propagation::Injector};
44
use opentelemetry_sdk::{
55
propagation::TraceContextPropagator, runtime::Tokio, trace::TracerProvider,
66
};
7-
use opentelemetry_stdout::SpanExporter;
7+
use opentelemetry_stdout::SpanExporterBuilder;
88

99
use opentelemetry::{
1010
trace::{SpanKind, TraceContextExt, Tracer},
@@ -15,7 +15,15 @@ fn init_tracer() {
1515
global::set_text_map_propagator(TraceContextPropagator::new());
1616
// Install stdout exporter pipeline to be able to retrieve the collected spans.
1717
let provider = TracerProvider::builder()
18-
.with_batch_exporter(SpanExporter::default(), Tokio)
18+
.with_batch_exporter(
19+
SpanExporterBuilder::default()
20+
.with_encoder(|writer, data| {
21+
serde_json::to_writer_pretty(writer, &data).unwrap();
22+
Ok(())
23+
})
24+
.build(),
25+
Tokio,
26+
)
1927
.build();
2028

2129
global::set_tracer_provider(provider);

examples/tracing-grpc/src/server.rs

+10-2
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,22 @@ use opentelemetry::{
88
use opentelemetry_sdk::{
99
propagation::TraceContextPropagator, runtime::Tokio, trace::TracerProvider,
1010
};
11-
use opentelemetry_stdout::SpanExporter;
11+
use opentelemetry_stdout::SpanExporterBuilder;
1212
use tonic::{transport::Server, Request, Response, Status};
1313

1414
fn init_tracer() {
1515
global::set_text_map_propagator(TraceContextPropagator::new());
1616
// Install stdout exporter pipeline to be able to retrieve the collected spans.
1717
let provider = TracerProvider::builder()
18-
.with_batch_exporter(SpanExporter::default(), Tokio)
18+
.with_batch_exporter(
19+
SpanExporterBuilder::default()
20+
.with_encoder(|writer, data| {
21+
serde_json::to_writer_pretty(writer, &data).unwrap();
22+
Ok(())
23+
})
24+
.build(),
25+
Tokio,
26+
)
1927
.build();
2028

2129
global::set_tracer_provider(provider);

examples/tracing-http-propagator/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@ $ cargo run --bin http-server
2424
$ cargo run --bin http-client
2525

2626
# The spans should be visible in stdout in the order that they were exported.
27-
```
27+
```

examples/tracing-http-propagator/src/server.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,8 @@ async fn router(req: Request<Body>) -> Result<Response<Body>, Infallible> {
7676
fn init_tracer() {
7777
global::set_text_map_propagator(TraceContextPropagator::new());
7878

79-
// Install stdout exporter pipeline to be able to retrieve the collected spans.
80-
// For the demonstration, use `Sampler::AlwaysOn` sampler to sample all traces. In a production
81-
// application, use `Sampler::ParentBased` or `Sampler::TraceIdRatioBased` with a desired ratio.
79+
// Setup tracerprovider with stdout exporter
80+
// that prints the spans to stdout.
8281
let provider = TracerProvider::builder()
8382
.with_simple_exporter(SpanExporter::default())
8483
.build();

opentelemetry-appender-tracing/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ rust-version = "1.65"
1414
log = { workspace = true, optional = true }
1515
opentelemetry = { version = "0.21", path = "../opentelemetry", features = ["logs"] }
1616
opentelemetry_sdk = { version = "0.21", path = "../opentelemetry-sdk", features = ["logs"] }
17-
tracing = { workspace = true, default-features = false, features = ["std"]}
17+
tracing = { workspace = true, features = ["std"]}
1818
tracing-core = { workspace = true }
1919
tracing-log = { version = "0.2", optional = true }
20-
tracing-subscriber = { workspace = true, default-features = false, features = ["registry", "std"] }
20+
tracing-subscriber = { workspace = true, features = ["registry", "std"] }
2121
once_cell = "1.13.0"
2222

2323
[dev-dependencies]

opentelemetry-http/Cargo.toml

+5-5
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ rust-version = "1.65"
1313
async-trait = { workspace = true }
1414
bytes = { workspace = true }
1515
http = { workspace = true }
16-
hyper = { workspace = true, default-features = false, features = ["http2", "client", "tcp"], optional = true }
17-
isahc = { workspace = true, default-features = false, optional = true }
16+
hyper = { workspace = true, features = ["http2", "client", "tcp"], optional = true }
17+
isahc = { workspace = true, optional = true }
1818
opentelemetry = { version = "0.21", path = "../opentelemetry", features = ["trace"] }
19-
reqwest = { workspace = true, default-features = false, features = ["blocking"], optional = true }
20-
surf = { workspace = true, default-features = false, optional = true }
21-
tokio = { workspace = true, default-features = false, features = ["time"], optional = true }
19+
reqwest = { workspace = true, features = ["blocking"], optional = true }
20+
surf = { workspace = true, optional = true }
21+
tokio = { workspace = true, features = ["time"], optional = true }
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Changelog
2+
3+
## vNext
4+
5+
## v0.1.0
6+
7+
### Added
8+
9+
- As part of the gradual deprecation of the exporter functionality of the opentelemetry-jaeger crate, move the opentelemetry-jaeger propagator functionality to a new crate named opentelemetry-jaeger-propagator [#1487](https://github.com/open-telemetry/opentelemetry-rust/pull/1487)
+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
[package]
2+
name = "opentelemetry-jaeger-propagator"
3+
version = "0.1.0"
4+
description = "Jaeger propagator for OpenTelemetry"
5+
homepage = "https://github.com/open-telemetry/opentelemetry-rust/tree/main/opentelemetry-jaeger-propagator"
6+
repository = "https://github.com/open-telemetry/opentelemetry-rust/tree/main/opentelemetry-jaeger-propagator"
7+
readme = "README.md"
8+
categories = [
9+
"development-tools::debugging",
10+
"development-tools::profiling",
11+
"asynchronous",
12+
]
13+
keywords = ["opentelemetry", "jaeger", "propagator"]
14+
license = "Apache-2.0"
15+
edition = "2021"
16+
rust-version = "1.65"
17+
18+
19+
[package.metadata.docs.rs]
20+
all-features = true
21+
rustdoc-args = ["--cfg", "docsrs"]
22+
23+
[dependencies]
24+
opentelemetry = { version = "0.21", default-features = false, features = [
25+
"trace",
26+
], path = "../opentelemetry" }
27+
28+
tonic = { workspace = true, optional = true }
29+
prost = { version = "0.11.6", optional = true }
30+
prost-types = { version = "0.11.6", optional = true }
31+
32+
[dev-dependencies]
33+
opentelemetry_sdk = { features = ["testing"], path = "../opentelemetry-sdk" }
34+
35+
[features]
36+
default = []
37+
integration_test = []

0 commit comments

Comments
 (0)