Movatterモバイル変換


[0]ホーム

URL:


tracing

package
v2.23.0Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2025 License:AGPL-3.0Imports:35Imported by:0

Details

Repository

github.com/coder/coder

Links

Documentation

Index

Constants

View Source
const TracerName = "coderd"

Variables

Functions

funcDefaultExporter

func DefaultExporter(ctxcontext.Context) (*otlptrace.Exporter,error)

funcEndHTTPSpan

func EndHTTPSpan(r *http.Request, statusint, spantrace.Span)

EndHTTPSpan captures request and response data after the handler is done.

funcFuncName

func FuncName()string

funcFuncNameSkip

func FuncNameSkip(skipint)string

funcGetTracerName

func GetTracerName(ctxcontext.Context)string

GetTracerName returns the tracer name from the context, or TracerName if noneis set.

funcHoneycombExporter

func HoneycombExporter(ctxcontext.Context, apiKeystring) (*otlptrace.Exporter,error)

funcMetadataFromContext

func MetadataFromContext(ctxcontext.Context) map[string]string

funcMetadataToContext

func MetadataToContext(ctxcontext.Context, metadata map[string]string)context.Context

funcMiddleware

func Middleware(tracerProvidertrace.TracerProvider) func(http.Handler)http.Handler

Middleware adds tracing to http routes.

funcPostgresDriver

func PostgresDriver(tptrace.TracerProvider, servicestring) (string,error)

Postgres driver will register a new tracing sql driver and return the driver name.

funcRunWithoutSpan

func RunWithoutSpan(ctxcontext.Context, fn func(ctxcontext.Context))

RunWithoutSpan runs the given function with the span stripped from thecontext and replaced with a no-op span. This is useful for avoiding logsbeing added to span (to save money).

funcSetTracerName

func SetTracerName(ctxcontext.Context, tracerNamestring)context.Context

SetTracerName sets the tracer name that will be used by all spans createdfrom the context.

funcStartSpan

StartSpan calls StartSpanWithName with the name set to the caller's functionname.

funcStartSpanWithName

func StartSpanWithName(ctxcontext.Context, namestring, opts ...trace.SpanStartOption) (context.Context,trace.Span)

StartSpanWithName starts a new span with the given name from the context. Ifa tracer name was set on the context (or one of its parents), it will be usedas the tracer name instead of the default TracerName.

funcStatusWriterMiddleware

func StatusWriterMiddleware(nexthttp.Handler)http.Handler

funcTracerProvider

func TracerProvider(ctxcontext.Context, servicestring, optsTracerOpts) (*sdktrace.TracerProvider, func(context.Context)error,error)

TracerProvider creates a grpc otlp exporter and configures a trace provider.Caller is responsible for calling TracerProvider.Shutdown to ensure all data is flushed.

Types

typeDRPCConn

type DRPCConn struct {drpc.Conn}

func (*DRPCConn)Invoke

func (c *DRPCConn) Invoke(ctxcontext.Context, rpcstring, encdrpc.Encoding, indrpc.Message, outdrpc.Message) (errerror)

Invoke implements drpc.Conn's Invoke method with tracing information injected into the context.

func (*DRPCConn)NewStream

func (c *DRPCConn) NewStream(ctxcontext.Context, rpcstring, encdrpc.Encoding) (_drpc.Stream, errerror)

NewStream implements drpc.Conn's NewStream method with tracing information injected into the context.

typeDRPCHandler

type DRPCHandler struct {Handlerdrpc.Handler}

func (*DRPCHandler)HandleRPC

func (t *DRPCHandler) HandleRPC(streamdrpc.Stream, rpcstring)error

typeSlogSink

type SlogSink struct{}

func (SlogSink)LogEntry

func (SlogSink) LogEntry(ctxcontext.Context, eslog.SinkEntry)

LogEntry implements slog.Sink. All entries are added as events to the spanin the context. If no span is present, the entry is dropped.

func (SlogSink)Sync

func (SlogSink) Sync()

Sync implements slog.Sink. No-op as syncing is handled externally by otel.

typeStatusWriter

type StatusWriter struct {http.ResponseWriterStatusintHijackedbool// contains filtered or unexported fields}

StatusWriter intercepts the status of the request and the response body upto maxBodySize if Status >= 400. It is guaranteed to be the ResponseWriterdirectly downstream from Middleware.

func (*StatusWriter)Flush

func (w *StatusWriter) Flush()

func (*StatusWriter)Hijack

func (w *StatusWriter) Hijack() (net.Conn, *bufio.ReadWriter,error)

func (*StatusWriter)ResponseBody

func (w *StatusWriter) ResponseBody() []byte

func (*StatusWriter)Write

func (w *StatusWriter) Write(b []byte) (int,error)

func (*StatusWriter)WriteHeader

func (w *StatusWriter) WriteHeader(statusint)

typeTracerOpts

type TracerOpts struct {// Default exports to a backend configured by environment variables. See://https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/exporter.mdDefaultbool// DataDog exports traces and profiles to the local DataDog daemon.DataDogbool// Exports traces to Honeycomb.io with the provided API key.Honeycombstring}

TracerOpts specifies which telemetry exporters should be configured.

Source Files

View all Source files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f orF : Jump to
y orY : Canonical URL
go.dev uses cookies from Google to deliver and enhance the quality of its services and to analyze traffic.Learn more.

[8]ページ先頭

©2009-2025 Movatter.jp