Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- data TracerProvider
- initializeGlobalTracerProvider :: IO TracerProvider
- initializeTracerProvider :: IO TracerProvider
- getTracerProviderInitializationOptions :: IO ([Processor], TracerProviderOptions)
- shutdownTracerProvider :: MonadIO m => TracerProvider -> m ()
- getGlobalTracerProvider :: MonadIO m => m TracerProvider
- setGlobalTracerProvider :: MonadIO m => TracerProvider -> m ()
- createTracerProvider :: MonadIO m => [Processor] -> TracerProviderOptions -> m TracerProvider
- data TracerProviderOptions = TracerProviderOptions {
- tracerProviderOptionsIdGenerator :: IdGenerator
- tracerProviderOptionsSampler :: Sampler
- tracerProviderOptionsResources :: MaterializedResources
- tracerProviderOptionsAttributeLimits :: AttributeLimits
- tracerProviderOptionsSpanLimits :: SpanLimits
- tracerProviderOptionsPropagators :: Propagator Context RequestHeaders ResponseHeaders
- emptyTracerProviderOptions :: TracerProviderOptions
- detectBuiltInResources :: IO (Resource 'Nothing)
- data Tracer
- tracerName :: Tracer -> InstrumentationLibrary
- getTracer :: MonadIO m => TracerProvider -> InstrumentationLibrary -> TracerOptions -> m Tracer
- newtype TracerOptions = TracerOptions {}
- tracerOptions :: TracerOptions
- class HasTracer s where
- data InstrumentationLibrary = InstrumentationLibrary {
- libraryName :: !Text
- libraryVersion :: !Text
- data Span
- createSpan :: (MonadIO m, HasCallStack) => Tracer -> Context -> Text -> SpanArguments -> m Span
- createSpanWithoutCallStack :: MonadIO m => Tracer -> Context -> Text -> SpanArguments -> m Span
- defaultSpanArguments :: SpanArguments
- data SpanArguments = SpanArguments {}
- updateName :: MonadIO m => Span -> Text -> m ()
- addAttribute :: (MonadIO m, ToAttribute a) => Span -> Text -> a -> m ()
- addAttributes :: MonadIO m => Span -> [(Text, Attribute)] -> m ()
- spanGetAttributes :: MonadIO m => Span -> m Attributes
- class ToAttribute a where
- toAttribute :: a -> Attribute
- class ToPrimitiveAttribute a where
- data Attribute
- data PrimitiveAttribute
- data SpanKind
- data Link = Link {}
- data Event
- data NewEvent = NewEvent {}
- addEvent :: MonadIO m => Span -> NewEvent -> m ()
- recordException :: (MonadIO m, Exception e) => Span -> [(Text, Attribute)] -> Maybe Timestamp -> e -> m ()
- setStatus :: MonadIO m => Span -> SpanStatus -> m ()
- data SpanStatus
- data SpanContext = SpanContext {
- traceFlags :: TraceFlags
- isRemote :: Bool
- traceId :: TraceId
- spanId :: SpanId
- traceState :: TraceState
- endSpan :: MonadIO m => Span -> Maybe Timestamp -> m ()
- data ImmutableSpan = ImmutableSpan {}
TracerProvider
operations
data TracerProvider #
Tracer
s can be create from a TracerProvider
.
shutdownTracerProvider :: MonadIO m => TracerProvider -> m () #
This method provides a way for provider to do any cleanup required.
This will also trigger shutdowns on all internal processors.
Since: hs-opentelemetry-api-0.0.1.0
Getting / setting the global TracerProvider
getGlobalTracerProvider :: MonadIO m => m TracerProvider #
setGlobalTracerProvider :: MonadIO m => TracerProvider -> m () #
Alternative TracerProvider
initialization
createTracerProvider :: MonadIO m => [Processor] -> TracerProviderOptions -> m TracerProvider #
Initialize a new tracer provider
You should generally use getGlobalTracerProvider
for most applications.
data TracerProviderOptions #
Tracer
operations
getTracer :: MonadIO m => TracerProvider -> InstrumentationLibrary -> TracerOptions -> m Tracer #
newtype TracerOptions #
data InstrumentationLibrary #
Instances
Span
operations
:: (MonadIO m, HasCallStack) | |
=> Tracer |
|
-> Context | Context, potentially containing a parent span. If no existing parent (or context) exists,
you can use |
-> Text | Span name |
-> SpanArguments | Additional span information |
-> m Span | The created span. |
Create a Span
.
If the provided Context
has a span in it (inserted via insertSpan
),
that Span
will be used as the parent of the Span
created via this API.
Note: if the hs-opentelemetry-sdk
or another SDK is not installed, all actions that use the created
Span
s produced will be no-ops.
Since: hs-opentelemetry-api-0.0.1.0
:: MonadIO m | |
=> Tracer |
|
-> Context | Context, potentially containing a parent span. If no existing parent (or context) exists,
you can use |
-> Text | Span name |
-> SpanArguments | Additional span information |
-> m Span | The created span. |
The same thing as createSpan
, except that it does not have a HasCallStack
constraint.
defaultSpanArguments :: SpanArguments #
Smart constructor for SpanArguments
providing reasonable values for most Span
s created
that are internal to an application.
Defaults:
kind
:Internal
attributes
:[]
links
:[]
startTime
:Nothing
(getTimestamp
will be called uponSpan
creation)
data SpanArguments #
Non-name fields that may be set on initial creation of a Span
.
SpanArguments | |
|
:: MonadIO m | |
=> Span | |
-> Text | The new span name, which supersedes whatever was passed in when the Span was started |
-> m () |
Updates the Span name. Upon this update, any sampling behavior based on Span name will depend on the implementation.
Note that Sampler
s can only consider information already present during span creation. Any changes done later, including updated span name, cannot change their decisions.
Alternatives for the name update may be late Span creation, when Span is started with the explicit timestamp from the past at the moment where the final Span name is known, or reporting a Span with the desired name as a child Span.
Since: hs-opentelemetry-api-0.0.1.0
addAttribute :: (MonadIO m, ToAttribute a) => Span -> Text -> a -> m () #
As an application developer when you need to record an attribute first consult existing semantic conventions for Resources, Spans, and Metrics. If an appropriate name does not exists you will need to come up with a new name. To do that consider a few options:
The name is specific to your company and may be possibly used outside the company as well. To avoid clashes with names introduced by other companies (in a distributed system that uses applications from multiple vendors) it is recommended to prefix the new name by your company’s reverse domain name, e.g. 'com.acme.shopname'.
The name is specific to your application that will be used internally only. If you already have an internal company process that helps you to ensure no name clashes happen then feel free to follow it. Otherwise it is recommended to prefix the attribute name by your application name, provided that the application name is reasonably unique within your organization (e.g. 'myuniquemapapp.longitude' is likely fine). Make sure the application name does not clash with an existing semantic convention namespace.
The name may be generally applicable to applications in the industry. In that case consider submitting a proposal to this specification to add a new name to the semantic conventions, and if necessary also to add a new namespace.
It is recommended to limit names to printable Basic Latin characters (more precisely to 'U+0021' .. 'U+007E' subset of Unicode code points), although the Haskell OpenTelemetry specification DOES provide full Unicode support.
Attribute names that start with 'otel.' are reserved to be defined by OpenTelemetry specification. These are typically used to express OpenTelemetry concepts in formats that don’t have a corresponding concept.
For example, the 'otel.library.name' attribute is used to record the instrumentation library name, which is an OpenTelemetry concept that is natively represented in OTLP, but does not have an equivalent in other telemetry formats and protocols.
Any additions to the 'otel.*' namespace MUST be approved as part of OpenTelemetry specification.
spanGetAttributes :: MonadIO m => Span -> m Attributes #
This can be useful for pulling data for attributes and using it to copy / otherwise use the data to further enrich instrumentation.
class ToAttribute a where #
Nothing
toAttribute :: a -> Attribute #
Instances
ToAttribute Bool | |
Defined in OpenTelemetry.Attributes toAttribute :: Bool -> Attribute # | |
ToAttribute Double | |
Defined in OpenTelemetry.Attributes toAttribute :: Double -> Attribute # | |
ToAttribute Int | |
Defined in OpenTelemetry.Attributes toAttribute :: Int -> Attribute # | |
ToAttribute Int64 | |
Defined in OpenTelemetry.Attributes toAttribute :: Int64 -> Attribute # | |
ToAttribute Text | |
Defined in OpenTelemetry.Attributes toAttribute :: Text -> Attribute # | |
ToAttribute Attribute | |
Defined in OpenTelemetry.Attributes toAttribute :: Attribute -> Attribute # | |
ToAttribute PrimitiveAttribute | |
Defined in OpenTelemetry.Attributes | |
ToPrimitiveAttribute a => ToAttribute [a] | |
Defined in OpenTelemetry.Attributes toAttribute :: [a] -> Attribute # |
class ToPrimitiveAttribute a where #
toPrimitiveAttribute :: a -> PrimitiveAttribute #
Instances
ToPrimitiveAttribute Bool | |
Defined in OpenTelemetry.Attributes | |
ToPrimitiveAttribute Double | |
Defined in OpenTelemetry.Attributes | |
ToPrimitiveAttribute Int | |
Defined in OpenTelemetry.Attributes | |
ToPrimitiveAttribute Int64 | |
Defined in OpenTelemetry.Attributes | |
ToPrimitiveAttribute Text | |
Defined in OpenTelemetry.Attributes | |
ToPrimitiveAttribute PrimitiveAttribute | |
Defined in OpenTelemetry.Attributes |
Instances
Eq Attribute | |
Data Attribute | |
Defined in OpenTelemetry.Attributes gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Attribute -> c Attribute # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Attribute # toConstr :: Attribute -> Constr # dataTypeOf :: Attribute -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Attribute) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Attribute) # gmapT :: (forall b. Data b => b -> b) -> Attribute -> Attribute # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Attribute -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Attribute -> r # gmapQ :: (forall d. Data d => d -> u) -> Attribute -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Attribute -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Attribute -> m Attribute # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Attribute -> m Attribute # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Attribute -> m Attribute # | |
Ord Attribute | |
Defined in OpenTelemetry.Attributes | |
Read Attribute | |
Show Attribute | |
Generic Attribute | |
Hashable Attribute | |
Defined in OpenTelemetry.Attributes | |
ToAttribute Attribute | |
Defined in OpenTelemetry.Attributes toAttribute :: Attribute -> Attribute # | |
type Rep Attribute | |
Defined in OpenTelemetry.Attributes type Rep Attribute = D1 ('MetaData "Attribute" "OpenTelemetry.Attributes" "hs-opentelemetry-api-0.0.1.0-6Dv2z1KBcop7UAQrDIczSS" 'False) (C1 ('MetaCons "AttributeValue" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 PrimitiveAttribute)) :+: C1 ('MetaCons "AttributeArray" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [PrimitiveAttribute]))) |
data PrimitiveAttribute #
Instances
SpanKind
describes the relationship between the Span
, its parents, and its children in a Trace. SpanKind
describes two independent properties that benefit tracing systems during analysis.
The first property described by SpanKind
reflects whether the Span
is a remote child or parent. Span
s with a remote parent are interesting because they are sources of external load. Spans with a remote child are interesting because they reflect a non-local system dependency.
The second property described by SpanKind
reflects whether a child Span
represents a synchronous call. When a child span is synchronous, the parent is expected to wait for it to complete under ordinary circumstances. It can be useful for tracing systems to know this property, since synchronous Span
s may contribute to the overall trace latency. Asynchronous scenarios can be remote or local.
In order for SpanKind
to be meaningful, callers SHOULD arrange that a single Span
does not serve more than one purpose. For example, a server-side span SHOULD NOT be used directly as the parent of another remote span. As a simple guideline, instrumentation should create a new Span
prior to extracting and serializing the SpanContext
for a remote call.
To summarize the interpretation of these kinds
SpanKind | Synchronous | Asynchronous | Remote Incoming | Remote Outgoing |
---|---|---|---|---|
Client | yes | yes | ||
Server | yes | yes | ||
Producer | yes | maybe | ||
Consumer | yes | maybe | ||
Internal |
Server | Indicates that the span covers server-side handling of a synchronous RPC or other remote request.
This span is the child of a remote |
Client | Indicates that the span describes a synchronous request to some remote service.
This span is the parent of a remote |
Producer | Indicates that the span describes the parent of an asynchronous request.
This parent span is expected to end before the corresponding child |
Consumer | Indicates that the span describes the child of an asynchronous |
Internal | Default value. Indicates that the span represents an internal operation within an application, as opposed to an operations with remote parents or children. |
A Span
may be linked to zero or more other Spans
(defined by SpanContext
) that are causally related.
Link
s can point to Spans inside a single Trace or across different Traces. Link
s can be used to represent
batched operations where a Span
was initiated by multiple initiating Spans, each representing a single incoming
item being processed in the batch.
Another example of using a Link is to declare the relationship between the originating and following trace. This can be used when a Trace enters trusted boundaries of a service and service policy requires the generation of a new Trace rather than trusting the incoming Trace context. The new linked Trace may also represent a long running asynchronous data processing operation that was initiated by one of many fast incoming requests.
When using the scattergather (also called forkjoin) pattern, the root operation starts multiple downstream processing operations and all of them are aggregated back in a single Span. This last Span is linked to many operations it aggregates. All of them are the Spans from the same Trace. And similar to the Parent field of a Span. It is recommended, however, to not set parent of the Span in this scenario as semantically the parent field represents a single parent scenario, in many cases the parent Span fully encloses the child Span. This is not the case in scatter/gather and batch scenarios.
Link | |
|
A “log” that happens as part of a span. An operation that is too fast for its own span, but too unique to roll up into its parent span.
Events contain a name, a timestamp, and an optional set of Attributes, along with a timestamp. Events represent an event that occurred at a specific time within a span’s workload.
NewEvent | |
|
recordException :: (MonadIO m, Exception e) => Span -> [(Text, Attribute)] -> Maybe Timestamp -> e -> m () #
A specialized variant of addEvent
that records attributes conforming to
the OpenTelemetry specification's
semantic conventions
Since: hs-opentelemetry-api-0.0.1.0
setStatus :: MonadIO m => Span -> SpanStatus -> m () #
Sets the Status of the Span. If used, this will override the default Span
status, which is Unset
.
These values form a total order: Ok > Error > Unset. This means that setting Status with StatusCode=Ok will override any prior or future attempts to set span Status with StatusCode=Error or StatusCode=Unset.
data SpanStatus #
The status of a Span
. This may be used to indicate the successful completion of a span.
The default is Unset
These values form a total order: Ok > Error > Unset. This means that setting Status with StatusCode=Ok will override any prior or future attempts to set span Status with StatusCode=Error or StatusCode=Unset.
Unset | The default status. |
Error Text | The operation contains an error. The text field may be empty, or else provide a description of the error. |
Ok | The operation has been validated by an Application developer or Operator to have completed successfully. |
Instances
Eq SpanStatus | |
Defined in OpenTelemetry.Internal.Trace.Types (==) :: SpanStatus -> SpanStatus -> Bool # (/=) :: SpanStatus -> SpanStatus -> Bool # | |
Ord SpanStatus | |
Defined in OpenTelemetry.Internal.Trace.Types compare :: SpanStatus -> SpanStatus -> Ordering # (<) :: SpanStatus -> SpanStatus -> Bool # (<=) :: SpanStatus -> SpanStatus -> Bool # (>) :: SpanStatus -> SpanStatus -> Bool # (>=) :: SpanStatus -> SpanStatus -> Bool # max :: SpanStatus -> SpanStatus -> SpanStatus # min :: SpanStatus -> SpanStatus -> SpanStatus # | |
Show SpanStatus | |
Defined in OpenTelemetry.Internal.Trace.Types showsPrec :: Int -> SpanStatus -> ShowS # show :: SpanStatus -> String # showList :: [SpanStatus] -> ShowS # |
data SpanContext #
A SpanContext
represents the portion of a Span
which must be serialized and
propagated along side of a distributed context. SpanContext
s are immutable.
SpanContext | |
|
Instances
Eq SpanContext | |
Defined in OpenTelemetry.Internal.Trace.Types (==) :: SpanContext -> SpanContext -> Bool # (/=) :: SpanContext -> SpanContext -> Bool # | |
Show SpanContext | |
Defined in OpenTelemetry.Internal.Trace.Types showsPrec :: Int -> SpanContext -> ShowS # show :: SpanContext -> String # showList :: [SpanContext] -> ShowS # |
:: MonadIO m | |
=> Span | |
-> Maybe Timestamp | Optional |
-> m () |
Signals that the operation described by this span has now (or at the time optionally specified) ended.
This does have any effects on child spans. Those may still be running and can be ended later.
This also does not inactivate the Span in any Context it is active in. It is still possible to use an ended span as parent via a Context it is contained in. Also, putting the Span into a Context will still work after the Span was ended.
Since: hs-opentelemetry-api-0.0.1.0
data ImmutableSpan #
ImmutableSpan | |
|