Skip to content

Commit c811133

Browse files
authored
Merge branch 'main' into fix-metrics-u64-serialization
2 parents c64d3b3 + 1904d4b commit c811133

File tree

10 files changed

+315
-98
lines changed

10 files changed

+315
-98
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ for specific dates and for Zoom meeting links. "OTel Rust SIG" is the name of
184184
meeting for this group.
185185

186186
Meeting notes are available as a public [Google
187-
doc](https://docs.google.com/document/d/1tGKuCsSnyT2McDncVJrMgg74_z8V06riWZa0Sr79I_4/edit).
187+
doc](https://docs.google.com/document/d/12upOzNk8c3SFTjsL6IRohCWMgzLKoknSCOOdMakbWo4/edit).
188188
If you have trouble accessing the doc, please get in touch on
189189
[Slack](https://cloud-native.slack.com/archives/C03GDP0H023).
190190

opentelemetry-otlp/CHANGELOG.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@
66
- Feature flag "populate-logs-event-name" is removed as no longer relevant.
77
LogRecord's `event_name()` is now automatically populated on the newly added
88
"event_name" field in LogRecord proto definition.
9-
9+
- Remove "grpc-tonic" feature from default, and instead add "http-proto" and
10+
"reqwest-blocking-client" features as default, to align with the
11+
specification.
12+
[2516](https://github.com/open-telemetry/opentelemetry-rust/pull/2516)
1013

1114
## 0.27.0
1215

opentelemetry-otlp/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ internal-logs = ["tracing", "opentelemetry/internal-logs"]
6262
# add ons
6363
serialize = ["serde", "serde_json"]
6464

65-
default = ["grpc-tonic", "trace", "metrics", "logs", "internal-logs"]
65+
default = ["http-proto", "reqwest-blocking-client", "trace", "metrics", "logs", "internal-logs"]
6666

6767
# grpc using tonic
6868
grpc-tonic = ["tonic", "prost", "http", "tokio", "opentelemetry-proto/gen-tonic"]

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

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

88
[features]
9-
default = ["reqwest-blocking"]
109
reqwest-blocking = ["opentelemetry-otlp/reqwest-blocking-client"]
1110
hyper = ["opentelemetry-otlp/hyper-client"]
1211

1312
[dependencies]
1413
once_cell = { workspace = true }
1514
opentelemetry = { path = "../../../opentelemetry" }
1615
opentelemetry_sdk = { path = "../../../opentelemetry-sdk", features = ["rt-tokio", "experimental_metrics_periodicreader_with_async_runtime"]}
17-
opentelemetry-otlp = { path = "../..", features = ["http-proto", "http-json", "logs", "internal-logs"] , default-features = false}
16+
opentelemetry-otlp = { path = "../..", features = ["http-proto", "http-json", "logs", "internal-logs"]}
1817
opentelemetry-appender-tracing = { path = "../../../opentelemetry-appender-tracing", default-features = false}
1918

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

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ publish = false
99
once_cell = { workspace = true }
1010
opentelemetry = { path = "../../../opentelemetry" }
1111
opentelemetry_sdk = { path = "../../../opentelemetry-sdk", features = ["rt-tokio"] }
12-
opentelemetry-otlp = { path = "../../../opentelemetry-otlp" }
12+
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}
1515
tracing = { workspace = true, features = ["std"]}

opentelemetry-proto/Cargo.toml

+3-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ path = "tests/json_serde.rs"
3030

3131
[features]
3232
default = ["full"]
33-
full = ["gen-tonic", "trace", "logs", "metrics", "zpages", "with-serde"]
33+
full = ["gen-tonic", "trace", "logs", "metrics", "zpages", "with-serde", "internal-logs"]
3434

3535
# crates used to generate rs files
3636
gen-tonic = ["gen-tonic-messages", "tonic/transport"]
@@ -44,6 +44,7 @@ zpages = ["trace"]
4444
testing = ["opentelemetry/testing"]
4545

4646
# add ons
47+
internal-logs = ["tracing"]
4748
with-schemars = ["schemars"]
4849
with-serde = ["serde", "hex"]
4950

@@ -55,6 +56,7 @@ opentelemetry_sdk = { version = "0.27", default-features = false, path = "../ope
5556
schemars = { version = "0.8", optional = true }
5657
serde = { workspace = true, optional = true, features = ["serde_derive"] }
5758
hex = { version = "0.4.3", optional = true }
59+
tracing = {workspace = true, optional = true} # optional for opentelemetry internal logging
5860

5961
[dev-dependencies]
6062
opentelemetry = { features = ["testing"], path = "../opentelemetry" }

opentelemetry-sdk/benches/metrics_counter.rs

+67-9
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
/*
22
The benchmark results:
33
criterion = "0.5.1"
4-
rustc 1.82.0 (f6e511eec 2024-10-15)
5-
OS: Ubuntu 22.04.3 LTS (5.15.167.4-microsoft-standard-WSL2)
6-
Hardware: AMD EPYC 7763 64-Core Processor - 2.44 GHz, 16vCPUs,
4+
rustc 1.83.0 (90b35a623 2024-11-26)
5+
OS: Ubuntu 22.04.4 LTS (5.15.167.4-microsoft-standard-WSL2)
6+
Hardware: Intel(R) Xeon(R) Platinum 8370C CPU @ 2.80GHz 2.79 GHz
77
RAM: 64.0 GB
8-
| Test | Average time|
9-
|--------------------------------|-------------|
10-
| Counter_Add_Sorted | 172 ns |
11-
| Counter_Add_Unsorted | 183 ns |
12-
| Counter_Overflow | 562 ns |
13-
| ThreadLocal_Random_Generator_5 | 37 ns |
8+
| Test | Average time|
9+
|-------------------------------------------------------|-------------|
10+
| Counter_Add_Sorted | 160 ns |
11+
| Counter_Add_Unsorted | 164 ns |
12+
| Counter_Add_Sorted_With_Non_Static_Values | 238 ns |
13+
| Counter_Overflow | 562 ns |
14+
| ThreadLocal_Random_Generator_5 | 37 ns |
1415
*/
1516

1617
use criterion::{criterion_group, criterion_main, BatchSize, Criterion};
@@ -51,6 +52,15 @@ fn create_counter(name: &'static str) -> Counter<u64> {
5152
fn criterion_benchmark(c: &mut Criterion) {
5253
counter_add_sorted(c);
5354
counter_add_unsorted(c);
55+
56+
let attribute_values: [String; 10] = (1..=10)
57+
.map(|i| format!("value{}", i))
58+
.collect::<Vec<String>>()
59+
.try_into()
60+
.expect("Expected a Vec of length 10");
61+
62+
counter_add_sorted_with_non_static_values(c, attribute_values);
63+
5464
counter_overflow(c);
5565
random_generator(c);
5666
}
@@ -127,6 +137,54 @@ fn counter_add_unsorted(c: &mut Criterion) {
127137
});
128138
}
129139

140+
fn counter_add_sorted_with_non_static_values(c: &mut Criterion, attribute_values: [String; 10]) {
141+
let counter = create_counter("Counter_Add_Sorted_With_Non_Static_Values");
142+
c.bench_function("Counter_Add_Sorted_With_Non_Static_Values", |b| {
143+
b.iter_batched(
144+
|| {
145+
// 4*4*10*10 = 1600 time series.
146+
CURRENT_RNG.with(|rng| {
147+
let mut rng = rng.borrow_mut();
148+
[
149+
rng.gen_range(0..4),
150+
rng.gen_range(0..4),
151+
rng.gen_range(0..10),
152+
rng.gen_range(0..10),
153+
]
154+
})
155+
},
156+
|rands| {
157+
let index_first_attribute = rands[0];
158+
let index_second_attribute = rands[1];
159+
let index_third_attribute = rands[2];
160+
let index_fourth_attribute = rands[3];
161+
counter.add(
162+
1,
163+
&[
164+
KeyValue::new(
165+
"attribute1",
166+
attribute_values[index_first_attribute].as_str().to_owned(),
167+
),
168+
KeyValue::new(
169+
"attribute2",
170+
attribute_values[index_second_attribute].as_str().to_owned(),
171+
),
172+
KeyValue::new(
173+
"attribute3",
174+
attribute_values[index_third_attribute].as_str().to_owned(),
175+
),
176+
KeyValue::new(
177+
"attribute4",
178+
attribute_values[index_fourth_attribute].as_str().to_owned(),
179+
),
180+
],
181+
);
182+
},
183+
BatchSize::SmallInput,
184+
);
185+
});
186+
}
187+
130188
fn counter_overflow(c: &mut Criterion) {
131189
let counter = create_counter("Counter_Overflow");
132190
// Cause overflow.

opentelemetry-sdk/benches/metrics_histogram.rs

+93-31
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
/*
22
The benchmark results:
33
criterion = "0.5.1"
4-
rustc 1.82.0 (f6e511eec 2024-10-15)
4+
rustc 1.83.0 (90b35a623 2024-11-26)
55
OS: Ubuntu 22.04.4 LTS (5.15.167.4-microsoft-standard-WSL2)
6-
Hardware: AMD EPYC 7763 64-Core Processor - 2.44 GHz, 16vCPUs,
6+
Hardware: Intel(R) Xeon(R) Platinum 8370C CPU @ 2.80GHz 2.79 GHz
77
RAM: 64.0 GB
8-
| Test | Average time|
9-
|--------------------------------|-------------|
10-
| Histogram_Record | 225.04 ns |
8+
| Test | Average time|
9+
|-------------------------------------------------------|-------------|
10+
| Histogram_Record | 186.24 ns |
11+
| Histogram_Record_With_Non_Static_Values | 264.70 ns |
1112
1213
*/
1314

14-
use criterion::{criterion_group, criterion_main, Criterion};
15+
use criterion::{criterion_group, criterion_main, BatchSize, Criterion};
1516
use opentelemetry::{
1617
metrics::{Histogram, MeterProvider as _},
1718
KeyValue,
@@ -48,36 +49,97 @@ fn create_histogram(name: &'static str) -> Histogram<u64> {
4849

4950
fn criterion_benchmark(c: &mut Criterion) {
5051
histogram_record(c);
52+
53+
let attribute_values: [String; 10] = (1..=10)
54+
.map(|i| format!("value{}", i))
55+
.collect::<Vec<String>>()
56+
.try_into()
57+
.expect("Expected a Vec of length 10");
58+
59+
histogram_record_with_non_static_values(c, attribute_values);
5160
}
5261

5362
fn histogram_record(c: &mut Criterion) {
5463
let histogram = create_histogram("Histogram_Record");
5564
c.bench_function("Histogram_Record", |b| {
56-
b.iter(|| {
57-
// 4*4*10*10 = 1600 time series.
58-
let rands = CURRENT_RNG.with(|rng| {
59-
let mut rng = rng.borrow_mut();
60-
[
61-
rng.gen_range(0..4),
62-
rng.gen_range(0..4),
63-
rng.gen_range(0..10),
64-
rng.gen_range(0..10),
65-
]
66-
});
67-
let index_first_attribute = rands[0];
68-
let index_second_attribute = rands[1];
69-
let index_third_attribute = rands[2];
70-
let index_fourth_attribute = rands[3];
71-
histogram.record(
72-
1,
73-
&[
74-
KeyValue::new("attribute1", ATTRIBUTE_VALUES[index_first_attribute]),
75-
KeyValue::new("attribute2", ATTRIBUTE_VALUES[index_second_attribute]),
76-
KeyValue::new("attribute3", ATTRIBUTE_VALUES[index_third_attribute]),
77-
KeyValue::new("attribute4", ATTRIBUTE_VALUES[index_fourth_attribute]),
78-
],
79-
);
80-
});
65+
b.iter_batched(
66+
|| {
67+
// 4*4*10*10 = 1600 time series.
68+
CURRENT_RNG.with(|rng| {
69+
let mut rng = rng.borrow_mut();
70+
[
71+
rng.gen_range(0..4),
72+
rng.gen_range(0..4),
73+
rng.gen_range(0..10),
74+
rng.gen_range(0..10),
75+
]
76+
})
77+
},
78+
|rands| {
79+
let index_first_attribute = rands[0];
80+
let index_second_attribute = rands[1];
81+
let index_third_attribute = rands[2];
82+
let index_fourth_attribute = rands[3];
83+
histogram.record(
84+
1,
85+
&[
86+
KeyValue::new("attribute1", ATTRIBUTE_VALUES[index_first_attribute]),
87+
KeyValue::new("attribute2", ATTRIBUTE_VALUES[index_second_attribute]),
88+
KeyValue::new("attribute3", ATTRIBUTE_VALUES[index_third_attribute]),
89+
KeyValue::new("attribute4", ATTRIBUTE_VALUES[index_fourth_attribute]),
90+
],
91+
);
92+
},
93+
BatchSize::SmallInput,
94+
);
95+
});
96+
}
97+
98+
fn histogram_record_with_non_static_values(c: &mut Criterion, attribute_values: [String; 10]) {
99+
let histogram = create_histogram("Histogram_Record_With_Non_Static_Values");
100+
c.bench_function("Histogram_Record_With_Non_Static_Values", |b| {
101+
b.iter_batched(
102+
|| {
103+
// 4*4*10*10 = 1600 time series.
104+
CURRENT_RNG.with(|rng| {
105+
let mut rng = rng.borrow_mut();
106+
[
107+
rng.gen_range(0..4),
108+
rng.gen_range(0..4),
109+
rng.gen_range(0..10),
110+
rng.gen_range(0..10),
111+
]
112+
})
113+
},
114+
|rands| {
115+
let index_first_attribute = rands[0];
116+
let index_second_attribute = rands[1];
117+
let index_third_attribute = rands[2];
118+
let index_fourth_attribute = rands[3];
119+
histogram.record(
120+
1,
121+
&[
122+
KeyValue::new(
123+
"attribute1",
124+
attribute_values[index_first_attribute].as_str().to_owned(),
125+
),
126+
KeyValue::new(
127+
"attribute2",
128+
attribute_values[index_second_attribute].as_str().to_owned(),
129+
),
130+
KeyValue::new(
131+
"attribute3",
132+
attribute_values[index_third_attribute].as_str().to_owned(),
133+
),
134+
KeyValue::new(
135+
"attribute4",
136+
attribute_values[index_fourth_attribute].as_str().to_owned(),
137+
),
138+
],
139+
);
140+
},
141+
BatchSize::SmallInput,
142+
);
81143
});
82144
}
83145

0 commit comments

Comments
 (0)