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 ¶
- Constants
- func EntDriverWithContext(d dialect.Driver, logger func(context.Context, zerolog.Level, string, error)) dialect.Driver
- func EntHook() ent.Hook
- func EntInterceptor() ent.Interceptor
- func Middleware(service string, opts ...Option) func(next http.Handler) http.Handler
- func StartSpanLogTrace(ctx context.Context, spanName string) (newCtx context.Context, span trace.Span, logger zerolog.Logger)
- func TraceContextHook(ctx context.Context) zerolog.Hook
- type EntDriver
- func (d *EntDriver) BeginTx(ctx context.Context, opts *sql.TxOptions) (dialect.Tx, error)
- func (d *EntDriver) Exec(ctx context.Context, query string, args, v any) error
- func (d *EntDriver) ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error)
- func (d *EntDriver) Query(ctx context.Context, query string, args, v any) error
- func (d *EntDriver) QueryContext(ctx context.Context, query string, args ...any) (*sql.Rows, error)
- func (d *EntDriver) Tx(ctx context.Context) (dialect.Tx, error)
- type Option
- type Tx
- func (d *Tx) Commit() error
- func (d *Tx) Exec(ctx context.Context, query string, args, v any) error
- func (d *Tx) ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error)
- func (d *Tx) Query(ctx context.Context, query string, args, v any) error
- func (d *Tx) QueryContext(ctx context.Context, query string, args ...any) (*sql.Rows, error)
- func (d *Tx) Rollback() error
- type ZeroWriter
Examples ¶
Constants ¶
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 ¶
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 ¶
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 ¶
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 ¶
BeginTx adds a log-id for the transaction and calls the underlying driver BeginTx command if it is supported.
func (*EntDriver) ExecContext ¶
ExecContext logs its params and calls the underlying driver ExecContext method if it is supported.
func (*EntDriver) QueryContext ¶
QueryContext logs its params and calls the underlying driver QueryContext method if it is supported.
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 ¶
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 ¶
Tx is a transaction implementation that logs all transaction operations.
func (*Tx) ExecContext ¶
ExecContext logs its params and calls the underlying transaction ExecContext method if it is supported.
func (*Tx) QueryContext ¶
QueryContext logs its params and calls the underlying transaction QueryContext method if it is supported.
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) WriteLevel ¶
WriteLevel decodes the JSON-encoded log record in p, and reports it as an error using w.Tracer.