Skip to content

Commit 5a89cad

Browse files
authored
Merge branch 'main' into rust-2024
2 parents d953d12 + 1ddecb0 commit 5a89cad

File tree

27 files changed

+619
-188
lines changed

27 files changed

+619
-188
lines changed

.github/workflows/integration_tests.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,7 @@ jobs:
2323
with:
2424
components: rustfmt
2525
- uses: arduino/setup-protoc@v3
26+
with:
27+
repo-token: ${{ secrets.GITHUB_TOKEN }}
2628
- name: Run integration tests
2729
run: ./scripts/integration_tests.sh

.github/workflows/pr_criterion.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@ jobs:
88
runs-on: ubuntu-latest
99
if: ${{ contains(github.event.pull_request.labels.*.name, 'performance') }}
1010
steps:
11-
- uses: actions/checkout@v3
11+
- uses: actions/checkout@v4
1212
- uses: arduino/setup-protoc@v3
13+
with:
14+
repo-token: ${{ secrets.GITHUB_TOKEN }}
1315
- uses: dtolnay/rust-toolchain@master
1416
with:
1517
toolchain: stable

.github/workflows/pr_naming.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
runs-on: ubuntu-latest
1010
steps:
1111
- name: PR Conventional Commit Validation
12-
uses: ytanikin/[email protected].0
12+
uses: ytanikin/[email protected].1
1313
with:
1414
task_types: '["build","chore","ci","docs","feat","fix","perf","refactor","revert","test"]'
1515
add_label: 'false'

opentelemetry-appender-log/src/lib.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@
1212
//!
1313
//! ```
1414
//! # #[tokio::main] async fn main() {
15-
//! # use opentelemetry_sdk::logs::{BatchLogProcessor, LoggerProvider};
15+
//! # use opentelemetry_sdk::logs::{BatchLogProcessor, SdkLoggerProvider};
1616
//! # use opentelemetry_sdk::runtime;
1717
//! let exporter = opentelemetry_stdout::LogExporter::default();
1818
//!
19-
//! let logger_provider = LoggerProvider::builder()
20-
//! .with_log_processor(BatchLogProcessor::builder(exporter, runtime::Tokio).build())
19+
//! let logger_provider = SdkLoggerProvider::builder()
20+
//! .with_log_processor(BatchLogProcessor::builder(exporter).build())
2121
//! .build();
2222
//! # }
2323
//! ```
@@ -26,12 +26,12 @@
2626
//!
2727
//! ```
2828
//! # #[tokio::main] async fn main() {
29-
//! # use opentelemetry_sdk::logs::{BatchLogProcessor, LoggerProvider};
29+
//! # use opentelemetry_sdk::logs::{BatchLogProcessor, SdkLoggerProvider};
3030
//! # use opentelemetry_sdk::runtime;
3131
//! # use opentelemetry_appender_log::OpenTelemetryLogBridge;
3232
//! # let exporter = opentelemetry_stdout::LogExporter::default();
33-
//! # let logger_provider = LoggerProvider::builder()
34-
//! # .with_log_processor(BatchLogProcessor::builder(exporter, runtime::Tokio).build())
33+
//! # let logger_provider = SdkLoggerProvider::builder()
34+
//! # .with_log_processor(BatchLogProcessor::builder(exporter).build())
3535
//! # .build();
3636
//! let otel_log_appender = OpenTelemetryLogBridge::new(&logger_provider);
3737
//!

opentelemetry-appender-tracing/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ name = "logs"
4444
harness = false
4545
required-features = ["spec_unstable_logs_enabled"]
4646

47+
[[bench]]
48+
name = "log-attributes"
49+
harness = false
50+
4751
[lib]
4852
bench = false
4953

