Liking cljdoc? Tell your friends :D

steffan-westcott.clj-otel.api.logs.log-record

Functions for emitting log records. IMPORTANT: This namespace is for use by logging libraries only. To add logging to an application or general library, use a logging library that has OpenTelemetry log signal support instead e.g. Log4j2, Timbre.

Functions for emitting log records.
IMPORTANT: This namespace is for use by logging libraries only. To add
logging to an application or general library, use a logging library that has
OpenTelemetry log signal support instead e.g. Log4j2, Timbre.
raw docstring

emitclj

(emit {:keys [logger context severity severity-text body attributes exception
              thread timestamp observed-timestamp event-name]
       :or {context (context/dyn) thread (Thread/currentThread)}
       {:keys [fn line col file]} :source})

Emits a log record.

IMPORTANT: This function is for use by logging libraries only. To add logging to an application or general library, use a logging library that has OpenTelemetry log signal support instead e.g. Log4j2, Timbre.

Takes an option map as below. The defaults for :context and :thread may be suitable only if emit is evaluated synchronously when the log record occurs.

keydescription
:loggerio.opentelemetry.api.logs.Logger used to create the log record (default: default logger, as set by set-default-logger!; if no default logger has been set, one will be set with default config).
:contextContext of the log record. If nil, use the root context (default: bound or current context).
:severity^io.opentelemetry.api.logs.Severity or keyword :traceN, :debugN, :infoN, :warnN, :errorN, :fatalN where N is nothing or 2, 3, 4 (default: nil).
:severity-textShort name of log record severity (default: nil).
:bodyBody of log record; may be string, keyword, boolean, long, double, byte array, map or seqable coll. Body may have nested structure. Keywords and map keys are transformed to strings (default: nil).
:attributesMap of additional attributes for the log record (default: no attributes).
:exceptionException to attach to log record. Exception details are merged with the :attributes value (default: nil).
:threadThread where the log record occurred, or nil for no thread. Thread details are merged with the :attributes value (default: current thread).
:timestampTimestamp for when the log record occurred. Value is either an Instant or vector [amount ^TimeUnit unit] (default: nil).
:observed-timestampTimestamp for when the log record was observed by OpenTelemetry; may be later than :timestamp for asynchronous processing. Value is either an Instant or vector [amount ^TimeUnit unit] (default: current timestamp).
:sourceMap describing source code where log record occurred. Optional keys are :fn, :line, :col and :file (default: nil).
:event-nameIf not nil, a string event name. An event name identifies this log record as an event with specific structure of :body and :attributes (default: nil).
Emits a log record.

IMPORTANT: This function is for use by logging libraries only. To add
logging to an application or general library, use a logging library that has
OpenTelemetry log signal support instead e.g. Log4j2, Timbre.

Takes an option map as below. The defaults for `:context` and `:thread` may
be suitable only if `emit` is evaluated synchronously when the log record
occurs.

| key                 | description |
|---------------------|-------------|
|`:logger`            | `io.opentelemetry.api.logs.Logger` used to create the log record (default: default logger, as set by [[set-default-logger!]]; if no default logger has been set, one will be set with default config).
|`:context`           | Context of the log record. If `nil`, use the root context (default: bound or current context).
|`:severity`          | `^io.opentelemetry.api.logs.Severity` or keyword `:traceN`, `:debugN`, `:infoN`, `:warnN`, `:errorN`, `:fatalN` where `N` is nothing or `2`, `3`, `4` (default: nil).
|`:severity-text`     | Short name of log record severity (default: nil).
|`:body`              | Body of log record; may be string, keyword, boolean, long, double, byte array, map or seqable coll. Body may have nested structure. Keywords and map keys are transformed to strings (default: nil).
|`:attributes`        | Map of additional attributes for the log record (default: no attributes).
|`:exception`         | Exception to attach to log record. Exception details are merged with the `:attributes` value (default: nil).
|`:thread`            | Thread where the log record occurred, or `nil` for no thread. Thread details are merged with the `:attributes` value (default: current thread).
|`:timestamp`         | Timestamp for when the log record occurred. Value is either an `Instant` or vector `[amount ^TimeUnit unit]` (default: nil).
|`:observed-timestamp`| Timestamp for when the log record was observed by OpenTelemetry; may be later than `:timestamp` for asynchronous processing. Value is either an `Instant` or vector `[amount ^TimeUnit unit]` (default: current timestamp).
|`:source`            | Map describing source code where log record occurred. Optional keys are `:fn`, `:line`, `:col` and `:file` (default: nil).
|`:event-name`        | If not nil, a string event name. An event name identifies this log record as an event with specific structure of `:body` and `:attributes` (default: nil).
sourceraw docstring

get-loggerclj

(get-logger)
(get-logger {:keys [name version schema-url open-telemetry]
             :or {name (:name default-library)
                  version (:version default-library)
                  schema-url (:schema-url default-library)}})

Builds and returns a io.opentelemetry.api.logs.Logger instance. May take an option map as follows:

keydescription
:nameName of the instrumentation library, not the instrumented library e.g. "io.opentelemetry.contrib.mongodb" (default: See config.edn resource file).
:versionInstrumentation library version e.g. "1.0.0" (default: See config.edn resource file).
:schema-urlURL of OpenTelemetry schema used by this instrumentation library (default: See config.edn resource file).
:open-telemetryOpenTelemetry instance to get logger from (default: default OpenTelemetry instance).
Builds and returns a `io.opentelemetry.api.logs.Logger` instance. May take
an option map as follows:

| key             | description |
|-----------------|-------------|
|`:name`          | Name of the *instrumentation* library, not the *instrumented* library e.g. `"io.opentelemetry.contrib.mongodb"` (default: See `config.edn` resource file).
|`:version`       | Instrumentation library version e.g. `"1.0.0"` (default: See `config.edn` resource file).
|`:schema-url`    | URL of OpenTelemetry schema used by this instrumentation library (default: See `config.edn` resource file).
|`:open-telemetry`| `OpenTelemetry` instance to get logger from (default: default `OpenTelemetry` instance).
sourceraw docstring

noop-loggerclj

(noop-logger)

Gets a no-op logger.

Gets a no-op logger.
sourceraw docstring

set-default-logger!clj

(set-default-logger! logger)

Sets the default io.opentelemetry.api.logs.Logger instance used when creating log records. Returns logger. See also get-logger.

Sets the default `io.opentelemetry.api.logs.Logger` instance used when
creating log records. Returns `logger`. See also [[get-logger]].
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close