Instrument token usage consumption for code generation
What does this merge request do and why?
Closes #417 (closed)
How to set up and validate locally
- Set up Snowplow micro https://gitlab.com/gitlab-org/gitlab-development-kit/-/blob/main/doc/howto/snowplow_micro.md?ref_type=heads
- Ensure that Snowplow tracking is enabled in
.env
file for AI Gateway.# Tracking AIGW_SNOWPLOW__ENABLED=true AIGW_SNOWPLOW__ENDPOINT="http://localhost:9090" AIGW_SNOWPLOW__BATCH_SIZE=1 AIGW_SNOWPLOW__THREAD_COUNT=1
- Trigger code completion requests (you can toggle
intent
to"completion"
, andstream
totrue
)curl -X POST -H "Content-Type: Application/json" -H "Authorization: Bearer $GDK_AI_API_TOKEN" http://gdk.test:3000/api/v4/code_suggestions/completions --data '{ "current_file": { "file_name": "utils.go", "content_above_cursor": "// generate function that loads env variables from .env file", "content_below_cursor": "" }, "project_path": "", "stream": false, "intent": "generation" }'
- Check that correct events were reported to snowplow micro collector
curl localhost:9091/micro/good | jq '.[] | .event.se_action, .event.se_value'
Merge request checklist
-
Tests added for new functionality. If not, please raise an issue to follow up. -
Documentation added/updated, if needed.
Edited by Tan Le