go.opencensus.iogo.opencensus.io/exporter/prometheus Index | Examples | Files | Directories

package prometheus

import "go.opencensus.io/exporter/prometheus"

Package prometheus contains a Prometheus exporter.

Please note that this exporter is currently work in progress and not complete.

Example

Code:play 

package main

import (
	"log"
	"net/http"

	"go.opencensus.io/exporter/prometheus"
	"go.opencensus.io/stats/view"
)

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

	// Serve the scrap endpoint at localhost:9999.
	http.Handle("/metrics", exporter)
	log.Fatal(http.ListenAndServe(":9999", nil))
}

Index

Examples

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. Only one exporter should exist per instance

func (*Exporter) ExportView

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 Counter Metric, DistributionData will be Histogram Metric, and MeanData will be Summary Metric. Please note the Summary Metric from MeanData does not have any quantiles.

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
	OnError   func(err error)
}

Options contains options for configuring the exporter.

Source Files

prometheus.go

Directories

PathSynopsis
exporter/prometheus/exampleCommand prometheus is an example program that collects data for video size.
Version
v0.6.0
Published
Mar 22, 2018
Platform
js/wasm
Imports
11 packages
Last checked
3 hours ago

Tools for package owners.