powered by
This is useful for avoiding computation when metrics collection is inactive.
is_measuring_enabled(meter = NULL)
TRUE is OpenTelemetry metrics collection is active, FALSE otherwise.
TRUE
FALSE
Meter object (otel_meter), or a meter name, the instrumentation scope, to pass to get_meter().
get_meter()
It calls get_meter() with name and then it calls the meter's $is_enabled() method.
name
$is_enabled()
Other OpenTelemetry metrics API: counter_add(), gauge_record(), histogram_record(), up_down_counter_add()
counter_add()
gauge_record()
histogram_record()
up_down_counter_add()
fun <- function() { if (otel::is_measuring_enabled()) { xattr <- calculate_some_extra_attributes() otel::counter_add("sessions", 1, attributes = xattr) } # ... }
Run the code above in your browser using DataLab