prometheus

package
v0.30.0 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: AGPL-3.0 Imports: 18 Imported by: 0

Documentation

Overview

Package prometheus is imported from the official OpenTelemetry package: https://github.com/open-telemetry/opentelemetry-go/tree/v1.14.0/exporters/prometheus The version of the exporter would be v0.37.0 (not v1.14.0, see releases).

Customisations applied:

  1. scope info keys are not "otel_scope_name", "otel_scope_version" but we're now using the semconv ones to be consistent if we switch over to gRPC. we're propagating them via the *resource.Resource (see Collect method) see here: https://github.com/open-telemetry/opentelemetry-go/blob/v1.14.0/exporters/prometheus/exporter.go#L48

  2. prometheus counters MUST have a _total suffix but that breaks our dashboards, so we removed it see here: https://github.com/open-telemetry/opentelemetry-go/blob/v1.14.0/exporters/prometheus/exporter.go#L73

  3. a global logger was used, we made it injectable via options see here: https://github.com/open-telemetry/opentelemetry-go/blob/v1.14.0/exporters/prometheus/exporter.go#L393

  4. removed unnecessary otel_scope_info metric

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

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.

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 WithLogger

func WithLogger(l logger) Option

WithLogger enables the logger

func WithNamespace added in v0.15.2

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 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 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.

Jump to

Keyboard shortcuts

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