🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.
TypeScript analyticsautogenevaluationlangchainlarge-language-modelsllama-indexllmllm-evaluationllm-observabilityllmopsmonitoringobservabilityopen-sourceopenaiplaygroundprompt-engineeringprompt-managementself-hostedycombinator
feat(observations-v2): expose trace_context field group in public API (#13620)
Niklas Semmler41c45ca342ee
diff --git a/fern/apis/server/definition/commons.yml b/fern/apis/server/definition/commons.ymlindex c3c300a8ec..2618781bf5 100644--- a/fern/apis/server/definition/commons.yml+++ b/fern/apis/server/definition/commons.yml@@ -326,6 +326,17 @@ types:type: optional<nullable<string>>docs: The matched model ID+ # Trace context fields (field group: trace_context)+ traceName:+ type: optional<nullable<string>>+ docs: The name of the parent trace+ tags:+ type: optional<nullable<list<string>>>+ docs: Tags from the parent trace (denormalized onto the observation)+ release:+ type: optional<nullable<string>>+ docs: The release version of the parent trace+Usage:docs: (Deprecated. Use usageDetails and costDetails instead.) Standard interface for usage and costproperties:diff --git a/fern/apis/server/definition/observations.yml b/fern/apis/server/definition/observations.ymlindex b2aa296972..e8052e19cd 100644--- a/fern/apis/server/definition/observations.yml+++ b/fern/apis/server/definition/observations.yml@@ -25,6 +25,7 @@ service:- `usage` - usageDetails, costDetails, totalCost, usagePricingTierName- `prompt` - promptId, promptName, promptVersion- `metrics` - latency, timeToFirstToken+ - `trace_context` - tags, release, traceNameIf not specified, `core` and `basic` field groups are returned.@@ -40,7 +41,7 @@ service:type: optional<string>docs: |Comma-separated list of field groups to include in the response.- Available groups: core, basic, time, io, metadata, model, usage, prompt, metrics.+ Available groups: core, basic, time, io, metadata, model, usage, prompt, metrics, trace_context.If not specified, `core` and `basic` field groups are returned.Example: "basic,usage,model"expandMetadata:diff --git a/packages/shared/src/domain/observation-field-groups.ts b/packages/shared/src/domain/observation-field-groups.tsindex efd4a4c71e..a6bbf6164b 100644--- a/packages/shared/src/domain/observation-field-groups.ts+++ b/packages/shared/src/domain/observation-field-groups.ts@@ -8,8 +8,8 @@* - OBSERVATION_FIELD_GROUPS_PUBLIC_API: v2 public API contract — the groups that the* v2 observations endpoint can return.* - OBSERVATION_FIELD_GROUPS_FULL: the complete set of column groups the- * events repository can project, including denormalized trace context and- * tool fields that the public API does not currently expose.+ * events repository can project, including tool fields that the public API+ * does not currently expose.** Defined in the client-safe domain layer (not inside the server-only* repository file) so frontend forms and Zod enums can reference the values@@ -26,6 +26,7 @@ export const OBSERVATION_FIELD_GROUPS_PUBLIC_API = ["usage", // usageDetails, costDetails, totalCost, usagePricingTierName"prompt", // promptId, promptName, promptVersion"metrics", // latency, timeToFirstToken+ "trace_context", // tags, release, traceName (denormalized trace metadata)] as const;export type ObservationFieldGroupPublicApi =@@ -34,7 +35,6 @@ export type ObservationFieldGroupPublicApi =export const OBSERVATION_FIELD_GROUPS_FULL = [...OBSERVATION_FIELD_GROUPS_PUBLIC_API,"tools", // toolDefinitions, toolCalls, toolCallNames- "trace_context", // tags, release, traceName (denormalized trace metadata)] as const;export type ObservationFieldGroupFull =diff --git a/packages/shared/src/domain/observations.ts b/packages/shared/src/domain/observations.tsindex e9e7a921e4..9bcdf98c84 100644--- a/packages/shared/src/domain/observations.ts+++ b/packages/shared/src/domain/observations.ts@@ -117,7 +117,7 @@ export const EventsObservationSchema = ObservationSchema.extend({sessionId: z.string().nullable(),traceName: z.string().nullable(),release: z.string().nullable().optional(),- tags: z.array(z.string()).optional(),+ tags: z.array(z.string()).nullable().optional(),bookmarked: z.boolean().optional(),public: z.boolean().optional(),});diff --git a/packages/shared/src/server/repositories/observations_converters.ts b/packages/shared/src/server/repositories/observations_converters.tsindex b17bf9a5a5..e555c36101 100644--- a/packages/shared/src/server/repositories/observations_converters.ts+++ b/packages/shared/src/server/repositories/observations_converters.ts@@ -412,7 +412,7 @@ export function convertEventsObservation(sessionId: record.session_id ?? null,traceName: record.trace_name ?? null,release: record.release ?? null,- tags: record.tags ?? [],+ tags: record.tags ?? null,bookmarked: record.bookmarked,public: record.public,};diff --git a/web/public/generated/api/openapi.yml b/web/public/generated/api/openapi.ymlindex 2d38dacf45..047522354b 100644--- a/web/public/generated/api/openapi.yml+++ b/web/public/generated/api/openapi.yml@@ -3133,6 +3133,8 @@ paths:- `metrics` - latency, timeToFirstToken+ - `trace_context` - tags, release, traceName+If not specified, `core` and `basic` field groups are returned.@@ -3154,7 +3156,7 @@ paths:Comma-separated list of field groups to include in the response.Available groups: core, basic, time, io, metadata, model, usage,- prompt, metrics.+ prompt, metrics, trace_context.If not specified, `core` and `basic` field groups are returned.@@ -8113,6 +8115,20 @@ components:type: stringnullable: truedescription: The matched model ID+ traceName:+ type: string+ nullable: true+ description: The name of the parent trace+ tags:+ type: array+ items:+ type: string+ nullable: true+ description: Tags from the parent trace (denormalized onto the observation)+ release:+ type: string+ nullable: true+ description: The release version of the parent tracerequired:- id- startTimediff --git a/web/src/__tests__/server/observations-api-v2.servertest.ts b/web/src/__tests__/server/observations-api-v2.servertest.tsindex d4fd3462ed..bb4b582038 100644--- a/web/src/__tests__/server/observations-api-v2.servertest.ts+++ b/web/src/__tests__/server/observations-api-v2.servertest.ts@@ -539,6 +539,10 @@ describe("/api/public/v2/observations API Endpoint", () => {"promptId","promptName","promptVersion",+ // trace_context+ "traceName",+ "tags",+ "release",] as const;let sharedObsId: string;@@ -581,6 +585,9 @@ describe("/api/public/v2/observations API Endpoint", () => {output: "contract output",metadata_names: ["key"],metadata_values: ["val"],+ trace_name: "contract-trace",+ tags: ["tag-a", "tag-b"],+ release: "1.2.3",});await createEventsCh([obs]);@@ -605,6 +612,9 @@ describe("/api/public/v2/observations API Endpoint", () => {promptVersion: 2,input: "contract input",output: "contract output",+ traceName: "contract-trace",+ tags: ["tag-a", "tag-b"],+ release: "1.2.3",usagePricingTierName: "contract-tier",};@@ -636,6 +646,7 @@ describe("/api/public/v2/observations API Endpoint", () => {// end_time), but the metrics group is still defined for documentation and to verify these fields are indeed// presentmetrics: ["latency", "timeToFirstToken"],+ trace_context: ["traceName", "tags", "release"],};for (const [group, expectedFields] of Object.entries(fieldsForGroup)) {diff --git a/web/src/features/public-api/types/observations.ts b/web/src/features/public-api/types/observations.tsindex d14cc815e3..1c917893ad 100644--- a/web/src/features/public-api/types/observations.ts+++ b/web/src/features/public-api/types/observations.ts@@ -156,6 +156,9 @@ export const transformDbToApiObservation = (// exclude trace name, this will only be available on events apitraceName,+ // exclude release, this will only be available on events api+ release,+// Exclude tagstags,traceTags,@@ -440,6 +443,11 @@ const APIObservationV2 = z// Enrichment fieldsmodelId: z.string().nullable().optional(),++ // Trace context fields (field group: trace_context)+ traceName: z.string().nullable().optional(),+ tags: z.array(z.string()).nullable().optional(),+ release: z.string().nullable().optional(),}).loose();