Documentation
¶
Overview ¶
Package tracing provides functions for starting and stopping our Open Telemetry tracing. This package is intended to be used from main and is simple to use. We offer a few choices on where traces export to. Here is an example to trace to stderr for all requests:
func main() {
ctx := context.Background()
// Set us up to always sample. The "trace" package is: "petstore/server/SearchPets/latency"
tracing.Sampler.Switch(trace.AlwaysSample())
// Start our tracing and pass the empty Stderr tracing arguments.
// Stderr{} has no required fields.
stop, err := tracing.Start(ctx, tracing.Stderr{})
if err != nil {
log.Fatalf("problem starting telemetry: %s", err)
}
// Stop kills our exporter when main() ends.
defer stop()
}
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // Tracer is the tracer initialized by Start(). Tracer trace.Tracer // *sdktrace.TracerProvider //otlptrace.Exporter // Sampler is our *sampler.Sampler used by the Tracer. Sampler *sampler.Sampler )
Tracer is the tracer initialized by Start().
Functions ¶
This section is empty.
Types ¶
type Exporter ¶
type Exporter interface {
// contains filtered or unexported methods
}
Exporter represents the exporter to send telemetry to.
type File ¶
type File struct {
// Path is the path to the file.
Path string
}
File exports trace data to a file. If the file exists, it is overwritten.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package sampler offers a Sampler that looks for a TraceID.Valid() == true or a gRPC metadata key called "trace" and if they exist will sample.
|
Package sampler offers a Sampler that looks for a TraceID.Valid() == true or a gRPC metadata key called "trace" and if they exist will sample. |
Click to show internal directories.
Click to hide internal directories.