Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions examples/metrics-advanced/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,3 @@ Run the following, and the Metrics will be written out to stdout.
```shell
$ cargo run
```



24 changes: 16 additions & 8 deletions examples/metrics-advanced/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,23 @@ async fn main() -> Result<(), Box<dyn Error + Send + Sync + 'static>> {
.with_description("My histogram example description")
.build();

// Record measurements using the histogram instrument.
// This metric will have a cardinality limit of 2,
// as set in the view. Because of this, only the first two
// measurements will be recorded, and the rest will be folded
// into the overflow attribute.
// Record measurements using the histogram instrument. This metric will have
// a cardinality limit of 2, as set in the view. Because of this, only the
// first two distinct attribute combinations will be recorded, and the rest
// will be folded into the overflow attribute. Any number of measurements
// can be recorded as long as they use the same or already-seen attribute
// combinations.
histogram2.record(1.5, &[KeyValue::new("mykey1", "v1")]);

histogram2.record(1.2, &[KeyValue::new("mykey1", "v2")]);

// Repeatedly emitting measurements for "v1" and "v2" will not
// trigger overflow, as they are already seen attribute combinations.
histogram2.record(1.7, &[KeyValue::new("mykey1", "v1")]);
histogram2.record(1.8, &[KeyValue::new("mykey1", "v2")]);

// Emitting measurements for new attribute combinations will trigger
// overflow, as the cardinality limit of 2 has been reached.
// All the below measurements will be folded into the overflow attribute.
histogram2.record(1.23, &[KeyValue::new("mykey1", "v3")]);

histogram2.record(1.4, &[KeyValue::new("mykey1", "v4")]);
Expand All @@ -104,9 +112,9 @@ async fn main() -> Result<(), Box<dyn Error + Send + Sync + 'static>> {

histogram2.record(1.8, &[KeyValue::new("mykey1", "v7")]);

// Metrics are exported by default every 30 seconds when using stdout exporter,
// Metrics are exported by default every 60 seconds when using stdout exporter,
// however shutting down the MeterProvider here instantly flushes
// the metrics, instead of waiting for the 30 sec interval.
// the metrics, instead of waiting for the 60 sec interval.
meter_provider.shutdown()?;
Ok(())
}
3 changes: 0 additions & 3 deletions examples/metrics-basic/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,3 @@ Run the following, and the Metrics will be written out to stdout.
```shell
$ cargo run
```



4 changes: 2 additions & 2 deletions examples/metrics-basic/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,9 @@ async fn main() -> Result<(), Box<dyn Error>> {
})
.build();

// Metrics are exported by default every 30 seconds when using stdout
// Metrics are exported by default every 60 seconds when using stdout
// exporter, however shutting down the MeterProvider here instantly flushes
// the metrics, instead of waiting for the 30 sec interval. Shutdown returns
// the metrics, instead of waiting for the 60 sec interval. Shutdown returns
// a result, which is bubbled up to the caller The commented code below
// demonstrates handling the shutdown result, instead of bubbling up the
// error.
Expand Down
3 changes: 1 addition & 2 deletions opentelemetry-otlp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ serde_json = { workspace = true, optional = true }

[dev-dependencies]
tokio-stream = { workspace = true, features = ["net"] }
# need tokio runtime to run smoke tests.
opentelemetry_sdk = { features = ["trace", "rt-tokio", "testing"], path = "../opentelemetry-sdk" }
opentelemetry_sdk = { features = ["trace", "testing"], path = "../opentelemetry-sdk" }
tokio = { workspace = true, features = ["macros", "rt-multi-thread"] }
futures-util = { workspace = true }
temp-env = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion opentelemetry-stdout/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ opentelemetry_sdk = { version = "0.30", path = "../opentelemetry-sdk" }

[dev-dependencies]
opentelemetry = { path = "../opentelemetry", features = ["metrics"] }
opentelemetry_sdk = { path = "../opentelemetry-sdk", features = ["rt-tokio", "metrics"] }
opentelemetry_sdk = { path = "../opentelemetry-sdk", features = ["metrics"] }
opentelemetry-appender-tracing = { workspace = true }
tracing = { workspace = true, features = ["std"]}
tracing-subscriber = { workspace = true, features = ["registry", "std"] }
Expand Down