Skip to content

Commit

Permalink
keep diff minimal
Browse files Browse the repository at this point in the history
  • Loading branch information
lalitb committed Dec 20, 2024
1 parent 158e922 commit 36ea18a
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 14 deletions.
2 changes: 1 addition & 1 deletion opentelemetry-otlp/src/exporter/http/logs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ impl LogExporter for OtlpHttpClient {
_ => Err(LogError::Other("exporter is already shut down".into())),
})?;

let (body, content_type) = { self.build_logs_export_body(&batch)? };
let (body, content_type) = { self.build_logs_export_body(batch)? };
let mut request = http::Request::builder()
.method(Method::POST)
.uri(&self.collector_endpoint)
Expand Down
2 changes: 1 addition & 1 deletion opentelemetry-otlp/src/exporter/http/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ impl OtlpHttpClient {
#[cfg(feature = "logs")]
fn build_logs_export_body(
&self,
logs: &LogBatch<'_>,
logs: LogBatch<'_>,
) -> opentelemetry_sdk::logs::LogResult<(Vec<u8>, &'static str)> {
use opentelemetry_proto::tonic::collector::logs::v1::ExportLogsServiceRequest;
let resource_logs = group_logs_by_resource_and_scope(logs, &self.resource);
Expand Down
2 changes: 1 addition & 1 deletion opentelemetry-otlp/src/exporter/tonic/logs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ impl LogExporter for TonicLogsClient {
None => return Err(LogError::Other("exporter is already shut down".into())),
};

let resource_logs = group_logs_by_resource_and_scope(&batch, &self.resource);
let resource_logs = group_logs_by_resource_and_scope(batch, &self.resource);

otel_debug!(name: "TonicsLogsClient.CallingExport");

Expand Down
6 changes: 3 additions & 3 deletions opentelemetry-proto/src/transform/logs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ pub mod tonic {
}

pub fn group_logs_by_resource_and_scope(
logs: &LogBatch<'_>,
logs: LogBatch<'_>,
resource: &ResourceAttributesWithSchema,
) -> Vec<ResourceLogs> {
// Group logs by target or instrumentation name
Expand Down Expand Up @@ -265,7 +265,7 @@ mod tests {
let resource: ResourceAttributesWithSchema = (&resource).into(); // Convert Resource to ResourceAttributesWithSchema

let grouped_logs =
crate::transform::logs::tonic::group_logs_by_resource_and_scope(&log_batch, &resource);
crate::transform::logs::tonic::group_logs_by_resource_and_scope(log_batch, &resource);

assert_eq!(grouped_logs.len(), 1);
let resource_logs = &grouped_logs[0];
Expand All @@ -285,7 +285,7 @@ mod tests {
let log_batch = LogBatch::new(&logs);
let resource: ResourceAttributesWithSchema = (&resource).into(); // Convert Resource to ResourceAttributesWithSchema
let grouped_logs =
crate::transform::logs::tonic::group_logs_by_resource_and_scope(&log_batch, &resource);
crate::transform::logs::tonic::group_logs_by_resource_and_scope(log_batch, &resource);

assert_eq!(grouped_logs.len(), 1);
let resource_logs = &grouped_logs[0];
Expand Down
4 changes: 1 addition & 3 deletions opentelemetry-sdk/src/logs/log_processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ use std::sync::mpsc::{self, RecvTimeoutError, SyncSender};
use opentelemetry::logs::Severity;
use opentelemetry::{otel_debug, otel_error, otel_warn, InstrumentationScope};

use std::sync::atomic::Ordering;
use std::sync::atomic::{AtomicBool, AtomicUsize};
use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering};
use std::{cmp::min, env, sync::Mutex};
use std::{
fmt::{self, Debug, Formatter},
Expand Down Expand Up @@ -613,7 +612,6 @@ impl<R: RuntimeChannel> BatchLogProcessorWithAsyncRuntime<R> {
let result = export_with_timeout(
config.max_export_timeout,
&mut exporter,
// Arc::clone(&exporter ),
&timeout_runtime,
logs.split_off(0),
)
Expand Down
6 changes: 3 additions & 3 deletions opentelemetry-stdout/src/logs/exporter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ impl opentelemetry_sdk::export::logs::LogExporter for LogExporter {
.compare_exchange(false, true, Ordering::SeqCst, Ordering::SeqCst)
.is_err()
{
print_logs(&batch);
print_logs(batch);
} else {
println!("Resource");
if let Some(schema_url) = self.resource.schema_url() {
Expand All @@ -55,7 +55,7 @@ impl opentelemetry_sdk::export::logs::LogExporter for LogExporter {
self.resource.iter().for_each(|(k, v)| {
println!("\t -> {}={:?}", k, v);
});
print_logs(&batch);
print_logs(batch);
}

Ok(())
Expand All @@ -72,7 +72,7 @@ impl opentelemetry_sdk::export::logs::LogExporter for LogExporter {
}
}

fn print_logs(batch: &LogBatch<'_>) {
fn print_logs(batch: LogBatch<'_>) {
for (i, log) in batch.iter().enumerate() {
println!("Log #{}", i);
let (record, _library) = log;
Expand Down
3 changes: 1 addition & 2 deletions stress/src/logs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ pub struct MockLogProcessor {
impl LogProcessor for MockLogProcessor {
fn emit(&self, record: &mut opentelemetry_sdk::logs::LogRecord, scope: &InstrumentationScope) {
let log_tuple = &[(record as &LogRecord, scope)];
let log_batch = LogBatch::new(log_tuple);
let _ = futures_executor::block_on(self.exporter.export(log_batch));
let _ = futures_executor::block_on(self.exporter.export(LogBatch::new(log_tuple)));
}

fn force_flush(&self) -> LogResult<()> {
Expand Down

0 comments on commit 36ea18a

Please sign in to comment.