@arizeai/phoenix-client 6.5.1 → 6.5.2

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
@@ -298,6 +298,200 @@ const experiment = await runExperiment({
298
298
 
299
299
  > **Hint:** Tasks and evaluators are instrumented using [OpenTelemetry](https://opentelemetry.io/). You can view detailed traces of experiment runs and evaluations directly in the Phoenix UI for debugging and performance analysis.
300
300
 
301
+ ## Traces
302
+
303
+ The `@arizeai/phoenix-client` package provides a `traces` export for retrieving trace data from Phoenix projects.
304
+
305
+ ### Fetching Traces
306
+
307
+ Use `getTraces` to retrieve traces with optional filtering, sorting, and pagination.
308
+
309
+ ```ts
310
+ import { getTraces } from "@arizeai/phoenix-client/traces";
311
+
312
+ // Get the latest 10 traces
313
+ const result = await getTraces({
314
+ project: { projectName: "my-project" },
315
+ limit: 10,
316
+ });
317
+ console.log(result.data); // array of trace objects
318
+
319
+ // Filter by time range and include full span details
320
+ const detailed = await getTraces({
321
+ project: { projectName: "my-project" },
322
+ startTime: "2026-03-01T00:00:00Z",
323
+ endTime: new Date(),
324
+ includeSpans: true,
325
+ sort: "latency_ms",
326
+ order: "desc",
327
+ });
328
+
329
+ // Filter by session
330
+ const sessionTraces = await getTraces({
331
+ project: { projectName: "my-project" },
332
+ sessionId: "my-session-id",
333
+ });
334
+ ```
335
+
336
+ | Parameter | Type | Description |
337
+ | -------------- | ------------------------------ | ------------------------------------------ |
338
+ | `project` | `ProjectIdentifier` | The project (by name or ID) — **required** |
339
+ | `startTime` | `Date \| string \| null` | Inclusive lower bound on trace start time |
340
+ | `endTime` | `Date \| string \| null` | Exclusive upper bound on trace start time |
341
+ | `sort` | `"start_time" \| "latency_ms"` | Sort field |
342
+ | `order` | `"asc" \| "desc"` | Sort direction |
343
+ | `limit` | `number` | Maximum number of traces to return |
344
+ | `cursor` | `string \| null` | Pagination cursor (Trace GlobalID) |
345
+ | `includeSpans` | `boolean` | Include full span details for each trace |
346
+ | `sessionId` | `string \| string[] \| null` | Filter traces by session identifier(s) |
347
+
348
+ ### Pagination
349
+
350
+ Use the `cursor` from a previous result to fetch the next page:
351
+
352
+ ```ts
353
+ import { getTraces } from "@arizeai/phoenix-client/traces";
354
+
355
+ let cursor: string | null = null;
356
+ const allTraces = [];
357
+
358
+ do {
359
+ const result = await getTraces({
360
+ project: { projectName: "my-project" },
361
+ limit: 50,
362
+ cursor,
363
+ });
364
+ allTraces.push(...result.data);
365
+ cursor = result.nextCursor ?? null;
366
+ } while (cursor);
367
+ ```
368
+
369
+ > **Note:** Requires Phoenix server >= 13.15.0.
370
+
371
+ ## Spans
372
+
373
+ The `@arizeai/phoenix-client` package provides a `spans` export for querying spans with powerful filtering.
374
+
375
+ ### Fetching Spans
376
+
377
+ Use `getSpans` to retrieve spans with filtering by kind, status, name, trace, and more.
378
+
379
+ ```ts
380
+ import { getSpans } from "@arizeai/phoenix-client/spans";
381
+
382
+ // Get recent spans
383
+ const result = await getSpans({
384
+ project: { projectName: "my-project" },
385
+ limit: 100,
386
+ });
387
+
388
+ // Filter by span kind and status
389
+ const errorLLMSpans = await getSpans({
390
+ project: { projectName: "my-project" },
391
+ spanKind: "LLM",
392
+ statusCode: "ERROR",
393
+ });
394
+
395
+ // Filter by name and trace
396
+ const spans = await getSpans({
397
+ project: { projectName: "my-project" },
398
+ name: "chat_completion",
399
+ traceIds: ["trace-abc", "trace-def"],
400
+ });
401
+
402
+ // Root spans only
403
+ const rootSpans = await getSpans({
404
+ project: { projectName: "my-project" },
405
+ parentId: null,
406
+ });
407
+ ```
408
+
409
+ | Parameter | Type | Description |
410
+ | ------------ | ------------------------------------ | --------------------------------------------------------------- |
411
+ | `project` | `ProjectIdentifier` | The project (by name or ID) — **required** |
412
+ | `startTime` | `Date \| string \| null` | Inclusive lower bound time |
413
+ | `endTime` | `Date \| string \| null` | Exclusive upper bound time |
414
+ | `limit` | `number` | Maximum number of spans to return |
415
+ | `cursor` | `string \| null` | Pagination cursor (Span GlobalID) |
416
+ | `traceIds` | `string[] \| null` | Filter by trace ID(s) |
417
+ | `parentId` | `string \| null` | Filter by parent span ID (`null` for root spans only) |
418
+ | `name` | `string \| string[] \| null` | Filter by span name(s) |
419
+ | `spanKind` | `SpanKindFilter \| SpanKindFilter[]` | Filter by span kind (`LLM`, `CHAIN`, `TOOL`, `RETRIEVER`, etc.) |
420
+ | `statusCode` | `SpanStatusCode \| SpanStatusCode[]` | Filter by status code (`OK`, `ERROR`, `UNSET`) |
421
+
422
+ ## Span Annotations
423
+
424
+ The `spans` export also provides functions for managing span annotations — adding evaluations, feedback, and labels to spans.
425
+
426
+ ### Adding a Single Annotation
427
+
428
+ ```ts
429
+ import { addSpanAnnotation } from "@arizeai/phoenix-client/spans";
430
+
431
+ const result = await addSpanAnnotation({
432
+ spanAnnotation: {
433
+ spanId: "f8b1c3a2d4e5f678",
434
+ name: "correctness",
435
+ label: "correct",
436
+ score: 1.0,
437
+ explanation: "The response accurately answered the question",
438
+ annotatorKind: "HUMAN",
439
+ },
440
+ sync: true, // wait for the annotation ID to be returned
441
+ });
442
+ // result: { id: "annotation-id" } when sync: true, null when sync: false
443
+ ```
444
+
445
+ ### Logging Multiple Annotations
446
+
447
+ ```ts
448
+ import { logSpanAnnotations } from "@arizeai/phoenix-client/spans";
449
+
450
+ const results = await logSpanAnnotations({
451
+ spanAnnotations: [
452
+ {
453
+ spanId: "f8b1c3a2d4e5f678",
454
+ name: "relevance",
455
+ label: "relevant",
456
+ score: 0.95,
457
+ annotatorKind: "LLM",
458
+ },
459
+ {
460
+ spanId: "a1b2c3d4e5f67890",
461
+ name: "relevance",
462
+ label: "irrelevant",
463
+ score: 0.2,
464
+ annotatorKind: "LLM",
465
+ },
466
+ ],
467
+ sync: true,
468
+ });
469
+ // results: [{ id: "..." }, { id: "..." }]
470
+ ```
471
+
472
+ ### Fetching Span Annotations
473
+
474
+ ```ts
475
+ import { getSpanAnnotations } from "@arizeai/phoenix-client/spans";
476
+
477
+ const result = await getSpanAnnotations({
478
+ project: { projectName: "my-project" },
479
+ spanIds: ["f8b1c3a2d4e5f678", "a1b2c3d4e5f67890"],
480
+ includeAnnotationNames: ["relevance", "correctness"],
481
+ limit: 100,
482
+ });
483
+ console.log(result.data); // array of span annotation objects
484
+ ```
485
+
486
+ | Parameter | Type | Description |
487
+ | ------------------------ | ------------------- | ------------------------------------------------ |
488
+ | `project` | `ProjectIdentifier` | The project (by name or ID) — **required** |
489
+ | `spanIds` | `string[]` | Span IDs to fetch annotations for — **required** |
490
+ | `includeAnnotationNames` | `string[]` | Only return annotations with these names |
491
+ | `excludeAnnotationNames` | `string[]` | Exclude annotations with these names |
492
+ | `cursor` | `string \| null` | Pagination cursor |
493
+ | `limit` | `number` | Maximum annotations to return |
494
+
301
495
  ## Examples
302
496
 
303
497
  To run examples, install dependencies using `pnpm` and run:
@@ -19,6 +19,7 @@ export declare const LIST_PROJECT_SESSIONS: RouteRequirement;
19
19
  export declare const ANNOTATE_SESSIONS: RouteRequirement;
20
20
  export declare const GET_SPANS_TRACE_IDS: ParameterRequirement;
21
21
  export declare const GET_SPANS_FILTERS: ParameterRequirement;
22
+ export declare const LIST_PROJECT_TRACES: RouteRequirement;
22
23
  /**
23
24
  * Aggregate list of every known capability requirement.
24
25
  *
@@ -1 +1 @@
1
- {"version":3,"file":"serverRequirements.d.ts","sourceRoot":"","sources":["../../../src/constants/serverRequirements.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EACV,qBAAqB,EACrB,oBAAoB,EACpB,gBAAgB,EACjB,MAAM,6BAA6B,CAAC;AAErC,eAAO,MAAM,WAAW,EAAE,gBAKzB,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,gBAK5B,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,gBAK7B,CAAC;AAEF,eAAO,MAAM,qBAAqB,EAAE,gBAKnC,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,gBAK/B,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,oBAMjC,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,oBAM/B,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,EAAE,SAAS,qBAAqB,EAQnD,CAAC"}
1
+ {"version":3,"file":"serverRequirements.d.ts","sourceRoot":"","sources":["../../../src/constants/serverRequirements.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EACV,qBAAqB,EACrB,oBAAoB,EACpB,gBAAgB,EACjB,MAAM,6BAA6B,CAAC;AAErC,eAAO,MAAM,WAAW,EAAE,gBAKzB,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,gBAK5B,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,gBAK7B,CAAC;AAEF,eAAO,MAAM,qBAAqB,EAAE,gBAKnC,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,gBAK/B,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,oBAMjC,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,oBAM/B,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,gBAKjC,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,EAAE,SAAS,qBAAqB,EASnD,CAAC"}
@@ -55,6 +55,12 @@ export const GET_SPANS_FILTERS = {
55
55
  route: "GET /v1/projects/{id}/spans",
56
56
  minServerVersion: [13, 15, 0],
57
57
  };
58
+ export const LIST_PROJECT_TRACES = {
59
+ kind: "route",
60
+ method: "GET",
61
+ path: "/v1/projects/{project_identifier}/traces",
62
+ minServerVersion: [13, 15, 0],
63
+ };
58
64
  /**
59
65
  * Aggregate list of every known capability requirement.
60
66
  *
@@ -69,5 +75,6 @@ export const ALL_REQUIREMENTS = [
69
75
  ANNOTATE_SESSIONS,
70
76
  GET_SPANS_TRACE_IDS,
71
77
  GET_SPANS_FILTERS,
78
+ LIST_PROJECT_TRACES,
72
79
  ];
73
80
  //# sourceMappingURL=serverRequirements.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"serverRequirements.js","sourceRoot":"","sources":["../../../src/constants/serverRequirements.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAQH,MAAM,CAAC,MAAM,WAAW,GAAqB;IAC3C,IAAI,EAAE,OAAO;IACb,MAAM,EAAE,KAAK;IACb,IAAI,EAAE,2BAA2B;IACjC,gBAAgB,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC;CAC7B,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAAqB;IAC9C,IAAI,EAAE,OAAO;IACb,MAAM,EAAE,QAAQ;IAChB,IAAI,EAAE,2BAA2B;IACjC,gBAAgB,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;CAC9B,CAAC;AAEF,MAAM,CAAC,MAAM,eAAe,GAAqB;IAC/C,IAAI,EAAE,OAAO;IACb,MAAM,EAAE,MAAM;IACd,IAAI,EAAE,qBAAqB;IAC3B,gBAAgB,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;CAC9B,CAAC;AAEF,MAAM,CAAC,MAAM,qBAAqB,GAAqB;IACrD,IAAI,EAAE,OAAO;IACb,MAAM,EAAE,KAAK;IACb,IAAI,EAAE,oCAAoC;IAC1C,gBAAgB,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC;CAC7B,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAqB;IACjD,IAAI,EAAE,OAAO;IACb,MAAM,EAAE,MAAM;IACd,IAAI,EAAE,yBAAyB;IAC/B,gBAAgB,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC;CAC7B,CAAC;AAEF,MAAM,CAAC,MAAM,mBAAmB,GAAyB;IACvD,IAAI,EAAE,WAAW;IACjB,aAAa,EAAE,UAAU;IACzB,iBAAiB,EAAE,OAAO;IAC1B,KAAK,EAAE,6BAA6B;IACp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C1C,gBAAgB,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC;CAC7B,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAqB;IACjD,IAAI,EAAE,OAAO;IACb,MAAM,EAAE,MAAM;IACd,IAAI,EAAE,yBAAyB;IAC/B,gBAAgB,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC;CAC7B,CAAC;AAEF,MAAM,CAAC,MAAM,mBAAmB,GAAyB;IACvD,IAAI,EAAE,WAAW;IACjB,aAAa,EAAE,UAAU;IACzB,iBAAiB,EAAE,OAAO;IAC1B,KAAK,EAAE,6BAA6B;IACpC,gBAAgB,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC;CAC7B,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAyB;IACrD,IAAI,EAAE,WAAW;IACjB,aAAa,EAAE,WAAW;IAC1B,iBAAiB,EAAE,OAAO;IAC1B,KAAK,EAAE,6BAA6B;IACpC,gBAAgB,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;CAC9B,CAAC;AAEF,MAAM,CAAC,MAAM,mBAAmB,GAAqB;IACnD,IAAI,EAAE,OAAO;IACb,MAAM,EAAE,KAAK;IACb,IAAI,EAAE,0CAA0C;IAChD,gBAAgB,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;CAC9B,CAAC;AAEF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAqC;IAChE,WAAW;IACX,cAAc;IACd,eAAe;IACf,qBAAqB;IACrB,iBAAiB;IACjB,mBAAmB;IACnB,iBAAiB;IACjB,mBAAmB;CACX,CAAC"}
@@ -0,0 +1,78 @@
1
+ import type { operations } from "../__generated__/api/v1.js";
2
+ import type { ClientFn } from "../types/core.js";
3
+ import type { ProjectIdentifier } from "../types/projects.js";
4
+ /**
5
+ * Parameters for getting traces from a project.
6
+ */
7
+ export interface GetTracesParams extends ClientFn {
8
+ /** The project to get traces from */
9
+ project: ProjectIdentifier;
10
+ /** Inclusive lower bound time. Must be a valid ISO 8601 string or Date object. */
11
+ startTime?: Date | string | null;
12
+ /** Exclusive upper bound time. Must be a valid ISO 8601 string or Date object. */
13
+ endTime?: Date | string | null;
14
+ /** Sort field */
15
+ sort?: "start_time" | "latency_ms";
16
+ /** Sort direction */
17
+ order?: "asc" | "desc";
18
+ /** Maximum number of traces to return */
19
+ limit?: number;
20
+ /** Pagination cursor (Trace GlobalID) */
21
+ cursor?: string | null;
22
+ /** If true, include full span details for each trace */
23
+ includeSpans?: boolean;
24
+ /** Filter traces by session identifier(s) (session_id strings or GlobalIDs) */
25
+ sessionId?: string | string[] | null;
26
+ }
27
+ export type GetTracesResponse = operations["listProjectTraces"]["responses"]["200"];
28
+ export type GetTracesResult = {
29
+ traces: GetTracesResponse["content"]["application/json"]["data"];
30
+ nextCursor: GetTracesResponse["content"]["application/json"]["next_cursor"];
31
+ };
32
+ /**
33
+ * Get traces from a project with filtering and sorting options.
34
+ *
35
+ * This method fetches traces from a project with support for time range filtering,
36
+ * sorting, session filtering, and cursor-based pagination.
37
+ *
38
+ * @requires Phoenix server >= 13.15.0
39
+ *
40
+ * @param params - The parameters to get traces
41
+ * @returns A paginated response containing traces and optional next cursor
42
+ *
43
+ * @example
44
+ * ```ts
45
+ * // Get recent traces from a project
46
+ * const result = await getTraces({
47
+ * client,
48
+ * project: { projectName: "my-project" },
49
+ * limit: 50,
50
+ * });
51
+ *
52
+ * // Get traces in a time range with spans included
53
+ * const result = await getTraces({
54
+ * client,
55
+ * project: { projectName: "my-project" },
56
+ * startTime: new Date("2024-01-01"),
57
+ * endTime: new Date("2024-01-02"),
58
+ * includeSpans: true,
59
+ * });
60
+ *
61
+ * // Paginate through results
62
+ * let cursor: string | undefined;
63
+ * do {
64
+ * const result = await getTraces({
65
+ * client,
66
+ * project: { projectName: "my-project" },
67
+ * cursor,
68
+ * limit: 100,
69
+ * });
70
+ * result.traces.forEach(trace => {
71
+ * console.log(`Trace: ${trace.trace_id}`);
72
+ * });
73
+ * cursor = result.nextCursor || undefined;
74
+ * } while (cursor);
75
+ * ```
76
+ */
77
+ export declare function getTraces({ client: _client, project, cursor, limit, startTime, endTime, sort, order, includeSpans, sessionId, }: GetTracesParams): Promise<GetTracesResult>;
78
+ //# sourceMappingURL=getTraces.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getTraces.d.ts","sourceRoot":"","sources":["../../../src/traces/getTraces.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAG1D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAI3D;;GAEG;AACH,MAAM,WAAW,eAAgB,SAAQ,QAAQ;IAC/C,qCAAqC;IACrC,OAAO,EAAE,iBAAiB,CAAC;IAC3B,kFAAkF;IAClF,SAAS,CAAC,EAAE,IAAI,GAAG,MAAM,GAAG,IAAI,CAAC;IACjC,kFAAkF;IAClF,OAAO,CAAC,EAAE,IAAI,GAAG,MAAM,GAAG,IAAI,CAAC;IAC/B,iBAAiB;IACjB,IAAI,CAAC,EAAE,YAAY,GAAG,YAAY,CAAC;IACnC,qBAAqB;IACrB,KAAK,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC;IACvB,yCAAyC;IACzC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,yCAAyC;IACzC,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,wDAAwD;IACxD,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,+EAA+E;IAC/E,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,IAAI,CAAC;CACtC;AAED,MAAM,MAAM,iBAAiB,GAC3B,UAAU,CAAC,mBAAmB,CAAC,CAAC,WAAW,CAAC,CAAC,KAAK,CAAC,CAAC;AAEtD,MAAM,MAAM,eAAe,GAAG;IAC5B,MAAM,EAAE,iBAAiB,CAAC,SAAS,CAAC,CAAC,kBAAkB,CAAC,CAAC,MAAM,CAAC,CAAC;IACjE,UAAU,EAAE,iBAAiB,CAAC,SAAS,CAAC,CAAC,kBAAkB,CAAC,CAAC,aAAa,CAAC,CAAC;CAC7E,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,wBAAsB,SAAS,CAAC,EAC9B,MAAM,EAAE,OAAO,EACf,OAAO,EACP,MAAM,EACN,KAAW,EACX,SAAS,EACT,OAAO,EACP,IAAI,EACJ,KAAK,EACL,YAAY,EACZ,SAAS,GACV,EAAE,eAAe,GAAG,OAAO,CAAC,eAAe,CAAC,CA2D5C"}
@@ -0,0 +1,96 @@
1
+ import { createClient } from "../client.js";
2
+ import { LIST_PROJECT_TRACES } from "../constants/serverRequirements.js";
3
+ import { resolveProjectIdentifier } from "../types/projects.js";
4
+ import { ensureServerCapability } from "../utils/serverVersionUtils.js";
5
+ /**
6
+ * Get traces from a project with filtering and sorting options.
7
+ *
8
+ * This method fetches traces from a project with support for time range filtering,
9
+ * sorting, session filtering, and cursor-based pagination.
10
+ *
11
+ * @requires Phoenix server >= 13.15.0
12
+ *
13
+ * @param params - The parameters to get traces
14
+ * @returns A paginated response containing traces and optional next cursor
15
+ *
16
+ * @example
17
+ * ```ts
18
+ * // Get recent traces from a project
19
+ * const result = await getTraces({
20
+ * client,
21
+ * project: { projectName: "my-project" },
22
+ * limit: 50,
23
+ * });
24
+ *
25
+ * // Get traces in a time range with spans included
26
+ * const result = await getTraces({
27
+ * client,
28
+ * project: { projectName: "my-project" },
29
+ * startTime: new Date("2024-01-01"),
30
+ * endTime: new Date("2024-01-02"),
31
+ * includeSpans: true,
32
+ * });
33
+ *
34
+ * // Paginate through results
35
+ * let cursor: string | undefined;
36
+ * do {
37
+ * const result = await getTraces({
38
+ * client,
39
+ * project: { projectName: "my-project" },
40
+ * cursor,
41
+ * limit: 100,
42
+ * });
43
+ * result.traces.forEach(trace => {
44
+ * console.log(`Trace: ${trace.trace_id}`);
45
+ * });
46
+ * cursor = result.nextCursor || undefined;
47
+ * } while (cursor);
48
+ * ```
49
+ */
50
+ export async function getTraces({ client: _client, project, cursor, limit = 100, startTime, endTime, sort, order, includeSpans, sessionId, }) {
51
+ const client = _client ?? createClient();
52
+ await ensureServerCapability({ client, requirement: LIST_PROJECT_TRACES });
53
+ const projectIdentifier = resolveProjectIdentifier(project);
54
+ const params = {
55
+ limit,
56
+ };
57
+ if (cursor) {
58
+ params.cursor = cursor;
59
+ }
60
+ if (startTime) {
61
+ params.start_time =
62
+ startTime instanceof Date ? startTime.toISOString() : startTime;
63
+ }
64
+ if (endTime) {
65
+ params.end_time = endTime instanceof Date ? endTime.toISOString() : endTime;
66
+ }
67
+ if (sort) {
68
+ params.sort = sort;
69
+ }
70
+ if (order) {
71
+ params.order = order;
72
+ }
73
+ if (includeSpans) {
74
+ params.include_spans = true;
75
+ }
76
+ if (sessionId) {
77
+ params.session_identifier = Array.isArray(sessionId)
78
+ ? sessionId
79
+ : [sessionId];
80
+ }
81
+ const { data, error } = await client.GET("/v1/projects/{project_identifier}/traces", {
82
+ params: {
83
+ path: {
84
+ project_identifier: projectIdentifier,
85
+ },
86
+ query: params,
87
+ },
88
+ });
89
+ if (error)
90
+ throw error;
91
+ return {
92
+ traces: data?.data ?? [],
93
+ nextCursor: data?.next_cursor ?? null,
94
+ };
95
+ }
96
+ //# sourceMappingURL=getTraces.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getTraces.js","sourceRoot":"","sources":["../../../src/traces/getTraces.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAGtE,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAE,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kB,GAAG,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC;YAClD,CAAC,CAAC,SAAS;YACX,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;IAClB,CAAC;IAED,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,MAAM,MAAM,CAAC,GAAG,CACtC,0CAA0C,EAC1C;QACE,MAAM,EAAE;YACN,IAAI,EAAE;gBACJ,kBAAkB,EAAE,iBAAiB;aACtC;YACD,KAAK,EAAE,MAAM;SACd;KACF,CACF,CAAC;IAEF,IAAI,KAAK;QAAE,MAAM,KAAK,CAAC;IACvB,OAAO;QACL,MAAM,EAAE,IAAI,EAAE,IAAI,IAAI,EAAE;QACxB,UAAU,EAAE,IAAI,EAAE,WAAW,IAAI,IAAI;KACtC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from "./getTraces.js";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/traces/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from "./getTraces.js";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/traces/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC"}