package module
Version: v0.0.0-...-731d59e Latest Latest

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

Go to latest
Published: Jun 22, 2022 License: Apache-2.0 Imports: 22 Imported by: 28


OpenCensus Go Datadog

CircleCI GoDoc

Provides OpenCensus stats and trace exporter support for Datadog Metrics and Datadog APM. The examples folder provides some simple usage examples.

Note: This repository is deprecated and is in maintenance mode. Bugs are being addressed, but new features are not being implemented. OpenCensus and OpenTracing have merged into OpenTelemetry. It is recommended that OpenTelemetry alongside the Datadog OpenTelemetry Exporter be used instead.


Please make sure to read through our contribution guidelines before opening an issue or a Pull Request.


In order to get accurate Datadog APM statistics and full distributed tracing, trace sampling must be done by the Datadog stack. For this to be possible, OpenCensus must be notified to forward all traces to our exporter:

trace.ApplyConfig(trace.Config{DefaultSampler: trace.AlwaysSample()})

This change simply means that Datadog will handle sampling. It does not mean that all traces will be sampled.



Package datadog contains a Datadog exporter for OpenCensus.



View Source
const (
	// DefaultStatsAddrUDP specifies the default protocol (UDP) and address
	// for the DogStatsD service.
	DefaultStatsAddrUDP = "localhost:8125"

	// DefaultStatsAddrUDS specifies the default socket address for the
	// DogStatsD service over UDS. Only useful for platforms supporting unix
	// sockets.
	DefaultStatsAddrUDS = "unix:///var/run/datadog/dsd.socket"


This section is empty.


This section is empty.


type Exporter

type Exporter struct {
	// contains filtered or unexported fields

Exporter exports stats to Datadog.

func NewExporter

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

NewExporter returns an exporter that exports stats and traces to Datadog. When using trace, it is important to call Stop at the end of your program for a clean exit and to flush any remaining tracing data to the Datadog agent. If an error occurs initializing the stats exporter, the error will be returned and the exporter will be nil.

func (*Exporter) ExportSpan

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

ExportSpan implements trace.Exporter.

func (*Exporter) ExportView

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

ExportView implements view.Exporter.

func (*Exporter) Stop

func (e *Exporter) Stop()

Stop cleanly stops the exporter, flushing any remaining spans and stats to the transport and reporting any errors. Make sure to always call Stop at the end of your program in order to not lose any tracing data. Only call Stop once per exporter. Repeated calls will cause panic.

type Options

type Options struct {
	// Namespace specifies the namespaces to which metric keys are appended.
	Namespace string

	// Service specifies the service name used for tracing.
	Service string

	// TraceAddr specifies the host[:port] address of the Datadog Trace Agent.
	// It defaults to localhost:8126.
	TraceAddr string

	// StatsAddr specifies the host[:port] address for DogStatsD. It defaults
	// to localhost:8125.
	StatsAddr string

	// OnError specifies a function that will be called if an error occurs during
	// processing stats or metrics.
	OnError func(err error)

	// Tags specifies a set of global tags to attach to each metric.
	Tags []string

	// GlobalTags holds a set of tags that will automatically be applied to all
	// exported spans.
	GlobalTags map[string]interface{}

	// DisableCountPerBuckets specifies whether to emit count_per_bucket metrics
	DisableCountPerBuckets bool

	// TagMetricNames specifies whether to include tags to metric names.
	TagMetricNames bool

	// StatsdOptions defines a set of options to be passed to the statsd client.
	StatsdOptions []statsd.Option

Options contains options for configuring the exporter.


Path Synopsis

Jump to

Keyboard shortcuts

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