Lines changed: 271 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,271 @@
1+
/*
2+
// Run this benchmark with:
3+
// cargo bench --bench log-attributes
4+
// Adding results in comments for a quick reference.
5+
// Apple M4 Pro
6+
// Total Number of Cores: 14 (10 performance and 4 efficiency)
7+
8+
| Test | Average time | Increment |
9+
|----------------------|--------------|-----------|
10+
| otel_0_attributes | 72 ns | - |
11+
| otel_1_attributes | 117 ns | +45 ns |
12+
| otel_2_attributes | 155 ns | +38 ns |
13+
| otel_3_attributes | 196 ns | +41 ns |
14+
| otel_4_attributes | 240 ns | +44 ns |
15+
| otel_5_attributes | 278 ns | +38 ns |
16+
| otel_6_attributes | 346 ns | +68 ns | // Array is full. 6th attribute causes vec! to be allocated
17+
| otel_7_attributes | 390 ns | +44 ns |
18+
| otel_8_attributes | 431 ns | +41 ns |
19+
| otel_9_attributes | 480 ns | +49 ns |
20+
| otel_10_attributes | 519 ns | +39 ns |
21+
| otel_11_attributes | 625 ns | +106 ns | // vec! initial capacity is 5. 11th attribute causes vec! to be reallocated
22+
| otel_12_attributes | 676 ns | +51 ns |
23+
*/
24+
25+
use criterion::{criterion_group, criterion_main, Criterion};
26+
use opentelemetry::InstrumentationScope;
27+
use opentelemetry_appender_tracing::layer as tracing_layer;
28+
use opentelemetry_sdk::error::OTelSdkResult;
29+
use opentelemetry_sdk::logs::{LogProcessor, SdkLogRecord, SdkLoggerProvider};
30+
use opentelemetry_sdk::Resource;
31+
#[cfg(not(target_os = "windows"))]
32+
use pprof::criterion::{Output, PProfProfiler};
33+
use tracing::error;
34+
use tracing_subscriber::prelude::*;
35+
use tracing_subscriber::Registry;
36+
37+
#[derive(Debug)]
38+
struct NoopProcessor;
39+
40+
impl LogProcessor for NoopProcessor {
41+
fn emit(&self, _: &mut SdkLogRecord, _: &InstrumentationScope) {}
42+
43+
fn force_flush(&self) -> OTelSdkResult {
44+
Ok(())
45+
}
46+
47+
fn shutdown(&self) -> OTelSdkResult {
48+
Ok(())
49+
}
50+
}
51+
52+
/// Creates a single benchmark for a specific number of attributes
53+
fn create_benchmark(c: &mut Criterion, num_attributes: usize) {
54+
let provider = SdkLoggerProvider::builder()
55+
.with_resource(
56+
Resource::builder_empty()
57+
.with_service_name("benchmark")
58+
.build(),
59+
)
60+
.with_log_processor(NoopProcessor)
61+
.build();
62+
63+
let ot_layer = tracing_layer::OpenTelemetryTracingBridge::new(&provider);
64+
let subscriber = Registry::default().with(ot_layer);
65+
66+
tracing::subscriber::with_default(subscriber, || {
67+
c.bench_function(&format!("otel_{}_attributes", num_attributes), |b| {
68+
b.iter(|| {
69+
// Dynamically generate the error! macro call based on the number of attributes
70+
match num_attributes {
71+
0 => {
72+
error!(
73+
name : "CheckoutFailed",
74+
message = "Unable to process checkout."
75+
);
76+
}
77+
1 => {
78+
error!(
79+
name : "CheckoutFailed",
80+
field1 = "field1",
81+
message = "Unable to process checkout."
82+
);
83+
}
84+
2 => {
85+
error!(
86+
name : "CheckoutFailed",
87+
field1 = "field1",
88+
field2 = "field2",
89+
message = "Unable to process checkout."
90+
);
91+
}
92+
3 => {
93+
error!(
94+
name : "CheckoutFailed",
95+
field1 = "field1",
96+
field2 = "field2",
97+
field3 = "field3",
98+
message = "Unable to process checkout."
99+
);
100+
}
101+
4 => {
102+
error!(
103+
name : "CheckoutFailed",
104+
field1 = "field1",
105+
field2 = "field2",
106+
field3 = "field3",
107+
field4 = "field4",
108+
message = "Unable to process checkout."
109+
);
110+
}
111+
5 => {
112+
error!(
113+
name : "CheckoutFailed",
114+
field1 = "field1",
115+
field2 = "field2",
116+
field3 = "field3",
117+
field4 = "field4",
118+
field5 = "field5",
119+
message = "Unable to process checkout."
120+
);
121+
}
122+
6 => {
123+
error!(
124+
name : "CheckoutFailed",
125+
field1 = "field1",
126+
field2 = "field2",
127+
field3 = "field3",
128+
field4 = "field4",
129+
field5 = "field5",
130+
field6 = "field6",
131+
message = "Unable to process checkout."
132+
);
133+
}
134+
7 => {
135+
error!(
136+
name : "CheckoutFailed",
137+
field1 = "field1",
138+
field2 = "field2",
139+
field3 = "field3",
140+
field4 = "field4",
141+
field5 = "field5",
142+
field6 = "field6",
143+
field7 = "field7",
144+
message = "Unable to process checkout."
145+
);
146+
}
147+
8 => {
148+
error!(
149+
name : "CheckoutFailed",
150+
field1 = "field1",
151+
field2 = "field2",
152+
field3 = "field3",
153+
field4 = "field4",
154+
field5 = "field5",
155+
field6 = "field6",
156+
field7 = "field7",
157+
field8 = "field8",
158+
message = "Unable to process checkout."
159+
);
160+
}
161+
9 => {
162+
error!(
163+
name : "CheckoutFailed",
164+
field1 = "field1",
165+
field2 = "field2",
166+
field3 = "field3",
167+
field4 = "field4",
168+
field5 = "field5",
169+
field6 = "field6",
170+
field7 = "field7",
171+
field8 = "field8",
172+
field9 = "field9",
173+
message = "Unable to process checkout."
174+
);
175+
}
176+
10 => {
177+
error!(
178+
name : "CheckoutFailed",
179+
field1 = "field1",
180+
field2 = "field2",
181+
field3 = "field3",
182+
field4 = "field4",
183+
field5 = "field5",
184+
field6 = "field6",
185+
field7 = "field7",
186+
field8 = "field8",
187+
field9 = "field9",
188+
field10 = "field10",
189+
message = "Unable to process checkout."
190+
);
191+
}
192+
11 => {
193+
error!(
194+
name : "CheckoutFailed",
195+
field1 = "field1",
196+
field2 = "field2",
197+
field3 = "field3",
198+
field4 = "field4",
199+
field5 = "field5",
200+
field6 = "field6",
201+
field7 = "field7",
202+
field8 = "field8",
203+
field9 = "field9",
204+
field10 = "field10",
205+
field11 = "field11",
206+
message = "Unable to process checkout."
207+
);
208+
}
209+
12 => {
210+
error!(
211+
name : "CheckoutFailed",
212+
field1 = "field1",
213+
field2 = "field2",
214+
field3 = "field3",
215+
field4 = "field4",
216+
field5 = "field5",
217+
field6 = "field6",
218+
field7 = "field7",
219+
field8 = "field8",
220+
field9 = "field9",
221+
field10 = "field10",
222+
field11 = "field11",
223+
field12 = "field12",
224+
message = "Unable to process checkout."
225+
);
226+
}
227+
_ => {
228+
// Fall back to 10 attributes for any higher number
229+
error!(
230+
name : "CheckoutFailed",
231+
field1 = "field1",
232+
field2 = "field2",
233+
field3 = "field3",
234+
field4 = "field4",
235+
field5 = "field5",
236+
field6 = "field6",
237+
field7 = "field7",
238+
field8 = "field8",
239+
field9 = "field9",
240+
field10 = "field10",
241+
message = "Unable to process checkout."
242+
);
243+
}
244+
}
245+
});
246+
});
247+
});
248+
}
249+
250+
fn criterion_benchmark(c: &mut Criterion) {
251+
// Run benchmarks for 0 to 12 attributes
252+
for num_attributes in 0..=12 {
253+
create_benchmark(c, num_attributes);
254+
}
255+
}
256+
257+
#[cfg(not(target_os = "windows"))]
258+
criterion_group! {
259+
name = benches;
260+
config = Criterion::default().with_profiler(PProfProfiler::new(100, Output::Flamegraph(None)));
261+
targets = criterion_benchmark
262+
}
263+
264+
#[cfg(target_os = "windows")]
265+
criterion_group! {
266+
name = benches;
267+
config = Criterion::default();
268+
targets = criterion_benchmark
269+
}
270+
271+
criterion_main!(benches);

