Skip to main content

Module lifecycle

Module lifecycle 

Source
Expand description

In-process OTel logs export plus a periodic Prometheus remote-write push for metrics. Both pipelines share one six-month BLS-BN254 JWT minted from the staking key. Tracing events go through an OTLP/HTTP batch exporter; an externally supplied prometheus::Registry is scraped on a tokio interval and POSTed to /api/v1/write as snappy-compressed protobuf.

Failure modes:

  • Proxy down: BatchLogProcessor queue fills (~2k records) then drops; metrics push warn!s and retries next tick. Neither uses disk nor blocks consensus.
  • JWT misconfig: init returns Err; the caller continues without telemetry.
  • Token TTL expiry mid-process is not handled; the six-month TTL outlasts typical restart cadence.

StructsΒ§

MetricsPushHandle πŸ”’
Handle to the metrics push thread. The thread owns a dedicated single-threaded runtime so a slow proxy can’t starve a consensus worker.
TelemetryHandle
Owns the OTel logger provider and, optionally, the metrics push task, so both flush on graceful shutdown. Stashes the JWT and endpoint so the push task can be spawned later via TelemetryHandle::attach_metrics_push once the API setup has built the Registry.
TelemetryOptions
Operator-facing telemetry configuration.

ConstantsΒ§

PUBKEY_SLUG_LEN πŸ”’
SERVICE_NAME πŸ”’
SHUTDOWN_TIMEOUT πŸ”’

StaticsΒ§

REGISTRY πŸ”’
Global handoff for the prometheus Registry populated by HotShot.

FunctionsΒ§

build_logger_provider πŸ”’
init
Initialize the OTel logger pipeline and, when registry is Some, spawn the metrics push immediately. Production passes None (the Registry isn’t built yet) and later calls TelemetryHandle::attach_metrics_push; tests pass it directly.
instance_id πŸ”’
join_bounded πŸ”’
Join thread, detaching it after SHUTDOWN_TIMEOUT so a wedged exporter can’t hang shutdown on the main thread.
pubkey_slug πŸ”’
registry
Read the registry deposited by set_registry. None if no API setup has run yet (tests, CLI tools without the HTTP module).
segment πŸ”’
set_registry
Deposit the Registry. Idempotent: subsequent calls are no-ops, since OnceLock::set returns Err.