Skip to content

Commit

Permalink
refactor: InMemoryLogsExporter and Builder non plural
Browse files Browse the repository at this point in the history
  • Loading branch information
pitoniak32 committed Oct 28, 2024
1 parent 17f4627 commit 973a8bd
Show file tree
Hide file tree
Showing 10 changed files with 59 additions and 59 deletions.
2 changes: 1 addition & 1 deletion examples/self-diagnostics/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ cargo run

- If the docker instance for collector is running, below error should be logged into the container. There won't be any logs from the `hyper`, `reqwest` and `tonic` crates.
```
otel-collector-1 | 2024-06-05T17:09:46.926Z info LogsExporter {"kind": "exporter", "data_type": "logs", "name": "logging", "resource logs": 1, "log records": 1}
otel-collector-1 | 2024-06-05T17:09:46.926Z info LogExporter {"kind": "exporter", "data_type": "logs", "name": "logging", "resource logs": 1, "log records": 1}
otel-collector-1 | 2024-06-05T17:09:46.926Z info ResourceLog #0
otel-collector-1 | Resource SchemaURL:
otel-collector-1 | Resource attributes:
Expand Down
12 changes: 6 additions & 6 deletions opentelemetry-appender-log/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -753,13 +753,13 @@ mod tests {
use super::OpenTelemetryLogBridge;

use opentelemetry::{logs::AnyValue, StringValue};
use opentelemetry_sdk::{logs::LoggerProvider, testing::logs::InMemoryLogsExporter};
use opentelemetry_sdk::{logs::LoggerProvider, testing::logs::InMemoryLogExporter};

use log::Log;

#[test]
fn logbridge_with_default_metadata_is_enabled() {
let exporter = InMemoryLogsExporter::default();
let exporter = InMemoryLogExporter::default();

let logger_provider = LoggerProvider::builder()
.with_simple_exporter(exporter)
Expand All @@ -778,7 +778,7 @@ mod tests {

#[test]
fn logbridge_with_record_can_log() {
let exporter = InMemoryLogsExporter::default();
let exporter = InMemoryLogExporter::default();

let logger_provider = LoggerProvider::builder()
.with_simple_exporter(exporter.clone())
Expand Down Expand Up @@ -892,7 +892,7 @@ mod tests {
}
}

let exporter = InMemoryLogsExporter::default();
let exporter = InMemoryLogExporter::default();

let logger_provider = LoggerProvider::builder()
.with_simple_exporter(exporter.clone())
Expand Down Expand Up @@ -1158,7 +1158,7 @@ mod tests {
CODE_FILEPATH, CODE_LINENO, CODE_NAMESPACE,
};

let exporter = InMemoryLogsExporter::default();
let exporter = InMemoryLogExporter::default();

let logger_provider = LoggerProvider::builder()
.with_simple_exporter(exporter.clone())
Expand Down Expand Up @@ -1201,7 +1201,7 @@ mod tests {

#[test]
fn test_flush() {
let exporter = InMemoryLogsExporter::default();
let exporter = InMemoryLogExporter::default();

let logger_provider = LoggerProvider::builder()
.with_simple_exporter(exporter)
Expand Down
12 changes: 6 additions & 6 deletions opentelemetry-appender-tracing/src/layer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ mod tests {
use opentelemetry::{logs::AnyValue, Key};
use opentelemetry_sdk::export::logs::{LogBatch, LogExporter};
use opentelemetry_sdk::logs::{LogRecord, LoggerProvider};
use opentelemetry_sdk::testing::logs::InMemoryLogsExporter;
use opentelemetry_sdk::testing::logs::InMemoryLogExporter;
use opentelemetry_sdk::trace;
use opentelemetry_sdk::trace::{Sampler, TracerProvider};
use tracing::{error, warn};
Expand All @@ -231,7 +231,7 @@ mod tests {
}

fn create_tracing_subscriber(
_exporter: InMemoryLogsExporter,
_exporter: InMemoryLogExporter,
logger_provider: &LoggerProvider,
) -> impl tracing::Subscriber {
let level_filter = tracing_subscriber::filter::LevelFilter::WARN; // Capture WARN and ERROR levels
Expand Down Expand Up @@ -309,7 +309,7 @@ mod tests {
#[test]
fn tracing_appender_standalone() {
// Arrange
let exporter: InMemoryLogsExporter = InMemoryLogsExporter::default();
let exporter: InMemoryLogExporter = InMemoryLogExporter::default();
let logger_provider = LoggerProvider::builder()
.with_simple_exporter(exporter.clone())
.build();
Expand Down Expand Up @@ -389,7 +389,7 @@ mod tests {
#[test]
fn tracing_appender_inside_tracing_context() {
// Arrange
let exporter: InMemoryLogsExporter = InMemoryLogsExporter::default();
let exporter: InMemoryLogExporter = InMemoryLogExporter::default();
let logger_provider = LoggerProvider::builder()
.with_simple_exporter(exporter.clone())
.build();
Expand Down Expand Up @@ -500,7 +500,7 @@ mod tests {
#[test]
fn tracing_appender_standalone_with_tracing_log() {
// Arrange
let exporter: InMemoryLogsExporter = InMemoryLogsExporter::default();
let exporter: InMemoryLogExporter = InMemoryLogExporter::default();
let logger_provider = LoggerProvider::builder()
.with_simple_exporter(exporter.clone())
.build();
Expand Down Expand Up @@ -565,7 +565,7 @@ mod tests {
#[test]
fn tracing_appender_inside_tracing_context_with_tracing_log() {
// Arrange
let exporter: InMemoryLogsExporter = InMemoryLogsExporter::default();
let exporter: InMemoryLogExporter = InMemoryLogExporter::default();
let logger_provider = LoggerProvider::builder()
.with_simple_exporter(exporter.clone())
.build();
Expand Down
2 changes: 1 addition & 1 deletion opentelemetry-otlp/examples/basic-otlp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ Value: 10
### Logs

```text
2024-05-22T20:25:42.914Z info LogsExporter {"kind": "exporter", "data_type": "logs", "name": "logging", "resource logs": 2, "log records": 2}
2024-05-22T20:25:42.914Z info LogExporter {"kind": "exporter", "data_type": "logs", "name": "logging", "resource logs": 2, "log records": 2}
2024-05-22T20:25:42.914Z info ResourceLog #0
Resource SchemaURL:
Resource attributes:
Expand Down
4 changes: 2 additions & 2 deletions opentelemetry-sdk/src/logs/log_emitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ mod tests {
resource::{
SERVICE_NAME, TELEMETRY_SDK_LANGUAGE, TELEMETRY_SDK_NAME, TELEMETRY_SDK_VERSION,
},
testing::logs::InMemoryLogsExporter,
testing::logs::InMemoryLogExporter,
trace::TracerProvider,
Resource,
};
Expand Down Expand Up @@ -480,7 +480,7 @@ mod tests {

#[test]
fn trace_context_test() {
let exporter = InMemoryLogsExporter::default();
let exporter = InMemoryLogExporter::default();

let logger_provider = LoggerProvider::builder()
.with_simple_exporter(exporter.clone())
Expand Down
30 changes: 15 additions & 15 deletions opentelemetry-sdk/src/logs/log_processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ mod tests {
};
use crate::export::logs::{LogBatch, LogExporter};
use crate::logs::LogRecord;
use crate::testing::logs::InMemoryLogsExporterBuilder;
use crate::testing::logs::InMemoryLogExporterBuilder;
use crate::{
logs::{
log_processor::{
Expand All @@ -543,7 +543,7 @@ mod tests {
BatchConfig, BatchConfigBuilder, LogProcessor, LoggerProvider, SimpleLogProcessor,
},
runtime,
testing::logs::InMemoryLogsExporter,
testing::logs::InMemoryLogExporter,
Resource,
};
use async_trait::async_trait;
Expand Down Expand Up @@ -690,7 +690,7 @@ mod tests {
];
temp_env::with_vars(env_vars.clone(), || {
let builder =
BatchLogProcessor::builder(InMemoryLogsExporter::default(), runtime::Tokio);
BatchLogProcessor::builder(InMemoryLogExporter::default(), runtime::Tokio);

assert_eq!(builder.config.max_export_batch_size, 500);
assert_eq!(
Expand All @@ -711,7 +711,7 @@ mod tests {

temp_env::with_vars(env_vars, || {
let builder =
BatchLogProcessor::builder(InMemoryLogsExporter::default(), runtime::Tokio);
BatchLogProcessor::builder(InMemoryLogExporter::default(), runtime::Tokio);
assert_eq!(builder.config.max_export_batch_size, 120);
assert_eq!(builder.config.max_queue_size, 120);
});
Expand All @@ -726,7 +726,7 @@ mod tests {
.with_max_queue_size(4)
.build();

let builder = BatchLogProcessor::builder(InMemoryLogsExporter::default(), runtime::Tokio)
let builder = BatchLogProcessor::builder(InMemoryLogExporter::default(), runtime::Tokio)
.with_batch_config(expected);

let actual = &builder.config;
Expand Down Expand Up @@ -784,7 +784,7 @@ mod tests {
async fn test_batch_shutdown() {
// assert we will receive an error
// setup
let exporter = InMemoryLogsExporterBuilder::default()
let exporter = InMemoryLogExporterBuilder::default()
.keep_records_on_shutdown()
.build();
let processor = BatchLogProcessor::new(
Expand All @@ -806,7 +806,7 @@ mod tests {

#[test]
fn test_simple_shutdown() {
let exporter = InMemoryLogsExporterBuilder::default()
let exporter = InMemoryLogExporterBuilder::default()
.keep_records_on_shutdown()
.build();
let processor = SimpleLogProcessor::new(Box::new(exporter.clone()));
Expand All @@ -831,7 +831,7 @@ mod tests {
#[tokio::test(flavor = "current_thread")]
#[ignore = "See issue https://github.com/open-telemetry/opentelemetry-rust/issues/1968"]
async fn test_batch_log_processor_shutdown_with_async_runtime_current_flavor_multi_thread() {
let exporter = InMemoryLogsExporterBuilder::default().build();
let exporter = InMemoryLogExporterBuilder::default().build();

Check warning on line 834 in opentelemetry-sdk/src/logs/log_processor.rs

View check run for this annotation

Codecov / codecov/patch

opentelemetry-sdk/src/logs/log_processor.rs#L834

Added line #L834 was not covered by tests
let processor = BatchLogProcessor::new(
Box::new(exporter.clone()),
BatchConfig::default(),
Expand All @@ -846,7 +846,7 @@ mod tests {

#[tokio::test(flavor = "current_thread")]
async fn test_batch_log_processor_shutdown_with_async_runtime_current_flavor_current_thread() {
let exporter = InMemoryLogsExporterBuilder::default().build();
let exporter = InMemoryLogExporterBuilder::default().build();
let processor = BatchLogProcessor::new(
Box::new(exporter.clone()),
BatchConfig::default(),
Expand All @@ -858,7 +858,7 @@ mod tests {

#[tokio::test(flavor = "multi_thread")]
async fn test_batch_log_processor_shutdown_with_async_runtime_multi_flavor_multi_thread() {
let exporter = InMemoryLogsExporterBuilder::default().build();
let exporter = InMemoryLogExporterBuilder::default().build();
let processor = BatchLogProcessor::new(
Box::new(exporter.clone()),
BatchConfig::default(),
Expand All @@ -870,7 +870,7 @@ mod tests {

#[tokio::test(flavor = "multi_thread")]
async fn test_batch_log_processor_shutdown_with_async_runtime_multi_flavor_current_thread() {
let exporter = InMemoryLogsExporterBuilder::default().build();
let exporter = InMemoryLogExporterBuilder::default().build();
let processor = BatchLogProcessor::new(
Box::new(exporter.clone()),
BatchConfig::default(),
Expand Down Expand Up @@ -989,7 +989,7 @@ mod tests {

#[test]
fn test_simple_processor_sync_exporter_without_runtime() {
let exporter = InMemoryLogsExporterBuilder::default().build();
let exporter = InMemoryLogExporterBuilder::default().build();
let processor = SimpleLogProcessor::new(Box::new(exporter.clone()));

let mut record: LogRecord = Default::default();
Expand All @@ -1002,7 +1002,7 @@ mod tests {

#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
async fn test_simple_processor_sync_exporter_with_runtime() {
let exporter = InMemoryLogsExporterBuilder::default().build();
let exporter = InMemoryLogExporterBuilder::default().build();
let processor = SimpleLogProcessor::new(Box::new(exporter.clone()));

let mut record: LogRecord = Default::default();
Expand All @@ -1015,7 +1015,7 @@ mod tests {

#[tokio::test(flavor = "multi_thread")]
async fn test_simple_processor_sync_exporter_with_multi_thread_runtime() {
let exporter = InMemoryLogsExporterBuilder::default().build();
let exporter = InMemoryLogExporterBuilder::default().build();
let processor = Arc::new(SimpleLogProcessor::new(Box::new(exporter.clone())));

let mut handles = vec![];
Expand All @@ -1038,7 +1038,7 @@ mod tests {

#[tokio::test(flavor = "current_thread")]
async fn test_simple_processor_sync_exporter_with_current_thread_runtime() {
let exporter = InMemoryLogsExporterBuilder::default().build();
let exporter = InMemoryLogExporterBuilder::default().build();
let processor = SimpleLogProcessor::new(Box::new(exporter.clone()));

let mut record: LogRecord = Default::default();
Expand Down
4 changes: 2 additions & 2 deletions opentelemetry-sdk/src/logs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub struct LogData {
#[cfg(all(test, feature = "testing"))]
mod tests {
use super::*;
use crate::testing::logs::InMemoryLogsExporter;
use crate::testing::logs::InMemoryLogExporter;
use crate::Resource;
use opentelemetry::logs::LogRecord;
use opentelemetry::logs::{Logger, LoggerProvider as _, Severity};
Expand All @@ -40,7 +40,7 @@ mod tests {
KeyValue::new("k3", "v3"),
KeyValue::new("k4", "v4"),
]);
let exporter: InMemoryLogsExporter = InMemoryLogsExporter::default();
let exporter: InMemoryLogExporter = InMemoryLogExporter::default();
let logger_provider = LoggerProvider::builder()
.with_resource(resource.clone())
.with_log_processor(SimpleLogProcessor::new(Box::new(exporter.clone())))
Expand Down
Loading

0 comments on commit 973a8bd

Please sign in to comment.