chore: track token issuer
What does this merge request do and why?
- added token_issuer to logging - this can be used to distinguish direct requests because direct requests will have token issuer set to "ai gateway"
- added is_direct_connection to snowplow event - this is for consistency with client-side events (https://gitlab.com/gitlab-org/iglu/-/merge_requests/121#note_1940394391)
- removed request count from snowplow tracking (request counts are not sent anymore gitlab-org/gitlab!153586 (merged))
Related to #428 (closed)
How to set up and validate locally
- Logging: verify that for incomming requests there is token_issuer included in logs
- Snowplow event: if no snowplow client is set, you can stub it with a snippet below and verify content of snowplow event in logs
diff --git a/ai_gateway/tracking/instrumentator.py b/ai_gateway/tracking/instrumentator.py
index 4e94d8d1..45754c3a 100644
--- a/ai_gateway/tracking/instrumentator.py
+++ b/ai_gateway/tracking/instrumentator.py
@@ -1,4 +1,5 @@
-from ai_gateway.tracking.snowplow import Client, SnowplowEvent
+import structlog
__all__ = ["SnowplowInstrumentator"]
@@ -11,4 +12,6 @@ class SnowplowInstrumentator:
self,
snowplow_event: SnowplowEvent,
) -> None:
+ log = structlog.stdlib.get_logger("instrumentator")
+ log.debug("instrumentator:", ev1=snowplow_event)
self.client.track(snowplow_event)
Merge request checklist
-
Tests added for new functionality. If not, please raise an issue to follow up. -
Documentation added/updated, if needed.
Edited by Jan Provaznik