ecluse:ecluse-runtime
Safe HaskellNone
LanguageGHC2021

Ecluse.Runtime.Telemetry.Tracing.Internal

Description

The middleware, the exchange tracing, the domain-span brackets and the attribute mappings behind Ecluse.Runtime.Telemetry.Tracing, which documents the tracing layer 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

WAI server span

telemetryWaiMiddleware :: Telemetry -> IO Middleware Source #

The WAI server-span middleware, or id without telemetry. It belongs outermost, so the span covers the request.

The data plane's client spans

dataPlaneTrace :: Telemetry -> IO TraceExchange Source #

Open each upstream exchange under one client span that carries W3C trace-context headers, when telemetry is enabled. The span comes from the global tracer provider, which the library reads.

tracedExchange :: HttpClientInstrumentationConfig -> TraceExchange Source #

One client span from the request to the response headers, with its bookkeeping masked. An asynchronous exception lands in the opener, where the span records it and ends, or in a thread's first context attach, which can wait on the context table's growth and leave the span unended.

Domain spans

withRuleEvalSpan :: MonadUnliftIO m => Telemetry -> PackageName -> Version -> m (a, ServeDecision) -> m a Source #

Run a rule-evaluation span around an action that yields its result and the verdict to record (ruleVerdictFields).

withMirrorEnqueueSpan :: MonadUnliftIO m => Telemetry -> PackageName -> Version -> Text -> (a -> Maybe Text) -> (Maybe RemoteSpanContext -> m a) -> m a Source #

Run a mirror-enqueue Producer span that hands the body its trace context. It records only the artifact authority, as a URL can carry a credential.

withMirrorJobSpan :: MonadUnliftIO m => Telemetry -> PackageName -> Version -> Maybe RemoteSpanContext -> (a -> JobSpanOutcome) -> m a -> m a Source #

Run a mirror-job Consumer span around the worker's fetch, verify and publish, linked to the enqueueing span.

withAdvisorySyncSpan :: MonadUnliftIO m => Telemetry -> Ecosystem -> (a -> (AdvisorySyncResult, Maybe OsvDbFetchFault)) -> m a -> m a Source #

Run an advisory-sync Internal span around one attempt, with the labels the ecluse.advisory.sync.* metrics use, so the two join.

The core tracing ports

tracingPortOf :: Telemetry -> TracingPort Source #

Project this module's serve-path spans onto the core TracingPort the pipeline brackets with.

workerTracingPortOf :: Telemetry -> WorkerTracingPort Source #

Project withMirrorJobSpan onto the core WorkerTracingPort that Ecluse.Core.Worker uses.

advisorySyncTracingPortOf :: Telemetry -> AdvisorySyncTracingPort Source #

Project withAdvisorySyncSpan onto the AdvisorySyncTracingPort Ecluse.Runtime.Cve.Sync brackets through. Inert when telemetry is disabled.

Verdict attribute mapping

ruleVerdictFields :: ServeDecision -> [(Text, Text)] Source #

A serve verdict's span fields. None carries a secret: the rule and class are closed sets, and the message is the rendered decision.