Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions opentelemetry-otlp/tests/integration_test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ reqwest-client = ["opentelemetry-otlp/reqwest-client", "opentelemetry-otlp/http-
reqwest-blocking-client = ["opentelemetry-otlp/reqwest-blocking-client", "opentelemetry-otlp/http-proto", "opentelemetry-otlp/trace","opentelemetry-otlp/logs", "opentelemetry-otlp/metrics", "internal-logs"]
tonic-client = ["opentelemetry-otlp/grpc-tonic", "opentelemetry-otlp/trace", "opentelemetry-otlp/logs", "opentelemetry-otlp/metrics", "internal-logs"]
internal-logs = ["opentelemetry-otlp/internal-logs"]
experimental_metadata_attributes = ["opentelemetry-appender-tracing/experimental_metadata_attributes"]

# Keep tonic as the default client
default = ["tonic-client", "internal-logs"]
Expand Down
21 changes: 19 additions & 2 deletions opentelemetry-otlp/tests/integration_test/src/logs_asserter.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
use anyhow::Result;
use opentelemetry_proto::tonic::logs::v1::{LogRecord, LogsData, ResourceLogs};
use opentelemetry_proto::tonic::{
common::v1::KeyValue,
logs::v1::{LogRecord, LogsData, ResourceLogs},
};
use std::fs::File;

// Given two ResourceLogs, assert that they are equal except for the timestamps
Expand Down Expand Up @@ -75,8 +78,22 @@ impl PartialEq for LogRecordWrapper {
a.severity_text, b.severity_text,
"severity_text does not match"
);
let a_attrs = a.attributes.clone();
#[cfg(feature = "experimental_metadata_attributes")]
let a_attrs: Vec<_> = a_attrs
.into_iter()
.filter(|KeyValue { key, .. }| !key.as_str().starts_with("code."))
.collect();

let b_attrs = b.attributes.clone();
#[cfg(feature = "experimental_metadata_attributes")]
let b_attrs: Vec<_> = b_attrs
.into_iter()
.filter(|KeyValue { key, .. }| !key.as_str().starts_with("code."))
.collect();

assert_eq!(a.body, b.body, "body does not match");
assert_eq!(a.attributes, b.attributes, "attributes do not match");
assert_eq!(a_attrs, b_attrs, "attributes do not match");
assert_eq!(
a.dropped_attributes_count, b.dropped_attributes_count,
"dropped_attributes_count does not match"
Expand Down
6 changes: 4 additions & 2 deletions opentelemetry-otlp/tests/integration_test/tests/logs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ mod logtests {
// current thread
#[test]
#[cfg(feature = "reqwest-blocking-client")]
#[cfg(not(feature = "tonic-client"))]
pub fn logs_batch_non_tokio_main_with_init_logs_outside_rt() -> Result<()> {
logs_non_tokio_helper(false, false)
}
Expand Down Expand Up @@ -295,7 +296,8 @@ mod logtests {
// Client - Reqwest-blocking
#[test]
#[cfg(feature = "reqwest-blocking-client")]
pub fn logs_simple_non_tokio_main_with_init_logs_outsie_rt_blocking() -> Result<()> {
#[cfg(not(feature = "tonic-client"))]
pub fn logs_simple_non_tokio_main_with_init_logs_outside_rt_blocking() -> Result<()> {
logs_non_tokio_helper(true, false)
}

Expand All @@ -309,7 +311,7 @@ mod logtests {
feature = "tonic-client",
feature = "reqwest-client"
))]
pub fn logs_simple_non_tokio_main_with_init_logs_outsie_rt() -> Result<()> {
pub fn logs_simple_non_tokio_main_with_init_logs_outside_rt() -> Result<()> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch!

logs_non_tokio_helper(true, false)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ pub async fn test_logs() -> Result<()> {
info!(target: "my-target", "hello from {}. My price is {}.", "banana", 2.99);
}

let _ = logger_provider.shutdown();
logger_provider.shutdown().unwrap();
tokio::time::sleep(std::time::Duration::from_secs(5)).await;
assert_logs_results(test_utils::LOGS_FILE, "expected/logs.json")?;
Ok(())
Expand Down
Loading