Open NickLarsenNZ opened 2 months ago
Recording down some output from recent discussions with @soenkeliebau and @Techassi...
@soenkeliebau made otlp exporters optional at runtime via:
let mut builder = Tracing::builder()
.service_name("whoyougonnacall")
.with_console_output("WYGC_CONSOLE", LevelFilter::INFO);
// Read env vars for whether to enable trace and log exporting
// We do this first in order to have tracing properly initialized
// when we start parsing the config
if enable_trace_exporter().context(ParseConfigSnafu)? {
builder = builder.with_otlp_trace_exporter("TEST_OTLP_TRACE", LevelFilter::TRACE);
}
if enable_log_exporter().context(ParseConfigSnafu)? {
builder = builder.with_otlp_log_exporter("TEST_OTLP_LOG", LevelFilter::TRACE);
}
let _tracing_guard = builder.build().init().context(InitializeTelemetrySnafu)?;
I suggested we could make this a little more developer friendly with some additional builder methods (and type states):
let _tracing_guard = Tracing::builder()
.service_name("whoyougonnacall")
.with_console_output("WYGC_CONSOLE", LevelFilter::INFO);
.with_otlp_trace_exporter("TEST_OTLP_TRACE", LevelFilter::TRACE)
.enabled(enable_trace_exporter().context(ParseConfigSnafu)?)
.with_otlp_log_exporter("TEST_OTLP_LOG", LevelFilter::TRACE)
.enabled(enable_log_exporter().context(ParseConfigSnafu)?)
.build().init().context(InitializeTelemetrySnafu)?;
@Techassi suggested a SettingsBuilder:
let _guard = Tracing::builder()
.service_name("stuff")
.with_console_output(
Settings::builder()
.env_var("MY_ENV_VAR")
.enabled(true)
)
To which I replied with the function signature taking anything that converts into a SettingsBuilder for the exporter:
fn with_console_output(settings: impl Into<ConsoleSettings>)
// example usage:
let _guard = Tracing::builder()
.service_name("stuff")
.with_console_output(
Settings::builder()
.env_var("MY_ENV_VAR")
.enabled(true)
.into() // gives us a ConfigSettingsBuilder
.log_format(Format::JSON)
.build()
)
// ...
The old initialize_logging implementation currently requires
opentelemetry-jaeger
which is now deprecated in favour of the vendor/collector agnostic OTLP protocol inopentelemetry-otlp
.This is preventing us from updating the opentelemetry related crates. (as seen in https://github.com/stackabletech/operator-rs/pull/867, among other past PRs).
The recommended path forward for using Jaeger is to use the OTLP protocol. stackable-telemetry already supports this, and so it is about time we deprecate the old log initialization and jaeger protocol and use stackable-telemetry.
Tasks
if let Some
so much).tracing_subscriber::filter::Directive
(instead of justtracing::level_filters::LevelFilter
).stackable_operator::logging::initialize_logging()
as#[deprecated, note = "Use stackable-telemetry instead, use OTLP instead of Jaeger protocol"]
.stackable_operator::utils::print_startup_string()
by using Span fields.stackable_operator::logging::initialize_logging()
withstckable_telemetry::Tracing::builder()
(discuss making astackable-operator
crate feature to initializestackable-telemetry
consistently across operators while keeping stackable-telemetry open for use outside of our operators).Acceptance Criteria
Code example for secret-operator:
secret-operator logging (before)
secret-operator logging (after)
The code above will be replaced with code looking like this: