hs-opentelemetry-api
Copyright(c) Ian Duncan 2026
LicenseBSD-3
Stabilityexperimental
Safe HaskellNone
LanguageHaskell2010

OpenTelemetry.Internal.Log.Core

Description

 
Synopsis

Documentation

data LoggerProviderOptions Source #

Since: 0.0.1.0

Constructors

LoggerProviderOptions 

Fields

emptyLoggerProviderOptions :: LoggerProviderOptions Source #

Options for creating a LoggerProvider with no resources and default limits.

In effect, logging is a no-op when using this configuration and no-op Processors.

Since: 0.0.1.0

createLoggerProvider :: MonadIO m => [LogRecordProcessor] -> LoggerProviderOptions -> m LoggerProvider Source #

Initialize a new LoggerProvider

You should generally use getGlobalLoggerProvider for most applications.

Since: 0.0.1.0

getLogger :: MonadIO m => LoggerProvider -> InstrumentationLibrary -> m Logger Source #

Like makeLogger, but logs a warning when libraryName is empty.

Since: 0.0.1.0

setGlobalLoggerProvider :: MonadIO m => LoggerProvider -> m () Source #

Overwrite the globally configured LoggerProvider.

Loggers acquired from the previously installed LoggerProviders will continue to use that LoggerProviders settings.

Since: 0.0.1.0

getGlobalLoggerProvider :: MonadIO m => m LoggerProvider Source #

Access the globally configured LoggerProvider. This LoggerProvider is no-op until initialized by the SDK

Since: 0.0.1.0

shutdownLoggerProvider Source #

Arguments

:: MonadIO m 
=> LoggerProvider 
-> Maybe Int

Optional timeout in microseconds, defaults to 5,000,000 (5s)

-> m ShutdownResult 

This method provides a way for provider to do any cleanup required.

This will also trigger shutdowns on all internal processors.

Since: 0.0.1.0

forceFlushLoggerProvider Source #

Arguments

:: MonadIO m 
=> LoggerProvider 
-> Maybe Int

Optional timeout in microseconds, defaults to 5,000,000 (5s)

-> m FlushResult

Result that denotes whether the flush action succeeded, failed, or timed out.

This method provides a way for provider to immediately export all LogRecords that have not yet been exported for all the internal processors.

Since: 0.0.1.0

makeLogger Source #

Arguments

:: LoggerProvider

The LoggerProvider holds the configuration for the Logger.

-> InstrumentationLibrary

The library that the Logger instruments. This uniquely identifies the Logger. Use a non-empty libraryName per the OpenTelemetry specification; use getLogger if you want a warning when the name is empty.

-> Logger 

Since: 0.0.1.0

loggerIsEnabled :: Logger -> Maybe SeverityNumber -> Maybe Text -> IO Bool Source #

Returns True if a log record with the given severity (and optional event name) would be forwarded to processors.

Checks, in order:

  1. Whether the provider has any registered processors.
  2. Whether the provider has been shut down.
  3. Whether the record's severity meets the provider's minimum severity threshold (set via LoggerProviderOptions or setLoggerMinSeverity).

When the caller passes Nothing for severity, the minimum-severity gate is skipped (the record is allowed through).

Callers SHOULD invoke this before each log emit to get the most up-to-date response, as the result may change over time.

Since: 0.1.0.0

loggerIsEnabled' :: MonadIO m => Logger -> Maybe SeverityNumber -> Maybe Text -> Maybe Context -> m Bool Source #

Like loggerIsEnabled but accepts an explicit Context. When Nothing, uses the current implicit context.

Since: 0.4.0.0

setLoggerMinSeverity :: MonadIO m => LoggerProvider -> Maybe SeverityNumber -> m () Source #

Set the minimum severity for a LoggerProvider at runtime.

Log records with a severity below the threshold will be suppressed by both loggerIsEnabled and emitLogRecord. Pass Nothing to disable severity filtering (the default).

Since: 0.4.0.0

getLoggerMinSeverity :: MonadIO m => LoggerProvider -> m (Maybe SeverityNumber) Source #

Read the current minimum severity threshold for a LoggerProvider.

Returns Nothing when no severity filtering is active.

Since: 0.4.0.0

emitLogRecord :: MonadIO m => Logger -> LogRecordArguments -> m ReadWriteLogRecord Source #

Emits a LogRecord with properties specified by the passed in Logger and LogRecordArguments. If observedTimestamp is not set in LogRecordArguments, it will default to the current timestamp. If context is not specified in LogRecordArguments it will default to the current context.

The emitted LogRecord will be passed to any LogRecordProcessors registered on the LoggerProvider that created the Logger, provided the record's severity meets the provider's minimum severity threshold.

Since: 0.0.1.0

addAttribute :: (IsReadWriteLogRecord r, MonadIO m, ToValue a) => r -> Text -> a -> m () Source #

Add an attribute to a log record. Not an atomic modification.

See the OTel attribute naming conventions for guidance on choosing attribute names.

Since: 0.0.1.0

addAttributes :: (IsReadWriteLogRecord r, MonadIO m, ToValue a) => r -> HashMap Text a -> m () Source #

A convenience function related to addAttribute that adds multiple attributes to a LogRecord at the same time.

This function may be slightly more performant than repeatedly calling addAttribute.

This is not an atomic modification

Since: 0.0.1.0

logRecordGetAttributes :: (IsReadableLogRecord r, MonadIO m) => r -> m LogAttributes Source #

This can be useful for pulling data for attributes and using it to copy / otherwise use the data to further enrich instrumentation.

Since: 0.0.1.0

emitOTelLogRecord :: MonadIO m => HashMap Text AnyValue -> SeverityNumber -> Text -> m ReadWriteLogRecord Source #

WARNING: this function should only be used to emit logs from the hs-opentelemetry-api library. DO NOT USE this function in any other context.