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 dde78cb

Browse files
authoredSep 10, 2024··
Merge branch 'main' into utpilla/Fix-metrics-dedup
2 parents c519747 + 089d9fb commit dde78cb

File tree

6 files changed

+29
-69
lines changed

6 files changed

+29
-69
lines changed
 

‎opentelemetry-otlp/examples/basic-otlp-http/src/main.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use opentelemetry::{
33
global,
44
metrics::MetricsError,
55
trace::{TraceContextExt, TraceError, Tracer, TracerProvider as _},
6-
Key, KeyValue,
6+
KeyValue,
77
};
88
use opentelemetry_appender_tracing::layer::OpenTelemetryTracingBridge;
99
use opentelemetry_otlp::Protocol;
@@ -146,7 +146,7 @@ async fn main() -> Result<(), Box<dyn Error + Send + Sync + 'static>> {
146146
let span = cx.span();
147147
span.add_event(
148148
"Nice operation!".to_string(),
149-
vec![Key::new("bogons").i64(100)],
149+
vec![KeyValue::new("bogons", 100)],
150150
);
151151
span.set_attribute(KeyValue::new("another.key", "yes"));
152152

‎opentelemetry-otlp/examples/basic-otlp/src/main.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use opentelemetry::metrics::MetricsError;
55
use opentelemetry::trace::{TraceError, TracerProvider};
66
use opentelemetry::{
77
trace::{TraceContextExt, Tracer},
8-
Key, KeyValue,
8+
KeyValue,
99
};
1010
use opentelemetry_appender_tracing::layer::OpenTelemetryTracingBridge;
1111
use opentelemetry_otlp::{ExportConfig, WithExportConfig};
@@ -136,7 +136,7 @@ async fn main() -> Result<(), Box<dyn Error + Send + Sync + 'static>> {
136136
let span = cx.span();
137137
span.add_event(
138138
"Nice operation!".to_string(),
139-
vec![Key::new("bogons").i64(100)],
139+
vec![KeyValue::new("bogons", 100)],
140140
);
141141
span.set_attribute(KeyValue::new("another.key", "yes"));
142142

‎opentelemetry-otlp/tests/integration_test/tests/traces.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ pub async fn traces() -> Result<(), Box<dyn Error + Send + Sync + 'static>> {
4141
let span = cx.span();
4242
span.add_event(
4343
"Nice operation!".to_string(),
44-
vec![Key::new("bogons").i64(100)],
44+
vec![KeyValue::new("bogons", 100)],
4545
);
4646
span.set_attribute(KeyValue::new(ANOTHER_KEY, "yes"));
4747

‎opentelemetry-sdk/benches/trace.rs

