Skip to content

feat(billing-events): Add billing event instrumentation on successful workflow

What does this merge request do and why?

This MR adds intial instrumentation for billing event on workflow.

https://gitlab.com/gitlab-org/gitlab/-/issues/569398

How to set up and validate locally

  1. Enable snowplow micro.

  2. Apply below patch in gitlab monolith, this will enable gitlab agentic chat in the local gdk.

diff --git a/ee/app/models/concerns/ai/user_authorizable.rb b/ee/app/models/concerns/ai/user_authorizable.rb
index 2d976c5ab0a8..cdfd83299fd2 100644
--- a/ee/app/models/concerns/ai/user_authorizable.rb
+++ b/ee/app/models/concerns/ai/user_authorizable.rb
@@ -101,6 +101,10 @@ def any_group_with_ai_available?
       end
 
       def allowed_to_use?(ai_feature, unit_primitive_name: nil, licensed_feature: :ai_features)
+        if Rails.env.development? && [:duo_chat, :duo_agentic_chat].include?(ai_feature)
+          return true
+        end
+
         allowed_to_use(ai_feature, unit_primitive_name: unit_primitive_name, licensed_feature: licensed_feature)
           .allowed?
       end
diff --git a/workhorse/internal/ai_assist/duoworkflow/handler.go b/workhorse/internal/ai_assist/duoworkflow/handler.go
index 37ba485cb5fc..5f8e3cf6df90 100644
--- a/workhorse/internal/ai_assist/duoworkflow/handler.go
+++ b/workhorse/internal/ai_assist/duoworkflow/handler.go
@@ -11,7 +11,11 @@ import (
 	"github.com/gorilla/websocket"
 )
 
-var upgrader = websocket.Upgrader{}
+var upgrader = websocket.Upgrader{
+    CheckOrigin: func(r *http.Request) bool {
+        return true
+   },
+}
 
 // Handler creates an HTTP handler for Duo Workflow WebSocket connections.
 func Handler(rails *api.API) http.Handler {

Screenshot_2025-09-20_at_15.40.13

On finishing of the workflow, billing event will be fired.

Screenshot_2025-09-20_at_15.41.15

Numbered steps to set up and validate the change are strongly suggested.

Merge request checklist

  • Tests added for new functionality. If not, please raise an issue to follow up.
  • Documentation added/updated, if needed.
  • If this change requires executor implementation: verified that issues/MRs exist for both Go executor and Node executor or confirmed that changes are backward-compatible and don't break existing executor functionality.
Edited by Ankit Panchal

Merge request reports

Loading