Skip to content

Commit

Permalink
Merge branch 'main' into set_attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
TommyCpp committed Nov 1, 2021
2 parents f0a5d7d + d127e94 commit 2af85ca
Show file tree
Hide file tree
Showing 16 changed files with 34 additions and 37 deletions.
2 changes: 1 addition & 1 deletion opentelemetry-otlp/Cargo.toml
Expand Up @@ -51,12 +51,12 @@ http = "0.2"
serde = { version = "1.0", features = ["derive"], optional = true }

[dev-dependencies]
chrono = "0.4"
tokio-stream = { version = "0.1", features = ["net"] }
# need tokio runtime to run smoke tests.
opentelemetry = { features = ["trace", "rt-tokio"], path = "../opentelemetry" }
protobuf-codegen = { version = "2.16"}
protoc-grpcio = { version = "3.0"}
time = { version = "0.3", features = ["macros"] }

[features]
trace = ["opentelemetry/trace"]
Expand Down
4 changes: 2 additions & 2 deletions opentelemetry-otlp/src/proto/grpcio/common.rs
@@ -1,4 +1,4 @@
// This file is generated by rust-protobuf 2.25.1. Do not edit
// This file is generated by rust-protobuf 2.25.2. Do not edit
// @generated

// https://github.com/rust-lang/rust-clippy/issues/702
Expand All @@ -21,7 +21,7 @@

/// Generated files are compatible only with the same version
/// of protobuf runtime.
// const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_2_25_1;
// const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_2_25_2;

#[derive(PartialEq,Clone,Default)]
#[cfg_attr(feature = "with-serde", derive(::serde::Serialize, ::serde::Deserialize))]
Expand Down
4 changes: 2 additions & 2 deletions opentelemetry-otlp/src/proto/grpcio/metrics.rs
@@ -1,4 +1,4 @@
// This file is generated by rust-protobuf 2.25.1. Do not edit
// This file is generated by rust-protobuf 2.25.2. Do not edit
// @generated

// https://github.com/rust-lang/rust-clippy/issues/702
Expand All @@ -21,7 +21,7 @@

/// Generated files are compatible only with the same version
/// of protobuf runtime.
// const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_2_25_1;
// const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_2_25_2;

#[derive(PartialEq,Clone,Default)]
#[cfg_attr(feature = "with-serde", derive(::serde::Serialize, ::serde::Deserialize))]
Expand Down
4 changes: 2 additions & 2 deletions opentelemetry-otlp/src/proto/grpcio/metrics_service.rs
@@ -1,4 +1,4 @@
// This file is generated by rust-protobuf 2.25.1. Do not edit
// This file is generated by rust-protobuf 2.25.2. Do not edit
// @generated

// https://github.com/rust-lang/rust-clippy/issues/702
Expand All @@ -21,7 +21,7 @@

/// Generated files are compatible only with the same version
/// of protobuf runtime.
// const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_2_25_1;
// const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_2_25_2;

#[derive(PartialEq,Clone,Default)]
#[cfg_attr(feature = "with-serde", derive(::serde::Serialize, ::serde::Deserialize))]
Expand Down
4 changes: 2 additions & 2 deletions opentelemetry-otlp/src/proto/grpcio/resource.rs
@@ -1,4 +1,4 @@
// This file is generated by rust-protobuf 2.25.1. Do not edit
// This file is generated by rust-protobuf 2.25.2. Do not edit
// @generated

// https://github.com/rust-lang/rust-clippy/issues/702
Expand All @@ -21,7 +21,7 @@

/// Generated files are compatible only with the same version
/// of protobuf runtime.
// const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_2_25_1;
// const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_2_25_2;

#[derive(PartialEq,Clone,Default)]
#[cfg_attr(feature = "with-serde", derive(::serde::Serialize, ::serde::Deserialize))]
Expand Down
4 changes: 2 additions & 2 deletions opentelemetry-otlp/src/proto/grpcio/trace.rs
@@ -1,4 +1,4 @@
// This file is generated by rust-protobuf 2.25.1. Do not edit
// This file is generated by rust-protobuf 2.25.2. Do not edit
// @generated

// https://github.com/rust-lang/rust-clippy/issues/702
Expand All @@ -21,7 +21,7 @@

/// Generated files are compatible only with the same version
/// of protobuf runtime.
// const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_2_25_1;
// const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_2_25_2;

