tracing

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// TracerName is the name of the tracer.
	TracerName = "code-search"
)

Variables

View Source
var (
	AttrRepoID       = attribute.Key("codesearch.repo.id")
	AttrRepoName     = attribute.Key("codesearch.repo.name")
	AttrConnectionID = attribute.Key("codesearch.connection.id")
	AttrHostType     = attribute.Key("codesearch.host.type")
	AttrJobID        = attribute.Key("codesearch.job.id")
	AttrJobType      = attribute.Key("codesearch.job.type")
	AttrSearchQuery  = attribute.Key("codesearch.search.query")
	AttrSearchType   = attribute.Key("codesearch.search.type")
	AttrResultCount  = attribute.Key("codesearch.search.result_count")
	AttrBranchCount  = attribute.Key("codesearch.branch.count")
	AttrBranches     = attribute.Key("codesearch.branches")
)

Common attribute keys for code search operations.

Functions

func AddEvent

func AddEvent(ctx context.Context, name string, attrs ...attribute.KeyValue)

AddEvent adds an event to the current span.

func HTTPMiddleware

func HTTPMiddleware(next http.Handler) http.Handler

HTTPMiddleware returns an HTTP middleware that adds tracing.

func RecordError

func RecordError(ctx context.Context, err error, attrs ...attribute.KeyValue)

RecordError records an error on the current span.

func SetAttributes

func SetAttributes(ctx context.Context, attrs ...attribute.KeyValue)

SetAttributes sets attributes on the current span.

func SetOK

func SetOK(ctx context.Context)

SetOK sets the span status to OK.

func SpanFromContext

func SpanFromContext(ctx context.Context) trace.Span

SpanFromContext returns the current span from context.

func StartSpan

func StartSpan(
	ctx context.Context,
	name string,
	opts ...trace.SpanStartOption,
) (context.Context, trace.Span)

StartSpan starts a new span with the given name.

func Tracer

func Tracer() trace.Tracer

Tracer returns the global tracer.

Types

type Config

type Config struct {
	// Enabled enables tracing.
	Enabled bool

	// ServiceName is the name of the service.
	ServiceName string

	// ServiceVersion is the version of the service.
	ServiceVersion string

	// Environment is the deployment environment (e.g., production, staging).
	Environment string

	// Endpoint is the OTLP endpoint (e.g., localhost:4317 for gRPC, localhost:4318 for HTTP).
	Endpoint string

	// Protocol is the OTLP protocol: "grpc" or "http".
	Protocol string

	// SampleRate is the sampling rate (0.0 to 1.0).
	SampleRate float64

	// Insecure disables TLS for the connection.
	Insecure bool

	// Headers are custom headers to send with requests (useful for Datadog API key).
	Headers map[string]string
}

Config holds tracing configuration.

func ConfigFromEnv

func ConfigFromEnv() *Config

ConfigFromEnv creates a config from environment variables. This supports standard OpenTelemetry env vars and Datadog-specific ones.

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns the default tracing configuration.

type Provider

type Provider struct {
	// contains filtered or unexported fields
}

Provider wraps the trace provider and shutdown function.

func InitTracing

func InitTracing(ctx context.Context, cfg *Config, logger *zap.Logger) (*Provider, error)

InitTracing initializes OpenTelemetry tracing.

func (*Provider) Shutdown

func (p *Provider) Shutdown(ctx context.Context) error

Shutdown gracefully shuts down the trace provider.

Jump to

Keyboard shortcuts

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