This is useful for avoiding computation when metrics collection is inactive.
is_measuring_enabled(meter = NULL)Meter object (otel_meter), or a meter name, the
instrumentation scope, to pass to get_meter().
TRUE is OpenTelemetry metrics collection is active,
FALSE otherwise.
It calls get_meter() with name and then it calls the meter's
$is_enabled() method.
Other OpenTelemetry metrics API:
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)
}
# ...
}