telemetry

package
v0.3.0-alpha.1 Latest Latest
Warning

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

Go to latest
Published: May 16, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package telemetry provides OpenTelemetry observability for Drover

Package telemetry provides OpenTelemetry observability for Drover

Package telemetry provides OpenTelemetry observability for Drover

Package telemetry provides OpenTelemetry observability for Drover

Index

Constants

View Source
const (
	// Project attributes
	KeyProjectID   = "drover.project.id"
	KeyProjectPath = "drover.project.path"
	KeyProjectName = "drover.project.name"

	// Workflow attributes
	KeyWorkflowID   = "drover.workflow.id"
	KeyWorkflowType = "drover.workflow.type"

	// Task attributes
	KeyTaskID       = "drover.task.id"
	KeyTaskTitle    = "drover.task.title"
	KeyTaskState    = "drover.task.state"
	KeyTaskType     = "drover.task.type"
	KeyTaskPriority = "drover.task.priority"
	KeyTaskAttempt  = "drover.task.attempt"
	KeyEpicID       = "drover.epic.id"

	// Worker attributes
	KeyWorkerID    = "drover.worker.id"
	KeyWorkerCount = "drover.worker.count"

	// Worktree attributes
	KeyWorktreePath = "drover.worktree.path"
	KeyWorktreeID   = "drover.worktree.id"

	// Agent attributes
	KeyAgentType     = "drover.agent.type"
	KeyAgentModel    = "drover.agent.model"
	KeyAgentPromptID = "drover.agent.prompt.id"

	// Blocker attributes
	KeyBlockerType   = "drover.blocker.type"
	KeyBlockerTaskID = "drover.blocker.task_id"
	KeyBlockerReason = "drover.blocker.reason"

	// Error attributes
	KeyErrorType     = "drover.error.type"
	KeyErrorCategory = "drover.error.category"
)

Semantic convention keys for Drover-specific attributes

View Source
const (
	// Workflow types
	WorkflowTypeSequential = "sequential"
	WorkflowTypeParallel   = "parallel"

	// Agent types
	AgentTypeClaudeCode = "claude-code"
	AgentTypeClaudeAPI  = "claude-api"
	AgentTypeCodex      = "codex"
	AgentTypeAmp        = "amp"
	AgentTypeOpenCode   = "opencode"

	// Error categories
	ErrorCategoryAgent    = "agent"
	ErrorCategoryGit      = "git"
	ErrorCategoryWorktree = "worktree"
	ErrorCategoryDatabase = "database"
	ErrorCategoryTimeout  = "timeout"
	ErrorCategoryUnknown  = "unknown"
)

Common attribute key values

View Source
const (
	// DefaultServiceName is the default service name for telemetry
	DefaultServiceName = "drover"

	// DefaultServiceVersion is populated at build time
	DefaultServiceVersion = "dev"

	// DefaultOTLPEndpoint is the default OTLP collector endpoint
	DefaultOTLPEndpoint = "localhost:4317"

	// EnvOTLPEndpoint is the environment variable for custom OTLP endpoint
	EnvOTLPEndpoint = "DROVER_OTEL_ENDPOINT"

	// EnvOTelEnabled is the environment variable to enable/disable telemetry
	EnvOTelEnabled = "DROVER_OTEL_ENABLED"
)
View Source
const (
	// Workflow spans
	SpanWorkflowRun        = "drover.workflow.run"
	SpanWorkflowSequential = "drover.workflow.sequential"
	SpanWorkflowParallel   = "drover.workflow.parallel"

	// Task spans
	SpanTaskClaim    = "drover.task.claim"
	SpanTaskExecute  = "drover.task.execute"
	SpanTaskComplete = "drover.task.complete"
	SpanTaskFail     = "drover.task.fail"
	SpanTaskRetry    = "drover.task.retry"

	// Worker spans
	SpanWorkerRun  = "drover.worker.run"
	SpanWorkerPoll = "drover.worker.poll"
	SpanWorkerLoop = "drover.worker.loop"

	// Worktree spans
	SpanWorktreeCreate  = "drover.worktree.create"
	SpanWorktreeSetup   = "drover.worktree.setup"
	SpanWorktreeCleanup = "drover.worktree.cleanup"

	// Agent spans
	SpanAgentExecute  = "drover.agent.execute"
	SpanAgentPrompt   = "drover.agent.prompt"
	SpanAgentToolCall = "drover.agent.tool_call"

	// Blocker spans
	SpanBlockerDetect    = "drover.blocker.detect"
	SpanBlockerAnalyze   = "drover.blocker.analyze"
	SpanBlockerCreateFix = "drover.blocker.create_fix_task"

	// Git spans
	SpanGitCommit = "drover.git.commit"
	SpanGitPush   = "drover.git.push"
	SpanGitMerge  = "drover.git.merge"
)

Span names for Drover operations

Variables

This section is empty.

Functions

func AddEpicAttrs

func AddEpicAttrs(span trace.Span, epicID string)

AddEpicAttrs adds epic attributes to a span

func AddProjectAttrs

func AddProjectAttrs(span trace.Span, projectID, path, name string)

AddProjectAttrs adds project attributes to a span

func ContextWithTraceID

func ContextWithTraceID(ctx context.Context) context.Context

ContextWithTraceID returns a context with trace information for logging

func EpicAttrs

func EpicAttrs(epicID string) []attribute.KeyValue

EpicAttrs returns a set of attributes for an epic

func ErrorTypeFromError

func ErrorTypeFromError(err error) string

ErrorTypeFromError extracts a human-readable error type

func GetSpanID

func GetSpanID(ctx context.Context) string

GetSpanID returns the span ID from context if available

func GetTraceID

func GetTraceID(ctx context.Context) string

GetTraceID returns the trace ID from context if available

func Init

func Init(ctx context.Context, cfg *Config) (shutdown func(context.Context) error, err error)

Init initializes OpenTelemetry with the given configuration. Returns a shutdown function that should be called when the application exits.

func InitMetrics

func InitMetrics() error

InitMetrics initializes metrics. Called automatically by Init(). Exported for explicit initialization if needed.

func MustInit

func MustInit(ctx context.Context, cfg *Config) func(context.Context) error

MustInit initializes telemetry or panics on error. Useful for main package initialization.

func ProjectAttrs

func ProjectAttrs(id, path, name string) []attribute.KeyValue

ProjectAttrs returns a set of attributes for a project

func RecordAgentDuration

func RecordAgentDuration(ctx context.Context, agentType string, duration time.Duration)

RecordAgentDuration records the duration of agent execution

func RecordAgentError

func RecordAgentError(ctx context.Context, agentType, errorType string)

RecordAgentError records an agent error

func RecordAgentPrompt

func RecordAgentPrompt(ctx context.Context, agentType string)

RecordAgentPrompt records an agent prompt

func RecordAgentToolCall

func RecordAgentToolCall(ctx context.Context, agentType, toolName string)

RecordAgentToolCall records an agent tool call

func RecordBlockerDetected

func RecordBlockerDetected(ctx context.Context, blockerType, projectID string)

RecordBlockerDetected records that a blocker was detected

func RecordClaimLatency

func RecordClaimLatency(ctx context.Context, projectID string, latency time.Duration)

RecordClaimLatency records the time from task ready to being claimed

func RecordError

func RecordError(span trace.Span, err error, errorType, errorCategory string)

RecordError records an error on a span with optional error type/category

func RecordErrorWithStatus

func RecordErrorWithStatus(span trace.Span, err error, errorType, errorCategory string)

RecordErrorWithStatus records an error and sets span status

func RecordFixTaskCreated

func RecordFixTaskCreated(ctx context.Context, blockerType, projectID string)

RecordFixTaskCreated records that a fix task was created for a blocker

func RecordSyncCompleted

func RecordSyncCompleted(ctx context.Context, worktreeID, projectID string, duration time.Duration, bytes int64)

RecordSyncCompleted records a successful worktree sync operation

func RecordSyncFailed

func RecordSyncFailed(ctx context.Context, worktreeID, projectID, errorType string, duration time.Duration)

RecordSyncFailed records a failed worktree sync operation

func RecordTaskClaimed

func RecordTaskClaimed(ctx context.Context, workerID, projectID string)

RecordTaskClaimed records that a task was claimed

func RecordTaskCompleted

func RecordTaskCompleted(ctx context.Context, workerID, projectID, taskType string, duration time.Duration)

RecordTaskCompleted records that a task completed successfully

func RecordTaskFailed

func RecordTaskFailed(ctx context.Context, workerID, projectID, taskType, errorType string, duration time.Duration)

RecordTaskFailed records that a task failed

func RecordTaskRetry

func RecordTaskRetry(ctx context.Context, taskID string, attempt int)

RecordTaskRetry records a task retry attempt

func RecordTestFailed

func RecordTestFailed(span trace.Span, passed, failed, skipped int, duration time.Duration, errorMsg string)

RecordTestFailed records failed test execution on a span

func RecordTestPassed

func RecordTestPassed(span trace.Span, passed, failed, skipped int, duration time.Duration)

RecordTestPassed records successful test execution on a span

func RecordWorktreeSetup

func RecordWorktreeSetup(ctx context.Context, duration time.Duration)

RecordWorktreeSetup records the time to set up a worktree

func SetBlockerInfo

func SetBlockerInfo(span trace.Span, blockerType, blockerTaskID, reason string)

SetBlockerInfo sets blocker-related attributes on a span

func SetTaskStatus

func SetTaskStatus(span trace.Span, status string)

SetTaskStatus sets the task status as a span attribute

func StartAgentSpan

func StartAgentSpan(ctx context.Context, agentType, model string, attrs ...attribute.KeyValue) (context.Context, trace.Span)

StartAgentSpan starts a span for agent execution

func StartTaskSpan

func StartTaskSpan(ctx context.Context, name string, taskAttrs ...attribute.KeyValue) (context.Context, trace.Span)

StartTaskSpan starts a span for a task operation with task attributes

func StartWorkerSpan

func StartWorkerSpan(ctx context.Context, name string, workerID string, attrs ...attribute.KeyValue) (context.Context, trace.Span)

StartWorkerSpan starts a span for a worker operation

func StartWorkflowSpan

func StartWorkflowSpan(ctx context.Context, workflowType, workflowID string, attrs ...attribute.KeyValue) (context.Context, trace.Span)

StartWorkflowSpan starts a span for workflow execution

func StartWorktreeSpan

func StartWorktreeSpan(ctx context.Context, name, worktreePath string, attrs ...attribute.KeyValue) (context.Context, trace.Span)

StartWorktreeSpan starts a span for worktree operations

func TaskAttrs

func TaskAttrs(id, title, state, taskType string, priority, attempt int) []attribute.KeyValue

TaskAttrs returns a set of attributes for a task

func TraceIDFromString

func TraceIDFromString(traceID string) string

TraceIDFromString extracts trace ID from a string for logging/correlation

func WithEpicID

func WithEpicID(epicID string) trace.SpanStartEventOption

WithEpicID creates an option to add epic ID to span attributes

func WithTaskID

func WithTaskID(taskID string) trace.SpanStartEventOption

WithTaskID creates an option to add task ID to span attributes

func WithWorkerID

func WithWorkerID(workerID string) trace.SpanStartEventOption

WithWorkerID creates an option to add worker ID to span attributes

func WorkerAttrs

func WorkerAttrs(workerID string) []attribute.KeyValue

WorkerAttrs returns a set of attributes for a worker

Types

type Config

type Config struct {
	// ServiceName is the name of the service
	ServiceName string

	// ServiceVersion is the version of the service
	ServiceVersion string

	// Environment is the deployment environment
	Environment string

	// OTLPEndpoint is the OTLP collector endpoint (host:port)
	OTLPEndpoint string

	// Enabled determines if telemetry is active
	Enabled bool

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

Config holds telemetry configuration

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns a config with sensible defaults

Jump to

Keyboard shortcuts

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