Skip to content

Commit 4c50b32

Browse files
authored
Merge branch 'main' into experimental-runtime
2 parents 6c49eea + b53c19e commit 4c50b32

File tree

12 files changed

+40
-128
lines changed

12 files changed

+40
-128
lines changed

.cspell.json

+2
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,12 @@
6060
"reqwest",
6161
"runtimes",
6262
"rustc",
63+
"serde",
6364
"shoppingcart",
6465
"struct",
6566
"Tescher",
6667
"testresults",
68+
"thiserror",
6769
"tracerprovider",
6870
"updown",
6971
"Zhongyang",

opentelemetry-otlp/examples/basic-otlp-http/Cargo.toml

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ license = "Apache-2.0"
66
publish = false
77

88
[features]
9+
default = ["reqwest-blocking"]
910
reqwest-blocking = ["opentelemetry-otlp/reqwest-blocking-client"]
10-
hyper = ["opentelemetry-otlp/hyper-client"]
1111

1212
[dependencies]
1313
once_cell = { workspace = true }
1414
opentelemetry = { path = "../../../opentelemetry" }
15-
opentelemetry_sdk = { path = "../../../opentelemetry-sdk", features = ["rt-tokio", "experimental_metrics_periodicreader_with_async_runtime"]}
16-
opentelemetry-otlp = { path = "../..", features = ["http-proto", "http-json", "logs", "internal-logs"]}
15+
opentelemetry_sdk = { path = "../../../opentelemetry-sdk" }
16+
opentelemetry-otlp = { path = "../..", features = ["http-proto", "http-json", "logs", "internal-logs"], default-features = false}
1717
opentelemetry-appender-tracing = { path = "../../../opentelemetry-appender-tracing", default-features = false}
1818

1919
tokio = { workspace = true, features = ["full"] }

opentelemetry-otlp/examples/basic-otlp-http/Dockerfile

-6
This file was deleted.

opentelemetry-otlp/examples/basic-otlp-http/README.md

+6-31
Original file line numberDiff line numberDiff line change
@@ -16,46 +16,25 @@ recommended approach when using OTLP exporters. While it can be modified to use
1616
a `SimpleExporter`, this requires making the main function a regular main and
1717
*not* tokio main.
1818

19-
// TODO: Document `hyper` feature flag when using SimpleProcessor.
19+
// TODO: Document how to use hyper client.
2020

2121
## Usage
2222

23-
### `docker-compose`
24-
25-
By default runs against the `otel/opentelemetry-collector:latest` image, and uses `reqwest-client`
26-
as the http client, using http as the transport.
27-
28-
```shell
29-
docker-compose up
30-
```
31-
32-
In another terminal run the application `cargo run`
33-
34-
The docker-compose terminal will display logs, traces, metrics.
35-
36-
Press Ctrl+C to stop the collector, and then tear it down:
37-
38-
```shell
39-
docker-compose down
40-
```
41-
42-
### Manual
43-
44-
If you don't want to use `docker-compose`, you can manually run the `otel/opentelemetry-collector` container
45-
and inspect the logs to see traces being transferred.
23+
Run the `otel/opentelemetry-collector` container using docker
24+
and inspect the logs to see the exported telemetry.
4625

4726
On Unix based systems use:
4827

4928
```shell
5029
# From the current directory, run `opentelemetry-collector`
51-
docker run --rm -it -p 4318:4318 -v $(pwd):/cfg otel/opentelemetry-collector:latest --config=/cfg/otel-collector-config.yaml
30+
docker run --rm -it -p 4317:4317 -p 4318:4318 -v $(pwd):/cfg otel/opentelemetry-collector:latest --config=/cfg/otel-collector-config.yaml
5231
```
5332

5433
On Windows use:
5534

5635
```shell
5736
# From the current directory, run `opentelemetry-collector`
58-
docker run --rm -it -p 4318:4318 -v "%cd%":/cfg otel/opentelemetry-collector:latest --config=/cfg/otel-collector-config.yaml
37+
docker run --rm -it -p 4317:4317 -p 4318:4318 -v "%cd%":/cfg otel/opentelemetry-collector:latest --config=/cfg/otel-collector-config.yaml
5938
```
6039

