Skip to main content

Crate signal_kit

Crate signal_kit 

Source
Expand description

§signal-kit

Opinionated OpenTelemetry initialisation for async Rust services.

Most applications should use ObservabilityBuilder or the convenience functions init and try_init.

use signal_kit::ObservabilityBuilder;

let _guard = ObservabilityBuilder::new("my-service")
    .with_attribute("version", env!("CARGO_PKG_VERSION"))
    .init()?;

Use try_init for production applications and tests. Use init for examples, prototypes, and binaries where panicking on startup failure is acceptable. The crate installs the global tracing subscriber and should usually be initialized once near the start of main.

§Environment Variables

Compile-time build metadata is read with option_env!: GIT_COMMIT, GIT_BRANCH, GIT_REPOSITORY_URL, and BUILD_NUMBER.

Runtime exporter variables follow OpenTelemetry conventions: OTEL_EXPORTER_OTLP_ENDPOINT, OTEL_EXPORTER_OTLP_TRACES_ENDPOINT, OTEL_EXPORTER_OTLP_METRICS_ENDPOINT, and OTEL_EXPORTER_OTLP_LOGS_ENDPOINT. Signal-specific endpoints take precedence over the general endpoint.

Crate-specific runtime variables are namespaced under SIGNAL_KIT_: SIGNAL_KIT_STRUCTURED_LOGGING, SIGNAL_KIT_FILE_ENABLED, SIGNAL_KIT_FILE_PATH, SIGNAL_KIT_FILE_ROTATION, and SIGNAL_KIT_FILE_RETENTION_DAYS.

Resource attributes are resolved in this order: explicit builder attributes, OTEL_RESOURCE_ATTRIBUTES, crate convenience aliases such as ENVIRONMENT, CLOUD_*, and KUBERNETES_*, then compile-time metadata.

Re-exports§

pub use file_logging::FileLoggingConfig;
pub use file_logging::FileLoggingError;
pub use file_logging::RotationConfig;
pub use file_logging::RotationStrategy;

Modules§

file_logging
File-based logging for the signal-kit crate.
metrics
Metrics initialization and configuration.

Structs§

InitSummary
Summary of what was initialized during observability setup.
MetricsInitContext
Context passed to metrics initialization callbacks.
ObservabilityBuilder
Builder for configuring and initializing observability.
OtelGuard
RAII guard that holds OpenTelemetry providers alive and shuts them down on drop.
OtelShutdownError
Aggregate shutdown error across OpenTelemetry providers.

Enums§

InitWarning
Warnings generated during observability initialization.
MetricsInitError
Errors that can occur during metrics initialization.
OtelInitError
Errors that can occur during observability initialization.
OtelShutdownFailure
Individual provider shutdown failure.
OtlpTransport
The OTLP transport used to export one signal.
SignalKind
Kind of OpenTelemetry signal.

Constants§

OBSERVABILITY_EXPORT_INTERVAL
The interval at which metrics and traces are exported to the otlp collector.

Functions§

build_resource
Create a Resource that captures information about the entity for which telemetry is recorded, with additional custom attributes.
init
Panicking observability initialization for examples, prototypes, and binaries where startup failure should abort the process.
resolve_otlp_transport
Resolve the OTLP transport for a signal ("traces", "metrics", "logs").
try_init
Fallible observability initialization for applications, libraries, and tests.

Type Aliases§

MetricsInitCallback
Callback type for registering custom metrics after the meter provider is set up.