Skip to content

opencensus-beam/opencensus-prometheus

Repository files navigation

Opencensus Prometheus integration for Erlang/BEAM

Copyright (c) 2018 Ilya Khaprov <i.khaprov@gmail.com>.

Version: 0.3.1

Hex.pm Hex.pm Downloads Build Status Coverage Status

Opencensus: Erlang stats collection and distributed tracing framework.

Prometheus.io: monitoring system and time series database client in Erlang.

Using

Opencensus has trace and stats packages, trace package if for distributed tracing and stats package is for backend-agnostic metrics collection.

This library implements a trace reporter for exporting spans duration as prometheus metrics and a stats exporter for exporting metrics collected using Opencensus.

Example configuration:

{opencensus, [
        {reporter, {oc_reporter_sequential, [
          {oc_reporter_zipkin, [
            {url, "http://localhost:9411"},
            {service_name, "service_name"}
          ]},
          {oc_prometheus_reporter, [{type, histogram}, %% metric type
                                    {name, span_histogram_seconds}, %% metric name, note the time unit
                                    {buckets, [0, 1, 2]}]} %% histogram buckets with bounds in the time unit
        ]}},
        {sampler, {oc_sampler_probability, [
            {probability, 0.001} %% one in a thousand
        ]}}
    ]}

Since Prometheus uses push model you don't need to set up Opencensus stats exporter as usual. Instead, this library provides oc_stat_exporter_prometheus which implements Prometheus collector interface.

  prometheus_registry:register_collector(oc_stat_exporter_prometheus)

Other Prometheus and Opencensus Links

Opencensus

Prometheus

Contributing

Section order:

  • Types
  • Macros
  • Callbacks
  • Public API
  • Deprecations
  • Private Parts

Install the git pre-commit hook:

./bin/pre-commit.sh install

The pre-commit check can be skipped by passing --no-verify to git commit.

License

MIT

Modules

oc_reporter_prometheus
oc_stat_exporter_prometheus