Skip to content

feat: add billable events for code suggestions

What does this merge request do and why?

Adds billable events for code generation and code completion

Resolves https://gitlab.com/gitlab-org/gitlab/-/issues/578266

How to set up and validate locally

  1. Enable snowplow micro for your GDK

  2. Make sure your AIGW config has the following enabled and pointing at your snowplow micro instance

    AIGW_INTERNAL_EVENT__ENABLED=true
    AIGW_INTERNAL_EVENT__ENDPOINT=http://127.0.0.1:9092
    
    AIGW_BILLING_EVENT__ENABLED=true
    AIGW_BILLING_EVENT__ENDPOINT=http://127.0.0.1:9092
  3. Send a code completion or generation request to your GDK

    curl -X "POST" "http://localhost:3000/api/v4/code_suggestions/completions" \
         -H 'Content-Type: application/json' \
         -d $'{
      "current_file": {
        "file_name": "car.py",
        "content_above_cursor": "class Car:\\n    def __init__(self):\\n        self.is_running = False\\n        self.speed = 0\\n    def increase_speed(self, increment):",
        "content_below_cursor": ""
      },
      "intent": "completion" # or "generation"
    }'
  4. Go to your snowplow micro URL http://localhost:9092/micro/ui and see a valid billable event for se_action: code_completion or se_action: code_generation

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 Tan Le

Merge request reports

Loading