| Copyright | (c) Ian Duncan 2026 |
|---|---|
| License | BSD-3 |
| Stability | experimental |
| Safe Haskell | None |
| Language | Haskell2010 |
OpenTelemetry.Internal.Log.Types
Description
Synopsis
- data UMaybe a where
- umaybe :: b -> (a -> b) -> UMaybe a -> b
- toBaseMaybe :: UMaybe a -> Maybe a
- data TracingDetails
- data LogRecordExporter
- data LogRecordExporterArguments = LogRecordExporterArguments {}
- mkLogRecordExporter :: LogRecordExporterArguments -> IO LogRecordExporter
- logRecordExporterExport :: LogRecordExporter -> Vector ReadableLogRecord -> IO ExportResult
- logRecordExporterForceFlush :: LogRecordExporter -> IO FlushResult
- logRecordExporterShutdown :: LogRecordExporter -> IO ()
- data LogRecordProcessor = LogRecordProcessor {}
- data LoggerProvider = LoggerProvider {
- loggerProviderProcessors :: Vector LogRecordProcessor
- loggerProviderResource :: MaterializedResources
- loggerProviderAttributeLimits :: AttributeLimits
- loggerProviderIsShutdown :: IORef Bool
- loggerProviderHasProcessors :: !Bool
- loggerProviderOnEmit :: ReadWriteLogRecord -> Context -> IO ()
- loggerProviderMinSeverity :: IORef (Maybe SeverityNumber)
- loggerProviderLoggerCache :: IORef (HashMap InstrumentationLibrary Logger)
- data Logger = Logger {}
- data ReadWriteLogRecord
- mkReadWriteLogRecord :: Logger -> ImmutableLogRecord -> IO ReadWriteLogRecord
- data ReadableLogRecord
- mkReadableLogRecord :: ReadWriteLogRecord -> IO ReadableLogRecord
- class IsReadableLogRecord r where
- class IsReadableLogRecord r => IsReadWriteLogRecord r where
- readLogRecordAttributeLimits :: r -> AttributeLimits
- modifyLogRecord :: r -> (ImmutableLogRecord -> ImmutableLogRecord) -> IO ()
- atomicModifyLogRecord :: r -> (ImmutableLogRecord -> (ImmutableLogRecord, b)) -> IO b
- data ImmutableLogRecord = ImmutableLogRecord {
- logRecordTimestamp :: !(UMaybe Timestamp)
- logRecordObservedTimestamp :: !Timestamp
- logRecordTracingDetails :: !TracingDetails
- logRecordSeverityText :: !(UMaybe Text)
- logRecordSeverityNumber :: !(UMaybe SeverityNumber)
- logRecordBody :: AnyValue
- logRecordAttributes :: LogAttributes
- logRecordEventName :: !(UMaybe Text)
- data LogRecordArguments = LogRecordArguments {}
- emptyLogRecordArguments :: LogRecordArguments
- data SeverityNumber
- toShortName :: SeverityNumber -> Maybe Text
UMaybe re-export for consumers of ImmutableLogRecord fields
An unboxed optional value. Single-constructor wrapper around an unboxed
sum, so {-# UNPACK #-} can flatten it into a parent record.
Since: 0.0.1.0
Constructors
| UMaybe (# (# #) | a #) |
toBaseMaybe :: UMaybe a -> Maybe a Source #
Since: 0.0.1.0
data TracingDetails Source #
Optional trace context attached to a log record. Uses a dedicated ADT
instead of UMaybe (TraceId, SpanId, TraceFlags) so GHC can unpack all
fields flat into the constructor — no intermediate boxed tuple.
Since: 0.4.0.0
Constructors
| NoTracingDetails | |
| TracingDetails !TraceId !SpanId !TraceFlags |
Instances
| Show TracingDetails Source # | |
Defined in OpenTelemetry.Internal.Log.Types Methods showsPrec :: Int -> TracingDetails -> ShowS # show :: TracingDetails -> String # showList :: [TracingDetails] -> ShowS # | |
| Eq TracingDetails Source # | |
Defined in OpenTelemetry.Internal.Log.Types Methods (==) :: TracingDetails -> TracingDetails -> Bool # (/=) :: TracingDetails -> TracingDetails -> Bool # | |
data LogRecordExporter Source #
Exports log records to a telemetry backend. Thread-safe: the internal
MVar serializes concurrent logRecordExporterExport calls.
Spec: https://opentelemetry.io/docs/specs/otel/logs/sdk/#logrecordexporter
Since: 0.0.1.0
data LogRecordExporterArguments Source #
See LogRecordExporter for documentation
Since: 0.0.1.0
Constructors
| LogRecordExporterArguments | |
Fields
| |
mkLogRecordExporter :: LogRecordExporterArguments -> IO LogRecordExporter Source #
Since: 0.0.1.0
logRecordExporterExport :: LogRecordExporter -> Vector ReadableLogRecord -> IO ExportResult Source #
Exports a batch of ReadableLogRecords. Protocol exporters that will implement this function are typically expected to serialize and transmit the data to the destination.
Export will never be called concurrently for the same exporter instance. Depending on the implementation the result of the export may be returned to the Processor not in the return value of the call to Export but in a language specific way for signaling completion of an asynchronous task. This means that while an instance of an exporter will never have it Export called concurrently it does not mean that the task of exporting can not be done concurrently. How this is done is outside the scope of this specification. Each implementation MUST document the concurrency characteristics the SDK requires of the exporter.
Export MUST NOT block indefinitely, there MUST be a reasonable upper limit after which the call must time out with an error result (Failure).
Concurrent requests and retry logic is the responsibility of the exporter. The default SDK’s LogRecordProcessors SHOULD NOT implement retry logic, as the required logic is likely to depend heavily on the specific protocol and backend the logs are being sent to. For example, the OpenTelemetry Protocol (OTLP) specification defines logic for both sending concurrent requests and retrying requests.
Result: Success - The batch has been successfully exported. For protocol exporters this typically means that the data is sent over the wire and delivered to the destination server. Failure - exporting failed. The batch must be dropped. For example, this can happen when the batch contains bad data and cannot be serialized.
Since: 0.0.1.0
logRecordExporterForceFlush :: LogRecordExporter -> IO FlushResult Source #
This is a hint to ensure that the export of any ReadableLogRecords the exporter has received prior to the call to ForceFlush SHOULD be completed as soon as possible, preferably before returning from this method.
ForceFlush SHOULD provide a way to let the caller know whether it succeeded, failed or timed out.
ForceFlush SHOULD only be called in cases where it is absolutely necessary, such as when using some FaaS providers that may suspend the process after an invocation, but before the exporter exports the ReadlableLogRecords.
ForceFlush SHOULD complete or abort within some timeout. ForceFlush can be implemented as a blocking API or an asynchronous API which notifies the caller via a callback or an event. OpenTelemetry SDK authors MAY decide if they want to make the flush timeout configurable.
Since: 0.0.1.0
logRecordExporterShutdown :: LogRecordExporter -> IO () Source #
Shuts down the exporter. Called when SDK is shut down. This is an opportunity for exporter to do any cleanup required.
Shutdown SHOULD be called only once for each LogRecordExporter instance. After the call to Shutdown subsequent calls to Export are not allowed and SHOULD return a Failure result.
Shutdown SHOULD NOT block indefinitely (e.g. if it attempts to flush the data and the destination is unavailable). OpenTelemetry SDK authors MAY decide if they want to make the shutdown timeout configurable.
Since: 0.0.1.0
data LogRecordProcessor Source #
Receives callbacks when log records are emitted. Built-in processors batch log records and pass them to exporters.
Spec: https://opentelemetry.io/docs/specs/otel/logs/sdk/#logrecordprocessor
Since: 0.0.1.0
Constructors
| LogRecordProcessor | |
Fields
| |
data LoggerProvider Source #
Factory for creating Logger instances. Holds processors, resource,
attribute limits, and shutdown state.
All operations on LoggerProvider are safe for concurrent use from multiple threads.
Spec: https://opentelemetry.io/docs/specs/otel/logs/sdk/#loggerprovider
Since: 0.0.1.0
Constructors
| LoggerProvider | |
Fields
| |
LogRecords can be created from Loggers. Loggers are uniquely identified by the libraryName, libraryVersion, schemaUrl fields of InstrumentationLibrary.
Creating two Loggers with the same identity but different libraryAttributes is a user error.
All operations on Logger are safe for concurrent use from multiple threads.
Since: 0.0.1.0
Constructors
| Logger | |
Fields
| |
data ReadWriteLogRecord Source #
This is a data type that can represent logs from various sources: application log files, machine generated events, system logs, etc. Specification outlined here. Existing log formats can be unambiguously mapped to this data type. Reverse mapping from this data type is also possible to the extent that the target log format has equivalent capabilities.
Since: 0.0.1.0
Instances
mkReadWriteLogRecord :: Logger -> ImmutableLogRecord -> IO ReadWriteLogRecord Source #
Since: 0.0.1.0
data ReadableLogRecord Source #
Since: 0.0.1.0
Instances
mkReadableLogRecord :: ReadWriteLogRecord -> IO ReadableLogRecord Source #
Snapshot the current state of a ReadWriteLogRecord into an immutable
ReadableLogRecord. Exporters that receive a ReadableLogRecord are
guaranteed to see a consistent point-in-time view.
Since: 0.0.1.0
class IsReadableLogRecord r where Source #
This is a typeclass representing LogRecords that can be read from.
A function receiving this as an argument MUST be able to access all the information added to the LogRecord. It MUST also be able to access the Instrumentation Scope and Resource information (implicitly) associated with the LogRecord.
The trace context fields MUST be populated from the resolved Context (either the explicitly passed Context or the current Context) when emitted.
Counts for attributes due to collection limits MUST be available for exporters to report as described in the transformation to non-OTLP formats specification.
Since: 0.0.1.0
Methods
readLogRecord :: r -> IO ImmutableLogRecord Source #
Reads the current state of the LogRecord from its internal IORef. The implementation mirrors readIORef.
readLogRecordInstrumentationScope :: r -> InstrumentationLibrary Source #
Reads the InstrumentationScope from the Logger that emitted the LogRecord
readLogRecordResource :: r -> MaterializedResources Source #
Reads the Resource from the LoggerProvider that emitted the LogRecord
class IsReadableLogRecord r => IsReadWriteLogRecord r where Source #
This is a typeclass representing LogRecords that can be read from or written to. All ReadWriteLogRecords are ReadableLogRecords.
A function receiving this as an argument MUST additionally be able to modify the following information added to the LogRecord:
- Timestamp
- ObservedTimestamp
- SeverityText
- SeverityNumber
- Body
- Attributes (addition, modification, removal)
- EventName
- TraceId
- SpanId
- TraceFlags
Since: 0.0.1.0
Methods
readLogRecordAttributeLimits :: r -> AttributeLimits Source #
Reads the attribute limits from the LoggerProvider that emitted the LogRecord. These are needed to add more attributes.
modifyLogRecord :: r -> (ImmutableLogRecord -> ImmutableLogRecord) -> IO () Source #
Atomically modifies the LogRecord using its internal IORef.
Uses atomicModifyIORef' (strict) to avoid thunk buildup and ensure
thread safety under concurrent mutation.
atomicModifyLogRecord :: r -> (ImmutableLogRecord -> (ImmutableLogRecord, b)) -> IO b Source #
Atomically modifies the LogRecord and returns a value.
Uses atomicModifyIORef' (strict) for thread safety.
Instances
| IsReadWriteLogRecord ReadWriteLogRecord Source # | |
Defined in OpenTelemetry.Internal.Log.Types Methods readLogRecordAttributeLimits :: ReadWriteLogRecord -> AttributeLimits Source # modifyLogRecord :: ReadWriteLogRecord -> (ImmutableLogRecord -> ImmutableLogRecord) -> IO () Source # atomicModifyLogRecord :: ReadWriteLogRecord -> (ImmutableLogRecord -> (ImmutableLogRecord, b)) -> IO b Source # | |
data ImmutableLogRecord Source #
Point-in-time snapshot of a log record's fields.
Spec: https://opentelemetry.io/docs/specs/otel/logs/data-model/
Since: 0.0.1.0
Constructors
| ImmutableLogRecord | |
Fields
| |
data LogRecordArguments Source #
Arguments that may be set on LogRecord creation. If observedTimestamp is not set, it will default to the current timestamp.
If context is not specified it will default to the current context. Refer to the documentation of LogRecord for descriptions
of the fields.
Since: 0.0.1.0
Constructors
| LogRecordArguments | |
Fields
| |
emptyLogRecordArguments :: LogRecordArguments Source #
Since: 0.0.1.0
data SeverityNumber Source #
Log severity level per the OTel log data model.
Spec: https://opentelemetry.io/docs/specs/otel/logs/data-model/#severity-fields
Since: 0.0.1.0
Constructors
| Trace | |
| Trace2 | |
| Trace3 | |
| Trace4 | |
| Debug | |
| Debug2 | |
| Debug3 | |
| Debug4 | |
| Info | |
| Info2 | |
| Info3 | |
| Info4 | |
| Warn | |
| Warn2 | |
| Warn3 | |
| Warn4 | |
| Error | |
| Error2 | |
| Error3 | |
| Error4 | |
| Fatal | |
| Fatal2 | |
| Fatal3 | |
| Fatal4 | |
| Unknown !Int |
Instances
toShortName :: SeverityNumber -> Maybe Text Source #
Since: 0.0.1.0