ocagent

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2018 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Example
exp, err := ocagent.NewExporter(ocagent.WithInsecure(), ocagent.WithServiceName("engine"))
if err != nil {
	log.Fatalf("Failed to create the agent exporter: %v", err)
}
defer exp.Stop()

// Now register it as a trace exporter.
trace.RegisterExporter(exp)

// Then use the OpenCensus tracing library, like we normally would.
ctx, span := trace.StartSpan(context.Background(), "AgentExporter-Example")
defer span.End()

for i := 0; i < 10; i++ {
	_, iSpan := trace.StartSpan(ctx, fmt.Sprintf("Sample-%d", i))
	<-time.After(6 * time.Millisecond)
	iSpan.End()
}
Output:

Index

Examples

Constants

View Source
const (
	DefaultAgentPort uint16 = 55678
	DefaultAgentHost string = "localhost"
)
View Source
const Version = "0.0.1"

Variables

This section is empty.

Functions

This section is empty.

Types

type Exporter

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

func NewExporter

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

func NewUnstartedExporter

func NewUnstartedExporter(opts ...ExporterOption) (*Exporter, error)

func (*Exporter) ExportSpan

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

func (*Exporter) Flush

func (ae *Exporter) Flush()

func (*Exporter) Start

func (ae *Exporter) Start() error

Start dials to the agent, establishing a connection to it. It also initiates the Config and Trace services by sending over the initial messages that consist of the node identifier. Start performs a best case attempt to try to send the initial messages, by applying exponential backoff at most 10 times.

func (*Exporter) Stop

func (ae *Exporter) Stop() error

Stop shuts down all the connections and resources related to the exporter.

type ExporterOption

type ExporterOption interface {
	// contains filtered or unexported methods
}

func WithAddress

func WithAddress(addr string) ExporterOption

WithAddress allows one to set the address that the exporter will connect to the agent on. If unset, it will instead try to use connect to DefaultAgentHost:DefaultAgentPort

func WithInsecure

func WithInsecure() ExporterOption

WithInsecure disables client transport security for the exporter's gRPC connection just like grpc.WithInsecure() https://godoc.org/google.golang.org/grpc#WithInsecure does. Note, by default, client security is required unless WithInsecure is used.

func WithPort

func WithPort(port uint16) ExporterOption

WithPort allows one to override the port that the exporter will connect to the agent on, instead of using DefaultAgentPort.

func WithServiceName

func WithServiceName(serviceName string) ExporterOption

WithServiceName allows one to set/override the service name that the exporter will report to the agent.

Jump to

Keyboard shortcuts

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