tracer

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	Shutdown()
}

Client is the interface for our tracer. It contains the underlying tracer provider and a Shutdown method to perform a clean shutdown.

func New

func New(config Config) (Client, error)

New is used to create a new tracer. For that we are creating a new TracerProvider and register it as the global so any imported instrumentation will default to using it. If tracing is disabled the setup function returns a client without a TracerProvider.

During the shutdown process of echoserver the "Shutdown" method of the returned client must be called.

To test the tracer we can start a local Jaeger instance with the following commands (the UI will be available at localhost:16686):

docker run --rm --name jaeger -d -p 16686:16686 -p 4317:4317 jaegertracing/all-in-one:1.54
docker stop jaeger

type Config

type Config struct {
	Enabled bool   `env:"ENABLED" enum:"true,false" default:"false" help:"Enable tracing."`
	Service string `env:"SERVICE" default:"echoserver" help:"The name of the service which should be used for tracing."`
	Address string `env:"ADDRESS" default:"localhost:4317" help:"The address of the tracing provider instance."`
}

Config is the configuration for our tracer. Via the configuration we can enable / disable the tracing. If the tracing is enabled we need the service name and address.

Jump to

Keyboard shortcuts

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