newrelic-opencensus-exporter-go: github.com/newrelic/newrelic-opencensus-exporter-go/nrcensus Index | Examples | Files

package nrcensus

import "github.com/newrelic/newrelic-opencensus-exporter-go/nrcensus"

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.

Code:

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

Examples

Package Files

doc.go exporter.go version.go

type Exporter Uses

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 Uses

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.

Code:

// To enable Infinite Tracing on the New Relic Edge, use the
// telemetry.ConfigSpansURLOverride along with the URL for your Trace
// Observer, including scheme and path.  See
// https://docs.newrelic.com/docs/understand-dependencies/distributed-tracing/enable-configure/enable-distributed-tracing
exporter, err := nrcensus.NewExporter(
    "My-OpenCensus-App", "__YOUR_NEW_RELIC_INSIGHTS_API_KEY__",
    telemetry.ConfigSpansURLOverride("https://nr-internal.aws-us-east-1.tracing.edge.nr-data.net/trace/v1"),
)
if err != nil {
    panic(err)
}
view.RegisterExporter(exporter)
trace.RegisterExporter(exporter)

// create stats, traces, etc

func (*Exporter) ExportSpan Uses

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 Uses

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

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

Package nrcensus imports 4 packages (graph) and is imported by 2 packages. Updated 2020-06-14. Refresh now. Tools for package owners.