Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

feat(aio): add Eve observability support (#74229)

Radu Raicea9c93bdd0e9c7
diff --git a/docs/onboarding/ai-observability/eve.tsx b/docs/onboarding/ai-observability/eve.tsx
new file mode 100644
index 000000000000..fc990aa86433
--- /dev/null
+++ b/docs/onboarding/ai-observability/eve.tsx
@@ -0,0 +1,106 @@
+import { OnboardingComponentsContext, createInstallation } from 'scenes/onboarding/shared/OnboardingDocsContentWrapper'
+
+import { StepDefinition } from '../steps'
+
+export const getEveSteps = (ctx: OnboardingComponentsContext): StepDefinition[] => {
+ const { Blockquote, CalloutBox, CodeBlock, Markdown, dedent, snippets } = ctx
+
+ const NotableGenerationProperties = snippets?.NotableGenerationProperties
+
+ return [
+ {
+ title: 'Install dependencies',
+ badge: 'required',
+ content: (
+ <>
+ <Markdown>
+ Install the PostHog AI exporter, OpenTelemetry HTTP exporter, and Vercel's OpenTelemetry
+ package.
+ </Markdown>
+
+ <CodeBlock
+ language="bash"
+ code={dedent`
+ npm install @posthog/ai @opentelemetry/exporter-trace-otlp-http @vercel/otel
+ `}
+ />
+ </>
+ ),
+ },
+ {
+ title: 'Set environment variables',
+ badge: 'required',
+ content: (
+ <>
+ <Markdown>Set your PostHog project token and host in your Eve project's environment.</Markdown>
+
+ <CodeBlock
+ language="bash"
+ code={dedent`
+ POSTHOG_PROJECT_TOKEN=<ph_project_token>
+ POSTHOG_HOST=<ph_client_api_host>
+ `}
+ />
+ </>
+ ),
+ },
+ {
+ title: 'Add Eve instrumentation',
+ badge: 'required',
+ content: (
+ <>
+ <Markdown>
+ Create `agent/instrumentation.ts`. Eve discovers this file and starts the exporter when your
+ agent server starts.
+ </Markdown>
+
+ <CodeBlock
+ language="typescript"
+ code={dedent`
+ import { PostHogTraceExporter } from '@posthog/ai/otel'
+ import { registerOTel } from '@vercel/otel'
+ import { defineInstrumentation } from 'eve/instrumentation'
+
+ export default defineInstrumentation({
+ setup: ({ agentName }) =>
+ registerOTel({
+ serviceName: agentName,
+ traceExporter: new PostHogTraceExporter({
+ projectToken: process.env.POSTHOG_PROJECT_TOKEN!,
+ host: process.env.POSTHOG_HOST,
+ }),
+ }),
+ })
+ `}
+ />
+
+ <CalloutBox type="fyi" icon="IconInfo" title="How this works">
+ <Markdown>
+ Eve emits Vercel AI SDK OpenTelemetry spans. `PostHogTraceExporter` sends the AI spans to
+ PostHog's OTLP ingestion endpoint. PostHog keeps the trace hierarchy, identifies the
+ framework as Eve, and groups turns using `eve.session.id`.
+ </Markdown>
+ </CalloutBox>
+
+ <Blockquote>
+ <Markdown>
+ **Data capture:** Eve records full message history and model outputs by default. Set
+ `recordInputs: false` or `recordOutputs: false` in `defineInstrumentation` if you do not
+ want that data included in exported spans.
+ </Markdown>
+ </Blockquote>
+
+ <Markdown>
+ {dedent`
+ You can expect captured \`$ai_generation\` events to have the following properties:
+ `}
+ </Markdown>
+
+ {NotableGenerationProperties && <NotableGenerationProperties />}
+ </>
+ ),
+ },
+ ]
+}
+
+export const EveInstallation = createInstallation(getEveSteps)
diff --git a/frontend/src/scenes/onboarding/legacy/sdks/ai-observability/AIObservabilitySDKInstructions.tsx b/frontend/src/scenes/onboarding/legacy/sdks/ai-observability/AIObservabilitySDKInstructions.tsx
index 695f83b3ddd6..74c8cc90179a 100644
--- a/frontend/src/scenes/onboarding/legacy/sdks/ai-observability/AIObservabilitySDKInstructions.tsx
+++ b/frontend/src/scenes/onboarding/legacy/sdks/ai-observability/AIObservabilitySDKInstructions.tsx
@@ -15,6 +15,7 @@ import { CrewAIInstallation } from '@posthog/shared-onboarding/ai-observability/
import { DedalusInstallation } from '@posthog/shared-onboarding/ai-observability/dedalus'
import { DeepSeekInstallation } from '@posthog/shared-onboarding/ai-observability/deepseek'
import { DSPyInstallation } from '@posthog/shared-onboarding/ai-observability/dspy'
+import { EveInstallation } from '@posthog/shared-onboarding/ai-observability/eve'
import { FireworksAIInstallation } from '@posthog/shared-onboarding/ai-observability/fireworks-ai'
import { GoogleInstallation } from '@posthog/shared-onboarding/ai-observability/google'
import { GroqInstallation } from '@posthog/shared-onboarding/ai-observability/groq'
@@ -95,6 +96,10 @@ const LLMVercelAIInstructionsWrapper = withOnboardingDocsWrapper({
Installation: VercelAIInstallation,
snippets: PROVIDER_SNIPPETS,
})
+const LLMEveInstructionsWrapper = withOnboardingDocsWrapper({
+ Installation: EveInstallation,
+ snippets: PROVIDER_SNIPPETS,
+})
const LLMVercelAIGatewayInstructionsWrapper = withOnboardingDocsWrapper({
Installation: VercelAIGatewayInstallation,
snippets: PROVIDER_SNIPPETS,
@@ -234,6 +239,7 @@ export const AIObservabilitySDKInstructions: SDKInstructionsMap = {
[SDKKey.AWS_BEDROCK]: LLMAWSBedrockInstructionsWrapper,
[SDKKey.GOOGLE_GEMINI]: LLMGoogleInstructionsWrapper,
[SDKKey.VERCEL_AI]: LLMVercelAIInstructionsWrapper,
+ [SDKKey.EVE]: LLMEveInstructionsWrapper,
[SDKKey.VERCEL_AI_GATEWAY]: LLMVercelAIGatewayInstructionsWrapper,
[SDKKey.LANGCHAIN]: LLMLangChainInstructionsWrapper,
[SDKKey.LITELLM]: LLMLiteLLMInstructionsWrapper,
diff --git a/frontend/src/scenes/onboarding/legacy/sdks/allSDKs.tsx b/frontend/src/scenes/onboarding/legacy/sdks/allSDKs.tsx
index 8dffa85827f2..40ac3d62a0d3 100644
--- a/frontend/src/scenes/onboarding/legacy/sdks/allSDKs.tsx
+++ b/frontend/src/scenes/onboarding/legacy/sdks/allSDKs.tsx
@@ -225,6 +225,14 @@ export const ALL_SDKS: SDK[] = [
image: 'https://res.cloudinary.com/dmukukwp6/image/upload/vercel_373fa70879.svg',
docsLink: 'https://posthog.com/docs/ai-observability/installation/vercel-ai',
},
+ {
+ name: 'Eve',
+ key: SDKKey.EVE,
+ tags: [SDKTag.FRAMEWORK],
+ searchTerms: ['Vercel Eve', 'agent'],
+ image: 'https://res.cloudinary.com/dmukukwp6/image/upload/vercel_373fa70879.svg',
+ docsLink: 'https://posthog.com/docs/ai-observability/installation/eve',
+ },
{
name: 'LangChain',
key: SDKKey.LANGCHAIN,
diff --git a/frontend/src/types.ts b/frontend/src/types.ts
index 6488407df8f4..e5a3ef510089 100644
--- a/frontend/src/types.ts
+++ b/frontend/src/types.ts
@@ -6906,6 +6906,7 @@ export enum SDKKey {
DOTNET = 'dotnet',
DSPY = 'dspy',
ELIXIR = 'elixir',
+ EVE = 'eve',
FRAMER = 'framer',
FIREWORKS_AI = 'fireworks_ai',
FLUTTER = 'flutter',
diff --git a/nodejs/src/ingestion/pipelines/ai/otel/middleware/vercel-ai.test.ts b/nodejs/src/ingestion/pipelines/ai/otel/middleware/vercel-ai.test.ts
index ce6ed59b8158..f1c73b1df25b 100644
--- a/nodejs/src/ingestion/pipelines/ai/otel/middleware/vercel-ai.test.ts
+++ b/nodejs/src/ingestion/pipelines/ai/otel/middleware/vercel-ai.test.ts
@@ -28,6 +28,7 @@ function mockMapOtelAttributes(e: { event: string; properties?: Record<string, u
'gen_ai.usage.cache_creation.input_tokens': '$ai_cache_creation_input_tokens',
'gen_ai.response.model': '$ai_model',
'gen_ai.provider.name': '$ai_provider',
+ $otel_span_name: '$ai_span_name',
}
if (props['gen_ai.input.messages'] !== undefined) {
const val = props['gen_ai.input.messages']
@@ -595,4 +596,28 @@ describe('vercel-ai middleware', () => {
expect(event.properties!['$ai_framework']).toBe('vercel')
})
})
+
+ describe('Eve', () => {
+ it('normalizes Eve turns with filtered Workflow parents as trace roots', () => {
+ const event = createEvent('$ai_span', {
+ 'eve.version': '0.27.8',
+ 'eve.environment': 'production',
+ 'eve.session.id': 'session-123',
+ 'eve.turn.id': 'turn-1',
+ 'ai.telemetry.functionId': 'customer-support',
+ $ai_parent_id: 'filtered-workflow-step',
+ $otel_span_name: 'ai.eve.turn',
+ })
+ convertOtelEvent(event)
+
+ expect(event.event).toBe('$ai_trace')
+ expect(event.properties!['$ai_parent_id']).toBeUndefined()
+ expect(event.properties!['$ai_span_name']).toBe('customer-support')
+ expect(event.properties!['$ai_framework']).toBe('eve')
+ expect(event.properties!['$ai_session_id']).toBe('session-123')
+ expect(event.properties!['eve.session.id']).toBeUndefined()
+ expect(event.properties!['$ai_lib']).toBe('opentelemetry/vercel-ai')
+ expect(event.properties!['eve.turn.id']).toBe('turn-1')
+ })
+ })
})
diff --git a/nodejs/src/ingestion/pipelines/ai/otel/middleware/vercel-ai.ts b/nodejs/src/ingestion/pipelines/ai/otel/middleware/vercel-ai.ts
index a1642890ebdc..1d17c1d2502f 100644
--- a/nodejs/src/ingestion/pipelines/ai/otel/middleware/vercel-ai.ts
+++ b/nodejs/src/ingestion/pipelines/ai/otel/middleware/vercel-ai.ts
@@ -5,11 +5,9 @@ import { PluginEvent } from '~/plugin-scaffold'
import { promotePosthogCustomMetadata } from './custom-metadata'
import { OtelLibraryMiddleware } from './types'
-// Vercel AI SDK attributes to strip after processing. Includes both
-// Vercel-specific ai.* attributes and standard GenAI semantic convention
-// attributes that have already been mapped to $ai_* properties.
+// Provider-specific and standard attributes to strip after processing.
const STRIP_KEYS = [
- // Vercel AI SDK specific
+ // Vercel AI SDK and Eve-specific
'ai.operationId',
'ai.telemetry.functionId',
'ai.model.id',
@@ -44,6 +42,7 @@ const STRIP_KEYS = [
'ai.schema.description',
'operation.name',
'resource.name',
+ 'eve.session.id',
// Standard GenAI semantic convention attributes not mapped to $ai_* properties
'gen_ai.request.max_tokens',
'gen_ai.response.id',
@@ -52,6 +51,8 @@ const STRIP_KEYS = [
// Metadata properties to promote to event properties
const STRING_AI_METADATA_KEYS = ['$ai_session_id', '$ai_prompt_name']
const AI_PROMPT_VERSION_KEY = '$ai_prompt_version'
+const EVE_MARKER_KEYS = ['eve.version', 'eve.session.id']
+const EVE_TURN_SPAN_NAME = 'ai.eve.turn'
function isNonEmptyString(value: unknown): value is string {
return typeof value === 'string' && value.length > 0
@@ -61,6 +62,17 @@ function isPromptVersion(value: unknown): value is string | number {
return isNonEmptyString(value) || (typeof value === 'number' && Number.isInteger(value) && value > 0)
}
+function isEveSpan(props: Record<string, unknown>): boolean {
+ return EVE_MARKER_KEYS.some((key) => props[key] !== undefined)
+}
+
+function isEveTurnSpan(props: Record<string, unknown>): boolean {
+ return (
+ isEveSpan(props) &&
+ (props['$otel_span_name'] === EVE_TURN_SPAN_NAME || props['$ai_span_name'] === EVE_TURN_SPAN_NAME)
+ )
+}
+
// Vercel AI SDK top-level spans (ai.generateText/ai.streamText/ai.*Object) record
// ai.prompt as a JSON object — { system?, prompt?, messages? } — not a bare
// messages array. Flatten it into a messages array so it maps to $ai_input.
@@ -105,6 +117,12 @@ function process(event: PluginEvent, next: () => void): void {
return next()
}
const props = event.properties
+ const eveSpan = isEveSpan(props)
+
+ // Eve's Workflow parent is filtered before ingestion, so the turn must become the logical trace root.
+ if (isEveTurnSpan(props)) {
+ delete props['$ai_parent_id']
+ }
// Capture opId before next() since STRIP_KEYS deletes it afterward
const opId = props['ai.operationId']
@@ -284,8 +302,15 @@ function process(event: PluginEvent, next: () => void): void {
delete props['ai.response.finishReason']
delete props['gen_ai.response.finish_reasons']
+ if (eveSpan) {
+ const eveSessionId = props['eve.session.id']
+ if (props['$ai_session_id'] === undefined && isNonEmptyString(eveSessionId)) {
+ props['$ai_session_id'] = eveSessionId
+ }
+ }
+
props['$ai_lib'] = 'opentelemetry/vercel-ai'
- props['$ai_framework'] ??= 'vercel'
+ props['$ai_framework'] ??= eveSpan ? 'eve' : 'vercel'
if (props['$ai_reasoning_tokens'] === undefined && aiSdkV7ReasoningTokens !== undefined) {
props['$ai_reasoning_tokens'] = aiSdkV7ReasoningTokens
@@ -311,7 +336,7 @@ function process(event: PluginEvent, next: () => void): void {
}
}
-const MARKER_KEYS = ['ai.operationId', 'ai.telemetry.functionId']
+const MARKER_KEYS = ['ai.operationId', 'ai.telemetry.functionId', ...EVE_MARKER_KEYS]
export const vercelAi: OtelLibraryMiddleware = {
name: 'vercel-ai',
diff --git a/posthog/hogql_queries/ai/session_query_runner.py b/posthog/hogql_queries/ai/session_query_runner.py
index eb09ba0c686d..5d07c1088304 100644
--- a/posthog/hogql_queries/ai/session_query_runner.py
+++ b/posthog/hogql_queries/ai/session_query_runner.py
@@ -84,7 +84,10 @@ class SessionQueryRunner(AnalyticsQueryRunner[SessionQueryResponse]):
tag_queries(ai_query_source="dedicated_table")
query_result = self.paginator.execute_hogql_query(
query=query,
- placeholders={"filter_conditions": rewrite_expr_for_ai_events_table(self._get_session_filter())},
+ placeholders={
+ "session_filter_conditions": rewrite_expr_for_ai_events_table(self._get_session_filter()),
+ "trace_filter_conditions": rewrite_expr_for_ai_events_table(self._get_trace_filter()),
+ },
team=self.team,
user=self.user,
query_type=NodeKind.SESSION_QUERY,
@@ -94,10 +97,11 @@ class SessionQueryRunner(AnalyticsQueryRunner[SessionQueryResponse]):
)
if not query_result.results:
- fallback_filter = self._get_events_fallback_filter()
- if fallback_filter is None:
+ fallback_filters = self._get_events_fallback_filters()
+ if fallback_filters is None:
return self._response_from_query_result(query_result, [])
+ fallback_session_filter, fallback_trace_filter = fallback_filters
with (
self.timings.measure("session_query_events_fallback_execute"),
tags_context(product=Product.LLM_ANALYTICS),
@@ -106,7 +110,10 @@ class SessionQueryRunner(AnalyticsQueryRunner[SessionQueryResponse]):
events_schema = use_new_events_schema(self.team.pk)
query_result = self.paginator.execute_hogql_query(
query=rewrite_query_for_events_table(query),
- placeholders={"filter_conditions": rewrite_expr_for_events_table(fallback_filter)},
+ placeholders={
+ "session_filter_conditions": rewrite_expr_for_events_table(fallback_session_filter),
+ "trace_filter_conditions": rewrite_expr_for_events_table(fallback_trace_filter),
+ },
team=self.team,
user=self.user,
query_type="SessionQueryEventsFallback",
@@ -239,7 +246,12 @@ class SessionQueryRunner(AnalyticsQueryRunner[SessionQueryResponse]):
WHERE event IN (
'$ai_span', '$ai_generation', '$ai_embedding', '$ai_metric', '$ai_feedback', '$ai_trace'
)
- AND {filter_conditions}
+ AND {trace_filter_conditions}
+ AND trace_id IN (
+ SELECT trace_id
+ FROM posthog.ai_events AS ai_events
+ WHERE {session_filter_conditions}
+ )
GROUP BY trace_id
ORDER BY first_timestamp DESC
""",
@@ -265,7 +277,7 @@ class SessionQueryRunner(AnalyticsQueryRunner[SessionQueryResponse]):
def _has_fallback_date_range(self) -> bool:
return bool(self.query.dateRange and self.query.dateRange.date_from)
- def _get_session_filter(self) -> ast.Expr:
+ def _get_trace_filter(self) -> ast.Expr:
return ast.And(
exprs=[
ast.Call(name="isNotNull", args=[ast.Field(chain=["ai_events", "trace_id"])]),
@@ -274,6 +286,13 @@ class SessionQueryRunner(AnalyticsQueryRunner[SessionQueryResponse]):
left=ast.Field(chain=["ai_events", "trace_id"]),
right=ast.Constant(value=""),
),
+ ]
+ )
+
+ def _get_session_filter(self) -> ast.Expr:
+ return ast.And(
+ exprs=[
+ self._get_trace_filter(),
ast.Call(name="isNotNull", args=[ast.Field(chain=["ai_events", "session_id"])]),
ast.CompareOperation(
op=ast.CompareOperationOp.Eq,
@@ -283,13 +302,12 @@ class SessionQueryRunner(AnalyticsQueryRunner[SessionQueryResponse]):
]
)
- def _get_events_fallback_filter(self) -> ast.Expr | None:
+ def _get_events_fallback_filters(self) -> tuple[ast.Expr, ast.Expr] | None:
if not self._has_fallback_date_range():
return None
- return ast.And(
+ date_filter = ast.And(
exprs=[
- self._get_session_filter(),
ast.CompareOperation(
op=ast.CompareOperationOp.GtEq,
left=ast.Field(chain=["ai_events", "timestamp"]),
@@ -300,7 +318,11 @@ class SessionQueryRunner(AnalyticsQueryRunner[SessionQueryResponse]):
left=ast.Field(chain=["ai_events", "timestamp"]),
right=self._date_range.date_to_as_hogql(),
),
- ]
+ ],
+ )
+ return (
+ ast.And(exprs=[self._get_session_filter(), date_filter]),
+ ast.And(exprs=[self._get_trace_filter(), date_filter]),
)
def _response_from_query_result(self, query_result: Any, results: list[LLMTrace]) -> SessionQueryResponse:
diff --git a/posthog/hogql_queries/ai/test/test_session_query_runner.py b/posthog/hogql_queries/ai/test/test_session_query_runner.py
index bdc7d8e5cada..240bc3ccbca4 100644
--- a/posthog/hogql_queries/ai/test/test_session_query_runner.py
+++ b/posthog/hogql_queries/ai/test/test_session_query_runner.py
@@ -16,14 +16,13 @@ from posthog.models.event.util import bulk_create_events
def _create_ai_generation_event_in_events_table(
*,
team: Team,
- session_id: str,
+ session_id: str | None,
trace_id: str,
distinct_id: str = "person1",
timestamp: datetime | None = None,
properties: dict[str, Any] | None = None,
) -> None:
props = {
- "$ai_session_id": session_id,
"$ai_trace_id": trace_id,
"$ai_latency": 1,
"$ai_input": [{"role": "user", "content": "hello"}],
@@ -33,6 +32,9 @@ def _create_ai_generation_event_in_events_table(
"$ai_total_cost_usd": 0.01,
**(properties or {}),
}
+ if session_id is not None:
+ props["$ai_session_id"] = session_id
+
bulk_create_events(
[
{
@@ -51,17 +53,32 @@ def _select_queries_without_metadata(queries: list[str]) -> list[str]:
class TestSessionQueryRunner(ClickhouseTestMixin, BaseTest):
- def test_reads_from_ai_events_without_date_range(self) -> None:
+ def test_reads_complete_trace_when_only_root_has_session_id(self) -> None:
bulk_create_ai_events(
[
{
- "event": "$ai_generation",
+ "event": "$ai_trace",
"distinct_id": "person1",
"team": self.team,
"timestamp": datetime(2025, 1, 15, 0, 0, tzinfo=UTC),
"properties": {
"$ai_session_id": "session-ai-events",
"$ai_trace_id": "trace-ai-events",
+ "$ai_span_id": "turn-root",
+ "$ai_span_name": "ai.eve.turn",
+ "$ai_framework": "eve",
+ "$ai_latency": 3,
+ },
+ },
+ {
+ "event": "$ai_generation",
+ "distinct_id": "person1",
+ "team": self.team,
+ "timestamp": datetime(2025, 1, 15, 0, 1, tzinfo=UTC),
+ "properties": {
+ "$ai_trace_id": "trace-ai-events",
+ "$ai_span_id": "generation-child",
+ "$ai_parent_id": "turn-root",
"$ai_latency": 1,
"$ai_input": [{"role": "user", "content": "hello"}],
"$ai_output_choices": [{"role": "assistant", "content": "hi"}],
@@ -69,7 +86,20 @@ class TestSessionQueryRunner(ClickhouseTestMixin, BaseTest):
"$ai_output_tokens": 2,
"$ai_total_cost_usd": 0.01,
},
- }
+ },
+ {
+ "event": "$ai_span",
+ "distinct_id": "person1",
+ "team": self.team,
+ "timestamp": datetime(2025, 1, 15, 0, 2, tzinfo=UTC),
+ "properties": {
+ "$ai_trace_id": "trace-ai-events",
+ "$ai_span_id": "tool-child",
+ "$ai_parent_id": "generation-child",
+ "$ai_span_name": "search",
+ "$ai_latency": 0.5,
+ },
+ },
]
)
@@ -85,8 +115,16 @@ class TestSessionQueryRunner(ClickhouseTestMixin, BaseTest):
self.assertEqual(len(select_queries), 1)
self.assertIn("ai_events", select_queries[0])
self.assertEqual(len(response.results), 1)
- self.assertEqual(response.results[0].id, "trace-ai-events")
- self.assertEqual(response.results[0].events[0].properties["$ai_input"][0]["content"], "hello")
+ trace = response.results[0]
+ self.assertEqual(trace.id, "trace-ai-events")
+ self.assertEqual(trace.aiSessionId, "session-ai-events")
+ self.assertEqual([event.event for event in trace.events], ["$ai_generation", "$ai_span"])
+ self.assertEqual(trace.events[0].properties["$ai_input"][0]["content"], "hello")
+ self.assertEqual(trace.events[1].properties["$ai_span_name"], "search")
+ self.assertEqual(trace.inputTokens, 5)
+ self.assertEqual(trace.outputTokens, 2)
+ self.assertAlmostEqual(trace.totalCost or 0, 0.01)
+ self.assertEqual(trace.totalLatency, 3)
def test_paginates_session_traces(self) -> None:
bulk_create_ai_events(
@@ -246,11 +284,29 @@ class TestSessionQueryRunner(ClickhouseTestMixin, BaseTest):
self.assertEqual(response.results, [])
def test_falls_back_to_events_with_date_from_only_range(self) -> None:
+ bulk_create_events(
+ [
+ {
+ "event": "$ai_trace",
+ "distinct_id": "person1",
+ "properties": {
+ "$ai_session_id": "session-date-from",
+ "$ai_trace_id": "trace-date-from",
+ "$ai_span_id": "turn-root",
+ "$ai_span_name": "ai.eve.turn",
+ "$ai_latency": 3,
+ },
+ "team": self.team,
+ "timestamp": datetime(2025, 1, 15, 0, 0, tzinfo=UTC),
+ }
+ ]
+ )
_create_ai_generation_event_in_events_table(
team=self.team,
- session_id="session-date-from",
+ session_id=None,
trace_id="trace-date-from",
- timestamp=datetime(2025, 1, 15, 0, 0, tzinfo=UTC),
+ timestamp=datetime(2025, 1, 15, 0, 1, tzinfo=UTC),
+ properties={"$ai_parent_id": "turn-root"},
)
runner = SessionQueryRunner(
@@ -272,5 +328,11 @@ class TestSessionQueryRunner(ClickhouseTestMixin, BaseTest):
self.assertIn("ai_events", select_queries[0])
self.assertIn("__ai_events_fallback.timestamp", select_queries[1])
self.assertEqual(len(response.results), 1)
- self.assertEqual(response.results[0].id, "trace-date-from")
- self.assertEqual(response.results[0].events[0].properties["$ai_output_choices"][0]["content"], "hi")
+ trace = response.results[0]
+ self.assertEqual(trace.id, "trace-date-from")
+ self.assertEqual(trace.aiSessionId, "session-date-from")
+ self.assertEqual(trace.events[0].properties["$ai_output_choices"][0]["content"], "hi")
+ self.assertEqual(trace.inputTokens, 5)
+ self.assertEqual(trace.outputTokens, 2)
+ self.assertAlmostEqual(trace.totalCost or 0, 0.01)
+ self.assertEqual(trace.totalLatency, 3)
diff --git a/rust/capture/src/otel/providers.rs b/rust/capture/src/otel/providers.rs
index 3b0a06ad023e..962b6757934a 100644
--- a/rust/capture/src/otel/providers.rs
+++ b/rust/capture/src/otel/providers.rs
@@ -37,9 +37,10 @@ const GEN_AI: SupportedProvider = SupportedProvider {
},
};
-/// Vercel AI SDK (`ai.*`).
+/// Vercel AI SDK (`ai.*`) and Eve (`eve.*`). Eve root turn spans can omit
+/// `ai.*` attributes, so its namespace must be accepted by the same provider.
const VERCEL_AI: SupportedProvider = SupportedProvider {
- prefixes: &["ai."],
+ prefixes: &["ai.", "eve."],
classify: |attrs| {
classify_by_key(attrs, "ai.operationId", |op_id| match op_id {
s if s.ends_with(".doGenerate") || s.ends_with(".doStream") => "$ai_generation",
@@ -217,6 +218,10 @@ mod tests {
get_event_name(&attrs_with("gen_ai.request.model", "gpt-4")),
Some("$ai_span")
);
+ assert_eq!(
+ get_event_name(&attrs_with("eve.session.id", "session-123")),
+ Some("$ai_span")
+ );
assert_eq!(
get_event_name(&attrs_with("pydantic_ai.agent_name", "my-agent")),
Some("$ai_span")