Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@
}
},
"overrides": [
{
"includes": ["docs/stylesheets/**"],
"linter": {
"enabled": false
}
},
{
"includes": ["**/*.test.ts"],
"linter": {
Expand Down
22 changes: 22 additions & 0 deletions packages/server/rpc/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,33 @@ export async function handleRpcRequest(
return json(invalidParams(requestId, formatZodError(paramsResult.error)));
}

// Build identity attributes from auth context
const identityAttrs: Record<string, string> = {};
const ctx = context as Record<string, unknown>;
if (ctx.engine && typeof ctx.engine === "object") {
const engine = ctx.engine as {
id?: string;
orgId?: string;
slug?: string;
};
if (engine.id) identityAttrs["engine.id"] = engine.id;
if (engine.orgId) identityAttrs["org.id"] = engine.orgId;
if (engine.slug) identityAttrs["engine.slug"] = engine.slug;
}
if (typeof ctx.userId === "string") identityAttrs["user.id"] = ctx.userId;
if (typeof ctx.apiKeyId === "string")
identityAttrs["api_key.id"] = ctx.apiKeyId;
if (ctx.identity && typeof ctx.identity === "object") {
const identity = ctx.identity as { id?: string };
if (identity.id) identityAttrs["identity.id"] = identity.id;
}

// Execute handler in a span
const result = await span(`rpc.${rpcRequest.method}`, {
attributes: {
"rpc.method": rpcRequest.method,
"rpc.request_id": String(requestId),
...identityAttrs,
},
callback: async () => {
const handlerContext: HandlerContext = {
Expand Down