-
-
Notifications
You must be signed in to change notification settings - Fork 21
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
Showing
13 changed files
with
338 additions
and
145 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
[package] | ||
name = "kitsune-config" | ||
edition.workspace = true | ||
version.workspace = true | ||
|
||
[dependencies] | ||
eyre = "0.6.8" | ||
serde = { version = "1.0.189", features = ["derive"] } | ||
smol_str = { version = "0.2.0", features = ["serde"] } | ||
tokio = { version = "1.33.0", features = ["fs"] } | ||
toml = "0.8.2" |
File renamed without changes.
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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
[package] | ||
name = "kitsune-observability" | ||
edition.workspace = true | ||
version.workspace = true | ||
|
||
[dependencies] | ||
eyre = "0.6.8" | ||
kitsune-config = { path = "../kitsune-config" } | ||
metrics = "0.21.1" | ||
metrics-opentelemetry = { git = "https://github.com/aumetra/metrics-opentelemetry.git", rev = "7c3176266c215bb9a7cbc31b3c32f75a22824928" } | ||
metrics-tracing-context = "0.14.0" | ||
metrics-util = "0.15.1" | ||
opentelemetry-otlp = { version = "0.13.0", default-features = false, features = [ | ||
"http-proto", | ||
"metrics", | ||
"trace", | ||
] } | ||
opentelemetry = { version = "0.20.0", default-features = false, features = [ | ||
"rt-tokio", | ||
"trace", | ||
] } | ||
tracing = "0.1.40" | ||
tracing-error = "0.2.0" | ||
tracing-opentelemetry = { version = "0.21.0", default-features = false } | ||
tracing-subscriber = "0.3.17" |
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 |
---|---|---|
@@ -0,0 +1,46 @@ | ||
use eyre::Context; | ||
use kitsune_config::Configuration; | ||
use metrics_opentelemetry::OpenTelemetryRecorder; | ||
use opentelemetry::{metrics::MeterProvider, trace::Tracer}; | ||
use std::env; | ||
use tracing_error::ErrorLayer; | ||
use tracing_opentelemetry::OpenTelemetryLayer; | ||
use tracing_subscriber::{ | ||
filter::{LevelFilter, Targets}, | ||
layer::SubscriberExt, | ||
Layer, Registry, | ||
}; | ||
|
||
fn initialise_metrics<S, M>(config: &Configuration, meter_provider: M) -> impl Layer<S> | ||
where | ||
S: for<'a> tracing_subscriber::registry::LookupSpan<'a> + tracing::Subscriber, | ||
M: MeterProvider, | ||
{ | ||
use metrics_tracing_context::{MetricsLayer, TracingContextLayer}; | ||
use metrics_util::layers::Layer as _; | ||
|
||
let recorder = TracingContextLayer::all() | ||
.layer(OpenTelemetryRecorder::new(meter_provider.meter("kitsune"))); | ||
metrics::set_boxed_recorder(Box::new(recorder)).unwrap(); | ||
|
||
MetricsLayer::new() | ||
} | ||
|
||
fn initialise_logging(config: &Configuration) -> eyre::Result<()> { | ||
let env_filter = env::var("RUST_LOG") | ||
.map_err(eyre::Report::from) | ||
.and_then(|targets| targets.parse().context("Failed to parse RUST_LOG value")) | ||
.unwrap_or_else(|_| Targets::default().with_default(LevelFilter::INFO)); | ||
|
||
let subscriber = Registry::default() | ||
.with(tracing_subscriber::fmt::layer().with_filter(env_filter)) | ||
.with(ErrorLayer::default()) | ||
.with(OpenTelemetryLayer::new()); | ||
|
||
let subscriber = subscriber.with(initialise_metrics(config)); | ||
|
||
tracing::subscriber::set_global_default(subscriber) | ||
.context("Couldn't install the global tracing subscriber")?; | ||
|
||
Ok(()) | ||
} |
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 |
---|---|---|
|
@@ -7,7 +7,6 @@ | |
forbidden_lint_groups | ||
)] | ||
|
||
#[cfg(feature = "metrics")] | ||
#[macro_use] | ||
extern crate metrics; | ||
|
||
|
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