opentelemetry-otlp/src/exporter/http/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,12 @@ pub struct HttpConfig {
5757
///
5858
/// ## Examples
5959
///
60-
/// ```
60+
/// ```no_run
6161
/// # #[cfg(feature="metrics")]
6262
/// use opentelemetry_sdk::metrics::Temporality;
6363
///
6464
/// # fn main() -> Result<(), Box<dyn std::error::Error>> {
65-
/// // Create a span exporter you can use to when configuring tracer providers
65+
/// // Create a span exporter you can use when configuring tracer providers
6666
/// # #[cfg(feature="trace")]
6767
/// let span_exporter = opentelemetry_otlp::SpanExporter::builder().with_http().build()?;
6868
///

opentelemetry-sdk/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
//! let exporter = new_exporter();
2121
//!
2222
//! // Create a new trace pipeline that prints to stdout
23-
//! let provider = TracerProvider::builder()
23+
//! let provider = SdkTracerProvider::builder()
2424
//! .with_simple_exporter(exporter)
2525
//! .build();
2626
//! let tracer = provider.tracer("readme_example");

opentelemetry-sdk/src/logs/batch_log_processor.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ type LogsData = Box<(SdkLogRecord, InstrumentationScope)>;
107107
/// ### Using a BatchLogProcessor:
108108
///
109109
/// ```rust
110-
/// use opentelemetry_sdk::logs::{BatchLogProcessor, BatchConfigBuilder, LoggerProvider};
110+
/// use opentelemetry_sdk::logs::{BatchLogProcessor, BatchConfigBuilder, SdkLoggerProvider};
111111
/// use opentelemetry::global;
112112
/// use std::time::Duration;
113113
/// use opentelemetry_sdk::logs::InMemoryLogExporter;
@@ -123,7 +123,7 @@ type LogsData = Box<(SdkLogRecord, InstrumentationScope)>;
123123
/// )
124124
/// .build();
125125
///
126-
/// let provider = LoggerProvider::builder()
126+
/// let provider = SdkLoggerProvider::builder()
127127
/// .with_log_processor(processor)
128128
/// .build();
129129
///

0 commit comments

Comments
 (0)