Learn R Programming

otel (version 0.2.0)

otel_counter: OpenTelemetry Counter Object

Description

otel_meter_provider -> otel_meter -> otel_counter, otel_up_down_counter, otel_histogram, otel_gauge

Arguments

Value

Not applicable.

Methods

counter$add()

Increment the counter by a fixed amount.

Usage

counter$add(value, attributes = NULL, span_context = NULL, ...)

Arguments

  • value: Value to increment the counter with.

  • attributes: Additional attributes to add.

  • span_context: Span context. If missing, the active context is used, if any.

Value

The counter object itself, invisibly.

Details

Usually you do not need to deal with otel_counter objects directly. counter_add() automatically sets up a meter and creates a counter instrument, as needed.

A counter object is created by calling the create_counter() method of an otel_meter_provider().

You can use the add() method to increment the counter by a positive amount.

In R counters are represented by double values.

See Also

Other low level metrics API: get_default_meter_provider(), get_meter(), meter_provider_noop, otel_gauge, otel_histogram, otel_meter, otel_meter_provider, otel_up_down_counter

Examples

Run this code
mp <- get_default_meter_provider()
mtr <- mp$get_meter()
ctr <- mtr$create_counter("session")
ctr$add(1)

Run the code above in your browser using DataLab