Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Logger ¶ added in v0.0.2
type Logger interface { Info(args ...interface{}) Error(args ...interface{}) }
Logger represents the internal library logger used for error and info messages
type Option ¶ added in v0.0.2
type Option interface {
// contains filtered or unexported methods
}
func WithConfig ¶ added in v0.0.2
func WithConfig(cfg *config.OpenTelemetry) Option
WithConfig sets the configuration options for the trace provider
Example
config := &config.OpenTelemetry{ Enabled: true, Exporter: "grpc", Endpoint: "localhost:4317", } provider, err := trace.NewProvider(trace.WithConfig(config)) if err != nil { panic(err) }
func WithContext ¶ added in v0.0.2
WithContext sets the context for the trace provider
Example
ctx := context.Background() provider, err := trace.NewProvider(trace.WithContext(ctx)) if err != nil { panic(err) }
func WithLogger ¶ added in v0.0.2
WithLogger sets the logger for the trace provider This is used to log errors and info messages for underlying operations
Example
logger := logrus.New().WithField("component", "trace") provider, err := trace.NewProvider(trace.WithLogger(logger)) if err != nil { panic(err) }
type Provider ¶
type Provider interface { // Shutdown execute the underlying exporter shutdown function Shutdown(context.Context) error // Tracer returns a tracer with pre-configured name. It's used to create spans. Tracer() Tracer }
Provider is the interface that wraps the basic methods of a trace provider. If missconfigured or disabled, the provider will return a noop tracer
func NewProvider ¶
NewProvider creates a new trace provider with the given options The trace provider is responsible for creating spans and sending them to the exporter Example provider, err := trace.NewProvider( trace.WithContext(context.Background()), trace.WithConfig(&config.OpenTelemetry{ Enabled: true, Exporter: "grpc", Endpoint: "localhost:4317", }), trace.WithLogger(logrus.New().WithField("component", "tyk")), ) if err != nil { panic(err) }
Click to show internal directories.
Click to hide internal directories.