You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
> **Tip:** When using `StarletteIASTelemetryMiddleware` (see [Automatic tenant and user injection](#automatic-tenant-and-user-injection)), `common.tenant_id` and `common.user_initiator_id` are filled automatically from the incoming IAS JWT. You only need to set them explicitly if you want to override the values from the token.
172
+
171
173
### Step 4: Send the Event
172
174
173
175
**Binary protobuf:**
@@ -284,6 +286,55 @@ Events are validated against protobuf constraints using `protovalidate` before s
284
286
285
287
---
286
288
289
+
## Automatic tenant and user injection
290
+
291
+
When `StarletteIASTelemetryMiddleware` is registered on your app, it parses the
292
+
incoming `Authorization: Bearer <token>` header on every request and stores the
293
+
IAS claims in the current async context.
294
+
295
+
`AuditClient.send()` reads that context automatically before validation and
296
+
back-fills two fields on the event's `common` block — only if they are not
297
+
already set by the caller:
298
+
299
+
| Field populated | IAS claim used |
300
+
|---|---|
301
+
|`common.tenant_id`|`app_tid`|
302
+
|`common.user_initiator_id`|`user_uuid`|
303
+
304
+
### Setup
305
+
306
+
Register the middleware once when your app starts:
307
+
308
+
```python
309
+
from sap_cloud_sdk.core.telemetry import auto_instrument
310
+
from sap_cloud_sdk.core.telemetry.middleware import StarletteIASTelemetryMiddleware
0 commit comments