#[derive(PartialEq,Clone,Default)]
#[cfg_attr(feature = "with-serde", derive(::serde::Serialize, ::serde::Deserialize))]
Expand Down
4 changes: 2 additions & 2 deletions opentelemetry-otlp/src/proto/grpcio/trace_config.rs
@@ -1,4 +1,4 @@
// This file is generated by rust-protobuf 2.25.1. Do not edit
// This file is generated by rust-protobuf 2.25.2. Do not edit
// @generated

// https://github.com/rust-lang/rust-clippy/issues/702
Expand All @@ -21,7 +21,7 @@

/// Generated files are compatible only with the same version
/// of protobuf runtime.
// const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_2_25_1;
// const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_2_25_2;

#[derive(PartialEq,Clone,Default)]
#[cfg_attr(feature = "with-serde", derive(::serde::Serialize, ::serde::Deserialize))]
Expand Down
4 changes: 2 additions & 2 deletions opentelemetry-otlp/src/proto/grpcio/trace_service.rs
@@ -1,4 +1,4 @@
// This file is generated by rust-protobuf 2.25.1. Do not edit
// This file is generated by rust-protobuf 2.25.2. Do not edit
// @generated

// https://github.com/rust-lang/rust-clippy/issues/702
Expand All @@ -21,7 +21,7 @@

/// Generated files are compatible only with the same version
/// of protobuf runtime.
// const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_2_25_1;
// const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_2_25_2;

