otel_logger_provider -> otel_logger
Details
Usually you do not need to deal with otel_logger objects directly.
log()
automatically sets up the logger for emitting the logs.
A logger object is created by calling the get_logger()
method of an
otel_logger_provider.
You can use the log()
method of the logger object to emit logs.
Typically there is a separate logger object for each instrumented R package.
Methods
logger$is_enabled()
Whether the logger is active and emitting logs at a certain severity level.
This is equivalent to the is_logging_enabled()
function.
logger$get_minimum_severity()
Get the current minimum severity at which the logger is emitting logs.
logger$set_minimum_severiry()
Set the minimum severity for emitting logs.
logger$log()
Log an OpenTelemetry log message.
Usage
logger$log(
msg = "",
severity = "info",
span_context = NULL,
span_id = NULL,
trace_id = NULL,
trace_flags = NULL,
timestamp = SYs.time(),
observed_timestamp = NULL,
attributes = NULL,
.envir = parent.frame()
)
Arguments
msg
: Log message, may contain R expressions to evaluate within braces.severity
: Log severity, a string, one of "trace", "trace2", "trace3", "trace4", "debug", "debug2", "debug3", "debug4", "info", "info2", "info3", "info4", "warn", "warn2", "warn3", "warn4", "error", "error2", "error3", "error4", "fatal", "fatal2", "fatal3", "fatal4".span_context
: An otel_span_context object to associate the log message with a span.span_id
: Alternatively tospan_context
, you can also specifyspan_id
,trace_id
andtrace_flags
to associate a log message with a span.trace_id
: Alternatively tospan_context
, you can also specifyspan_id
,trace_id
andtrace_flags
to associate a log message with a span.trace_flags
: Alternatively tospan_context
, you can also specifyspan_id
,trace_id
andtrace_flags
to associate a log message with a span.timestamp
: Time stamp, defaults to the current time. This is the time the logged event occurred.observed_timestamp
: Observed time stamp, this is the time the event was observed.attributes
: Optional attributes, seeas_attributes()
for the possible values..envir
: Environment to evaluate the interpolated expressions of the log message in. `
See also
Other low level logs API:
get_default_logger_provider()
,
get_logger()
,
logger_provider_noop
,
otel_logger_provider
Examples
lp <- get_default_logger_provider()
lgr <- lp$get_logger()
platform <- utils::sessionInfo()$platform
lgr$log("This is a log message from {platform}.", severity = "trace")