Version: v0.0.0-...-fe632b3 Latest Latest

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

Go to latest
Published: Feb 26, 2020 License: Apache-2.0 Imports: 7 Imported by: 0



Package opencensus contains support code for writing adapters that use OpenCensus.



This section is empty.


This section is empty.


func ExtractParentContext

func ExtractParentContext(traceID, parentSpanID string) (trace.SpanContext, bool)

ExtractParentContext returns an OpenCensus SpanContext that corresponds to the parent of the given trace and parent span id that are in the hex encoded string that comes from tracespan instances. The second return value will be false if the trace id is invalid.

func ExtractSpanContext

func ExtractSpanContext(spanID string, parent trace.SpanContext) (trace.SpanContext, bool)

ExtractSpanContext returns an OpenCensus SpanContext that corresponds to the the given span id and parent span context. The second return value will be false if the span id is invalid.


type Handler

type Handler struct {

	// NewExporter creates OpenCensus exporters where generated spans will be exported.
	NewExporter NewExporterFunc
	// Sampler to be applied to each span.
	Sampler trace.Sampler
	// CloseFunc will be called when this handler is closed. Optional.
	CloseFunc func() error
	// contains filtered or unexported fields

Handler implements tracespan.Handler using an OpenCensus TraceExporter.

func NewTraceHandler

func NewTraceHandler(newExporter NewExporterFunc, sampler trace.Sampler) *Handler

NewTraceHandler returns a new tracespan adapter that sends spans to the provided exporter.

func (*Handler) Close

func (h *Handler) Close() error

Close calls the CloseFunc (if any) that was provided when this Handler was created.

func (*Handler) HandleTraceSpan

func (h *Handler) HandleTraceSpan(_ context.Context, values []*tracespan.Instance) (retErr error)

HandleTraceSpan transforms tracespan template instances into OpenCensus spans and sends them to the configured OpenCensus exporter.

type NewExporterFunc

type NewExporterFunc func(name string, endpoint string) trace.Exporter

NewExporterFunc is a callback to create new OpenCensus exporters for a given workload name and endpoint.

The format of endpoint will be IP_ADDRESS:PORT. name and endpoint refer to the logical owning workload of this span. For server spans, the values are the destinationName and destinationIp, for clients the sourceName and sourceIp.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL