@inference/tracing 0.0.21 → 0.0.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -11,6 +11,9 @@ prompts, responses, token usage, and parent-child agent flows.
11
11
  This package is currently in beta. APIs may change before `1.0`, but the package
12
12
  name and import paths are intended to remain stable.
13
13
 
14
+ Full documentation lives at
15
+ [docs.inference.net/integrations/traces/overview](https://docs.inference.net/integrations/traces/overview).
16
+
14
17
  ## Install
15
18
 
16
19
  ```bash
@@ -192,8 +195,11 @@ await agentSpan(
192
195
  agentName: "Refund Review Agent",
193
196
  spanName: "refund-review.run",
194
197
  sessionId: "conversation-1842",
198
+ userId: "user-7723",
195
199
  role: "refunds",
196
200
  system: "internal",
201
+ metadata: { queue: "priority" },
202
+ tags: ["refunds", "beta"],
197
203
  },
198
204
  async (span) => {
199
205
  span.setInput("Review refund request #1842");
@@ -210,10 +216,12 @@ await tracing.shutdown();
210
216
  survives display-name changes so Catalyst can group executions correctly in the
211
217
  agent dashboard. `agentName` is optional and becomes `agent.name` when you want
212
218
  a human-readable display label. `sessionId` is optional and should identify one
213
- conversation, not the whole process. Any child spans created inside the callback
214
- automatically parent under the agent span and supported SDK wrappers copy the
215
- active `agent.id` and optional `agent.name` / `agent.role` onto their child
216
- spans.
219
+ conversation, not the whole process. `userId` is optional and becomes `user.id`
220
+ so Catalyst can filter and group traces by end user. `metadata` and `tags` are
221
+ also optional: `metadata` attaches a JSON bag and `tags` attaches a string
222
+ array to the span. Any child spans created inside the callback automatically
223
+ parent under the agent span and supported SDK wrappers copy the active
224
+ `agent.id` and optional `agent.name` / `agent.role` onto their child spans.
217
225
 
218
226
  ## Configuration
219
227
 
@@ -244,6 +252,7 @@ understand them without custom adapters:
244
252
  | Model metadata | `llm.model_name`, `llm.invocation_parameters` |
245
253
  | Token counts | `llm.token_count.prompt`, `llm.token_count.completion`, `llm.token_count.total` |
246
254
  | Provider/system | `gen_ai.system` |
255
+ | Agent and session | `agent.id`, `agent.name`, `agent.role`, `session.id`, `user.id`, `metadata`, `tags` |
247
256
 
248
257
  Constants are exported for custom spans:
249
258
 
@@ -56,6 +56,15 @@ export interface AgentSpanOptions {
56
56
  * so downstream viewers can group agent spans by conversation.
57
57
  */
58
58
  sessionId?: string;
59
+ /**
60
+ * End-user identifier the work runs on behalf of. Becomes this span's
61
+ * `user.id` so downstream viewers can filter and group traces by user.
62
+ */
63
+ userId?: string;
64
+ /** Free-form metadata bag — JSON-stringified onto the `metadata` attribute. */
65
+ metadata?: Record<string, unknown>;
66
+ /** Free-form string tags — set on the `tags` attribute as a string array. */
67
+ tags?: readonly string[];
59
68
  }
60
69
  /**
61
70
  * Options accepted by {@link manualSpan}.
@@ -91,6 +100,11 @@ export interface ManualSpanOptions {
91
100
  * so downstream viewers can group manual spans by conversation.
92
101
  */
93
102
  sessionId?: string;
103
+ /**
104
+ * End-user identifier the work runs on behalf of. Becomes this span's
105
+ * `user.id` so downstream viewers can filter and group traces by user.
106
+ */
107
+ userId?: string;
94
108
  /** Convenience: set `input.value` from the callback. Strings pass through; objects are JSON-stringified. */
95
109
  input?: unknown;
96
110
  /** Convenience: set `output.value` before the callback runs (rare — usually set inside the callback). */
@@ -233,7 +247,7 @@ export declare function manualSpan<T>(tracer: Tracer, options: ManualSpanOptions
233
247
  * Wrap a chunk of agent work in an OpenInference-shaped AGENT span.
234
248
  *
235
249
  * Sets `openinference.span.kind=AGENT`, `agent.id`, optional
236
- * `agent.name` / `agent.role` / `session.id`, and `gen_ai.system`; the
250
+ * `agent.name` / `agent.role` / `session.id` / `user.id`, and `gen_ai.system`; the
237
251
  * callback can fill in `input`, `output`, model, and tokens via the handle.
238
252
  * The callback runs inside the span's active OTel context, so any child spans
239
253
  * created by an instrumented LLM SDK (or by `tracer.startSpan(...)` inside the
@@ -80,6 +80,9 @@ export async function manualSpan(tracer, options, fn) {
80
80
  const sessionId = options.sessionId?.trim();
81
81
  if (sessionId)
82
82
  startAttributes[Attr.SESSION_ID] = sessionId;
83
+ const userId = options.userId?.trim();
84
+ if (userId)
85
+ startAttributes[Attr.USER_ID] = userId;
83
86
  if (options.attributes)
84
87
  Object.assign(startAttributes, options.attributes);
85
88
  if (options.metadata && Object.keys(options.metadata).length > 0) {
@@ -122,7 +125,7 @@ export async function manualSpan(tracer, options, fn) {
122
125
  * Wrap a chunk of agent work in an OpenInference-shaped AGENT span.
123
126
  *
124
127
  * Sets `openinference.span.kind=AGENT`, `agent.id`, optional
125
- * `agent.name` / `agent.role` / `session.id`, and `gen_ai.system`; the
128
+ * `agent.name` / `agent.role` / `session.id` / `user.id`, and `gen_ai.system`; the
126
129
  * callback can fill in `input`, `output`, model, and tokens via the handle.
127
130
  * The callback runs inside the span's active OTel context, so any child spans
128
131
  * created by an instrumented LLM SDK (or by `tracer.startSpan(...)` inside the
@@ -190,6 +193,9 @@ export async function agentSpan(tracer, options, fn) {
190
193
  agentName,
191
194
  agentRole: options.role,
192
195
  sessionId: options.sessionId,
196
+ userId: options.userId,
197
+ metadata: options.metadata,
198
+ tags: options.tags,
193
199
  }, fn);
194
200
  }
195
201
  function makeHandle(span) {
package/dist/semconv.d.ts CHANGED
@@ -134,6 +134,13 @@ export declare const Attr: {
134
134
  * Wire key: `session.id`
135
135
  */
136
136
  readonly SESSION_ID: "session.id";
137
+ /**
138
+ * End-user identifier the work runs on behalf of, used to filter and
139
+ * group traces by user.
140
+ *
141
+ * Wire key: `user.id`
142
+ */
143
+ readonly USER_ID: "user.id";
137
144
  };
138
145
  /**
139
146
  * Canonical string values for {@link Attr.SPAN_KIND}.
package/dist/semconv.js CHANGED
@@ -134,6 +134,13 @@ export const Attr = {
134
134
  * Wire key: `session.id`
135
135
  */
136
136
  SESSION_ID: "session.id",
137
+ /**
138
+ * End-user identifier the work runs on behalf of, used to filter and
139
+ * group traces by user.
140
+ *
141
+ * Wire key: `user.id`
142
+ */
143
+ USER_ID: "user.id",
137
144
  };
138
145
  /**
139
146
  * Canonical string values for {@link Attr.SPAN_KIND}.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inference/tracing",
3
- "version": "0.0.21",
3
+ "version": "0.0.22",
4
4
  "type": "module",
5
5
  "description": "First-party OpenInference-shaped tracing for TypeScript LLM and agent applications on Catalyst by Inference.net.",
6
6
  "homepage": "https://inference.net",