package lightstepoc

import "github.com/lightstep/lightstep-tracer-go/lightstepoc"

Package lightstepoc provides an OpenCensus exporter for sending OpenCensus spans back to LightStep.

NOTE: This package is currently experimental. Breaking changes may occur, independent of version.

func Example() {
    exporterOptions := []lightstepoc.Option{}
    exporter, err := lightstepoc.NewExporter(exporterOptions...)}
    if err != nil {
        log.Fatal(err)
    }
    defer exporter.Close(context.Background())

    trace.RegisterExporter(nil)
}

Index

Constants

const (
	DefaultSatelliteHost = "localhost"
	DefaultSatellitePort = 8360
)

By default, the exporter will attempt to connect to a local satellite

Variables

var (
	// ErrFailedToCreateExporter indicates that the underlying tracer could not be created,
	// but the root reason is not known.
	ErrFailedToCreateExporter = errors.New("lightstepoc: failed to create exporter")
)

Types

type Attributes

type Attributes map[string]interface{}

Attributes provide extra information in a span

type Exporter

type Exporter struct {
	// contains filtered or unexported fields
}

Exporter may be registered with OpenCensus so that span data can be exported to LightStep

func NewExporter

func NewExporter(opts ...Option) (*Exporter, error)

NewExporter creates a new Exporter. It returns an error if the underlying tracer could not be created, e.g., due to invalid options

func (*Exporter) Close

func (e *Exporter) Close(ctx context.Context)

Close flushes all buffered spans and then kills open connections to LightStep, releasing resources

func (*Exporter) ExportSpan

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

ExportSpan queues the span to be sent LightStep. Spans are typically batched for performance reasons. Call `Exporter#Flush` to send all queued spans.

func (*Exporter) Flush

func (e *Exporter) Flush(ctx context.Context)

Flush sends all buffered spans to LightStep

type Option

type Option func(*config)

Option provides configuration for the Exporter

func WithAccessToken

func WithAccessToken(accessToken string) Option

WithAccessToken sets an access token for communicating with LightStep

func WithComponentName

func WithComponentName(componentName string) Option

WithComponentName overrides the component (service) name that will be used in LightStep

func WithDefaultAttributes

func WithDefaultAttributes(attrs Attributes) Option

WithDefaultAttributes sets attributes that will be appended to every span that is exported to the trace.

func WithInsecure

func WithInsecure(insecure bool) Option

WithInsecure prevents the Exporter from communicating over TLS with the satellite, i.e., the connection will run over HTTP instead of HTTPS

func WithMaxBufferedSpans

func WithMaxBufferedSpans(value int) Option

WithMaxBufferedSpans sets the maximum number of spans that will be buffered before sending them to a collector. Should be used to override the `DefaultMaxSpan` value of 1000.

func WithMetaEventReportingEnabled

func WithMetaEventReportingEnabled(metaEventReportingEnabled bool) Option

WithMetaEventReportingEnabled configures the tracer to send meta events, e.g., events for span creation

func WithSatelliteHost

func WithSatelliteHost(satelliteHost string) Option

WithSatelliteHost sets the satellite host to which spans will be sent

func WithSatellitePort

func WithSatellitePort(satellitePort int) Option

WithSatellitePort sets the satellite port to which spans will be sent

Source Files

exporter.go options.go package.go

Directories

PathSynopsis
lightstepoc/internal
Version
v0.26.0 (latest)
Published
Aug 4, 2022
Platform
js/wasm
Imports
9 packages
Last checked
1 week ago

Tools for package owners.