This is useful for avoiding computation when metrics collection is inactive.
Arguments
- meter
Meter object (otel_meter), or a meter name, the instrumentation scope, to pass to
get_meter()
.
Details
It calls get_meter()
with name
and then it calls the meter's
$is_enabled()
method.
See also
Other OpenTelemetry metrics API:
counter_add()
,
gauge_record()
,
histogram_record()
,
up_down_counter_add()
Examples
fun <- function() {
if (otel::is_measuring_enabled()) {
xattr <- calculate_some_extra_attributes()
otel::counter_add("sessions", 1, attributes = xattr)
}
# ...
}