Back to

Package graphite

Latest Go to latest

The latest major version is .

Published: Apr 24, 2020 | License: Apache-2.0 | Module:


Package graphite contains a Graphite exporter that supports exporting OpenCensus views as Graphite metrics.



package main

import (

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

	// Serve the scrape endpoint on port 9999.
	log.Fatal(http.ListenAndServe(":9999", nil))



type Exporter

type Exporter struct {
	// contains filtered or unexported fields

Exporter exports stats to Graphite

func NewExporter

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

NewExporter returns an exporter that exports stats to Graphite.

func (*Exporter) ExportView

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

ExportView exports to the Graphite if view data has one or more rows. Each OpenCensus stats records will be converted to corresponding Graphite Metric

func (*Exporter) Flush

func (e *Exporter) Flush()

type Options

type Options struct {
	// Host contains de host address for the graphite server.
	// The default value is "".
	Host string

	// Port is the port in which the carbon endpoint is available.
	// The default value is 2003.
	Port int

	// Namespace is optional and will be the first element in the path.
	Namespace string

	// Tags specifies a set of default tags to attach to each metric.
	// Tags is optional and will work only for Graphite above 1.1.x.
	// Example : []string{"tagName1=tagValue1", "tagName2=tagValue2"}
	Tags []string

	// OnError is the hook to be called when there is
	// an error uploading the stats or tracing data.
	// If no custom hook is set, errors are logged.
	// Optional.
	OnError func(err error)

Options contains options for configuring the exporter.

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier