Version: v0.4.0 Latest Latest

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

Go to latest
Published: Feb 13, 2020 License: Apache-2.0 Imports: 4 Imported by: 3



Package nrcensus provides an exporter for sending OpenCensus stats and traces to New Relic.

To use, simply instantiate a new Exporter using `nrcensus.NewExporter` with your service name and Insights API key and register it with the OpenCensus view and/or trace API.

exporter, err := nrcensus.NewExporter("My-OpenCensus-App", "__YOUR_NEW_RELIC_INSIGHTS_API_KEY__")
if err != nil {

// create stats, traces, etc



This section is empty.


This section is empty.


This section is empty.


type Exporter

type Exporter struct {
	// Harvester is expected to be populated by the *telemetry.Harvester
	// (
	// to use for reporting trace and view data.  It is an interface here to
	// facilitate testing.
	Harvester interface {
		RecordSpan(telemetry.Span) error
	// ServiceName is the name of this service or application.
	ServiceName string
	// IgnoreStatusCodes controls which trace.Status
	// ( Codes are turned into
	// errors on Spans.  A Span with a trace.Status greater than 0 that is not
	// in this slice will be marked as an error.  When instantiated with
	// NewExporter this field defaults to only include 5 (NOT_FOUND).
	IgnoreStatusCodes []int32
	// DeltaCalculator translates OpenCensus's cumulative metrics into delta
	// metrics.  This field must be populated to record metrics, as is done by
	// NewExporter.
	// This is a cache which is cleared by default every 20 minutes.  If your
	// metrics are being recorded on an intermittent basis, you may have to
	// modify the cache cleaning interval on this DeltaCalculator in order to
	// avoid missing metrics or spikes in graphs when your data is assimilated.
	DeltaCalculator *cumulative.DeltaCalculator

Exporter implements trace.Exporter ( and view.Exporter ( It enables sending of trace and view data from OpenCensus applications to New Relic.

func NewExporter

func NewExporter(serviceName, apiKey string, options ...func(*telemetry.Config)) (*Exporter, error)

NewExporter creates a new Exporter. serviceName is the name of this service or application. apiKey is required and refers to a New Relic Insights Insert API key.

func (*Exporter) ExportSpan

func (e *Exporter) ExportSpan(s *trace.SpanData)

ExportSpan implements trace.Exporter and records spans with the Harvester for later sending to New Relic.

func (*Exporter) ExportView

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

ExportView implements view.Exporter and records metrics with the Harvester for later sending to New Relic.

Jump to

Keyboard shortcuts

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