ecluse:ecluse-runtime
Safe HaskellNone
LanguageGHC2021

Ecluse.Runtime.Telemetry.ExportFailure.Internal

Description

The throttle and the sink behind Ecluse.Runtime.Telemetry.ExportFailure, which documents the routing and re-exports the curated surface. Importing this module opts out of that stability promise, the convention text and bytestring use, so production code imports the public one.

Synopsis

The throttle (pure core)

data ThrottleState Source #

The throttle's state, exposed so a test steps the throttle without a wall clock.

Constructors

ThrottleState 

Fields

data ThrottleEmit Source #

What throttleStep decided to do with an export error.

Constructors

EmitFirst

The first error: surface it plainly.

EmitHeartbeat Int

The window elapsed: surface a heartbeat with the count of errors since the last surfaced one, this one included.

EmitSuppress

Within the window: suppress and count.

initialThrottle :: ThrottleState Source #

The initial throttle state: nothing logged, nothing suppressed.

throttleStep :: NominalDiffTime -> UTCTime -> ThrottleState -> (ThrottleState, ThrottleEmit) Source #

Advance the throttle for one export error at now, with a heartbeat due once interval has passed since the last surfaced error.

Routing

data ExportFailureSink Source #

One throttle and one katip target that every export-failure feed shares.

newExportFailureSink :: IO UTCTime -> (Severity -> Text -> IO ()) -> IO ExportFailureSink Source #

Build an export-failure sink over an injected clock and surfacing action.

exportFailureSink :: LogEnv -> IO ExportFailureSink Source #

The production sink: the wall clock and the composition-root LogEnv as the katip target.

observeExportResult :: ExportFailureSink -> Text -> ExportResult -> IO () Source #

Route a failed export from the signal exporter through the sink. The exporter's request holds every collector header, so the error renders through displayFaultT.

observeFlushFault :: ExportFailureSink -> SomeException -> IO () Source #

Route a metric series the batching flush dropped because its replay into the SDK threw.

installExportErrorHandler :: ExportFailureSink -> IO () Source #

Install a process-global handler that forwards the SDK's own diagnostic text verbatim. Failed exports reach the sink separately, through observeExportResult.