Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(foundations): spelling #210

Merged
merged 1 commit into from
May 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions foundations/examples/src/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ use scuffle_foundations::bootstrap::{bootstrap, Bootstrap, RuntimeSettings};
use scuffle_foundations::runtime::spawn;
use scuffle_foundations::settings::auto_settings;
use scuffle_foundations::settings::cli::Matches;
use scuffle_foundations::telementry::opentelemetry::OpenTelemetrySpanExt;
use scuffle_foundations::telementry::settings::TelementrySettings;
use scuffle_foundations::telemetry::opentelemetry::OpenTelemetrySpanExt;
use scuffle_foundations::telemetry::settings::TelemetrySettings;
use scuffle_foundations::{wrapped, BootstrapResult};
use socket2::Socket;
use tokio::net::{TcpListener, TcpStream};
Expand All @@ -22,7 +22,7 @@ type Body = http_body_util::Full<Bytes>;
#[auto_settings]
#[serde(default)]
struct Config {
telemetry: TelementrySettings,
telemetry: TelemetrySettings,
runtime: RuntimeSettings,
#[settings(default = SocketAddr::from(([127, 0, 0, 1], 8080)))]
bind: SocketAddr,
Expand All @@ -37,7 +37,7 @@ impl Bootstrap for Config {
self.runtime.clone()
}

fn telemetry_config(&self) -> Option<TelementrySettings> {
fn telemetry_config(&self) -> Option<TelemetrySettings> {
Some(self.telemetry.clone())
}
}
Expand Down
14 changes: 7 additions & 7 deletions foundations/examples/src/simple.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
use scuffle_foundations::bootstrap::{bootstrap, Bootstrap, RuntimeSettings};
use scuffle_foundations::settings::auto_settings;
use scuffle_foundations::settings::cli::Matches;
use scuffle_foundations::telementry::metrics::metrics;
use scuffle_foundations::telementry::settings::TelementrySettings;
use scuffle_foundations::telemetry::metrics::metrics;
use scuffle_foundations::telemetry::settings::TelemetrySettings;

#[metrics]
mod http_server {
use std::sync::Arc;

use scuffle_foundations::telementry::metrics::prometheus_client::metrics::counter::Counter;
use scuffle_foundations::telemetry::metrics::prometheus_client::metrics::counter::Counter;

/// Number of active client connections.
pub fn active_connections(endpoint_name: &str) -> Counter;
Expand All @@ -26,8 +26,8 @@ mod http_server {

#[auto_settings]
pub struct HttpServerSettings {
/// Telementry Settings
telementry: TelementrySettings,
/// Telemetry Settings
telemetry: TelemetrySettings,
/// Runtime Settings
runtime: RuntimeSettings,
}
Expand All @@ -39,8 +39,8 @@ impl Bootstrap for HttpServerSettings {
self.runtime.clone()
}

fn telemetry_config(&self) -> Option<TelementrySettings> {
Some(self.telementry.clone())
fn telemetry_config(&self) -> Option<TelemetrySettings> {
Some(self.telemetry.clone())
}
}

Expand Down
12 changes: 6 additions & 6 deletions foundations/macros/src/metrics/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ fn metric_function(

let metric_ident = if has_args {
quote::quote! {
#crate_path::telementry::metrics::serde::Family<__Args, #ret>
#crate_path::telemetry::metrics::serde::Family<__Args, #ret>
}
} else {
quote::quote! {
Expand All @@ -347,14 +347,14 @@ fn metric_function(
let constructor = quote::quote! {
{
(|| {
#crate_path::telementry::metrics::MetricBuilder::build(&#builder)
#crate_path::telemetry::metrics::MetricBuilder::build(&#builder)
}) as fn() -> #ret
}
};

if has_args {
quote::quote! {
#crate_path::telementry::metrics::serde::Family::new_with_constructor(#constructor)
#crate_path::telemetry::metrics::serde::Family::new_with_constructor(#constructor)
}
} else {
quote::quote! {
Expand All @@ -364,7 +364,7 @@ fn metric_function(
} else {
if has_args {
quote::quote! {
#crate_path::telementry::metrics::serde::Family::default()
#crate_path::telemetry::metrics::serde::Family::default()
}
} else {
quote::quote! {
Expand All @@ -375,11 +375,11 @@ fn metric_function(

let registry = if item.attrs.options.optional || options.optional {
quote::quote! {
#crate_path::telementry::metrics::registries::Registries::get_optional_sub_registry(stringify!(#module_name))
#crate_path::telemetry::metrics::registries::Registries::get_optional_sub_registry(stringify!(#module_name))
}
} else {
quote::quote! {
#crate_path::telementry::metrics::registries::Registries::get_main_sub_registry(stringify!(#module_name))
#crate_path::telemetry::metrics::registries::Registries::get_main_sub_registry(stringify!(#module_name))
}
};

Expand Down
4 changes: 2 additions & 2 deletions foundations/src/bootstrap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ pub fn bootstrap<C: Bootstrap, F: Fn(Matches<C>) -> Fut, Fut: Future<Output = an
runtime.block_on(async move {
#[cfg(feature = "_telemetry")]
if let Some(telemetry) = matches.settings.telemetry_config() {
crate::telementry::settings::init(info, telemetry).await;
crate::telemetry::settings::init(info, telemetry).await;
}

main(matches).await
Expand Down Expand Up @@ -67,7 +67,7 @@ pub trait Bootstrap: Sized + From<Self::Settings> {
}

#[cfg(feature = "_telemetry")]
fn telemetry_config(&self) -> Option<crate::telementry::settings::TelementrySettings> {
fn telemetry_config(&self) -> Option<crate::telemetry::settings::TelemetrySettings> {
None
}

Expand Down
2 changes: 1 addition & 1 deletion foundations/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub mod settings;
pub mod bootstrap;

#[cfg(feature = "_telemetry")]
pub mod telementry;
pub mod telemetry;

#[cfg(feature = "signal")]
pub mod signal;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub mod server;
type Underlying = tracing::level_filters::LevelFilter;

#[cfg(feature = "env-filter")]
type Underlying = crate::telementry::EnvFilter;
type Underlying = crate::telemetry::EnvFilter;

#[derive(Debug)]
pub struct LevelFilter(Underlying);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::sync::Arc;

use itertools::Itertools;
use opentelemetry::trace::TraceError;
use ::opentelemetry::trace::TraceError;
use opentelemetry_otlp::SpanExporter;
use opentelemetry_sdk::Resource;
use thread_local::ThreadLocal;
Expand All @@ -15,8 +15,8 @@ use super::node::SpanNode;
use crate::runtime::spawn;

#[cfg(feature = "metrics")]
#[crate::telementry::metrics::metrics(crate_path = "crate")]
mod opentelementry {
#[crate::telemetry::metrics::metrics(crate_path = "crate")]
mod opentelemetry {
use prometheus_client::metrics::counter::Counter;

#[derive(serde::Serialize, Debug, Clone, Copy, PartialEq, Eq, Hash)]
Expand Down Expand Up @@ -97,8 +97,8 @@ impl BatchExporter {

pub fn with_service_info(&mut self, info: crate::ServiceInfo) -> &mut Self {
self.resource.merge(&Resource::new(vec![
opentelemetry::KeyValue::new("service.name", info.metric_name),
opentelemetry::KeyValue::new("service.version", info.version),
::opentelemetry::KeyValue::new("service.name", info.metric_name),
::opentelemetry::KeyValue::new("service.version", info.version),
]));

self
Expand Down Expand Up @@ -177,18 +177,18 @@ fn export_batch(internal: Arc<ExportInternal>, batch: Vec<SpanNode>, pending_per
#[cfg(feature = "metrics")]
if internal.config.metrics {
let reason = match err {
TraceError::ExportTimedOut(_) => opentelementry::SpanDroppedReason::ExportTimeout,
_ => opentelementry::SpanDroppedReason::ExportFailed,
TraceError::ExportTimedOut(_) => opentelemetry::SpanDroppedReason::ExportTimeout,
_ => opentelemetry::SpanDroppedReason::ExportFailed,
};

opentelementry::spans_dropped(reason).inc_by(size as u64);
opentelemetry::spans_dropped(reason).inc_by(size as u64);
}

(internal.config.error_handler)(err, size);
} else {
#[cfg(feature = "metrics")]
if internal.config.metrics {
opentelementry::spans_exported().inc_by(size as u64);
opentelemetry::spans_exported().inc_by(size as u64);
}

(internal.config.export_handler)(size);
Expand Down Expand Up @@ -239,7 +239,7 @@ impl Exporter {

#[cfg(feature = "metrics")]
if self.internal.config.metrics {
opentelementry::spans_dropped(opentelementry::SpanDroppedReason::ThreadBackpressure)
opentelemetry::spans_dropped(opentelemetry::SpanDroppedReason::ThreadBackpressure)
.inc_by(total_dropped as u64);
}

Expand Down Expand Up @@ -285,7 +285,7 @@ impl Exporter {

#[cfg(feature = "metrics")]
if self.internal.config.metrics {
opentelementry::spans_dropped(opentelementry::SpanDroppedReason::PendingExportBackpressure)
opentelemetry::spans_dropped(opentelemetry::SpanDroppedReason::PendingExportBackpressure)
.inc_by(pending_total_dropped as u64);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ async fn pprof_cpu(
}

match tokio::task::spawn_blocking(move || {
crate::telementry::pprof::Cpu::new(query.frequency, &query.blocklist)
crate::telemetry::pprof::Cpu::new(query.frequency, &query.blocklist)
.capture(std::time::Duration::from_secs(query.seconds as u64))
})
.await
Expand Down Expand Up @@ -106,7 +106,7 @@ async fn pprof_cpu(

#[cfg(feature = "pprof-heap")]
async fn pprof_heap() -> axum::response::Response<axum::body::Body> {
match tokio::task::spawn_blocking(|| crate::telementry::pprof::Heap::new().capture()).await {
match tokio::task::spawn_blocking(|| crate::telemetry::pprof::Heap::new().capture()).await {
Ok(Ok(contents)) => axum::response::Response::builder()
.status(axum::http::StatusCode::OK)
.header("content-type", "application/octet-stream")
Expand Down Expand Up @@ -140,7 +140,7 @@ struct MetricsQuery {
async fn metrics(
axum::extract::Query(query): axum::extract::Query<MetricsQuery>,
) -> axum::response::Response<axum::body::Body> {
match tokio::task::spawn_blocking(move || crate::telementry::metrics::collect(query.optional)).await {
match tokio::task::spawn_blocking(move || crate::telemetry::metrics::collect(query.optional)).await {
Ok(Ok(contents)) => axum::response::Response::builder()
.status(axum::http::StatusCode::OK)
.header("content-type", "text/plain")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ use opentelemetry_sdk::Resource;
use tracing_subscriber::fmt::time::{ChronoLocal, ChronoUtc};

#[cfg(feature = "logging")]
use crate::telementry::logging::TimeFormatter;
use crate::telementry::opentelemetry::{complex_rate_sampler, BatchExporter, Sampler, SpanObserver};
use crate::telemetry::logging::TimeFormatter;
use crate::telemetry::opentelemetry::{complex_rate_sampler, BatchExporter, Sampler, SpanObserver};

#[crate::settings::auto_settings(crate_path = "crate")]
pub struct TelementrySettings {
pub struct TelemetrySettings {
/// Settings for metric exporting.
pub metrics: MetricsSettings,
/// Settings for opentelemetry span exporting.
Expand Down Expand Up @@ -271,18 +271,18 @@ pub struct ServerSettings {
pub health_timeout: Option<std::time::Duration>,
}

pub async fn init(info: crate::ServiceInfo, settings: TelementrySettings) {
pub async fn init(info: crate::ServiceInfo, settings: TelemetrySettings) {
#[cfg(feature = "metrics")]
if settings.metrics.enabled {
crate::telementry::metrics::init(info, &settings.metrics.labels);
crate::telemetry::metrics::init(info, &settings.metrics.labels);
}

#[cfg(any(feature = "opentelemetry", feature = "logging"))]
{
#[cfg(feature = "opentelemetry")]
let opentelemetry = if settings.opentelemetry.enabled {
Some(
crate::telementry::opentelemetry::layer(
crate::telemetry::opentelemetry::layer(
SpanObserver {
max_unprocessed_spans_per_thread: settings.opentelemetry.max_backpressure,
sampler: match settings.opentelemetry.sampler {
Expand Down Expand Up @@ -326,7 +326,7 @@ pub async fn init(info: crate::ServiceInfo, settings: TelementrySettings) {
Resource::new(kv)
},
drop_handler: {
const DROPPED_SPANS_ERROR: &str = "opentelementry exporter dropped spans due to backpressure";
const DROPPED_SPANS_ERROR: &str = "opentelemetry exporter dropped spans due to backpressure";

match settings.opentelemetry.logging.dropped_spans {
OpentelemetrySettingsLoggingLevel::Error => Box::new(|count| {
Expand All @@ -348,7 +348,7 @@ pub async fn init(info: crate::ServiceInfo, settings: TelementrySettings) {
}
},
error_handler: {
const EXPORTER_ERROR: &str = "opentelementry exporter failed to export spans";
const EXPORTER_ERROR: &str = "opentelemetry exporter failed to export spans";

match settings.opentelemetry.logging.exporter_errors {
OpentelemetrySettingsLoggingLevel::Error => Box::new(|err, count| {
Expand All @@ -370,7 +370,7 @@ pub async fn init(info: crate::ServiceInfo, settings: TelementrySettings) {
}
},
export_handler: {
const EXPORTER_SUCCESS: &str = "opentelementry exporter successfully exported spans";
const EXPORTER_SUCCESS: &str = "opentelemetry exporter successfully exported spans";

match settings.opentelemetry.logging.exporter_success {
OpentelemetrySettingsLoggingLevel::Error => Box::new(|count| {
Expand Down Expand Up @@ -455,7 +455,7 @@ pub async fn init(info: crate::ServiceInfo, settings: TelementrySettings) {
use crate::runtime::spawn;

spawn(async move {
match crate::telementry::server::init(super::server::ServerSettings {
match crate::telemetry::server::init(super::server::ServerSettings {
bind: settings.server.bind,
#[cfg(feature = "metrics")]
metrics_path: settings.server.metrics_path,
Expand Down
Loading