Counter is the most common synchronous instrument. This instrument supports an Add(increment) function for reporting a sum, and is restricted to non-negative increments. The default aggregation is Sum, as for any additive instrument.

Example uses for Counter:

  1. count the number of bytes received.
  2. count the number of requests completed.
  3. count the number of accounts created.
  4. count the number of checkpoints run.
  5. count the number of 5xx errors.

    1.3.0

    interface Counter<
        AttributesTypes extends
            @opentelemetry/api.MetricAttributes = @opentelemetry/api.MetricAttributes,
    > {
        add(
            value: number,
            attributes?: AttributesTypes,
            context?: @opentelemetry/api.Context,
        ): void;
    }

    Type Parameters

    Methods

    Methods