prometheus

package module
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2022 License: Apache-2.0 Imports: 11 Imported by: 294

README

OpenCensus Go Prometheus Exporter

Build Status GoDoc

Provides OpenCensus metrics export support for Prometheus.

Installation

$ go get -u contrib.go.opencensus.io/exporter/prometheus

Documentation

Overview

Package prometheus contains a Prometheus exporter that supports exporting OpenCensus views as Prometheus metrics.

Example
package main

import (
	"log"
	"net/http"

	"contrib.go.opencensus.io/exporter/prometheus"
)

func main() {
	exporter, err := prometheus.NewExporter(prometheus.Options{})
	if err != nil {
		log.Fatal(err)
	}

	// Serve the scrape endpoint on port 9999.
	http.Handle("/metrics", exporter)
	log.Fatal(http.ListenAndServe(":9999", nil))
}
Output:

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Exporter

type Exporter struct {
	// contains filtered or unexported fields
}

Exporter exports stats to Prometheus, users need to register the exporter as an http.Handler to be able to export.

func NewExporter

func NewExporter(o Options) (*Exporter, error)

NewExporter returns an exporter that exports stats to Prometheus.

func (*Exporter) ExportView deprecated

func (e *Exporter) ExportView(vd *view.Data)

ExportView exports to the Prometheus if view data has one or more rows. Each OpenCensus AggregationData will be converted to corresponding Prometheus Metric: SumData will be converted to Untyped Metric, CountData will be a Counter Metric, DistributionData will be a Histogram Metric.

Deprecated: in lieu of metricexport.Reader interface.

func (*Exporter) ServeHTTP

func (e *Exporter) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP serves the Prometheus endpoint.

type Options

type Options struct {
	Namespace   string
	Registry    *prometheus.Registry
	Registerer  prometheus.Registerer
	Gatherer    prometheus.Gatherer
	OnError     func(err error)
	ConstLabels prometheus.Labels // ConstLabels will be set as labels on all views.
}

Options contains options for configuring the exporter.

Directories

Path Synopsis
Command prometheus is an example program that collects data for video size.
Command prometheus is an example program that collects data for video size.

Jump to

Keyboard shortcuts

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