Documentation

Overview

    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 {
        panic(err)
    }
    view.RegisterExporter(exporter)
    trace.RegisterExporter(exporter)
    
    // create stats, traces, etc
    

    Index

    Constants

    This section is empty.

    Variables

    This section is empty.

    Functions

    This section is empty.

    Types

    type Exporter

    type Exporter struct {
    	// Harvester is expected to be populated by the *telemetry.Harvester
    	// (https://godoc.org//github.com/newrelic/newrelic-telemetry-sdk-go/telemetry#Harvester)
    	// to use for reporting trace and view data.  It is an interface here to
    	// facilitate testing.
    	Harvester interface {
    		RecordSpan(telemetry.Span) error
    		RecordMetric(telemetry.Metric)
    	}
    	// ServiceName is the name of this service or application.
    	ServiceName string
    	// IgnoreStatusCodes controls which trace.Status
    	// (https://opencensus.io/tracing/span/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 (https://godoc.org/go.opencensus.io/trace#Exporter) and view.Exporter (https://godoc.org/go.opencensus.io/stats/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.