Modules

oc_reporter oc_reporter_noop oc_reporter_sequential oc_reporter_zipkin oc_sampler oc_sampler_always oc_sampler_never oc_sampler_probability oc_server oc_span oc_span_ctx_binary oc_span_ctx_header oc_stat oc_stat_aggregation oc_stat_aggregation_count oc_stat_aggregation_distribution oc_stat_aggregation_latest oc_stat_aggregation_sum oc_stat_config oc_stat_exporter oc_stat_exporter_prometheus oc_stat_measure oc_stat_view oc_std_encoder oc_tag_ctx_binary oc_tag_ctx_header oc_tags oc_trace oc_trace_pb oc_transform ocp opencensus opencensus_app opencensus_sup

Module oc_stat_measure

Measure represents a type of metric to be tracked and recorded.

Description

For example, latency, request Mb/s, and response Mb/s are measures to collect from a server.

Measure is a generic interface for recording values in aggregations via subscribed views. When recording a value, we have to obtain the list of all subscribed views and call respective aggregations. We use code generation to optimize this. When a view subscribed or unsubscribed we regenerate unrolled loop in a special module (one for each measure). Module names generated from measurement names (1-to-1). If we know a measure name at the compile time, we can eliminate the module name lookup and inject remote call directly, replacing oc_stat:record with <GENERATED_MEASURE_MODULE>:record. For that {parse_transform, oc_stat_measure} option must be used.

Data Types

description()


      description() = binary() | string()
      

measure()


      measure() = #measure{name = name(), module = module(), description = description(), unit = unit()}
      

name()


      name() = atom() | binary() | string()
      

unit()


      unit() = atom()
      

Function Index

exists/1 Returns a measure with the Name or false..
new/3 Creates and registers a measure.
parse_transform/2 oc_stat_measure is also a parse transform.

Function Details

exists/1


      exists(Name::name()) -> measure() | false
      

Returns a measure with the Name or false..

new/3


      new(Name::name(), Description::description(), Unit::unit()) -> oc_stat_view:measure()
      

Creates and registers a measure. If a measure with the same name already exists, old measure returned.

parse_transform/2

parse_transform(Forms, Options) -> any()

oc_stat_measure is also a parse transform. It can detect oc_stat:record calls with constant measure names and generate remote measure module call from that. At the run-time this means we don't have to do a lookup for the module name and if measure doesn't exist, {unknown_measure, Name} error will be thrown.