ecluse:ecluse-runtime
Safe HaskellNone
LanguageGHC2021

Ecluse.Runtime.Telemetry.Instruments.Internal

Description

Instrument handles and recording helpers behind Ecluse.Runtime.Telemetry.Instruments. Production callers use the public module's curated interface.

Synopsis

The instrument handle

data Metrics Source #

Domain instruments. WAI emits http.server.request.duration from its own meter.

newMetrics :: Telemetry -> IO Metrics Source #

Build instruments on the telemetry meter, or the SDK's no-op meter when disabled.

The core recording ports

metricsPortOf :: Metrics -> MetricsPort Source #

Project the instruments onto the core MetricsPort that Ecluse.Core.Server.Pipeline records through. It is inert when telemetry is off, since the instruments are.

workerMetricsPortOf :: Metrics -> WorkerMetricsPort Source #

Project the instruments onto the core WorkerMetricsPort that Ecluse.Core.Worker records through. It is inert when telemetry is off, since the instruments are.

dredgerMetricsPortOf :: Metrics -> DredgerMetricsPort Source #

Project the instruments onto the core DredgerMetricsPort that Ecluse.Core.Registry.Sweep records through. It is inert when telemetry is off, since the instruments are.

advisorySyncMetricsPortOf :: Metrics -> AdvisorySyncMetricsPort Source #

Project the instruments onto the core AdvisorySyncMetricsPort that Ecluse.Runtime.Cve.Sync records through. It is inert when telemetry is off, since the instruments are.

advisoryCompileMetricsPortOf :: Metrics -> Maybe Ecosystem -> AdvisoryCompileMetricsPort Source #

Bind compile observations to an ecosystem. An unknown ecosystem records no series.

Serve decision

recordServeDecision :: MonadIO m => Metrics -> Decision -> m () Source #

Record one serve decision (ecluse.serve.decision): admit, deny, or unavailable.

Rule gate

recordRuleDenial :: MonadIO m => Metrics -> Maybe Text -> ReasonClass -> m () Source #

Record one rule denial (ecluse.rule.denials) by reason class and, for a policy denial, the deciding rule. A non-policy refusal has no rule to attribute, so none is labelled.

recordRuleEvalDuration :: MonadIO m => Metrics -> Tier -> Double -> m () Source #

Record a rule-evaluation latency sample (ecluse.rule.eval.duration) by tier.

recordRuleEffectfulFailure :: MonadIO m => Metrics -> Cause -> m () Source #

Record one effectful-rule failure (ecluse.rule.effectful.failures) by cause.

recordBreakerState :: MonadIO m => Metrics -> BreakerSource -> BreakerState -> m () Source #

Record the current circuit-breaker state (ecluse.rule.breaker.state) for a source as the gauge's bounded ordinal (0 closed, 1 half-open, 2 open).

Upstream fetch (data plane)

recordUpstreamRequest :: MonadIO m => Metrics -> Text -> PublicReadKind -> ExchangeOutcome -> m () Source #

Record one public HTTP attempt using the host of its formed request.

recordUpstreamFetch :: MonadIO m => Metrics -> Upstream -> StatusClass -> Double -> m () Source #

Record an upstream metadata-fetch latency sample to ecluse.upstream.fetch.duration.

recordUpstreamFetchError :: MonadIO m => Metrics -> Upstream -> Cause -> m () Source #

Record one upstream metadata-fetch error to ecluse.upstream.fetch.errors.

Metadata cache

recordCacheRequest :: MonadIO m => Metrics -> CacheResult -> m () Source #

Record one metadata-cache lookup (ecluse.metadata_cache.requests) as hit, miss, or collapsed.

recordCacheEntries :: MonadIO m => Metrics -> Int -> m () Source #

Record the metadata cache's current occupancy (ecluse.metadata_cache.entries).

Mirror

recordMirrorEnqueued :: MonadIO m => Metrics -> m () Source #

Record one mirror job enqueued (ecluse.mirror.enqueued).

recordMirrorEnqueueFailure :: MonadIO m => Metrics -> m () Source #

Record one mirror enqueue failure (ecluse.mirror.enqueue.failures).

recordMirrorJobProcessed :: MonadIO m => Metrics -> MirrorResult -> m () Source #

Record one processed mirror job (ecluse.mirror.jobs.processed) by its result.

recordMirrorPublishDuration :: MonadIO m => Metrics -> Double -> m () Source #

Record a mirror publish latency sample (ecluse.mirror.publish.duration).

Credentials

recordCredentialRefresh :: MonadIO m => Metrics -> Provider -> CredentialResult -> m () Source #

Record one credential refresh (ecluse.credential.refresh) by result and provider.

registerCredentialTokenTtl :: Metrics -> IO UTCTime -> IO [(Provider, UTCTime)] -> IO () Source #

Collect the shortest active expiry per provider as non-negative whole seconds remaining.

Advisory sync

recordAdvisorySyncAttempt :: MonadIO m => Metrics -> Ecosystem -> AdvisorySyncResult -> m () Source #

Record one advisory sync attempt to ecluse.advisory.sync.attempts.

recordAdvisorySyncDuration :: MonadIO m => Metrics -> Ecosystem -> AdvisorySyncResult -> Double -> m () Source #

Record one advisory sync attempt's latency in seconds (ecluse.advisory.sync.duration).

Advisory ages (observable)

registerAdvisoryDatabaseAge :: Metrics -> Ecosystem -> IO (Maybe Double) -> IO () Source #

Attach one ecosystem's advisory-database age to ecluse.advisory.database.age.seconds. The SDK calls back at each collection, so a sync task that dies cannot freeze or reset the age.

reportAdvisoryDatabaseAge :: Ecosystem -> IO (Maybe Double) -> ObservableResult Int64 -> IO () Source #

What one collection reports: whole seconds from the install stamp to now. With no generation installed it observes nothing, so a never-filled slot never reads as fresh.

registerAdvisorySourceAge :: Metrics -> Ecosystem -> IO (Maybe UTCTime) -> IO () Source #

Attach one ecosystem's advisory-source age, the age advisory denies expire on, to ecluse.advisory.source.age.seconds.

reportAdvisorySourceAge :: Ecosystem -> IO (Maybe UTCTime) -> ObservableResult Int64 -> IO () Source #

What one collection reports: whole seconds from the publication time to now. With no push time to measure, it observes nothing rather than a zero.

Memory budget (observable)

registerMemoryMeter :: Metrics -> IO MeterSnapshot -> IO () Source #

Attach the memory meter's figures to their gauges, read at each collection.

registerOverflowQueue :: Metrics -> IO Int -> IO () Source #

Attach the overflow queue's depth to its gauge, read at each collection.

Advisory compile

recordAdvisoryCompileAccepted :: MonadIO m => Metrics -> Ecosystem -> Int -> m () Source #

Record the advisory entries one compile pass accepted (ecluse.advisory.compile.accepted).

recordAdvisoryCompileDropped :: MonadIO m => Metrics -> Ecosystem -> AdvisoryDropCause -> Int -> m () Source #

Record the advisory entries one compile pass dropped for a bounded cause (ecluse.advisory.compile.dropped).

recordAdvisoryCompileRun :: MonadIO m => Metrics -> Ecosystem -> AdvisoryCompileResult -> m () Source #

Record how one compile pass concluded (ecluse.advisory.compile.runs).