Back to Gitlabhq

GitLab Duo Agent Platform observability (Rails)

doc/development/ai_features/duo_agent_platform_observability.md

19.2.011.2 KB
Original Source

The GitLab Duo Agent Platform (formerly GitLab Duo Workflow Service) uses the following monitoring and observability instrumentation in the GitLab Rails monolith. Workhorse-side instrumentation is not covered.

Prometheus metrics

Existing metrics

All three metrics live in ProcessAuditEventsWorker (ee/app/workers/ai/duo_workflows/process_audit_events_worker.rb) and track AI audit event persistence only.

Metric nameTypeLabelsWhat it tracks
gitlab_ai_audit_events_buffered_totalCounternoneAI audit events enqueued to the ClickHouse Redis write buffer
gitlab_ai_audit_events_pg_fallback_totalCounternoneAI audit events stored by PostgreSQL when ClickHouse is unavailable
gitlab_ai_audit_events_stored_totalCounterstore: :postgresqlAI audit events durably written to PostgreSQL

Missing metrics (gaps to address)

The following are important signals that have no Prometheus coverage. Internal events exist for some of them, but those feed analytics pipelines, not alerting or dashboards.

SignalSuggested metric nameTypeSuggested labels
Session lifecycle transitions (created, started, finished, stopped, dropped, resumed)gitlab_duo_agent_platform_sessions_totalCounterstatus
Stuck sessions cleaned up by crongitlab_duo_agent_platform_stuck_sessions_totalCounternone
Workflow execution start, finish, retrygitlab_duo_agent_platform_workflow_executions_totalCounterevent (start, finish, retry)
CI workload pipeline completiongitlab_duo_agent_platform_workload_pipelines_totalCounterstatus, workflow_definition
CI workload pipeline durationgitlab_duo_agent_platform_workload_pipeline_duration_secondsHistogramstatus, workflow_definition
Model Context Protocol (MCP) tool call start and finishgitlab_duo_agent_platform_mcp_tool_calls_totalCountertool_name, success
MCP tool call durationgitlab_duo_agent_platform_mcp_tool_call_duration_secondsHistogramtool_name
gRPC calls to GitLab Duo Workflow Service (latency and errors)gitlab_duo_workflow_service_grpc_requests_total and gitlab_duo_workflow_service_grpc_request_duration_secondsCounter and Histogrammethod, status
POST /ai/duo_workflows/direct_access rate limit hitsgitlab_duo_agent_platform_rate_limit_hits_totalCounterendpoint
Vulnerability workflow triggersgitlab_duo_agent_platform_vulnerability_workflow_triggers_totalCounterworkflow_definition
GraphQL duoWorkflowWorkflows query calls (executor polling)gitlab_duo_agent_platform_graphql_workflow_queries_totalCounterstatus (success, error)
GraphQL toolCallApproved field resolutionsgitlab_duo_agent_platform_tool_call_approved_checks_totalCounterapproved (true/false)
GraphQL WorkflowEventsUpdated subscription connectionsgitlab_duo_agent_platform_graphql_subscriptions_totalCounterevent (subscribe, unsubscribe)
GraphQL mutations (create, deleteWorkflow, updateAgentPrivileges, updateToolCallApprovals)gitlab_duo_agent_platform_graphql_mutations_totalCountermutation, status

Internal events (GitLab Analytics / Snowplow)

These feed product analytics and are not suitable for alerting or service-level objectives (SLOs). All event definitions live under ee/config/events/.

Session lifecycle

All carry label (flow type, for example chat), property (environment, for example web), and value (session ID). Identifiers: user, project, namespace.

EventTrigger locationWhat it tracks
agent_platform_session_createdWorkflowEventTracking concernSession record created
agent_platform_session_startedWorkflowEventTracking concernSession started by executor
agent_platform_session_finishedWorkflowEventTracking concernSession finished cleanly
agent_platform_session_stoppedWorkflowEventTracking concernSession stopped by user
agent_platform_session_droppedWorkflowEventTracking concernSession dropped on error
agent_platform_session_resumedWorkflowEventTracking concernSession resumed after pause
cleanup_stuck_agent_platform_sessionCleanStuckWorkflowsServiceStuck session cleaned up by cron. property = new status

Workflow execution

Carry label (workflow type), property (request ID), workflow_id. Identifier: user.

EventTrigger locationWhat it tracks
start_duo_workflow_executionWorkflowEventTracking concernWorkflow execution started
finish_duo_workflow_executionWorkflowEventTracking concernWorkflow execution finished
retry_duo_workflow_executionWorkflowEventTracking concernWorkflow retried

CI workload completion

Fired in WorkloadMetrics concern (ee/app/services/ai/duo_workflows/concerns/workload_metrics.rb), triggered by UpdateWorkflowStatusEventWorker. Also has an extra tracker (Gitlab::Tracking::AiTracking).

EventAdditional propertiesWhat it tracks
duo_workflow_workload_completedlabel = pipeline status, property = build failure reason, value = pipeline duration in seconds, workflow_id, workflow_definitionCI pipeline for a workload completed (success or failure)

MCP tool calls

Carry tool_name, session_id, duo_add_on. Identifiers: user, namespace. Also have an extra tracker (Gitlab::Tracking::AiTracking).

