Skip to content

Commit

Permalink
Fix periodic reader to trigger first exporter at the interval (#1766)
Browse files Browse the repository at this point in the history
  • Loading branch information
cijothomas authored May 15, 2024
1 parent 0cc7228 commit 48112e0
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 7 deletions.
18 changes: 15 additions & 3 deletions opentelemetry-otlp/examples/basic-otlp-http/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,24 @@ docker-compose down
If you don't want to use `docker-compose`, you can manually run the `otel/opentelemetry-collector` container
and inspect the logs to see traces being transferred.

On Unix based systems use:

```shell
# From the current directory, run `opentelemetry-collector`
$ docker run --rm -it -p 4318:4318 -v $(pwd):/cfg otel/opentelemetry-collector:latest --config=/cfg/otel-collector-config.yaml
docker run --rm -it -p 4318:4318 -v $(pwd):/cfg otel/opentelemetry-collector:latest --config=/cfg/otel-collector-config.yaml
```

On Windows use:

# Run the app which exports logs, metrics and traces via OTLP to the collector.
$ cargo run
```shell
# From the current directory, run `opentelemetry-collector`
docker run --rm -it -p 4318:4318 -v "%cd%":/cfg otel/opentelemetry-collector:latest --config=/cfg/otel-collector-config.yaml
```

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

```shell
cargo run
```

## View results
Expand Down
18 changes: 15 additions & 3 deletions opentelemetry-otlp/examples/basic-otlp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,24 @@ docker-compose down
If you don't want to use `docker-compose`, you can manually run the `otel/opentelemetry-collector` container
and inspect the logs to see traces being transferred.

On Unix based systems use:

```shell
# From the current directory, run `opentelemetry-collector`
$ docker run --rm -it -p 4317:4317 -v $(pwd):/cfg otel/opentelemetry-collector:latest --config=/cfg/otel-collector-config.yaml
docker run --rm -it -p 4317:4317 -v $(pwd):/cfg otel/opentelemetry-collector:latest --config=/cfg/otel-collector-config.yaml
```

On Windows use:

# Run the app which exports logs, metrics and traces via OTLP to the collector.
$ cargo run
```shell
# From the current directory, run `opentelemetry-collector`
docker run --rm -it -p 4317:4317 -v "%cd%":/cfg otel/opentelemetry-collector:latest --config=/cfg/otel-collector-config.yaml
```

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

```shell
cargo run
```

## View results
Expand Down
1 change: 0 additions & 1 deletion opentelemetry-otlp/examples/basic-otlp/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ async fn main() -> Result<(), Box<dyn Error + Send + Sync + 'static>> {
for _ in 0..10 {
counter.add(1, &[KeyValue::new("test_key", "test_value")]);
}
counter.add(1, &[KeyValue::new("test_key", "test_value")]);

tracer.in_span("Main operation", |cx| {
let span = cx.span();
Expand Down
3 changes: 3 additions & 0 deletions opentelemetry-sdk/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
[1612](https://github.com/open-telemetry/opentelemetry-rust/pull/1612/files)
- [#1422](https://github.com/open-telemetry/opentelemetry-rust/pull/1422)
Fix metrics aggregation bug when using Views to drop attributes.
- [#1766](https://github.com/open-telemetry/opentelemetry-rust/pull/1766)
Fix Metrics PeriodicReader to trigger first collect/export at the first interval
instead of doing it right away.
- [#1623](https://github.com/open-telemetry/opentelemetry-rust/pull/1623) Add Drop implementation for SdkMeterProvider,
which shuts down metricreaders, thereby allowing metrics still in memory to be flushed out.
- **Breaking** [#1624](https://github.com/open-telemetry/opentelemetry-rust/pull/1624) Remove `OsResourceDetector` and
Expand Down
1 change: 1 addition & 0 deletions opentelemetry-sdk/src/metrics/periodic_reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ where
let ticker = self
.runtime
.interval(self.interval)
.skip(1) // The ticker is fired immediately, so we should skip the first one to align with the interval.
.map(|_| Message::Export);

let messages = Box::pin(stream::select(message_receiver, ticker));
Expand Down

0 comments on commit 48112e0

Please sign in to comment.