+22-22
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use criterion::{criterion_group, criterion_main, Criterion};
22
use futures_util::future::BoxFuture;
33
use opentelemetry::{
44
trace::{Span, Tracer, TracerProvider},
5-
Key,
5+
KeyValue,
66
};
77
use opentelemetry_sdk::{
88
export::trace::{ExportResult, SpanData, SpanExporter},
@@ -16,42 +16,42 @@ fn criterion_benchmark(c: &mut Criterion) {
1616

1717
trace_benchmark_group(c, "start-end-span-4-attrs", |tracer| {
1818
let mut span = tracer.start("foo");
19-
span.set_attribute(Key::new("key1").bool(false));
20-
span.set_attribute(Key::new("key2").string("hello"));
21-
span.set_attribute(Key::new("key4").f64(123.456));
19+
span.set_attribute(KeyValue::new("key1", false));
20+
span.set_attribute(KeyValue::new("key2", "hello"));
21+
span.set_attribute(KeyValue::new("key4", 123.456));
2222
span.end();
2323
});
2424

2525
trace_benchmark_group(c, "start-end-span-8-attrs", |tracer| {
2626
let mut span = tracer.start("foo");
27-
span.set_attribute(Key::new("key1").bool(false));
28-
span.set_attribute(Key::new("key2").string("hello"));
29-
span.set_attribute(Key::new("key4").f64(123.456));
30-
span.set_attribute(Key::new("key11").bool(false));
31-
span.set_attribute(Key::new("key12").string("hello"));
32-
span.set_attribute(Key::new("key14").f64(123.456));
27+
span.set_attribute(KeyValue::new("key1", false));
28+
span.set_attribute(KeyValue::new("key2", "hello"));
29+
span.set_attribute(KeyValue::new("key4", 123.456));
30+
span.set_attribute(KeyValue::new("key11", false));
31+
span.set_attribute(KeyValue::new("key12", "hello"));
32+
span.set_attribute(KeyValue::new("key14", 123.456));
3333
span.end();
3434
});
3535

3636
trace_benchmark_group(c, "start-end-span-all-attr-types", |tracer| {
3737
let mut span = tracer.start("foo");
38-
span.set_attribute(Key::new("key1").bool(false));
39-
span.set_attribute(Key::new("key2").string("hello"));
40-
span.set_attribute(Key::new("key3").i64(123));
41-
span.set_attribute(Key::new("key5").f64(123.456));
38+
span.set_attribute(KeyValue::new("key1", false));
39+
span.set_attribute(KeyValue::new("key2", "hello"));
40+
span.set_attribute(KeyValue::new("key3", 123));
41+
span.set_attribute(KeyValue::new("key5", 123.456));
4242
span.end();
4343
});
4444

4545
trace_benchmark_group(c, "start-end-span-all-attr-types-2x", |tracer| {
4646
let mut span = tracer.start("foo");
47-
span.set_attribute(Key::new("key1").bool(false));
48-
span.set_attribute(Key::new("key2").string("hello"));
49-
span.set_attribute(Key::new("key3").i64(123));
50-
span.set_attribute(Key::new("key5").f64(123.456));
51-
span.set_attribute(Key::new("key11").bool(false));
52-
span.set_attribute(Key::new("key12").string("hello"));
53-
span.set_attribute(Key::new("key13").i64(123));
54-
span.set_attribute(Key::new("key15").f64(123.456));
47+
span.set_attribute(KeyValue::new("key1", false));
48+
span.set_attribute(KeyValue::new("key2", "hello"));
49+
span.set_attribute(KeyValue::new("key3", 123));
50+
span.set_attribute(KeyValue::new("key5", 123.456));
51+
span.set_attribute(KeyValue::new("key11", false));
52+
span.set_attribute(KeyValue::new("key12", "hello"));
53+
span.set_attribute(KeyValue::new("key13", 123));
54+
span.set_attribute(KeyValue::new("key15", 123.456));
5555
span.end();
5656
});
5757
}

‎opentelemetry-sdk/src/propagation/baggage.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ static BAGGAGE_FIELDS: Lazy<[String; 1]> = Lazy::new(|| [BAGGAGE_HEADER.to_owned
2525
/// # Examples
2626
///
2727
/// ```
28-
/// use opentelemetry::{baggage::BaggageExt, Key, propagation::TextMapPropagator};
28+
/// use opentelemetry::{baggage::BaggageExt, KeyValue, propagation::TextMapPropagator};
2929
/// use opentelemetry_sdk::propagation::BaggagePropagator;
3030
/// use std::collections::HashMap;
3131
///
@@ -43,7 +43,7 @@ static BAGGAGE_FIELDS: Lazy<[String; 1]> = Lazy::new(|| [BAGGAGE_HEADER.to_owned
4343
/// }
4444
///
4545
/// // Add new baggage
46-
/// let cx_with_additions = cx.with_baggage(vec![Key::new("server_id").i64(42)]);
46+
/// let cx_with_additions = cx.with_baggage(vec![KeyValue::new("server_id", 42)]);
4747
///
4848
/// // Inject baggage into http request
4949
/// propagator.inject_context(&cx_with_additions, &mut headers);

‎opentelemetry/src/common.rs

-40
Original file line numberDiff line numberDiff line change
@@ -32,46 +32,6 @@ impl Key {
3232
Key(OtelString::Static(value))
3333
}
3434

35-
/// Create a `KeyValue` pair for `bool` values.
36-
pub fn bool<T: Into<bool>>(self, value: T) -> KeyValue {
37-
KeyValue {
38-
key: self,
39-
value: Value::Bool(value.into()),
40-
}
41-
}
42-
43-
/// Create a `KeyValue` pair for `i64` values.
44-
pub fn i64(self, value: i64) -> KeyValue {
45-
KeyValue {
46-
key: self,
47-
value: Value::I64(value),
48-
}
49-
}
50-
51-
/// Create a `KeyValue` pair for `f64` values.
52-
pub fn f64(self, value: f64) -> KeyValue {
53-
KeyValue {
54-
key: self,
55-
value: Value::F64(value),
56-
}
57-
}
58-
59-
/// Create a `KeyValue` pair for string-like values.
60-
pub fn string(self, value: impl Into<StringValue>) -> KeyValue {
61-
KeyValue {
62-
key: self,
63-
value: Value::String(value.into()),
64-
}
65-
}
66-
67-
/// Create a `KeyValue` pair for arrays.
68-
pub fn array<T: Into<Array>>(self, value: T) -> KeyValue {
69-
KeyValue {
70-
key: self,
71-
value: Value::Array(value.into()),
72-
}
73-
}
74-
7535
/// Returns a reference to the underlying key name
7636
pub fn as_str(&self) -> &str {
7737
self.0.as_str()

0 commit comments

Comments
 (0)
Please sign in to comment.