Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 359babe

Browse files
authoredMar 12, 2024··
Merge branch 'main' into otel-json
2 parents 5d5e06e + a34c5ee commit 359babe

File tree

14 files changed

+2168
-1229
lines changed

14 files changed

+2168
-1229
lines changed
 

‎.github/workflows/ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ jobs:
5353
external-types:
5454
strategy:
5555
matrix:
56-
example: [opentelemetry, opentelemetry-sdk]
56+
example: [opentelemetry, opentelemetry-sdk, opentelemetry-otlp, opentelemetry-zipkin]
5757
runs-on: ubuntu-latest
5858
steps:
5959
- uses: actions/checkout@v4

‎.github/workflows/markdown-link-check.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
- uses: actions/checkout@v4
1616

1717
- name: Install markdown-link-check
18-
run: npm install -g markdown-link-check
18+
run: npm install -g markdown-link-check@3.11.2
1919

2020
- name: Run markdown-link-check
2121
run: |

‎RELEASING.md

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Releasing OpenTelemetry Rust
2+
3+
The primary audience for this is the SIG Maintainers. It provides the list of steps for how to release the crates and the
4+
considerations to make before releasing the crate. It may provide use to consumers of the crate if/when we develop a
5+
release cadence.
6+
7+
## Release cadence
8+
9+
As of Feb 2024, there is no established cadence for the OpenTelemetry crates. The balance is required between too many
10+
breaking changes in a single release, and since we have instability flipping between implementations across 0.x
11+
releases. Perhaps once we've established a 1.0 we can consider adopting a consistent release cadence.
12+
13+
## Considerations
14+
15+
A draft PR can be created, but before releasing consider the following:
16+
17+
* Are there any pending pull requests which should be included in the next release?
18+
* Are they blockers?
19+
* Are there any unresolved issues which should be resolved before the next release?
20+
* Bring it up at a SIG meeting, this can usually get some of these questions answered sooner than later. It will also
21+
help establish a person to perform the release. Ideally this can be someone different each time to ensure that the
22+
process is documented.
23+
24+
## Steps to Release
25+
26+
1. Create a release PR
27+
- For each crate
28+
- Bump appropriate version
29+
- Update change logs to reflect release version.
30+
- Update API/SDK version as necessary
31+
- Attach `integration test` label to the PR to run integration tests
32+
- If there's a large enough set of changes, consider writing a migration guide.
33+
2. Merge the PR
34+
- Get reviews from other Maintainers
35+
- Ensure that there haven't been any interfering PRs
36+
3. Tag the release commit based on the [tagging convention](#tagging-convention). It should usually be a bump on minor version before 1.0
37+
4. Create Github Release
38+
5. [Publish](#publishing-crates) to crates.io using the version as of the release commit
39+
6. Post to [#otel-rust](https://cloud-native.slack.com/archives/C03GDP0H023) on CNCF Slack.
40+
41+
42+
## Tagging Convention
43+
44+
For each crate: it should be `<crate-name>-<version>` `<version>` being the simple `X.Y.Z`.
45+
46+
## Publishing Crates
47+
48+
For now we use the [basic procedure](https://doc.rust-lang.org/cargo/reference/publishing.html) from crates.io.
49+
50+
Follow this for each crate as necessary.
51+
52+
For any new crates remember to add open-telemetry/rust-maintainers to the list.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Copyright The OpenTelemetry Authors
2+
# SPDX-License-Identifier: Apache-2.0
3+
# This is used with cargo-check-external-types to reduce the surface area of downstream crates from
4+
# the public API. Ideally this can have a few exceptions as possible.
5+
allowed_external_types = [
6+
"opentelemetry::*",
7+
"opentelemetry_http::*",
8+
"opentelemetry_sdk::*",
9+
# http is a pre 1.0 crate
10+
"http::uri::InvalidUri",
11+
"http::header::name::InvalidHeaderName",
12+
"http::header::value::InvalidHeaderValue",
13+
# prost is a pre 1.0 crate
14+
"prost::error::EncodeError",
15+
# tonic is a pre 1.0 crate
16+
"tonic::status::Code",
17+
"tonic::status::Status",
18+
"tonic::metadata::map::MetadataMap",
19+
"tonic::transport::channel::Channel",
20+
"tonic::transport::error::Error",
21+
"tonic::service::interceptor::Interceptor",
22+
]

‎opentelemetry-sdk/src/metrics/mod.rs

+109
Original file line numberDiff line numberDiff line change
@@ -590,6 +590,115 @@ mod tests {
590590
);
591591
}
592592

593+
// "multi_thread" tokio flavor must be used else flush won't
594+
// be able to make progress!
595+
#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
596+
#[ignore = "Known bug: https://github.com/open-telemetry/opentelemetry-rust/issues/1598"]
597+
async fn delta_memory_efficiency_test() {
598+
// Run this test with stdout enabled to see output.
599+
// cargo test delta_memory_efficiency_test --features=metrics,testing -- --nocapture
600+
601+
// Arrange
602+
let exporter = InMemoryMetricsExporterBuilder::new()
603+
.with_temporality_selector(DeltaTemporalitySelector())
604+
.build();
605+
let reader = PeriodicReader::builder(exporter.clone(), runtime::Tokio).build();
606+
let meter_provider = SdkMeterProvider::builder().with_reader(reader).build();
607+
608+
// Act
609+
let meter = meter_provider.meter("test");
610+
let counter = meter
611+
.u64_counter("my_counter")
612+
.with_unit(Unit::new("my_unit"))
613+
.init();
614+
counter.add(1, &[KeyValue::new("key1", "value1")]);
615+
counter.add(1, &[KeyValue::new("key1", "value1")]);
616+
counter.add(1, &[KeyValue::new("key1", "value1")]);
617+
counter.add(1, &[KeyValue::new("key1", "value1")]);
618+
counter.add(1, &[KeyValue::new("key1", "value1")]);
619+
620+
counter.add(1, &[KeyValue::new("key1", "value2")]);
621+
counter.add(1, &[KeyValue::new("key1", "value2")]);
622+
counter.add(1, &[KeyValue::new("key1", "value2")]);
623+
624+
meter_provider.force_flush().unwrap();
625+
626+
// Assert
627+
let resource_metrics = exporter
628+
.get_finished_metrics()
629+
.expect("metrics are expected to be exported.");
630+
assert!(!resource_metrics.is_empty());
631+
let metric = &resource_metrics[0].scope_metrics[0].metrics[0];
632+
assert_eq!(metric.name, "my_counter");
633+
assert_eq!(metric.unit.as_str(), "my_unit");
634+
let sum = metric
635+
.data
636+
.as_any()
637+
.downcast_ref::<data::Sum<u64>>()
638+
.expect("Sum aggregation expected for Counter instruments by default");
639+
640+
// Expecting 2 time-series.
641+
assert_eq!(sum.data_points.len(), 2);
642+
assert!(sum.is_monotonic, "Counter should produce monotonic.");
643+
assert_eq!(
644+
sum.temporality,
645+
data::Temporality::Delta,
646+
"Should produce Delta as configured"
647+
);
648+
649+
// find and validate key1=value1 datapoint
650+
let mut data_point1 = None;
651+
for datapoint in &sum.data_points {
652+
if datapoint
653+
.attributes
654+
.iter()
655+
.any(|(k, v)| k.as_str() == "key1" && v.as_str() == "value1")
656+
{
657+
data_point1 = Some(datapoint);
658+
}
659+
}
660+
assert_eq!(
661+
data_point1
662+
.expect("datapoint with key1=value1 expected")
663+
.value,
664+
5
665+
);
666+
667+
// find and validate key1=value2 datapoint
668+
let mut data_point1 = None;
669+
for datapoint in &sum.data_points {
670+
if datapoint
671+
.attributes
672+
.iter()
673+
.any(|(k, v)| k.as_str() == "key1" && v.as_str() == "value2")
674+
{
675+
data_point1 = Some(datapoint);
676+
}
677+
}
678+
assert_eq!(
679+
data_point1
680+
.expect("datapoint with key1=value2 expected")
681+
.value,
682+
3
683+
);
684+
685+
// flush again, and validate that nothing is flushed
686+
// as delta temporality.
687+
meter_provider.force_flush().unwrap();
688+
let resource_metrics = exporter
689+
.get_finished_metrics()
690+
.expect("metrics are expected to be exported.");
691+
println!("resource_metrics: {:?}", resource_metrics);
692+
assert!(resource_metrics.is_empty(), "No metrics should be exported as no new measurements were recorded since last collect.");
693+
}
694+
695+
struct DeltaTemporalitySelector();
696+
impl TemporalitySelector for DeltaTemporalitySelector {
697+
fn temporality(&self, _kind: InstrumentKind) -> Temporality {
698+
Temporality::Delta
699+
}
700+
}
701+
593702
struct TestContext {
594703
exporter: InMemoryMetricsExporter,
595704
meter_provider: SdkMeterProvider,

‎opentelemetry-semantic-conventions/CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
## vNext
44

5+
### Changed
6+
7+
- Update to [v1.24.0](https://github.com/open-telemetry/semantic-conventions/releases/tag/v1.24.0) of the semantic conventions.
8+
[#1596](https://github.com/open-telemetry/opentelemetry-rust/pull/1596)
9+
510
## v0.14.0
611

712
### Changed

‎opentelemetry-semantic-conventions/scripts/generate-consts-from-spec.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
55
CRATE_DIR="${SCRIPT_DIR}/../"
66

77
# freeze the spec version and generator version to make generation reproducible
8-
SPEC_VERSION=1.21.0
9-
SEMCOVGEN_VERSION=0.19.0
8+
SPEC_VERSION=1.24.0
9+
SEMCOVGEN_VERSION=0.23.0
1010

1111
cd "$CRATE_DIR"
1212

‎opentelemetry-semantic-conventions/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ pub mod trace;
2020

2121
/// The schema URL that matches the version of the semantic conventions that
2222
/// this crate defines.
23-
pub const SCHEMA_URL: &str = "https://opentelemetry.io/schemas/1.21.0";
23+
pub const SCHEMA_URL: &str = "https://opentelemetry.io/schemas/1.24.0";

‎opentelemetry-semantic-conventions/src/resource.rs

+510-388
Large diffs are not rendered by default.

‎opentelemetry-semantic-conventions/src/trace.rs

+1,319-836
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Copyright The OpenTelemetry Authors
2+
# SPDX-License-Identifier: Apache-2.0
3+
# This is used with cargo-check-external-types to reduce the surface area of downstream crates from
4+
# the public API. Ideally this can have a few exceptions as possible.
5+
allowed_external_types = [
6+
"opentelemetry::*",
7+
"opentelemetry_http::*",
8+
"opentelemetry_sdk::*",
9+
# http is a pre 1.0 crate
10+
"http::error::Error",
11+
"http::uri::InvalidUri",
12+
]

‎opentelemetry/Cargo.toml

+10
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,13 @@ otel_unstable = []
4242

4343
[dev-dependencies]
4444
opentelemetry_sdk = { path = "../opentelemetry-sdk" } # for documentation tests
45+
criterion = { version = "0.3" }
46+
47+
[[bench]]
48+
name = "metrics"
49+
harness = false
50+
required-features = ["metrics"]
51+
52+
[[bench]]
53+
name = "attributes"
54+
harness = false

‎opentelemetry/benches/attributes.rs

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
use criterion::{black_box, criterion_group, criterion_main, Criterion};
2+
use opentelemetry::KeyValue;
3+
4+
// Run this benchmark with:
5+
// cargo bench --bench attributes
6+
7+
fn criterion_benchmark(c: &mut Criterion) {
8+
attributes_creation(c);
9+
}
10+
11+
fn attributes_creation(c: &mut Criterion) {
12+
c.bench_function("CreateOTelKeyValue", |b| {
13+
b.iter(|| {
14+
let _v1 = black_box(KeyValue::new("attribute1", "value1"));
15+
});
16+
});
17+
18+
c.bench_function("CreateKeyValueTuple", |b| {
19+
b.iter(|| {
20+
let _v1 = black_box(("attribute1", "value1"));
21+
});
22+
});
23+
24+
#[allow(clippy::useless_vec)]
25+
c.bench_function("CreateVector_KeyValue", |b| {
26+
b.iter(|| {
27+
let _v1 = black_box(vec![
28+
KeyValue::new("attribute1", "value1"),
29+
KeyValue::new("attribute2", "value2"),
30+
KeyValue::new("attribute3", "value3"),
31+
KeyValue::new("attribute4", "value4"),
32+
]);
33+
});
34+
});
35+
36+
#[allow(clippy::useless_vec)]
37+
c.bench_function("CreateVector_StringPairs", |b| {
38+
b.iter(|| {
39+
let _v1 = black_box(vec![
40+
("attribute1", "value1"),
41+
("attribute2", "value2"),
42+
("attribute3", "value3"),
43+
("attribute4", "value4"),
44+
]);
45+
});
46+
});
47+
}
48+
49+
criterion_group!(benches, criterion_benchmark);
50+
51+
criterion_main!(benches);

‎opentelemetry/benches/metrics.rs

+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
use criterion::{criterion_group, criterion_main, Criterion};
2+
use opentelemetry::{
3+
metrics::{noop::NoopMeterProvider, Counter, MeterProvider as _},
4+
KeyValue,
5+
};
6+
7+
// Run this benchmark with:
8+
// cargo bench --bench metrics --features=metrics
9+
10+
fn create_counter() -> Counter<u64> {
11+
let meter_provider: NoopMeterProvider = NoopMeterProvider::default();
12+
let meter = meter_provider.meter("benchmarks");
13+
let counter = meter.u64_counter("counter_bench").init();
14+
counter
15+
}
16+
17+
fn criterion_benchmark(c: &mut Criterion) {
18+
counter_add(c);
19+
}
20+
21+
fn counter_add(c: &mut Criterion) {
22+
let counter = create_counter();
23+
24+
c.bench_function("Counter_NoAttributes", |b| {
25+
b.iter(|| {
26+
counter.add(1, &[]);
27+
});
28+
});
29+
30+
c.bench_function("Counter_AddWithInlineStaticAttributes", |b| {
31+
b.iter(|| {
32+
counter.add(
33+
1,
34+
&[
35+
KeyValue::new("attribute1", "value1"),
36+
KeyValue::new("attribute2", "value2"),
37+
KeyValue::new("attribute3", "value3"),
38+
KeyValue::new("attribute4", "value4"),
39+
],
40+
);
41+
});
42+
});
43+
44+
c.bench_function("Counter_AddWithStaticArray", |b| {
45+
b.iter(|| {
46+
let kv = [
47+
KeyValue::new("attribute1", "value1"),
48+
KeyValue::new("attribute2", "value2"),
49+
KeyValue::new("attribute3", "value3"),
50+
KeyValue::new("attribute4", "value4"),
51+
];
52+
53+
counter.add(1, &kv);
54+
});
55+
});
56+
57+
c.bench_function("Counter_AddWithDynamicAttributes", |b| {
58+
b.iter(|| {
59+
let kv = vec![
60+
KeyValue::new("attribute1", "value1"),
61+
KeyValue::new("attribute2", "value2"),
62+
KeyValue::new("attribute3", "value3"),
63+
KeyValue::new("attribute4", "value4"),
64+
];
65+
66+
counter.add(1, &kv);
67+
});
68+
});
69+
}
70+
71+
criterion_group!(benches, criterion_benchmark);
72+
73+
criterion_main!(benches);

0 commit comments

Comments
 (0)
Please sign in to comment.