6140
Run the app which exports logs, metrics and traces via OTLP to the collector
@@ -64,11 +43,7 @@ Run the app which exports logs, metrics and traces via OTLP to the collector
6443
cargo run
6544
```
6645

67-
By default the app will use a `reqwest` client to send. A hyper 0.14 client can be used with the `hyper` feature enabled
68-
69-
```shell
70-
cargo run --no-default-features --features=hyper
71-
```
46+
The app will use a `reqwest-blocking` client to send.
7247

7348
## View results
7449

opentelemetry-otlp/examples/basic-otlp-http/docker-compose.yaml

-15
This file was deleted.

opentelemetry-otlp/examples/basic-otlp-http/src/main.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,8 @@ fn init_metrics() -> Result<opentelemetry_sdk::metrics::SdkMeterProvider, Metric
6969
.build())
7070
}
7171

72-
// #[tokio::main]
73-
// TODO: Re-enable tokio::main, if needed, after
74-
fn main() -> Result<(), Box<dyn Error + Send + Sync + 'static>> {
72+
#[tokio::main]
73+
async fn main() -> Result<(), Box<dyn Error + Send + Sync + 'static>> {
7574
let logger_provider = init_logs()?;
7675

7776
// Create a new OpenTelemetryTracingBridge using the above LoggerProvider.

opentelemetry-otlp/examples/basic-otlp/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ publish = false
88
[dependencies]
99
once_cell = { workspace = true }
1010
opentelemetry = { path = "../../../opentelemetry" }
11-
opentelemetry_sdk = { path = "../../../opentelemetry-sdk", features = ["rt-tokio"] }
11+
opentelemetry_sdk = { path = "../../../opentelemetry-sdk" }
1212
opentelemetry-otlp = { path = "../../../opentelemetry-otlp", features = ["grpc-tonic"] }
1313
tokio = { version = "1.0", features = ["full"] }
1414
opentelemetry-appender-tracing = { path = "../../../opentelemetry-appender-tracing", default-features = false}

opentelemetry-otlp/examples/basic-otlp/Dockerfile

-6
This file was deleted.

opentelemetry-otlp/examples/basic-otlp/README.md

+4-25
Original file line numberDiff line numberDiff line change
@@ -49,42 +49,21 @@ fn main() -> Result<(), Box<dyn Error + Send + Sync + 'static>> {
4949

5050
## Usage
5151

52-
### `docker-compose`
53-
54-
By default runs against the `otel/opentelemetry-collector:latest` image, and uses the `tonic`'s
55-
`grpc` example as the transport.
56-
57-
```shell
58-
docker-compose up
59-
```
60-
61-
In another terminal run the application `cargo run`
62-
63-
The docker-compose terminal will display logs, traces, metrics.
64-
65-
Press Ctrl+C to stop the collector, and then tear it down:
66-
67-
```shell
68-
docker-compose down
69-
```
70-
71-
### Manual
72-
73-
If you don't want to use `docker-compose`, you can manually run the `otel/opentelemetry-collector` container
74-
and inspect the logs to see traces being transferred.
52+
Run the `otel/opentelemetry-collector` container using docker
53+
and inspect the logs to see the exported telemetry.
7554

7655
On Unix based systems use:
7756

7857
```shell
7958
# From the current directory, run `opentelemetry-collector`
80-
docker run --rm -it -p 4317:4317 -v $(pwd):/cfg otel/opentelemetry-collector:latest --config=/cfg/otel-collector-config.yaml
59+
docker run --rm -it -p 4317:4317 -p 4318:4318 -v $(pwd):/cfg otel/opentelemetry-collector:latest --config=/cfg/otel-collector-config.yaml
8160
```
8261

8362
On Windows use:
8463

8564
```shell
8665
# From the current directory, run `opentelemetry-collector`
87-
docker run --rm -it -p 4317:4317 -v "%cd%":/cfg otel/opentelemetry-collector:latest --config=/cfg/otel-collector-config.yaml
66+
docker run --rm -it -p 4317:4317 -p 4318:4318 -v "%cd%":/cfg otel/opentelemetry-collector:latest --config=/cfg/otel-collector-config.yaml
8867
```
8968

9069
Run the app which exports logs, metrics and traces via OTLP to the collector

opentelemetry-otlp/examples/basic-otlp/docker-compose.yaml

-15
This file was deleted.

opentelemetry-sdk/src/logs/log_processor.rs

+8
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,14 @@ type LogsData = Box<(LogRecord, InstrumentationScope)>;
223223
/// - **Export timeout**: Maximum duration allowed for an export operation.
224224
/// - **Scheduled delay**: Frequency at which the batch is exported.
225225
///
226+
/// When using this processor with the OTLP Exporter, the following exporter
227+
/// features are supported:
228+
/// - `grpc-tonic`: This requires `MeterProvider` to be created within a tokio
229+
/// runtime.
230+
/// - `reqwest-blocking-client`: Works with a regular `main` or `tokio::main`.
231+
///
232+
/// In other words, other clients like `reqwest` and `hyper` are not supported.
233+
///
226234
/// ### Using a BatchLogProcessor:
227235
///
228236
/// ```rust

