Metadata
Metadata is arbitrary structured data (string keys, JSON-serializable values) attached to traces. It helps you filter and understand production traffic in the Noryen UI.
Per-event metadata
Pass metadata on each track() call:
track.ts
noryen.track({model: "gpt-4o-mini",prompt: "Hello",response: "Hi!",metadata: {userId: "usr_123",feature: "chat",deployment: "eu-west",},});
Good candidates: internal user or tenant ids (non-PII where possible), feature flags, request route names, environment names, and correlation ids.
Global context with setContext
This is default metadata, not the RAG TrackContext field on individual traces.
noryen.setContext(metadata) merges into a client-wide map. Every subsequent track() (including wrapper emissions) merges: global context first, then per-event metadata, so per-event keys override globals on conflict.
context.ts
noryen.setContext({service: "billing-worker",version: process.env.APP_VERSION,});// Later events merge global context with per-event metadatanoryen.track({model: "gpt-4o-mini",prompt: "…",response: "…",metadata: { step: "invoice_summary" },});// Effective metadata includes service, version, and step
Wrapper-level metadata
When using wrappers, you can pass metadata in WrapOptions so every wrapped call includes the same fields:
wrap-options.ts
const client = noryen.wrapOpenAI(openai, {metadata: { route: "api/chat" },});
Avoid storing secrets, full prompts with sensitive data, or regulated health/financial payloads in metadata if your compliance policy restricts logging—metadata is sent to Noryen with the trace batch.