@arizeai/phoenix-client 7.11.0 → 7.12.0
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/CHANGELOG.md +6 -0
- package/README.md +13 -5
- package/dist/esm/__generated__/api/v1.d.ts +98 -4
- package/dist/esm/__generated__/api/v1.d.ts.map +1 -1
- package/dist/esm/constants/serverRequirements.d.ts +2 -0
- package/dist/esm/constants/serverRequirements.d.ts.map +1 -1
- package/dist/esm/constants/serverRequirements.js +16 -0
- package/dist/esm/constants/serverRequirements.js.map +1 -1
- package/dist/esm/sessions/listSessions.d.ts +10 -1
- package/dist/esm/sessions/listSessions.d.ts.map +1 -1
- package/dist/esm/sessions/listSessions.js +10 -1
- package/dist/esm/sessions/listSessions.js.map +1 -1
- package/dist/esm/traces/getTraces.d.ts +10 -2
- package/dist/esm/traces/getTraces.d.ts.map +1 -1
- package/dist/esm/traces/getTraces.js +12 -4
- package/dist/esm/traces/getTraces.js.map +1 -1
- package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
- package/dist/src/__generated__/api/v1.d.ts +98 -4
- package/dist/src/__generated__/api/v1.d.ts.map +1 -1
- package/dist/src/constants/serverRequirements.d.ts +2 -0
- package/dist/src/constants/serverRequirements.d.ts.map +1 -1
- package/dist/src/constants/serverRequirements.js +17 -1
- package/dist/src/constants/serverRequirements.js.map +1 -1
- package/dist/src/sessions/listSessions.d.ts +10 -1
- package/dist/src/sessions/listSessions.d.ts.map +1 -1
- package/dist/src/sessions/listSessions.js +9 -0
- package/dist/src/sessions/listSessions.js.map +1 -1
- package/dist/src/traces/getTraces.d.ts +10 -2
- package/dist/src/traces/getTraces.d.ts.map +1 -1
- package/dist/src/traces/getTraces.js +11 -3
- package/dist/src/traces/getTraces.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/docs/sessions.mdx +13 -0
- package/docs/traces.mdx +7 -6
- package/package.json +10 -10
- package/src/__generated__/api/v1.ts +98 -4
- package/src/constants/serverRequirements.ts +18 -0
- package/src/sessions/listSessions.ts +22 -2
- package/src/traces/getTraces.ts +21 -2
package/docs/sessions.mdx
CHANGED
|
@@ -42,6 +42,19 @@ Each session includes cumulative prompt, completion, and total token counts acro
|
|
|
42
42
|
all of its spans. The fields may be `undefined` when using a Phoenix server that
|
|
43
43
|
does not return session token usage.
|
|
44
44
|
|
|
45
|
+
Pass a `filter` expression to narrow the results. The language is documented on the
|
|
46
|
+
[Filter Expressions](/docs/phoenix/tracing/how-to-tracing/filter-expressions) page.
|
|
47
|
+
|
|
48
|
+
```ts
|
|
49
|
+
const failedSessions = await listSessions({
|
|
50
|
+
project: "support-bot",
|
|
51
|
+
filter: "num_traces_with_error > 0 and duration_ms >= 60000",
|
|
52
|
+
});
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Empty expressions do not filter. Invalid expressions return HTTP 400; older
|
|
56
|
+
servers are rejected before sending an expression.
|
|
57
|
+
|
|
45
58
|
## Retrieve A Session And Its Turns
|
|
46
59
|
|
|
47
60
|
```ts
|
package/docs/traces.mdx
CHANGED
|
@@ -60,16 +60,16 @@ console.log(result.nextCursor);
|
|
|
60
60
|
- `cursor`
|
|
61
61
|
- `includeSpans`
|
|
62
62
|
- `sessionId`
|
|
63
|
-
- `
|
|
64
|
-
- `
|
|
65
|
-
- `
|
|
63
|
+
- `filter` — a trace DSL expression, combined with other filters using AND
|
|
64
|
+
- `error` (deprecated; use `filter`)
|
|
65
|
+
- `minLatencyMs` (deprecated; use `filter`)
|
|
66
|
+
- `maxLatencyMs` (deprecated; use `filter`)
|
|
66
67
|
|
|
67
68
|
```ts
|
|
68
69
|
// Slow traces that contain at least one errored span
|
|
69
70
|
const slowFailures = await getTraces({
|
|
70
71
|
project: { projectName: "support-bot" },
|
|
71
|
-
|
|
72
|
-
minLatencyMs: 1000,
|
|
72
|
+
filter: "error_count > 0 and latency_ms >= 1000",
|
|
73
73
|
});
|
|
74
74
|
```
|
|
75
75
|
|
|
@@ -79,7 +79,8 @@ const slowFailures = await getTraces({
|
|
|
79
79
|
- Use the returned `nextCursor` to continue pagination
|
|
80
80
|
- Set `includeSpans` when you need a trace-centric fetch that also contains span details
|
|
81
81
|
- `project` accepts `{ project }`, `{ projectId }`, or `{ projectName }`
|
|
82
|
-
- `
|
|
82
|
+
- `filter` takes a trace filter expression; the language is documented on the [Filter Expressions](/docs/phoenix/tracing/how-to-tracing/filter-expressions) page, and its [Finding field names](/docs/phoenix/tracing/how-to-tracing/filter-expressions#finding-field-names) section covers discovering valid names for your project.
|
|
83
|
+
- `error`, `minLatencyMs`, and `maxLatencyMs` remain supported on Phoenix server >= 20.8.0. Replace them with `error_count > 0` / `error_count == 0`, `latency_ms >= N`, and `latency_ms <= N` respectively. Latency bounds are inclusive and errors include child spans.
|
|
83
84
|
|
|
84
85
|
## Move Traces To Another Project
|
|
85
86
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arizeai/phoenix-client",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.12.0",
|
|
4
4
|
"description": "A client for the Phoenix API",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"arize",
|
|
@@ -103,31 +103,31 @@
|
|
|
103
103
|
}
|
|
104
104
|
},
|
|
105
105
|
"dependencies": {
|
|
106
|
-
"@arizeai/openinference-semantic-conventions": "^2.
|
|
106
|
+
"@arizeai/openinference-semantic-conventions": "^2.12.0",
|
|
107
107
|
"@arizeai/phoenix-config": "0.5.0",
|
|
108
108
|
"@arizeai/phoenix-otel": "2.2.0",
|
|
109
109
|
"async": "^3.2.6",
|
|
110
110
|
"openapi-fetch": "^0.17.0",
|
|
111
111
|
"tiny-invariant": "^1.3.3",
|
|
112
|
-
"zod": "^4.5
|
|
112
|
+
"zod": "^4.6.5"
|
|
113
113
|
},
|
|
114
114
|
"devDependencies": {
|
|
115
|
-
"@ai-sdk/openai": "^4.0.
|
|
116
|
-
"@ai-sdk/otel": "^1.0.
|
|
115
|
+
"@ai-sdk/openai": "^4.0.71",
|
|
116
|
+
"@ai-sdk/otel": "^1.0.107",
|
|
117
117
|
"@anthropic-ai/sdk": "^0.111.0",
|
|
118
118
|
"@arizeai/phoenix-evals": "2.5.0",
|
|
119
119
|
"@arizeai/phoenix-testing": "0.0.0",
|
|
120
120
|
"@opentelemetry/api": "^1.9.1",
|
|
121
121
|
"@opentelemetry/sdk-trace-node": "^2.11.0",
|
|
122
|
-
"@types/async": "^3.2.
|
|
123
|
-
"@types/node": "^26.
|
|
124
|
-
"ai": "^7.0.
|
|
122
|
+
"@types/async": "^3.2.26",
|
|
123
|
+
"@types/node": "^26.6.2",
|
|
124
|
+
"ai": "^7.0.107",
|
|
125
125
|
"dotenv": "^17.4.2",
|
|
126
|
-
"jest": "^30.5.
|
|
126
|
+
"jest": "^30.5.2",
|
|
127
127
|
"openai": "^6.49.0",
|
|
128
128
|
"openapi-typescript": "^7.13.0",
|
|
129
129
|
"tsx": "^4.23.13",
|
|
130
|
-
"vitest": "^5.0.
|
|
130
|
+
"vitest": "^5.0.1"
|
|
131
131
|
},
|
|
132
132
|
"peerDependencies": {
|
|
133
133
|
"@anthropic-ai/sdk": "^0.35.0",
|
|
@@ -430,7 +430,8 @@ export interface paths {
|
|
|
430
430
|
path?: never;
|
|
431
431
|
cookie?: never;
|
|
432
432
|
};
|
|
433
|
-
|
|
433
|
+
/** List dataset splits */
|
|
434
|
+
get: operations["listDatasetSplits"];
|
|
434
435
|
put?: never;
|
|
435
436
|
/** Create a dataset split */
|
|
436
437
|
post: operations["createDatasetSplit"];
|
|
@@ -3980,6 +3981,13 @@ export interface components {
|
|
|
3980
3981
|
/** Data */
|
|
3981
3982
|
data: components["schemas"]["DatasetLabel"][];
|
|
3982
3983
|
};
|
|
3984
|
+
/** ListDatasetSplitsResponseBody */
|
|
3985
|
+
ListDatasetSplitsResponseBody: {
|
|
3986
|
+
/** Data */
|
|
3987
|
+
data: components["schemas"]["DatasetSplit"][];
|
|
3988
|
+
/** Next Cursor */
|
|
3989
|
+
next_cursor: string | null;
|
|
3990
|
+
};
|
|
3983
3991
|
/** ListDatasetVersionsResponseBody */
|
|
3984
3992
|
ListDatasetVersionsResponseBody: {
|
|
3985
3993
|
/** Data */
|
|
@@ -8959,6 +8967,61 @@ export interface operations {
|
|
|
8959
8967
|
};
|
|
8960
8968
|
};
|
|
8961
8969
|
};
|
|
8970
|
+
listDatasetSplits: {
|
|
8971
|
+
parameters: {
|
|
8972
|
+
query?: {
|
|
8973
|
+
/** @description Cursor for pagination */
|
|
8974
|
+
cursor?: string | null;
|
|
8975
|
+
/** @description The max number of dataset splits to return at a time. */
|
|
8976
|
+
limit?: number;
|
|
8977
|
+
};
|
|
8978
|
+
header?: never;
|
|
8979
|
+
path: {
|
|
8980
|
+
/** @description The dataset identifier: either dataset ID or dataset name. */
|
|
8981
|
+
dataset_identifier: string;
|
|
8982
|
+
};
|
|
8983
|
+
cookie?: never;
|
|
8984
|
+
};
|
|
8985
|
+
requestBody?: never;
|
|
8986
|
+
responses: {
|
|
8987
|
+
/** @description Successful Response */
|
|
8988
|
+
200: {
|
|
8989
|
+
headers: {
|
|
8990
|
+
[name: string]: unknown;
|
|
8991
|
+
};
|
|
8992
|
+
content: {
|
|
8993
|
+
"application/json": components["schemas"]["ListDatasetSplitsResponseBody"];
|
|
8994
|
+
};
|
|
8995
|
+
};
|
|
8996
|
+
/** @description Forbidden */
|
|
8997
|
+
403: {
|
|
8998
|
+
headers: {
|
|
8999
|
+
[name: string]: unknown;
|
|
9000
|
+
};
|
|
9001
|
+
content: {
|
|
9002
|
+
"text/plain": string;
|
|
9003
|
+
};
|
|
9004
|
+
};
|
|
9005
|
+
/** @description Dataset not found */
|
|
9006
|
+
404: {
|
|
9007
|
+
headers: {
|
|
9008
|
+
[name: string]: unknown;
|
|
9009
|
+
};
|
|
9010
|
+
content: {
|
|
9011
|
+
"text/plain": string;
|
|
9012
|
+
};
|
|
9013
|
+
};
|
|
9014
|
+
/** @description Invalid request */
|
|
9015
|
+
422: {
|
|
9016
|
+
headers: {
|
|
9017
|
+
[name: string]: unknown;
|
|
9018
|
+
};
|
|
9019
|
+
content: {
|
|
9020
|
+
"text/plain": string;
|
|
9021
|
+
};
|
|
9022
|
+
};
|
|
9023
|
+
};
|
|
9024
|
+
};
|
|
8962
9025
|
createDatasetSplit: {
|
|
8963
9026
|
parameters: {
|
|
8964
9027
|
query?: never;
|
|
@@ -10112,12 +10175,23 @@ export interface operations {
|
|
|
10112
10175
|
include_spans?: boolean;
|
|
10113
10176
|
/** @description List of session identifiers to filter traces by. Each value can be either a session_id string or a session GlobalID. Only traces belonging to the specified sessions will be returned. */
|
|
10114
10177
|
session_identifier?: string[] | null;
|
|
10115
|
-
/**
|
|
10178
|
+
/**
|
|
10179
|
+
* @deprecated
|
|
10180
|
+
* @description Deprecated: use `filter=error_count > 0` or `filter=error_count == 0`. Filter by trace error status. If true, only return traces that contain at least one span with `status_code == ERROR`. If false, only return traces with no errored spans. If omitted, traces are not filtered by error status.
|
|
10181
|
+
*/
|
|
10116
10182
|
error?: boolean | null;
|
|
10117
|
-
/**
|
|
10183
|
+
/**
|
|
10184
|
+
* @deprecated
|
|
10185
|
+
* @description Inclusive lower bound on trace latency in milliseconds. Deprecated: use `filter=latency_ms >= N`.
|
|
10186
|
+
*/
|
|
10118
10187
|
min_latency_ms?: number | null;
|
|
10119
|
-
/**
|
|
10188
|
+
/**
|
|
10189
|
+
* @deprecated
|
|
10190
|
+
* @description Inclusive upper bound on trace latency in milliseconds. Deprecated: use `filter=latency_ms <= N`.
|
|
10191
|
+
*/
|
|
10120
10192
|
max_latency_ms?: number | null;
|
|
10193
|
+
/** @description Trace filter expression, as documented at https://arize.com/docs/phoenix/tracing/how-to-tracing/filter-expressions. Combined with other filters using AND. Empty expressions do not filter. Invalid expressions return 400. */
|
|
10194
|
+
filter?: string | null;
|
|
10121
10195
|
};
|
|
10122
10196
|
header?: never;
|
|
10123
10197
|
path: {
|
|
@@ -10137,6 +10211,15 @@ export interface operations {
|
|
|
10137
10211
|
"application/json": components["schemas"]["GetTracesResponseBody"];
|
|
10138
10212
|
};
|
|
10139
10213
|
};
|
|
10214
|
+
/** @description Bad Request */
|
|
10215
|
+
400: {
|
|
10216
|
+
headers: {
|
|
10217
|
+
[name: string]: unknown;
|
|
10218
|
+
};
|
|
10219
|
+
content: {
|
|
10220
|
+
"text/plain": string;
|
|
10221
|
+
};
|
|
10222
|
+
};
|
|
10140
10223
|
/** @description Forbidden */
|
|
10141
10224
|
403: {
|
|
10142
10225
|
headers: {
|
|
@@ -11904,6 +11987,8 @@ export interface operations {
|
|
|
11904
11987
|
limit?: number;
|
|
11905
11988
|
/** @description Sort order by ID: 'asc' (ascending) or 'desc' (descending). */
|
|
11906
11989
|
order?: "asc" | "desc";
|
|
11990
|
+
/** @description Session filter expression, as documented at https://arize.com/docs/phoenix/tracing/how-to-tracing/filter-expressions. Empty expressions do not filter. Invalid expressions return 400. */
|
|
11991
|
+
filter?: string | null;
|
|
11907
11992
|
};
|
|
11908
11993
|
header?: never;
|
|
11909
11994
|
path: {
|
|
@@ -11923,6 +12008,15 @@ export interface operations {
|
|
|
11923
12008
|
"application/json": components["schemas"]["GetSessionsResponseBody"];
|
|
11924
12009
|
};
|
|
11925
12010
|
};
|
|
12011
|
+
/** @description Bad Request */
|
|
12012
|
+
400: {
|
|
12013
|
+
headers: {
|
|
12014
|
+
[name: string]: unknown;
|
|
12015
|
+
};
|
|
12016
|
+
content: {
|
|
12017
|
+
"text/plain": string;
|
|
12018
|
+
};
|
|
12019
|
+
};
|
|
11926
12020
|
/** @description Forbidden */
|
|
11927
12021
|
403: {
|
|
11928
12022
|
headers: {
|
|
@@ -108,6 +108,22 @@ export const GET_TRACES_FILTERS: ParameterRequirement = {
|
|
|
108
108
|
"The 'error', 'min_latency_ms', and 'max_latency_ms' query parameters on GET /v1/projects/{id}/traces",
|
|
109
109
|
};
|
|
110
110
|
|
|
111
|
+
export const GET_TRACES_FILTER_EXPRESSION: ParameterRequirement = {
|
|
112
|
+
kind: "parameter",
|
|
113
|
+
parameterName: "filter",
|
|
114
|
+
parameterLocation: "query",
|
|
115
|
+
route: "GET /v1/projects/{id}/traces",
|
|
116
|
+
minServerVersion: [20, 12, 0],
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
export const LIST_SESSIONS_FILTER_EXPRESSION: ParameterRequirement = {
|
|
120
|
+
kind: "parameter",
|
|
121
|
+
parameterName: "filter",
|
|
122
|
+
parameterLocation: "query",
|
|
123
|
+
route: "GET /v1/projects/{id}/sessions",
|
|
124
|
+
minServerVersion: [20, 12, 0],
|
|
125
|
+
};
|
|
126
|
+
|
|
111
127
|
export const TRANSFER_TRACES: RouteRequirement = {
|
|
112
128
|
kind: "route",
|
|
113
129
|
method: "POST",
|
|
@@ -245,6 +261,8 @@ export const ALL_REQUIREMENTS: readonly CapabilityRequirement[] = [
|
|
|
245
261
|
GET_SPANS_BY_ATTRIBUTE,
|
|
246
262
|
LIST_PROJECT_TRACES,
|
|
247
263
|
GET_TRACES_FILTERS,
|
|
264
|
+
GET_TRACES_FILTER_EXPRESSION,
|
|
265
|
+
LIST_SESSIONS_FILTER_EXPRESSION,
|
|
248
266
|
TRANSFER_TRACES,
|
|
249
267
|
DATASET_UPLOAD_EXAMPLE_IDS,
|
|
250
268
|
ADD_TRACE_NOTE_IDENTIFIER,
|
|
@@ -2,7 +2,10 @@ import invariant from "tiny-invariant";
|
|
|
2
2
|
|
|
3
3
|
import type { components } from "../__generated__/api/v1";
|
|
4
4
|
import { createClient } from "../client";
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
LIST_PROJECT_SESSIONS,
|
|
7
|
+
LIST_SESSIONS_FILTER_EXPRESSION,
|
|
8
|
+
} from "../constants/serverRequirements";
|
|
6
9
|
import type { ClientFn } from "../types/core";
|
|
7
10
|
import type { ProjectIdentifier } from "../types/projects";
|
|
8
11
|
import { resolveProjectIdentifier } from "../types/projects";
|
|
@@ -10,7 +13,15 @@ import type { Session } from "../types/sessions";
|
|
|
10
13
|
import { ensureServerCapability } from "../utils/serverVersionUtils";
|
|
11
14
|
import { toSession } from "./sessionUtils";
|
|
12
15
|
|
|
13
|
-
export type ListSessionsParams = ClientFn &
|
|
16
|
+
export type ListSessionsParams = ClientFn &
|
|
17
|
+
ProjectIdentifier & {
|
|
18
|
+
/**
|
|
19
|
+
* Session filter expression.
|
|
20
|
+
* @see https://arize.com/docs/phoenix/tracing/how-to-tracing/filter-expressions
|
|
21
|
+
* @requires Phoenix server >= 20.12.0
|
|
22
|
+
*/
|
|
23
|
+
filter?: string | null;
|
|
24
|
+
};
|
|
14
25
|
|
|
15
26
|
type SessionsResponse = components["schemas"]["GetSessionsResponseBody"];
|
|
16
27
|
|
|
@@ -20,6 +31,8 @@ const DEFAULT_PAGE_SIZE = 100;
|
|
|
20
31
|
* List all sessions for a project with automatic pagination handling.
|
|
21
32
|
*
|
|
22
33
|
* @requires Phoenix server >= 13.5.0
|
|
34
|
+
* @param params - Project and filtering options.
|
|
35
|
+
* @param params.filter - Session filter expression, passed unchanged on every page.
|
|
23
36
|
*
|
|
24
37
|
* @example
|
|
25
38
|
* ```ts
|
|
@@ -39,6 +52,12 @@ export async function listSessions(
|
|
|
39
52
|
): Promise<Session[]> {
|
|
40
53
|
const client = params.client || createClient();
|
|
41
54
|
await ensureServerCapability({ client, requirement: LIST_PROJECT_SESSIONS });
|
|
55
|
+
if (params.filter) {
|
|
56
|
+
await ensureServerCapability({
|
|
57
|
+
client,
|
|
58
|
+
requirement: LIST_SESSIONS_FILTER_EXPRESSION,
|
|
59
|
+
});
|
|
60
|
+
}
|
|
42
61
|
const projectIdentifier = resolveProjectIdentifier(params);
|
|
43
62
|
|
|
44
63
|
const sessions: Session[] = [];
|
|
@@ -54,6 +73,7 @@ export async function listSessions(
|
|
|
54
73
|
query: {
|
|
55
74
|
cursor,
|
|
56
75
|
limit: DEFAULT_PAGE_SIZE,
|
|
76
|
+
filter: params.filter || undefined,
|
|
57
77
|
},
|
|
58
78
|
},
|
|
59
79
|
});
|
package/src/traces/getTraces.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { operations } from "../__generated__/api/v1";
|
|
2
2
|
import { createClient } from "../client";
|
|
3
3
|
import {
|
|
4
|
+
GET_TRACES_FILTER_EXPRESSION,
|
|
4
5
|
GET_TRACES_FILTERS,
|
|
5
6
|
LIST_PROJECT_TRACES,
|
|
6
7
|
} from "../constants/serverRequirements";
|
|
@@ -31,22 +32,31 @@ export interface GetTracesParams extends ClientFn {
|
|
|
31
32
|
includeSpans?: boolean;
|
|
32
33
|
/** Filter traces by session identifier(s) (session_id strings or GlobalIDs) */
|
|
33
34
|
sessionId?: string | string[] | null;
|
|
35
|
+
/**
|
|
36
|
+
* Trace filter expression, combined with other filters using AND.
|
|
37
|
+
* @see https://arize.com/docs/phoenix/tracing/how-to-tracing/filter-expressions
|
|
38
|
+
* @requires Phoenix server >= 20.12.0
|
|
39
|
+
*/
|
|
40
|
+
filter?: string | null;
|
|
34
41
|
/**
|
|
35
42
|
* Filter by trace error status. `true` returns only traces containing at
|
|
36
43
|
* least one errored span, `false` only traces with no errored spans.
|
|
37
44
|
* Omit to leave traces unfiltered by error status.
|
|
45
|
+
* @deprecated Use `filter: "error_count > 0"` or `filter: "error_count == 0"`.
|
|
38
46
|
*
|
|
39
47
|
* @requires Phoenix server >= 20.8.0
|
|
40
48
|
*/
|
|
41
49
|
error?: boolean | null;
|
|
42
50
|
/**
|
|
43
51
|
* Inclusive lower bound on trace latency in milliseconds.
|
|
52
|
+
* @deprecated Use `filter: "latency_ms >= N"`.
|
|
44
53
|
*
|
|
45
54
|
* @requires Phoenix server >= 20.8.0
|
|
46
55
|
*/
|
|
47
56
|
minLatencyMs?: number | null;
|
|
48
57
|
/**
|
|
49
58
|
* Inclusive upper bound on trace latency in milliseconds.
|
|
59
|
+
* @deprecated Use `filter: "latency_ms <= N"`.
|
|
50
60
|
*
|
|
51
61
|
* @requires Phoenix server >= 20.8.0
|
|
52
62
|
*/
|
|
@@ -96,11 +106,15 @@ function buildQuery({
|
|
|
96
106
|
order,
|
|
97
107
|
includeSpans,
|
|
98
108
|
sessionId,
|
|
109
|
+
filter,
|
|
99
110
|
error,
|
|
100
111
|
minLatencyMs,
|
|
101
112
|
maxLatencyMs,
|
|
102
113
|
}: Omit<GetTracesParams, "client" | "project">): ListProjectTracesQuery {
|
|
103
114
|
const query: ListProjectTracesQuery = { limit };
|
|
115
|
+
if (filter) {
|
|
116
|
+
query.filter = filter;
|
|
117
|
+
}
|
|
104
118
|
if (cursor) {
|
|
105
119
|
query.cursor = cursor;
|
|
106
120
|
}
|
|
@@ -195,8 +209,7 @@ export type GetTracesResult = {
|
|
|
195
209
|
* const slowFailures = await getTraces({
|
|
196
210
|
* client,
|
|
197
211
|
* project: { projectName: "my-project" },
|
|
198
|
-
*
|
|
199
|
-
* minLatencyMs: 1000,
|
|
212
|
+
* filter: "error_count > 0 and latency_ms >= 1000",
|
|
200
213
|
* });
|
|
201
214
|
* ```
|
|
202
215
|
*/
|
|
@@ -209,6 +222,12 @@ export async function getTraces({
|
|
|
209
222
|
const client = _client ?? createClient();
|
|
210
223
|
validateLatencyBounds({ minLatencyMs, maxLatencyMs });
|
|
211
224
|
await ensureServerCapability({ client, requirement: LIST_PROJECT_TRACES });
|
|
225
|
+
if (params.filter) {
|
|
226
|
+
await ensureServerCapability({
|
|
227
|
+
client,
|
|
228
|
+
requirement: GET_TRACES_FILTER_EXPRESSION,
|
|
229
|
+
});
|
|
230
|
+
}
|
|
212
231
|
if (errorFilter != null || minLatencyMs != null || maxLatencyMs != null) {
|
|
213
232
|
await ensureServerCapability({ client, requirement: GET_TRACES_FILTERS });
|
|
214
233
|
}
|