opentelemetry-sdk/src/metrics/periodic_reader.rs

+14-23
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,6 @@ const METRIC_EXPORT_INTERVAL_NAME: &str = "OTEL_METRIC_EXPORT_INTERVAL";
2626
const METRIC_EXPORT_TIMEOUT_NAME: &str = "OTEL_METRIC_EXPORT_TIMEOUT";
2727

2828
/// Configuration options for [PeriodicReader].
29-
///
30-
/// A periodic reader is a [MetricReader] that collects and exports metric data
31-
/// to the exporter at a defined interval.
32-
///
33-
/// By default, the returned [MetricReader] will collect and export data every
34-
/// 60 seconds. The export time is not counted towards the interval between
35-
/// attempts. PeriodicReader itself does not enforce timeout. Instead timeout
36-
/// is passed on to the exporter for each export attempt.
37-
///
38-
/// The [collect] method of the returned [MetricReader] continues to gather and
39-
/// return metric data to the user. It will not automatically send that data to
40-
/// the exporter outside of the predefined interval.
41-
///
42-
/// [collect]: MetricReader::collect
4329
#[derive(Debug)]
4430
pub struct PeriodicReaderBuilder<E> {
4531
interval: Duration,
@@ -104,20 +90,25 @@ where
10490
}
10591
}
10692

107-
/// A [MetricReader] that continuously collects and exports metric data at a set
93+
/// A [MetricReader] that continuously collects and exports metrics at a set
10894
/// interval.
10995
///
110-
/// By default, PeriodicReader will collect and export data every
111-
/// 60 seconds. The export time is not counted towards the interval between
112-
/// attempts. PeriodicReader itself does not enforce timeout.
113-
/// Instead timeout is passed on to the exporter for each export attempt.
96+
/// By default, `PeriodicReader` will collect and export metrics every 60
97+
/// seconds. The export time is not counted towards the interval between
98+
/// attempts. `PeriodicReader` itself does not enforce a timeout. Instead, the
99+
/// timeout is passed on to the configured exporter for each export attempt.
114100
///
115-
/// The [collect] method of the returned continues to gather and
116-
/// return metric data to the user. It will not automatically send that data to
117-
/// the exporter outside of the predefined interval.
101+
/// `PeriodicReader` spawns a background thread to handle the periodic
102+
/// collection and export of metrics. The background thread will continue to run
103+
/// until `shutdown()` is called.
118104
///
105+
/// When using this reader with the OTLP Exporter, the following exporter
106+
/// features are supported:
107+
/// - `grpc-tonic`: This requires `MeterProvider` to be created within a tokio
108+
/// runtime.
109+
/// - `reqwest-blocking-client`: Works with a regular `main` or `tokio::main`.
119110
///
120-
/// [collect]: MetricReader::collect
111+
/// In other words, other clients like `reqwest` and `hyper` are not supported.
121112
///
122113
/// # Example
123114
///

0 commit comments

Comments
 (0)