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§
- Init
Summary - Summary of what was initialized during observability setup.
- Metrics
Init Context - Context passed to metrics initialization callbacks.
- Observability
Builder - Builder for configuring and initializing observability.
- Otel
Guard - RAII guard that holds OpenTelemetry providers alive and shuts them down on drop.
- Otel
Shutdown Error - Aggregate shutdown error across OpenTelemetry providers.
Enums§
- Init
Warning - Warnings generated during observability initialization.
- Metrics
Init Error - Errors that can occur during metrics initialization.
- Otel
Init Error - Errors that can occur during observability initialization.
- Otel
Shutdown Failure - Individual provider shutdown failure.
- Otlp
Transport - The OTLP transport used to export one signal.
- Signal
Kind - 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§
- Metrics
Init Callback - Callback type for registering custom metrics after the meter provider is set up.