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
- func AddEpicAttrs(span trace.Span, epicID string)
- func AddProjectAttrs(span trace.Span, projectID, path, name string)
- func ContextWithTraceID(ctx context.Context) context.Context
- func EpicAttrs(epicID string) []attribute.KeyValue
- func ErrorTypeFromError(err error) string
- func GetSpanID(ctx context.Context) string
- func GetTraceID(ctx context.Context) string
- func Init(ctx context.Context, cfg *Config) (shutdown func(context.Context) error, err error)
- func InitMetrics() error
- func MustInit(ctx context.Context, cfg *Config) func(context.Context) error
- func ProjectAttrs(id, path, name string) []attribute.KeyValue
- func RecordAgentDuration(ctx context.Context, agentType string, duration time.Duration)
- func RecordAgentError(ctx context.Context, agentType, errorType string)
- func RecordAgentPrompt(ctx context.Context, agentType string)
- func RecordAgentToolCall(ctx context.Context, agentType, toolName string)
- func RecordBlockerDetected(ctx context.Context, blockerType, projectID string)
- func RecordClaimLatency(ctx context.Context, projectID string, latency time.Duration)
- func RecordError(span trace.Span, err error, errorType, errorCategory string)
- func RecordErrorWithStatus(span trace.Span, err error, errorType, errorCategory string)
- func RecordFixTaskCreated(ctx context.Context, blockerType, projectID string)
- func RecordSyncCompleted(ctx context.Context, worktreeID, projectID string, duration time.Duration, ...)
- func RecordSyncFailed(ctx context.Context, worktreeID, projectID, errorType string, ...)
- func RecordTaskClaimed(ctx context.Context, workerID, projectID string)
- func RecordTaskCompleted(ctx context.Context, workerID, projectID, taskType string, ...)
- func RecordTaskFailed(ctx context.Context, workerID, projectID, taskType, errorType string, ...)
- func RecordTaskRetry(ctx context.Context, taskID string, attempt int)
- func RecordTestFailed(span trace.Span, passed, failed, skipped int, duration time.Duration, ...)
- func RecordTestPassed(span trace.Span, passed, failed, skipped int, duration time.Duration)
- func RecordWorktreeSetup(ctx context.Context, duration time.Duration)
- func SetBlockerInfo(span trace.Span, blockerType, blockerTaskID, reason string)
- func SetTaskStatus(span trace.Span, status string)
- func StartAgentSpan(ctx context.Context, agentType, model string, attrs ...attribute.KeyValue) (context.Context, trace.Span)
- func StartTaskSpan(ctx context.Context, name string, taskAttrs ...attribute.KeyValue) (context.Context, trace.Span)
- func StartWorkerSpan(ctx context.Context, name string, workerID string, attrs ...attribute.KeyValue) (context.Context, trace.Span)
- func StartWorkflowSpan(ctx context.Context, workflowType, workflowID string, ...) (context.Context, trace.Span)
- func StartWorktreeSpan(ctx context.Context, name, worktreePath string, attrs ...attribute.KeyValue) (context.Context, trace.Span)
- func TaskAttrs(id, title, state, taskType string, priority, attempt int) []attribute.KeyValue
- func TraceIDFromString(traceID string) string
- func WithEpicID(epicID string) trace.SpanStartEventOption
- func WithTaskID(taskID string) trace.SpanStartEventOption
- func WithWorkerID(workerID string) trace.SpanStartEventOption
- func WorkerAttrs(workerID string) []attribute.KeyValue
- type Config
Constants ¶
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
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
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" )
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 ¶
AddEpicAttrs adds epic attributes to a span
func AddProjectAttrs ¶
AddProjectAttrs adds project attributes to a span
func ContextWithTraceID ¶
ContextWithTraceID returns a context with trace information for logging
func ErrorTypeFromError ¶
ErrorTypeFromError extracts a human-readable error type
func GetTraceID ¶
GetTraceID returns the trace ID from context if available
func Init ¶
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 ¶
MustInit initializes telemetry or panics on error. Useful for main package initialization.
func ProjectAttrs ¶
ProjectAttrs returns a set of attributes for a project
func RecordAgentDuration ¶
RecordAgentDuration records the duration of agent execution
func RecordAgentError ¶
RecordAgentError records an agent error
func RecordAgentPrompt ¶
RecordAgentPrompt records an agent prompt
func RecordAgentToolCall ¶
RecordAgentToolCall records an agent tool call
func RecordBlockerDetected ¶
RecordBlockerDetected records that a blocker was detected
func RecordClaimLatency ¶
RecordClaimLatency records the time from task ready to being claimed
func RecordError ¶
RecordError records an error on a span with optional error type/category
func RecordErrorWithStatus ¶
RecordErrorWithStatus records an error and sets span status
func RecordFixTaskCreated ¶
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 ¶
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 ¶
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 ¶
RecordTestPassed records successful test execution on a span
func RecordWorktreeSetup ¶
RecordWorktreeSetup records the time to set up a worktree
func SetBlockerInfo ¶
SetBlockerInfo sets blocker-related attributes on a span
func SetTaskStatus ¶
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 TraceIDFromString ¶
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 ¶
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