-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2adbfd5
commit dc6493e
Showing
8 changed files
with
37 additions
and
52 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,29 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
use log::Level; | ||
use opentelemetry::global::logger_provider; | ||
use opentelemetry_appender_log::OpenTelemetryLogBridge; | ||
|
||
use opentelemetry_otlp; | ||
use opentelemetry_appender_tracing::layer::OpenTelemetryTracingBridge; | ||
use opentelemetry_sdk::{logs::Config, runtime}; | ||
|
||
use tracing_subscriber::prelude::*; | ||
|
||
use opentelemetry_sdk::logs as sdklogs; | ||
|
||
use super::get_resource_attr; | ||
|
||
pub fn init_logger() { | ||
let _ = opentelemetry_otlp::new_pipeline() | ||
pub fn init_logger() -> Result<sdklogs::Logger, opentelemetry::logs::LogError> { | ||
opentelemetry_otlp::new_pipeline() | ||
.logging() | ||
.with_log_config(Config::default().with_resource(get_resource_attr())) | ||
.with_exporter(opentelemetry_otlp::new_exporter().tonic()) | ||
.install_batch(runtime::Tokio); | ||
|
||
set_log_bridge(); | ||
.install_batch(runtime::Tokio) | ||
} | ||
|
||
fn set_log_bridge() { | ||
let logger_provider = logger_provider(); | ||
|
||
let otel_log_appender = OpenTelemetryLogBridge::new(&logger_provider); | ||
log::set_boxed_logger(Box::new(otel_log_appender)).unwrap(); | ||
log::set_max_level(Level::Info.to_level_filter()); | ||
pub fn configure_global_logger(tracer: opentelemetry_sdk::trace::Tracer) { | ||
let telemetry = tracing_opentelemetry::layer().with_tracer(tracer); | ||
let logger_provider = opentelemetry::global::logger_provider(); | ||
let layer = OpenTelemetryTracingBridge::new(&logger_provider); | ||
let _ = tracing_subscriber::registry() | ||
.with(layer) | ||
.with(telemetry) | ||
.init(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters