prometheus – go.opentelemetry.io/otel/exporters/prometheus Index | Files

package prometheus

import "go.opentelemetry.io/otel/exporters/prometheus"

Package prometheus provides a Prometheus Exporter that converts OTLP metrics into the Prometheus exposition format and implements prometheus.Collector to provide a handler for these metrics.

Index

Types

type Exporter

type Exporter struct {
	metric.Reader
}

Exporter is a Prometheus Exporter that embeds the OTel metric.Reader interface for easy instantiation with a MeterProvider.

func New

func New(opts ...Option) (*Exporter, error)

New returns a Prometheus Exporter.

func (*Exporter) MarshalLog

func (e *Exporter) MarshalLog() interface{}

MarshalLog returns logging data about the Exporter.

type Option

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

Option sets exporter option values.

func WithAggregationSelector

func WithAggregationSelector(agg metric.AggregationSelector) Option

WithAggregationSelector configure the Aggregation Selector the exporter will use. If no AggregationSelector is provided the DefaultAggregationSelector is used.

func WithNamespace

func WithNamespace(ns string) Option

WithNamespace configures the Exporter to prefix metric with the given namespace. Metadata metrics such as target_info and otel_scope_info are not prefixed since these have special behavior based on their name.

func WithProducer

func WithProducer(producer metric.Producer) Option

WithProducer configure the metric Producer the exporter will use as a source of external metric data.

func WithRegisterer

func WithRegisterer(reg prometheus.Registerer) Option

WithRegisterer configures which prometheus Registerer the Exporter will register with. If no registerer is used the prometheus DefaultRegisterer is used.

func WithResourceAsConstantLabels

func WithResourceAsConstantLabels(resourceFilter attribute.Filter) Option

WithResourceAsConstantLabels configures the Exporter to add the resource attributes the resourceFilter returns true for as attributes on all exported metrics.

The does not affect the target info generated from resource attributes.

func WithoutCounterSuffixes

func WithoutCounterSuffixes() Option

WithoutCounterSuffixes disables exporter's addition _total suffixes on counters.

By default, metric names include a _total suffix to follow Prometheus naming conventions. For example, the counter metric happy.people would become happy_people_total. With this option set, the name would instead be happy_people.

func WithoutScopeInfo

func WithoutScopeInfo() Option

WithoutScopeInfo configures the Exporter to not export the otel_scope_info metric. If not specified, the Exporter will create a otel_scope_info metric containing the metrics' Instrumentation Scope, and also add labels about Instrumentation Scope to all metric points.

func WithoutTargetInfo

func WithoutTargetInfo() Option

WithoutTargetInfo configures the Exporter to not export the resource target_info metric. If not specified, the Exporter will create a target_info metric containing the metrics' resource.Resource attributes.

func WithoutUnits

func WithoutUnits() Option

WithoutUnits disables exporter's addition of unit suffixes to metric names, and will also prevent unit comments from being added in OpenMetrics once unit comments are supported.

By default, metric names include a unit suffix to follow Prometheus naming conventions. For example, the counter metric request.duration, with unit milliseconds would become request_duration_milliseconds_total. With this option set, the name would instead be request_duration_total.

Source Files

config.go doc.go exporter.go

Version
v0.57.0 (latest)
Published
Mar 5, 2025
Platform
darwin/amd64
Imports
18 packages
Last checked
now

Tools for package owners.