Skip to content

Commit 5e1a813

Browse files
authored
Merge branch 'main' into shutdown_channel
2 parents 52757f0 + 590c7ab commit 5e1a813

File tree

33 files changed

+125
-125
lines changed

33 files changed

+125
-125
lines changed

.github/workflows/ci.yml

+9-20
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,12 @@ jobs:
2424
- uses: actions/checkout@v4
2525
with:
2626
submodules: true
27-
- uses: actions-rs/toolchain@v1
27+
- uses: dtolnay/rust-toolchain@master
2828
with:
2929
toolchain: ${{ matrix.rust }}
3030
components: rustfmt
31-
profile: minimal
31+
- name: "Set rustup profile"
32+
run: rustup set profile minimal
3233
- uses: arduino/setup-protoc@v3
3334
- name: Test
3435
run: ./scripts/test.sh
@@ -38,11 +39,9 @@ jobs:
3839
- uses: actions/checkout@v4
3940
with:
4041
submodules: true
41-
- uses: actions-rs/toolchain@v1
42+
- uses: dtolnay/rust-toolchain@stable
4243
with:
43-
toolchain: stable
4444
components: rustfmt
45-
profile: minimal
4645
- uses: arduino/setup-protoc@v3
4746
- uses: actions-rs/cargo@v1
4847
with:
@@ -57,11 +56,10 @@ jobs:
5756
runs-on: ubuntu-latest
5857
steps:
5958
- uses: actions/checkout@v4
60-
- uses: actions-rs/toolchain@v1
59+
- uses: dtolnay/rust-toolchain@nightly
6160
with:
6261
toolchain: nightly-2024-02-07
6362
components: rustfmt
64-
override: true
6563
- name: external-type-check
6664
run: |
6765
cargo install cargo-check-external-types
@@ -76,11 +74,9 @@ jobs:
7674
- uses: actions/checkout@v4
7775
with:
7876
submodules: true
79-
- uses: actions-rs/toolchain@v1
77+
- uses: dtolnay/rust-toolchain@stable
8078
with:
81-
toolchain: stable
8279
components: rustfmt
83-
profile: minimal
8480
- uses: arduino/setup-protoc@v3
8581
- name: Build
8682
run: |
@@ -92,11 +88,7 @@ jobs:
9288
- uses: actions/checkout@v4
9389
with:
9490
submodules: true
95-
- uses: actions-rs/toolchain@v1
96-
with:
97-
profile: minimal
98-
toolchain: 1.65.0
99-
override: true
91+
- uses: dtolnay/rust-toolchain@1.65.0
10092
- name: Patch dependencies versions # some dependencies bump MSRV without major version bump
10193
run: ./scripts/patch_dependencies.sh
10294
- name: Run tests
@@ -117,11 +109,9 @@ jobs:
117109
runs-on: ubuntu-latest
118110
steps:
119111
- uses: actions/checkout@v4
120-
- uses: actions-rs/toolchain@v1
112+
- uses: dtolnay/rust-toolchain@nightly
121113
with:
122-
toolchain: nightly
123114
components: rustfmt
124-
override: true
125115
- uses: arduino/setup-protoc@v3
126116
- name: doc
127117
run: cargo doc --no-deps --all-features
@@ -136,11 +126,10 @@ jobs:
136126
- uses: actions/checkout@v4
137127
with:
138128
submodules: true
139-
- uses: actions-rs/toolchain@v1
129+
- uses: dtolnay/rust-toolchain@stable
140130
with:
141131
toolchain: stable
142132
components: rustfmt,llvm-tools-preview
143-
override: true
144133
- uses: arduino/setup-protoc@v3
145134
- name: cargo install cargo-llvm-cov
146135
uses: taiki-e/install-action@cargo-llvm-cov

.github/workflows/integration_tests.yml

+1-3
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,9 @@ jobs:
2020
- uses: actions/checkout@v4
2121
with:
2222
submodules: true
23-
- uses: actions-rs/toolchain@v1
23+
- uses: dtolnay/rust-toolchain@stable
2424
with:
25-
toolchain: stable
2625
components: rustfmt
27-
profile: minimal
2826
- uses: arduino/setup-protoc@v3
2927
- name: Run integration tests using docker compose
3028
run: ./scripts/integration_tests.sh

