| Safe Haskell | None |
|---|---|
| Language | GHC2024 |
Arbiter.Core.Trace
Description
W3C trace context carried on enqueued jobs, and the producer and consumer spans around them. The OpenTelemetry API is inert until an SDK installs a provider.
Synopsis
- data TraceContext = TraceContext {
- traceparent :: Text
- tracestate :: Maybe Text
- currentTraceContext :: IO (Maybe TraceContext)
- withPublishSpan :: (HasKind payload, MonadUnliftIO m) => TableName -> [JobWrite payload] -> m a -> m a
- withJobParent :: MonadUnliftIO m => JobRead payload -> m a -> m a
- markSpanError :: MonadIO m => Text -> m ()
- recordJobFailure :: MonadIO m => JobRead payload -> Text -> m ()
- recordJobCancelled :: MonadIO m => JobRead payload -> Text -> m ()
- data Tracer
- instrumentationScope :: InstrumentationLibrary
- data ConsumeSpan
- data ConsumeShape
- toConsumeShape :: Int -> ConsumeShape
- consumeSpanFor :: TableName -> ConsumeShape -> ConsumeSpan
- withConsumeSpan :: MonadUnliftIO m => Maybe Tracer -> ConsumeSpan -> NonEmpty (JobRead payload) -> m a -> m a
- resolveTracer :: MonadIO m => m (Maybe Tracer)
- capturingContext :: MonadUnliftIO m => m (m a -> m a)
- capturingContextIO :: MonadUnliftIO m => m (IO a -> IO a)
- stampTraceContext :: Maybe TraceContext -> JobWrite payload -> JobWrite payload
Job trace context
data TraceContextSource #
A job's W3C trace context.
Constructors
| TraceContext | |
Fields
| |
Instances
Producer
currentTraceContext :: IO (Maybe TraceContext)Source #
The ambient span's trace context, or Nothing when no span is active or its span
context is invalid. Read from the thread-local context of the enqueuing thread.
withPublishSpan :: (HasKind payload, MonadUnliftIO m) => TableName -> [JobWrite payload] -> m a -> m aSource #
Run an action inside a publish <queue> producer span over the given jobs.
Consumer
withJobParent :: MonadUnliftIO m => JobRead payload -> m a -> m aSource #
Run an action with the job's stored trace context as the ambient parent.
Span enrichment
Reach for hs-opentelemetry-api directly for custom spans and attributes.
markSpanError :: MonadIO m => Text -> m ()Source #
Mark the currently active span failed. A no-op when none is active.
recordJobFailure :: MonadIO m => JobRead payload -> Text -> m ()Source #
Record one job's failure as an event on the active span. A no-op when none is active. The span status is left alone.
recordJobCancelled :: MonadIO m => JobRead payload -> Text -> m ()Source #
Record one job's cancellation as an event on the active span. A no-op when none is active.
Internal
Internal to the arbiter packages. Not covered by the PVP.
Creates and manages Spans for a specific instrumentation scope.
Spec: https://opentelemetry.io/docs/specs/otel/trace/api/#tracer
Since: hs-opentelemetry-api-0.0.1.0
instrumentationScope :: InstrumentationLibrarySource #
Instrumentation scope for arbiter's tracer, meter and logger.
data ConsumeSpanSource #
Queue attributes for consumer spans. Resolve them one time for each pool and reuse them for claimed jobs.
data ConsumeShapeSource #
What one consumer span covers.
Instances
| Eq ConsumeShape Source # | |
Defined in Arbiter.Core.Trace | |
| Show ConsumeShape Source # | |
Defined in Arbiter.Core.Trace Methods showsPrec :: Int -> ConsumeShape -> ShowS# show :: ConsumeShape -> String# showList :: [ConsumeShape] -> ShowS# | |
toConsumeShape :: Int -> ConsumeShapeSource #
The shape over this many jobs. One job narrows the span to that job.
consumeSpanFor :: TableName -> ConsumeShape -> ConsumeSpanSource #
A queue's consumer-span name and attributes, under the given shape.
withConsumeSpan :: MonadUnliftIO m => Maybe Tracer -> ConsumeSpan -> NonEmpty (JobRead payload) -> m a -> m aSource #
Run a job handler inside a process <queue> consumer span linked to its producer.
A batch span links each job's producer, up to a fixed cap.
resolveTracer :: MonadIO m => m (Maybe Tracer)Source #
Resolve the arbiter tracer, or Nothing when nothing is collecting.
capturingContext :: MonadUnliftIO m => m (m a -> m a)Source #
Capture the caller context for an action on a child thread. Return the unchanged action if the context has no span.
capturingContextIO :: MonadUnliftIO m => m (IO a -> IO a)Source #
capturingContext for an action run from IO.
stampTraceContext :: Maybe TraceContext -> JobWrite payload -> JobWrite payloadSource #
Fill a job's trace context. A job that carries one of its own keeps it.