EventAdditional propertiesWhat it tracks
start_mcp_tool_callnoneMCP tool call started
finish_mcp_tool_callhas_tool_call_success, failure_reason, error_statusMCP tool call finished

Vulnerability workflow triggers

Fired in Workflows#track_event (ee/lib/api/ai/duo_workflows/workflows.rb) only when the workflow definition matches a known vulnerability workflow.

EventWorkflow definitionWhat it tracks
trigger_sast_vulnerability_fp_detection_workflowStatic Application Security Testing (SAST) FP detectionSAST false-positive detection workflow triggered
trigger_sast_vulnerability_resolution_workflowSAST resolutionSAST resolution workflow triggered
trigger_secret_detection_vulnerability_fp_detection_workflowSecret detection FPSecret detection false-positive workflow triggered

GraphQL API

The duoWorkflowWorkflows field is exposed on both the root query type and ProjectType. The duoWorkflowWorkflows field is the primary interface used by the GitLab Duo Workflow Service executor to poll session state on every execution cycle.

The GraphQL layer has no observability instrumentation. No Prometheus metrics, internal events, error tracking, or structured logging exist in any resolver, type, mutation, or subscription for this surface.

Queries

FieldWhere exposedWhat it returns
duoWorkflowWorkflowsRoot query and ProjectTypeSession list filtered by workflowId, projectPath, type, environment, statusGroup, and others

Key fields fetched by the executor on each poll cycle: statusName, projectId, project (languages, URLs, context exclusion settings), namespaceId, namespace (AI settings including promptInjectionProtectionLevel), agentPrivilegesNames, preApprovedAgentPrivilegesNames, mcpEnabled, allowAgentToRequestUser, latestCheckpoint (with compressedCheckpoint available in GitLab 19.0), archived, stalled.

Field resolvers

FieldWhat it does
toolCallApproved(toolName, toolCallArgs)Checks whether a specific tool call is approved for the session. Called on every tool invocation
auditEventsReturns AI audit events for the session. Gated by read_agent_artifacts ability and agent_artifacts_page feature flag (GitLab 19.0+)

Mutations

MutationWhat it does
duoWorkflowsCreateCreates a new workflow session
duoWorkflowsDeleteWorkflowDeletes a workflow session
duoWorkflowsUpdateAgentPrivilegesUpdates agent privilege grants for a session
duoWorkflowsUpdateToolCallApprovalsUpdates per-session tool call approval policy

Subscriptions

SubscriptionWhat it does
duoWorkflowsWorkflowEventsUpdatedStreams live checkpoint events to the workflow owner; restricted to the session owner (not compliance reviewers)

Error tracking (Sentry)

Gitlab::ErrorTracking.track_exception is called with workflow context in:

  • CreateWorkflowService: workflow creation failures
  • DestroyWorkflowService: workflow deletion failures
  • GenerateWorkflowTitleService: title generation failures (workflow_id attached)
  • SummarizeWorkflowService: summary generation failures (workflow_id attached)
  • UpdateToolCallApprovalsService: tool call approval update failures (workflow_id attached)
  • Otel::CreateWorkflowService: OpenTelemetry (OTel) workflow creation failures (workflow_id attached)
  • CodeReview::ReviewMergeRequestService: code review start failures (unit_primitive attached)
  • CancelAssociatedPipelinesWorker: pipeline cancellation failures

Rate limiting

Both endpoints share the same limiter key.

EndpointLimiter keyThresholdScope
POST /api/v4/ai/duo_workflows/direct_accessduo_workflow_direct_access50 req/minper user
GET /api/v4/ai/duo_workflows/list_toolsduo_workflow_direct_access50 req/minper user

Violations return HTTP 429 with a Retry-After header. No dedicated Prometheus counter tracks rate limit hits (see the gaps section above).

Audit events

IngestAuditEventsService receives events from the GitLab Duo Workflow Service by using gRPC, batches them, and enqueues ProcessAuditEventsWorker. The worker:

  1. Writes to ClickHouse by using the Redis write buffer (preferred path).
  2. Falls back to PostgreSQL bulk insert when ClickHouse is unavailable.
  3. Streams each event to configured audit event destinations.
  4. Logs each event to Gitlab::AuditJsonLogger.

A unique index on (cloud_event_id, created_at) guarantees idempotency.

Key source files

FileRole
ee/app/workers/ai/duo_workflows/process_audit_events_worker.rbOnly file with Prometheus counters
ee/app/services/ai/duo_workflows/concerns/workload_metrics.rbduo_workflow_workload_completed internal event
ee/app/services/ai/duo_workflows/concerns/workflow_event_tracking.rbSession and execution internal events
ee/app/services/ai/duo_workflows/code_review/observability.rbCode review error tracking and conditional logging
ee/app/workers/ai/duo_workflows/update_workflow_status_event_worker.rbTriggers workload metrics on CI pipeline completion
ee/lib/api/ai/duo_workflows/workflows.rbPublic API. Rate limiting and vulnerability workflow event tracking
ee/lib/api/ai/duo_workflows/workflows_internal.rbInternal API consumed by GitLab Duo Workflow Service and Executor
ee/lib/ee/gitlab/application_rate_limiter.rbduo_workflow_direct_access rate limit definition (50 req/min)
ee/config/events/Internal event definitions (agent_platform_session_*, duo_workflow_*, *_mcp_tool_call)