Learn R Programming

otel (version 0.2.0)

is_logging_enabled: Check whether OpenTelemetry logging is active

Description

This is useful for avoiding computation when logging is inactive.

Usage

is_logging_enabled(severity = "info", logger = NULL)

Value

TRUE is OpenTelemetry logging is active, FALSE otherwise.

Arguments

severity

Check if logs are emitted at this severity level.

logger

Logger object (otel_logger), or a logger name, the instrumentation scope, to pass to get_logger().

Details

It calls get_logger() with name and then it calls the logger's $is_enabled() method.

See Also

Other OpenTelemetry logs API: log(), log_severity_levels

Examples

Run this code
fun <- function() {
  if (otel::is_logging_enabled()) {
    xattr <- calculate_some_extra_attributes()
    otel::log("Starting fun", attributes = xattr)
  }
  # ...
}

Run the code above in your browser using DataLab