Documentation
¶
Index ¶
- Constants
- Variables
- func AddEvent(ctx context.Context, name string, attrs ...attribute.KeyValue)
- func HTTPMiddleware(next http.Handler) http.Handler
- func RecordError(ctx context.Context, err error, attrs ...attribute.KeyValue)
- func SetAttributes(ctx context.Context, attrs ...attribute.KeyValue)
- func SetOK(ctx context.Context)
- func SpanFromContext(ctx context.Context) trace.Span
- func StartSpan(ctx context.Context, name string, opts ...trace.SpanStartOption) (context.Context, trace.Span)
- func Tracer() trace.Tracer
- type Config
- type Provider
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 HTTPMiddleware ¶
HTTPMiddleware returns an HTTP middleware that adds tracing.
func RecordError ¶
RecordError records an error on the current span.
func SetAttributes ¶
SetAttributes sets attributes on the current span.
func SpanFromContext ¶
SpanFromContext returns the current span from context.
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 ¶
InitTracing initializes OpenTelemetry tracing.
Click to show internal directories.
Click to hide internal directories.