tracer

package
v0.0.0-...-cfeb2ff Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2023 License: Apache-2.0 Imports: 24 Imported by: 6

Documentation

Overview

Package tracer is implements an adapter to talks low-level trace observability. # This manifest was generated by ymir. DO NOT EDIT.

Package tracer is implements an adapter to talks low-level trace observability. # This manifest was generated by ymir. DO NOT EDIT.

Package tracer is implements an adapter to talks low-level trace observability. # This manifest was generated by ymir. DO NOT EDIT.

Index

Examples

Constants

View Source
const (
	// SpanIDFieldName is the field name for the span ID.
	SpanIDFieldName = "span.id"

	// SpanContext is the field name for the span context.
	SpanContext = "span.context"

	// TraceIDFieldName is the field name for the trace ID.
	TraceIDFieldName = "trace.id"

	// CarrierID is the field name for the carrier propagator.
	CarrierID = "carrier.id"
)

Variables

This section is empty.

Functions

func EntDriverWithContext

func EntDriverWithContext(d dialect.Driver, logger func(context.Context, zerolog.Level, string, error)) dialect.Driver

EntDriverWithContext gets a driver and a logging function, and returns a new tracer-driver that prints all outgoing operations with context.

func EntHook

func EntHook() ent.Hook

EntHook defines the "mutation middleware". A function that gets a Mutator and returns a Mutator.

func EntInterceptor

func EntInterceptor() ent.Interceptor

EntInterceptor defines an execution middleware for various types of Ent queries.

func Middleware

func Middleware(service string, opts ...Option) func(next http.Handler) http.Handler

Middleware sets up a handler to start tracing the incoming requests. The service parameter should describe the name of the (virtual) server handling the request.

func StartSpanLogTrace

func StartSpanLogTrace(ctx context.Context, spanName string) (
	newCtx context.Context, span trace.Span, logger zerolog.Logger,
)

StartSpanLogTrace returns a copy of parent with span set as the current Span and logging.

func TraceContextHook

func TraceContextHook(ctx context.Context) zerolog.Hook

TraceContextHook returns a zerolog.Hook that will add any trace context contained in ctx to log events.

Example
handleRequest := func(w http.ResponseWriter, req *http.Request) {
	logger := zerolog.Ctx(req.Context()).Hook(TraceContextHook(req.Context()))
	logger.Error().Msg("message")
}
http.HandleFunc("/", handleRequest)
Output:

Types

type EntDriver

type EntDriver struct {
	dialect.Driver // underlying driver.
	// contains filtered or unexported fields
}

EntDriver is a driver that logs all driver operations.

func (*EntDriver) BeginTx

func (d *EntDriver) BeginTx(ctx context.Context, opts *sql.TxOptions) (dialect.Tx, error)

BeginTx adds a log-id for the transaction and calls the underlying driver BeginTx command if it is supported.

func (*EntDriver) Exec

func (d *EntDriver) Exec(ctx context.Context, query string, args, v any) error

Exec logs its params and calls the underlying driver Exec method.

func (*EntDriver) ExecContext

func (d *EntDriver) ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error)

ExecContext logs its params and calls the underlying driver ExecContext method if it is supported.

func (*EntDriver) Query

func (d *EntDriver) Query(ctx context.Context, query string, args, v any) error

Query logs its params and calls the underlying driver Query method.

func (*EntDriver) QueryContext

func (d *EntDriver) QueryContext(ctx context.Context, query string, args ...any) (*sql.Rows, error)

QueryContext logs its params and calls the underlying driver QueryContext method if it is supported.

func (*EntDriver) Tx

func (d *EntDriver) Tx(ctx context.Context) (dialect.Tx, error)

Tx adds a log-id for the transaction and calls the underlying driver Tx command.

type Option

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

Option specifies instrumentation configuration options.

func WithPropagators

func WithPropagators(propagators propagation.TextMapPropagator) Option

WithPropagators specifies propagators to use for extracting information from the HTTP requests. If none are specified, global ones will be used.

func WithSpanNameFormatter

func WithSpanNameFormatter(fn func(routeName string, r *http.Request) string) Option

WithSpanNameFormatter specifies a function to use for generating a custom span name. By default, the route name (path template or regexp) is used. The route name is provided, so you can use it in the span name without needing to duplicate the logic for extracting it from the request.

func WithTracerProvider

func WithTracerProvider(provider otelTrace.TracerProvider) Option

WithTracerProvider specifies a tracer provider to use for creating a tracer. If none is specified, the global provider is used.

type Tx

type Tx struct {
	dialect.Tx // underlying transaction.
	// contains filtered or unexported fields
}

Tx is a transaction implementation that logs all transaction operations.

func (*Tx) Commit

func (d *Tx) Commit() error

Commit logs this step and calls the underlying transaction Commit method.

func (*Tx) Exec

func (d *Tx) Exec(ctx context.Context, query string, args, v any) error

Exec logs its params and calls the underlying transaction Exec method.

func (*Tx) ExecContext

func (d *Tx) ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error)

ExecContext logs its params and calls the underlying transaction ExecContext method if it is supported.

func (*Tx) Query

func (d *Tx) Query(ctx context.Context, query string, args, v any) error

Query logs its params and calls the underlying transaction Query method.

func (*Tx) QueryContext

func (d *Tx) QueryContext(ctx context.Context, query string, args ...any) (*sql.Rows, error)

QueryContext logs its params and calls the underlying transaction QueryContext method if it is supported.

func (*Tx) Rollback

func (d *Tx) Rollback() error

Rollback logs this step and calls the underlying transaction Rollback method.

type ZeroWriter

type ZeroWriter struct {
	// MinLevel holds the minimum level of logs to send to
	//
	// MinLevel must be greater than or equal to zerolog.ErrorLevel.
	// If it is less than this, zerolog.ErrorLevel will be used as
	// the minimum instead.
	MinLevel zerolog.Level
}

func (*ZeroWriter) Write

func (*ZeroWriter) Write(p []byte) (int, error)

Write is a no-op.

func (*ZeroWriter) WriteLevel

func (w *ZeroWriter) WriteLevel(level zerolog.Level, p []byte) (int, error)

WriteLevel decodes the JSON-encoded log record in p, and reports it as an error using w.Tracer.

Jump to

Keyboard shortcuts

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