search

OpenCensus Go Exporter

Zenoss maintains the opencensus-go-exporter-zenoss library to allow Go applications instrumented with OpenCensus to export metrics to Zenoss Cloud.

Installation

You can install this library into your GOPATH with the following command.

go get -u github.com/zenoss/opencensus-go-exporter-zenoss

Usage

Using the exporter requires importing the package, creating an exporter, and registering the exporter.

package main

import (
    "go.opencensus.io/stats/view"
    zenoss "github.com/zenoss/opencensus-go-exporter-zenoss"
)

func main() {
    options := zenoss.Options{
        APIKey: "YOUR-ZENOSS-API-KEY",

        // GlobalDimensions are added to all sent metrics and models.
        GlobalDimensions: map[string]string{"source": "YOUR-APP-NAME"},

        // ModelDimensionTags selects OpenCensus stats tags to use as Zenoss dimensions.
        ModelDimensionTags: []string{"grpc_server_method", "grpc_server_status"},
    }

    exporter, err := zenoss.NewExporter(options)
    if err != nil {
        panic(err)
    }

    view.RegisterExporter(exporter)

    // Instrument your application with OpenCensus stats.
}

A complete working example can be found in the examples/ directory of the opencensus-go-exporter-zenoss repository.