#[derive(PartialEq,Clone,Default)]
#[cfg_attr(feature = "with-serde", derive(::serde::Serialize, ::serde::Deserialize))]
Expand Down
6 changes: 3 additions & 3 deletions opentelemetry-otlp/src/transform/metrics.rs
Expand Up @@ -314,7 +314,6 @@ mod tests {
use crate::transform::common::tonic::Attributes;
use crate::transform::metrics::tonic::merge;
use crate::transform::{record_to_metric, sink, ResourceWrapper};
use chrono::prelude::*;
use opentelemetry::attributes::AttributeSet;
use opentelemetry::metrics::{
Descriptor, InstrumentKind, MetricsError, Number, NumberKind,
Expand All @@ -326,6 +325,7 @@ mod tests {
use opentelemetry::sdk::{InstrumentationLibrary, Resource};
use std::cmp::Ordering;
use std::sync::Arc;
use time::macros::datetime;

impl From<(&str, &str)> for KeyValue {
fn from(kv: (&str, &str)) -> Self {
Expand Down Expand Up @@ -500,8 +500,8 @@ mod tests {
opentelemetry::KeyValue::new("process", "rust"),
opentelemetry::KeyValue::new("runtime", "sync"),
]);
let start_time = Utc.ymd(2020, 12, 25).and_hms(10, 10, 0); // unit nano 1608891000000000000
let end_time = Utc.ymd(2020, 12, 25).and_hms(10, 10, 30); // unix nano 1608891030000000000
let start_time = datetime!(2020-12-25 10:10:0 UTC); // unit nano 1608891000000000000
let end_time = datetime!(2020-12-25 10:10:30 UTC); // unix nano 1608891030000000000

// Sum
{
Expand Down
1 change: 0 additions & 1 deletion opentelemetry-zpages/Cargo.toml
Expand Up @@ -36,7 +36,6 @@ with-serde = ["protobuf/with-serde"]

[dev-dependencies]
tokio = { version = "1.0", features = ["full"] }
chrono = "0.4"
opentelemetry = { path = "../opentelemetry", default-features = false, features = ["trace", "testing"] }

[build-dependencies]
Expand Down
4 changes: 2 additions & 2 deletions opentelemetry-zpages/src/proto/common.rs
@@ -1,4 +1,4 @@
// This file is generated by rust-protobuf 2.25.1. Do not edit
// This file is generated by rust-protobuf 2.25.2. Do not edit
// @generated

// https://github.com/rust-lang/rust-clippy/issues/702
Expand All @@ -21,7 +21,7 @@

/// Generated files are compatible only with the same version
/// of protobuf runtime.
// const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_2_25_1;
// const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_2_25_2;

#[derive(PartialEq,Clone,Default)]
#[cfg_attr(feature = "with-serde", derive(::serde::Serialize, ::serde::Deserialize))]
Expand Down
4 changes: 2 additions & 2 deletions opentelemetry-zpages/src/proto/resource.rs
@@ -1,4 +1,4 @@
// This file is generated by rust-protobuf 2.25.1. Do not edit
// This file is generated by rust-protobuf 2.25.2. Do not edit
// @generated

// https://github.com/rust-lang/rust-clippy/issues/702
Expand All @@ -21,7 +21,7 @@

/// Generated files are compatible only with the same version
/// of protobuf runtime.
// const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_2_25_1;
// const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_2_25_2;

#[derive(PartialEq,Clone,Default)]
#[cfg_attr(feature = "with-serde", derive(::serde::Serialize, ::serde::Deserialize))]
Expand Down
4 changes: 2 additions & 2 deletions opentelemetry-zpages/src/proto/trace.rs
@@ -1,4 +1,4 @@
// This file is generated by rust-protobuf 2.25.1. Do not edit
// This file is generated by rust-protobuf 2.25.2. Do not edit
// @generated

// https://github.com/rust-lang/rust-clippy/issues/702
Expand All @@ -21,7 +21,7 @@

/// Generated files are compatible only with the same version
/// of protobuf runtime.
// const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_2_25_1;
// const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_2_25_2;

#[derive(PartialEq,Clone,Default)]
#[cfg_attr(feature = "with-serde", derive(::serde::Serialize, ::serde::Deserialize))]
Expand Down
4 changes: 2 additions & 2 deletions opentelemetry-zpages/src/proto/tracez.rs
@@ -1,4 +1,4 @@
// This file is generated by rust-protobuf 2.25.1. Do not edit
// This file is generated by rust-protobuf 2.25.2. Do not edit
// @generated

// https://github.com/rust-lang/rust-clippy/issues/702
Expand All @@ -21,7 +21,7 @@

/// Generated files are compatible only with the same version
/// of protobuf runtime.
// const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_2_25_1;
// const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_2_25_2;

#[derive(PartialEq,Clone,Default)]
#[cfg_attr(feature = "with-serde", derive(::serde::Serialize, ::serde::Deserialize))]
Expand Down
10 changes: 4 additions & 6 deletions opentelemetry-zpages/src/trace/aggregator.rs
Expand Up @@ -206,7 +206,6 @@ mod tests {
use crate::trace::aggregator::{SpanAggregator, LATENCY_BUCKET_COUNT};
use crate::trace::span_queue::SpanQueue;
use crate::trace::TracezMessage;
use chrono::{DateTime, NaiveDateTime, Utc};
use opentelemetry::sdk::export::trace::SpanData;
use opentelemetry::testing::trace::new_test_export_span_data;
use std::borrow::Cow;
Expand Down Expand Up @@ -264,18 +263,17 @@ mod tests {
pub(crate) fn get_input(&self) -> (Vec<SpanData>, Vec<SpanData>) {
let mut start_spans = Vec::new();
let mut end_spans = Vec::new();
let start_time = DateTime::<Utc>::from_utc(NaiveDateTime::from_timestamp(61, 0), Utc);
let start_time = SystemTime::now();
for input in &self.input {
let mut span_data = span_data(input.0, input.1, input.2, input.3);
match input.4 {
Action::Start => {
span_data.start_time = start_time.into();
span_data.start_time = start_time;
start_spans.push(span_data);
}
Action::End(duration) => {
span_data.start_time = start_time.into();
span_data.end_time =
SystemTime::from(start_time).checked_add(duration).unwrap();
span_data.start_time = start_time;
span_data.end_time = start_time.checked_add(duration).unwrap();
end_spans.push(span_data);
}
}
Expand Down
8 changes: 4 additions & 4 deletions opentelemetry-zpages/src/trace/span_queue.rs
Expand Up @@ -106,9 +106,9 @@ impl SpanQueue {
#[cfg(test)]
mod tests {
use super::*;
use chrono::{DateTime, NaiveDateTime, Utc};
use opentelemetry::testing::trace::new_test_export_span_data;
use opentelemetry::trace::{SpanId, TraceFlags, TraceId, TraceState};
use std::time::SystemTime;

enum Action {
PushBack(u128, u64),
Expand Down Expand Up @@ -136,12 +136,12 @@ mod tests {
TraceState::default(),
)
};
let time = SystemTime::now();
let get_span_data = |trace_id: u128, span_id: u64| {
let mut span_data = new_test_export_span_data();
span_data.span_context = get_span_context(trace_id, span_id);
let time = DateTime::<Utc>::from_utc(NaiveDateTime::from_timestamp(61, 0), Utc);
span_data.start_time = time.into();
span_data.end_time = time.into();
span_data.start_time = time;
span_data.end_time = time;
span_data
};
let plans = vec![
Expand Down

0 comments on commit 2af85ca

Please sign in to comment.