prometheus

package module
v0.0.0-...-1e3363d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 19, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package prometheus provides a bridge from Prometheus to OpenTelemetry.

The Prometheus Bridge allows using the Prometheus Golang client library with the OpenTelemetry SDK. This enables prometheus instrumentation libraries to be used with OpenTelemetry exporters, including OTLP.

Limitations:

  • Summary metrics are dropped by the bridge.
  • Start times for histograms and counters are set to the process start time.
  • Prometheus histograms are translated to OpenTelemetry fixed-bucket histograms, rather than exponential histograms.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewMetricProducer

func NewMetricProducer(opts ...Option) metric.Producer

NewMetricProducer returns a metric.Producer that fetches metrics from Prometheus. This can be used to allow Prometheus instrumentation to be added to an OpenTelemetry export pipeline.

Example
package main

import (
	"github.com/dillonstreator/opentelemetry-go-contrib/bridges/prometheus"
	"go.opentelemetry.io/otel/sdk/metric"
)

func main() {
	// Create a Promethes bridge "Metric Producer" which adds metrics from the
	// prometheus.DefaultGatherer. Add the WithGatherer option to add metrics
	// from other registries.
	bridge := prometheus.NewMetricProducer()
	// This reader is used as a stand-in for a reader that will actually export
	// data. See https://pkg.go.dev/go.opentelemetry.io/otel/exporters for
	// exporters that can be used as or with readers. The metric.WithProducer
	// option adds metrics from the Prometheus bridge to the reader.
	reader := metric.NewManualReader(metric.WithProducer(bridge))
	// Create an OTel MeterProvider with our reader. Metrics from OpenTelemetry
	// instruments are combined with metrics from Prometheus instruments in
	// exported batches of metrics.
	_ = metric.NewMeterProvider(metric.WithReader(reader))
}
Output:

Types

type Option

type Option interface {
	// contains filtered or unexported methods
}

Option sets producer option values.

func WithGatherer

func WithGatherer(gatherer prometheus.Gatherer) Option

WithGatherer configures which prometheus Gatherer the Bridge will gather from. If no registerer is used the prometheus DefaultGatherer is used.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL