Documentation ¶
Overview ¶
Package kafka contains the OpenCensus exporters for Tracing.
This exporter can be used to send traces to kafka brokers.
Most of the codes base on https://github.com/census-ecosystem/opencensus-go-exporter-stackdriver.git
Example (Defaults) ¶
exporter, err := kafka.NewExporter( kafka.Options{ Brokers: []string{"127.0.0.1:9092"}, Topic: "oc-kafka", }) if err != nil { log.Fatal(err) } // Export to Kafka Trace. trace.RegisterExporter(exporter) // Use default B3 format header to outgoing requests: client := &http.Client{ Transport: &ochttp.Transport{}, } _ = client // use client // All outgoing requests from client will include a B3(default) Trace header. // See the ochttp package for how to handle incoming requests.
Output:
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Exporter ¶
type Exporter struct {
// contains filtered or unexported fields
}
Exporter is a trace.Exporter implementation that uploads data to Kafka.
func NewExporter ¶
NewExporter creates a new Exporter that implements trace.Exporter.
func (*Exporter) ExportSpan ¶
ExportSpan exports a SpanData to Kafka.
type Options ¶
type Options struct { // Brokers is the addresses of the kafka brokers // Required Brokers []string // Topic is the topic of kafka to send spans to // Required Topic string // OnError is the hook to be called when there is // an error uploading the tracing data. // If no custom hook is set, errors are logged. // Optional. OnError func(err error) // BundleDelayThreshold determines the max amount of time // the exporter can wait before uploading view data to // the backend. // Optional. BundleDelayThreshold time.Duration // BundleCountThreshold determines how many view data events // can be buffered before batch uploading them to the backend. // Optional. BundleCountThreshold int // DefaultTraceAttributes will be appended to every span that is exported to // Kafka Trace. DefaultTraceAttributes map[string]interface{} // Context allows users to provide a custom context for API calls. // // This context will be used several times: first, to create Kafka // trace and metric clients, and then every time a new batch of traces or // stats needs to be uploaded. // // If unset, context.Background() will be used. Context context.Context // contains filtered or unexported fields }
Options contains options for configuring the exporter.
Click to show internal directories.
Click to hide internal directories.