opentelemetry-http/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ pub trait HttpClient: Debug + Send + Sync {
6767
#[cfg(feature = "reqwest")]
6868
mod reqwest {
6969
use super::{async_trait, Bytes, HttpClient, HttpError, Request, Response};
70-
use std::convert::TryInto;
7170

7271
#[async_trait]
7372
impl HttpClient for reqwest::Client {

opentelemetry-jaeger-propagator/src/propagator.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -214,12 +214,7 @@ impl TextMapPropagator for Propagator {
214214
#[cfg(test)]
215215
mod tests {
216216
use super::*;
217-
use opentelemetry::{
218-
propagation::{Injector, TextMapPropagator},
219-
testing::trace::TestSpan,
220-
trace::{SpanContext, SpanId, TraceContextExt, TraceFlags, TraceId, TraceState},
221-
Context,
222-
};
217+
use opentelemetry::testing::trace::TestSpan;
223218
use std::collections::HashMap;
224219

225220
const LONG_TRACE_ID_STR: &str = "000000000000004d0000000000000016";

opentelemetry-jaeger/src/exporter/config/agent.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,8 @@ use std::sync::Arc;
44
use std::{env, net};
55

66
use opentelemetry::trace::TraceError;
7+
use opentelemetry_sdk::trace::{BatchConfig, Config, TracerProvider};
78
use opentelemetry_sdk::trace::{BatchSpanProcessor, Tracer};
8-
use opentelemetry_sdk::{
9-
self,
10-
trace::{BatchConfig, Config, TracerProvider},
11-
};
129

1310
use crate::exporter::agent::{AgentAsyncClientUdp, AgentSyncClientUdp};
1411
use crate::exporter::config::{

opentelemetry-jaeger/src/exporter/config/collector/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use std::borrow::BorrowMut;
2-
use std::convert::TryFrom;
32
use std::env;
43
use std::sync::Arc;
54
#[cfg(feature = "collector_client")]

opentelemetry-otlp/src/logs.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use opentelemetry::{
1616
global,
1717
logs::{LogError, LoggerProvider},
1818
};
19-
use opentelemetry_sdk::{self, export::logs::LogData, runtime::RuntimeChannel};
19+
use opentelemetry_sdk::{export::logs::LogData, runtime::RuntimeChannel};
2020

2121
/// Compression algorithm to use, defaults to none.
2222
pub const OTEL_EXPORTER_OTLP_LOGS_COMPRESSION: &str = "OTEL_EXPORTER_OTLP_LOGS_COMPRESSION";

opentelemetry-otlp/tests/integration_test/expected/failed_traces.json

+6-6
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
"parentSpanId": "",
2424
"name": "Sub operation...",
2525
"kind": 1,
26-
"startTimeUnixNano": 1703985537070566698,
27-
"endTimeUnixNano": 1703985537070572718,
26+
"startTimeUnixNano": "1703985537070566698",
27+
"endTimeUnixNano": "1703985537070572718",
2828
"attributes": [
2929
{
3030
"key": "lemons",
@@ -35,7 +35,7 @@
3535
],
3636
"events": [
3737
{
38-
"timeUnixNano": 1703985537070567697,
38+
"timeUnixNano": "1703985537070567697",
3939
"name": "Sub span event"
4040
}
4141
],
@@ -68,8 +68,8 @@
6868
"parentSpanId": "cd7cf7bf939930b7",
6969
"name": "operation",
7070
"kind": 1,
71-
"startTimeUnixNano": 1703985537070558635,
72-
"endTimeUnixNano": 1703985537070580454,
71+
"startTimeUnixNano": "1703985537070558635",
72+
"endTimeUnixNano": "1703985537070580454",
7373
"attributes": [
7474
{
7575
"key": "ex.com/another",
@@ -80,7 +80,7 @@
8080
],
8181
"events": [
8282
{
83-
"timeUnixNano": 1703985537070563326,
83+
"timeUnixNano": "1703985537070563326",
8484
"name": "Nice operation!",
8585
"attributes": [
8686
{

opentelemetry-otlp/tests/integration_test/expected/traces.json

+6-6
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
"parentSpanId": "d58cf2d702a061e0",
2424
"name": "Sub operation...",
2525
"kind": 1,
26-
"startTimeUnixNano": 1703985537070566698,
27-
"endTimeUnixNano": 1703985537070572718,
26+
"startTimeUnixNano": "1703985537070566698",
27+
"endTimeUnixNano": "1703985537070572718",
2828
"attributes": [
2929
{
3030
"key": "lemons",
@@ -35,7 +35,7 @@
3535
],
3636
"events": [
3737
{
38-
"timeUnixNano": 1703985537070567697,
38+
"timeUnixNano": "1703985537070567697",
3939
"name": "Sub span event"
4040
}
4141
],
@@ -68,8 +68,8 @@
6868
"parentSpanId": "",
6969
"name": "operation",
7070
"kind": 1,
71-
"startTimeUnixNano": 1703985537070558635,
72-
"endTimeUnixNano": 1703985537070580454,
71+
"startTimeUnixNano": "1703985537070558635",
72+
"endTimeUnixNano": "1703985537070580454",
7373
"attributes": [
7474
{
7575
"key": "ex.com/another",
@@ -80,7 +80,7 @@
8080
],
8181
"events": [
8282
{
83-
"timeUnixNano": 1703985537070563326,
83+
"timeUnixNano": "1703985537070563326",
8484
"name": "Nice operation!",
8585
"attributes": [
8686
{

opentelemetry-proto/src/proto.rs

+14
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,21 @@ pub(crate) mod serializers {
6969
Ok(Some(AnyValue { value }))
7070
}
7171

72+
pub fn serialize_u64_to_string<S>(value: &u64, serializer: S) -> Result<S::Ok, S::Error>
73+
where
74+
S: Serializer,
75+
{
76+
let s = value.to_string();
77+
serializer.serialize_str(&s)
78+
}
7279

80+
pub fn deserialize_string_to_u64<'de, D>(deserializer: D) -> Result<u64, D::Error>
81+
where
82+
D: Deserializer<'de>,
83+
{
84+
let s: String = Deserialize::deserialize(deserializer)?;
85+
s.parse::<u64>().map_err(de::Error::custom)
86+
}
7387
}
7488

7589
#[cfg(feature = "gen-tonic-messages")]

opentelemetry-proto/src/proto/tonic/opentelemetry.proto.trace.v1.rs

+21
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,13 @@ pub struct Span {
166166
///
167167
/// This field is semantically required and it is expected that end_time >= start_time.
168168
#[prost(fixed64, tag = "7")]
169+
#[cfg_attr(
170+
feature = "with-serde",
171+
serde(
172+
serialize_with = "crate::proto::serializers::serialize_u64_to_string",
173+
deserialize_with = "crate::proto::serializers::deserialize_string_to_u64"
174+
)
175+
)]
169176
pub start_time_unix_nano: u64,
170177
/// end_time_unix_nano is the end time of the span. On the client side, this is the time
171178
/// kept by the local machine where the span execution ends. On the server side, this
@@ -174,6 +181,13 @@ pub struct Span {
174181
///
175182
/// This field is semantically required and it is expected that end_time >= start_time.
176183
#[prost(fixed64, tag = "8")]
184+
#[cfg_attr(
185+
feature = "with-serde",
186+
serde(
187+
serialize_with = "crate::proto::serializers::serialize_u64_to_string",
188+
deserialize_with = "crate::proto::serializers::deserialize_string_to_u64"
189+
)
190+
)]
177191
pub end_time_unix_nano: u64,
178192
/// attributes is a collection of key/value pairs. Note, global attributes
179193
/// like server name can be set using the resource API. Examples of attributes:
@@ -227,6 +241,13 @@ pub mod span {
227241
pub struct Event {
228242
/// time_unix_nano is the time the event occurred.
229243
#[prost(fixed64, tag = "1")]
244+
#[cfg_attr(
245+
feature = "with-serde",
246+
serde(
247+
serialize_with = "crate::proto::serializers::serialize_u64_to_string",
248+
deserialize_with = "crate::proto::serializers::deserialize_string_to_u64"
249+
)
250+
)]
230251
pub time_unix_nano: u64,
231252
/// name of the event.
232253
/// This field is semantically required to be set to non-empty string.

opentelemetry-proto/tests/grpc_build.rs

+13
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,19 @@ fn build_tonic() {
7373
.field_attribute(path, "#[cfg_attr(feature = \"with-serde\", serde(serialize_with = \"crate::proto::serializers::serialize_to_hex_string\", deserialize_with = \"crate::proto::serializers::deserialize_from_hex_string\"))]")
7474
}
7575

76+
// special serializer and deserializer for timestamp
77+
// OTLP/JSON format may uses string for timestamp
78+
// the proto file uses u64 for timestamp
79+
// Thus, special serializer and deserializer are needed
80+
for path in [
81+
"trace.v1.Span.start_time_unix_nano",
82+
"trace.v1.Span.end_time_unix_nano",
83+
"trace.v1.Span.Event.time_unix_nano",
84+
] {
85+
builder = builder
86+
.field_attribute(path, "#[cfg_attr(feature = \"with-serde\", serde(serialize_with = \"crate::proto::serializers::serialize_u64_to_string\", deserialize_with = \"crate::proto::serializers::deserialize_string_to_u64\"))]")
87+
}
88+
7689
// add custom serializer and deserializer for AnyValue
7790
builder = builder
7891
.field_attribute("common.v1.KeyValue.value", "#[cfg_attr(feature =\"with-serde\", serde(serialize_with = \"crate::proto::serializers::serialize_to_value\", deserialize_with = \"crate::proto::serializers::deserialize_from_value\"))]");

opentelemetry-proto/tests/json_deserialize.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ mod json_deserialize {
4141
"spanId": "EEE19B7EC3C1B174",
4242
"parentSpanId": "EEE19B7EC3C1B173",
4343
"name": "I'm a server span",
44-
"startTimeUnixNano": 1544712660000000000,
45-
"endTimeUnixNano": 1544712661000000000,
44+
"startTimeUnixNano": "1544712660000000000",
45+
"endTimeUnixNano": "1544712661000000000",
4646
"kind": 2,
4747
"attributes": [
4848
{
@@ -73,7 +73,7 @@ mod json_deserialize {
7373
const EVENT_JSON: &str = r#"
7474
{
7575
"name": "my_event",
76-
"time_unix_nano": 1234567890
76+
"time_unix_nano": "1234567890"
7777
}
7878
"#;
7979

opentelemetry-sdk/benches/metric_counter.rs

+11
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,17 @@ fn counter_add(c: &mut Criterion) {
6767
);
6868
});
6969
});
70+
71+
c.bench_function("Random_Generator_5", |b| {
72+
b.iter(|| {
73+
let mut rng = SmallRng::from_entropy();
74+
let _i1 = rng.gen_range(0..4);
75+
let _i2 = rng.gen_range(0..4);
76+
let _i3 = rng.gen_range(0..10);
77+
let _i4 = rng.gen_range(0..10);
78+
let _i5 = rng.gen_range(0..10);
79+
});
80+
});
7081
}
7182

7283
criterion_group!(benches, criterion_benchmark);

opentelemetry-sdk/src/metrics/view.rs

-1
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,6 @@ pub fn new_view(criteria: Instrument, mask: Stream) -> Result<Box<dyn View>> {
177177
#[cfg(test)]
178178
mod tests {
179179
use super::*;
180-
use crate::metrics::Instrument;
181180
#[test]
182181
fn test_new_view_matching_all() {
183182
let criteria = Instrument::new().name("*");

opentelemetry-sdk/src/propagation/baggage.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -155,9 +155,7 @@ impl TextMapPropagator for BaggagePropagator {
155155
#[cfg(test)]
156156
mod tests {
157157
use super::*;
158-
use opentelemetry::{
159-
baggage::BaggageMetadata, propagation::TextMapPropagator, Key, KeyValue, StringValue, Value,
160-
};
158+
use opentelemetry::{baggage::BaggageMetadata, Key, KeyValue, StringValue, Value};
161159
use std::collections::HashMap;
162160

163161
#[rustfmt::skip]

opentelemetry-sdk/src/propagation/trace_context.rs

-5
Original file line numberDiff line numberDiff line change
@@ -154,12 +154,7 @@ impl TextMapPropagator for TraceContextPropagator {
154154
mod tests {
155155
use super::*;
156156
use crate::testing::trace::TestSpan;
157-
use opentelemetry::{
158-
propagation::{Extractor, Injector, TextMapPropagator},
159-
trace::{SpanContext, SpanId, TraceId},
160-
};
161157
use std::collections::HashMap;
162-
use std::str::FromStr;
163158

164159
#[rustfmt::skip]
165160
fn extract_data() -> Vec<(&'static str, &'static str, SpanContext)> {

opentelemetry-sdk/src/resource/mod.rs

-2
Original file line numberDiff line numberDiff line change
@@ -259,8 +259,6 @@ pub trait ResourceDetector {
259259
#[cfg(test)]
260260
mod tests {
261261
use super::*;
262-
use crate::resource::EnvResourceDetector;
263-
use std::collections::HashMap;
264262
use std::time;
265263

266264
#[test]

0 commit comments

Comments
 (0)