| Safe Haskell | None |
|---|---|
| Language | GHC2024 |
Arbiter.Otel
Description
OpenTelemetry for arbiter: traces, metrics and logs.
Spans and trace-context propagation are built in. This module is the SDK side.
runWorkerPools installs the exporters and instruments the pools. The With variants
take a handle the caller installed itself.
env <- createHasqlEnv ... runHasqlDb env $ Otel.runWorkerPools [namedWorkerPool emailCfg]
Synopsis
- data Telemetry = Telemetry {
- meters :: Maybe ArbiterMeters
- provider :: MeterProvider
- logDestination :: Maybe LogDestination
- gaugeRefresh :: NominalDiffTime
- telemetrySummary :: Text
- withTelemetry :: (Telemetry -> IO a) -> IO a
- withTelemetryIf :: Bool -> (Telemetry -> IO a) -> IO a
- withTelemetryFromEnv :: (Telemetry -> IO a) -> IO a
- withExternalTelemetry :: Maybe MeterProvider -> Maybe LoggerProvider -> (Telemetry -> IO a) -> IO a
- telemetryLogConfig :: Telemetry -> LogConfig -> LogConfig
- instrumentPool :: forall (m :: Type -> Type). MonadUnliftIO m => Telemetry -> NamedWorkerPool m -> NamedWorkerPool m
- instrumentPools :: forall (m :: Type -> Type). MonadUnliftIO m => Telemetry -> [NamedWorkerPool m] -> [NamedWorkerPool m]
- instrumentConfig :: forall (m :: Type -> Type) payload. (HasKind payload, KnownSymbol (TableForPayload payload (RegistryOf m)), MonadUnliftIO m) => Telemetry -> WorkerConfig m payload -> WorkerConfig m payload
- runWorkerPools :: (MonadArbiter m, RegistryTables (RegistryOf m)) => [NamedWorkerPool m] -> m ()
- runSelectedWorkerPools :: (MonadArbiter m, RegistryTables (RegistryOf m)) => [Text] -> [NamedWorkerPool m] -> m ()
- runWorkerPoolsWith :: (MonadArbiter m, RegistryTables (RegistryOf m)) => Telemetry -> LogConfig -> [NamedWorkerPool m] -> m ()
- runSelectedWorkerPoolsWith :: (MonadArbiter m, RegistryTables (RegistryOf m)) => Telemetry -> LogConfig -> [Text] -> [NamedWorkerPool m] -> m ()
- withGauges :: (MonadArbiter m, RegistryTables (RegistryOf m)) => Telemetry -> LogConfig -> m b -> m b
- startGauges :: MonadArbiter m => Telemetry -> LogConfig -> (forall a. m a -> IO a) -> SchemaName -> [(TableName, [Text])] -> NominalDiffTime -> IO (IO ())
- arbiterMetricNames :: [Text]
Setup
A running telemetry handle: instruments, provider, and resolved settings.
Constructors
| Telemetry | |
Fields
| |
Source #withTelemetry :: (Telemetry -> IO a) -> IO a
Bracketed OpenTelemetry init/shutdown. Nested brackets unwind partial setup. Every
signal is the SDK's, resolved from its own OTEL_ variables.
withTelemetryFromEnv is the gated form.
Source #withTelemetryIf :: Bool -> (Telemetry -> IO a) -> IO a
withTelemetry when the flag is set. An inert handle when the flag is off.
Source #withTelemetryFromEnv :: (Telemetry -> IO a) -> IO a
withTelemetryIf on OTEL_SDK_DISABLED, the spec's own switch.
Source #withExternalTelemetry :: Maybe MeterProvider -> Maybe LoggerProvider -> (Telemetry -> IO a) -> IO a
Run an action with application-owned providers. Missing providers disable their applicable signals.
Source #telemetryLogConfig :: Telemetry -> LogConfig -> LogConfig
Send log output to the configured destination and this handle's destination.
Instrumenting a pool
Source #instrumentPool :: forall (m :: Type -> Type). MonadUnliftIO m => Telemetry -> NamedWorkerPool m -> NamedWorkerPool m
Give a pool consumer spans, lifecycle metrics, and the telemetry log destination. The pool's registry queue name labels its metrics and gauges. Apply it once per pool.
Source #instrumentPools :: forall (m :: Type -> Type). MonadUnliftIO m => Telemetry -> [NamedWorkerPool m] -> [NamedWorkerPool m]
instrumentPool over a pool list.
Source #instrumentConfig :: forall (m :: Type -> Type) payload. (HasKind payload, KnownSymbol (TableForPayload payload (RegistryOf m)), MonadUnliftIO m) => Telemetry -> WorkerConfig m payload -> WorkerConfig m payload
instrumentPool over a bare config, labelled by the payload's registry queue.
Running pools
Source #runWorkerPools :: (MonadArbiter m, RegistryTables (RegistryOf m)) => [NamedWorkerPool m] -> m ()
runWorkerPools with the SDK installed from the environment, the
pools instrumented and the gauges running. Take the handle yourself with
runWorkerPoolsWith when something else needs it.
Source #runSelectedWorkerPools :: (MonadArbiter m, RegistryTables (RegistryOf m)) => [Text] -> [NamedWorkerPool m] -> m ()
runWorkerPools over an explicit queue list.
Source #runWorkerPoolsWith :: (MonadArbiter m, RegistryTables (RegistryOf m)) => Telemetry -> LogConfig -> [NamedWorkerPool m] -> m ()
runWorkerPools over a handle the caller installed itself, with the gauge loop's
base log config.
Source #runSelectedWorkerPoolsWith :: (MonadArbiter m, RegistryTables (RegistryOf m)) => Telemetry -> LogConfig -> [Text] -> [NamedWorkerPool m] -> m ()
runSelectedWorkerPools over a handle the caller installed itself.
Gauges
Source #withGauges :: (MonadArbiter m, RegistryTables (RegistryOf m)) => Telemetry -> LogConfig -> m b -> m b
Run the registry's depth and health gauges alongside action. Nothing is scanned
when the handle has metrics off.
Source #startGauges :: MonadArbiter m => Telemetry -> LogConfig -> (forall a. m a -> IO a) -> SchemaName -> [(TableName, [Text])] -> NominalDiffTime -> IO (IO ())
Register gauge instruments and return their refresh loop.
Metric names
Source #arbiterMetricNames :: [Text]
Every metric name arbiter exports.