arbiter-core-0.1.0.0
arbiter-core
Safe HaskellNone
LanguageGHC2024

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

Job trace context

data TraceContextSource #

A job's W3C trace context.

Constructors

TraceContext 

Fields

Instances

Instances details
Eq TraceContext Source # 
Instance details

Defined in Arbiter.Core.Job.TraceContext

Generic TraceContext Source # 
Instance details

Defined in Arbiter.Core.Job.TraceContext

Associated Types

type Rep TraceContext 
Instance details

Defined in Arbiter.Core.Job.TraceContext

type Rep TraceContext = D1 ('MetaData "TraceContext" "Arbiter.Core.Job.TraceContext" "arbiter-core-0.1.0.0-inplace" 'False) (C1 ('MetaCons "TraceContext" 'PrefixI 'True) (S1 ('MetaSel ('Just "traceparent") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text) :*: S1 ('MetaSel ('Just "tracestate") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe Text))))
Show TraceContext Source # 
Instance details

Defined in Arbiter.Core.Job.TraceContext

type Rep TraceContext Source # 
Instance details

Defined in Arbiter.Core.Job.TraceContext

type Rep TraceContext = D1 ('MetaData "TraceContext" "Arbiter.Core.Job.TraceContext" "arbiter-core-0.1.0.0-inplace" 'False) (C1 ('MetaCons "TraceContext" 'PrefixI 'True) (S1 ('MetaSel ('Just "traceparent") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text) :*: S1 ('MetaSel ('Just "tracestate") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe Text))))

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.

data Tracer#

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

Instances

Instances details
Show Tracer # 
Instance details

Defined in OpenTelemetry.Internal.Trace.Types

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.

Constructors

PerJob

One span for one job.

PerBatch

One span for a batch of jobs.

Instances

Instances details
Eq ConsumeShape Source # 
Instance details

Defined in Arbiter.Core.Trace

Show ConsumeShape Source # 
Instance details

Defined in Arbiter.Core.Trace

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.