-
Notifications
You must be signed in to change notification settings - Fork 112
Include deploymentId in Langfuse telemetry metadata #2828
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,46 +1,29 @@ | ||||||||||||||||||||||||||||||||||||||||||||
| import { traceGeneration } from "@giselles-ai/langfuse"; | ||||||||||||||||||||||||||||||||||||||||||||
| import type { | ||||||||||||||||||||||||||||||||||||||||||||
| CompletedGeneration, | ||||||||||||||||||||||||||||||||||||||||||||
| FailedGeneration, | ||||||||||||||||||||||||||||||||||||||||||||
| OutputFileBlob, | ||||||||||||||||||||||||||||||||||||||||||||
| } from "@giselles-ai/protocol"; | ||||||||||||||||||||||||||||||||||||||||||||
| import type { ModelMessage, ProviderMetadata } from "ai"; | ||||||||||||||||||||||||||||||||||||||||||||
| import type { CurrentTeam } from "@/services/teams"; | ||||||||||||||||||||||||||||||||||||||||||||
| import { Langfuse } from "langfuse"; | ||||||||||||||||||||||||||||||||||||||||||||
| import { traceGeneration } from "@repo/langfuse/trace-generation"; | ||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+1
to
+2
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 1. trace.ts imports not organized The new imports in apps/studio.giselles.ai/lib/trace.ts are not organized/sorted in a Biome-compatible way, which can cause formatting/CI failures and inconsistent style. Biome typically expects organized imports (including consistent ordering). Agent Prompt
|
||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| type TeamForPlan = Pick< | ||||||||||||||||||||||||||||||||||||||||||||
| CurrentTeam, | ||||||||||||||||||||||||||||||||||||||||||||
| "id" | "activeSubscriptionId" | "activeCustomerId" | "plan" | ||||||||||||||||||||||||||||||||||||||||||||
| >; | ||||||||||||||||||||||||||||||||||||||||||||
| const langfuse = new Langfuse({ | ||||||||||||||||||||||||||||||||||||||||||||
| secretKey: process.env.LANGFUSE_SECRET_KEY, | ||||||||||||||||||||||||||||||||||||||||||||
| publicKey: process.env.LANGFUSE_PUBLIC_KEY, | ||||||||||||||||||||||||||||||||||||||||||||
| baseUrl: process.env.LANGFUSE_BASE_URL, | ||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+4
to
+8
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 3. Wrong langfuse base env apps/studio.giselles.ai/lib/trace.ts reads LANGFUSE_BASE_URL, but the repo documents LANGFUSE_BASEURL, so baseUrl configuration will not be applied. This can route telemetry to the wrong Langfuse endpoint or fail in self-hosted setups. Agent Prompt
Comment on lines
+1
to
+8
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "== Direct imports of lib/trace from client modules =="
rg -n --type ts --type tsx 'from ["'\''].*lib/trace["'\'']|from ["'\''].*\/trace["'\'']' apps/studio.giselles.ai \
| cut -d: -f1 | sort -u \
| while read -r file; do
if rg -n '^\s*["'\'']use client["'\'']' "$file" >/dev/null; then
echo "CLIENT_IMPORT: $file"
fi
doneRepository: giselles-ai/giselle Length of output: 283 🏁 Script executed: #!/bin/bash
set -euo pipefail
# First, let's check the current content of the trace.ts file
echo "=== Current content of trace.ts ==="
cat -n apps/studio.giselles.ai/lib/trace.ts
echo ""
echo "=== Checking for direct imports of trace module ==="
# Fix: Use simpler regex pattern for ripgrep
rg 'from ["\x27].*trace["\x27]' apps/studio.giselles.ai --type ts --type tsx -n
echo ""
echo "=== Checking for imports with full path ==="
rg 'import.*from.*lib/trace' apps/studio.giselles.ai --type ts --type tsx -n
echo ""
echo "=== Checking for client components that might import trace ==="
rg '(use client|"use client")' apps/studio.giselles.ai --type ts --type tsx -l | head -20Repository: giselles-ai/giselle Length of output: 987 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "=== Searching for imports of trace module ==="
# Search for imports of the trace module
rg 'from ["\x27].*trace["\x27]|import.*trace' apps/studio.giselles.ai -n | grep -i 'lib/trace\|/trace'
echo ""
echo "=== Checking if trace is imported in any client component ==="
# Find all client components first
find apps/studio.giselles.ai -type f \( -name "*.ts" -o -name "*.tsx" \) | while read -r file; do
if grep -q '"use client"' "$file" 2>/dev/null; then
# This is a client component - check if it imports trace
if grep -q 'trace' "$file" 2>/dev/null; then
echo "CLIENT_COMPONENT_WITH_TRACE: $file"
grep -n 'import.*trace\|from.*trace' "$file" 2>/dev/null || true
fi
fi
done
echo ""
echo "=== Searching all imports of trace anywhere ==="
rg 'import.*trace' apps/studio.giselles.ai -n | head -30Repository: giselles-ai/giselle Length of output: 1219 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "=== Checking trigger/generate-content-job.ts ==="
head -30 apps/studio.giselles.ai/trigger/generate-content-job.ts
echo ""
echo "=== Checking app/giselle.ts ==="
head -50 apps/studio.giselles.ai/app/giselle.ts
echo ""
echo "=== Verifying if any of these importing files are client components ==="
for file in apps/studio.giselles.ai/trigger/generate-content-job.ts apps/studio.giselles.ai/app/giselle.ts; do
echo "File: $file"
grep '"use client"' "$file" 2>/dev/null && echo " -> HAS 'use client'" || echo " -> NO 'use client' (server-side)"
done
echo ""
echo "=== Checking what is exported from trace.ts ==="
grep '^export' apps/studio.giselles.ai/lib/trace.tsRepository: giselles-ai/giselle Length of output: 3425 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "=== Full content of trace.ts ==="
wc -l apps/studio.giselles.ai/lib/trace.ts
echo ""
echo "=== Complete trace.ts file ==="
cat apps/studio.giselles.ai/lib/trace.ts
echo ""
echo "=== Searching for traceGenerationForTeam in the entire apps/studio.giselles.ai ==="
rg 'traceGenerationForTeam' apps/studio.giselles.ai -nRepository: giselles-ai/giselle Length of output: 1541 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "=== Searching for traceGenerationForTeam export ==="
rg 'export.*traceGenerationForTeam' apps/studio.giselles.ai -n
echo ""
echo "=== Searching for traceGenerationForTeam definition anywhere in repo ==="
rg 'const traceGenerationForTeam|function traceGenerationForTeam|export.*traceGenerationForTeam' . -n | head -20
echo ""
echo "=== Check if there might be a re-export or aliasing in trace.ts ==="
rg 'traceGenerationForTeam' apps/studio.giselles.ai/lib/trace.ts -nRepository: giselles-ai/giselle Length of output: 114 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "=== Checking if trace.ts might be exporting traceGenerationForTeam via star export or re-export ==="
cat apps/studio.giselles.ai/lib/trace.ts | grep -E 'export|traceGenerationForTeam' || echo "No match found"
echo ""
echo "=== Looking for any trace.ts files ==="
find apps/studio.giselles.ai -name "trace.ts" -o -name "trace.tsx"
echo ""
echo "=== Checking if there's an index file that might re-export ==="
ls -la apps/studio.giselles.ai/lib/ | grep -E 'index|trace'
echo ""
echo "=== Let's verify the actual import line from generate-content-job.ts ==="
sed -n '1,10p' apps/studio.giselles.ai/trigger/generate-content-job.tsRepository: giselles-ai/giselle Length of output: 873 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "=== Searching for traceGenerationForTeam in entire repository ==="
rg 'traceGenerationForTeam' . -n 2>/dev/null | head -30
echo ""
echo "=== Checking `@repo/langfuse` package for this export ==="
find . -path "*/langfuse/*" -name "*.ts" -o -name "*.tsx" 2>/dev/null | head -20
echo ""
echo "=== Checking if there's a langfuse directory ==="
find . -type d -name "langfuse" 2>/dev/nullRepository: giselles-ai/giselle Length of output: 2192 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "=== Looking for langfuse in packages directory ==="
find . -path "*/packages/*langfuse*" -type d 2>/dev/null | head -10
echo ""
echo "=== Checking monorepo structure ==="
ls -la packages/ 2>/dev/null | head -20
echo ""
echo "=== Search for where traceGenerationForTeam might be defined ==="
rg 'export.*function.*traceGenerationForTeam|export const traceGenerationForTeam' . 2>/dev/null
echo ""
echo "=== Check if perhaps the review comment is about a file that doesn't match current state ==="
echo "Looking for any recent changes or different trace files:"
find apps -name "*trace*" -type f 2>/dev/null | grep -v node_modulesRepository: giselles-ai/giselle Length of output: 1402 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "=== Checking packages/langfuse structure ==="
find packages/langfuse -type f -name "*.ts" -o -name "*.tsx" 2>/dev/null
echo ""
echo "=== Checking main export from packages/langfuse ==="
cat packages/langfuse/src/index.ts 2>/dev/null || cat packages/langfuse/src/main.ts 2>/dev/null || ls -la packages/langfuse/src/
echo ""
echo "=== Search for traceGenerationForTeam in packages ==="
rg 'traceGenerationForTeam' packages/ 2>/dev/null
echo ""
echo "=== Check if trace.ts might be a recent addition and this is incomplete ==="
echo "Looking at the actual import in context:"
sed -n '1,25p' apps/studio.giselles.ai/app/giselle.ts | tail -10Repository: giselles-ai/giselle Length of output: 433 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "=== Content of packages/langfuse/src/trace-generation.ts ==="
cat packages/langfuse/src/trace-generation.ts
echo ""
echo "=== Content of packages/langfuse/src/trace-embedding.ts ==="
head -50 packages/langfuse/src/trace-embedding.tsRepository: giselles-ai/giselle Length of output: 1892 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "=== Comprehensive search for traceGenerationForTeam in entire repo ==="
rg 'traceGenerationForTeam' . --type ts --type tsx 2>/dev/null | head -30
echo ""
echo "=== Check if maybe it's defined in app/giselle.ts itself ==="
grep -n 'traceGenerationForTeam\|export.*trace' apps/studio.giselles.ai/app/giselle.ts | head -20
echo ""
echo "=== Check if there's aliasing happening in the imports ==="
grep -A5 'import.*trace' apps/studio.giselles.ai/app/giselle.ts | head -20
echo ""
echo "=== Double-check what's actually exported from trace.ts ==="
grep '^export' apps/studio.giselles.ai/lib/trace.tsRepository: giselles-ai/giselle Length of output: 133 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "=== Checking the exact line where traceGenerationForTeam is imported ==="
sed -n '7p' apps/studio.giselles.ai/trigger/generate-content-job.ts
echo ""
echo "=== Checking if perhaps the file has been modified and export is missing ==="
echo "Full trace.ts again:"
cat -n apps/studio.giselles.ai/lib/trace.ts
echo ""
echo "=== Let's check if there are any TypeScript errors or if this even compiles ==="
echo "Checking tsconfig paths to understand module resolution:"
grep -r '"@/lib' apps/studio.giselles.ai/tsconfig.json 2>/dev/null || grep -r '"@/' tsconfig.json 2>/dev/null | head -5Repository: giselles-ai/giselle Length of output: 1217 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "=== Checking git status to see if trace.ts is being modified ==="
cd apps/studio.giselles.ai && git diff lib/trace.ts 2>/dev/null || echo "No git diff available"
cd - > /dev/null
echo ""
echo "=== Let's verify what the actual issue is - check app/giselle.ts usage ==="
sed -n '228,235p' apps/studio.giselles.ai/app/giselle.ts
echo ""
echo "=== Let's see how traceGenerationForTeam is being called ==="
sed -n '228,245p' apps/studio.giselles.ai/app/giselle.tsRepository: giselles-ai/giselle Length of output: 851 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "=== This is a critical issue - let's understand what traceGenerationForTeam should be ==="
echo "Based on usage patterns, checking if it's supposed to be a wrapper around trace:"
echo ""
echo "=== Check if there's a team parameter in the trace function ==="
sed -n '10,29p' apps/studio.giselles.ai/lib/trace.ts
echo ""
echo "=== Let's check what parameters traceGenerationForTeam receives ==="
sed -n '66,75p' apps/studio.giselles.ai/trigger/generate-content-job.ts
echo ""
echo "=== Summary: Is trace.ts exporting everything it should? ==="
echo "Expected exports from trace.ts based on imports:"
echo "1. trace (currently exported)"
echo "2. traceGenerationForTeam (NOT exported - MISSING!)"
echo ""
echo "=== This appears to be incomplete code - let's verify the review comment is about this file ==="
echo "Review comment references lines 1-8 of trace.ts, which matches what we see."Repository: giselles-ai/giselle Length of output: 1399 Add This module initializes Langfuse with secret keys ( Proposed fix+import "server-only";
import { Langfuse } from "langfuse";
import { traceGeneration } from "@repo/langfuse/trace-generation";📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
Comment on lines
+4
to
+8
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fail fast on missing Langfuse credentials with actionable errors. Lines 5-6 currently pass env vars through without validation. If missing, telemetry failures become hard to diagnose. Proposed fix import { Langfuse } from "langfuse";
import { traceGeneration } from "@repo/langfuse/trace-generation";
+const getRequiredEnvVar = (name: string): string => {
+ const value = process.env[name];
+ if (!value) {
+ throw new Error(`Missing required environment variable: ${name}`);
+ }
+ return value;
+};
+
const langfuse = new Langfuse({
- secretKey: process.env.LANGFUSE_SECRET_KEY,
- publicKey: process.env.LANGFUSE_PUBLIC_KEY,
+ secretKey: getRequiredEnvVar("LANGFUSE_SECRET_KEY"),
+ publicKey: getRequiredEnvVar("LANGFUSE_PUBLIC_KEY"),
baseUrl: process.env.LANGFUSE_BASE_URL,
});🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| export async function traceGenerationForTeam(args: { | ||||||||||||||||||||||||||||||||||||||||||||
| generation: CompletedGeneration | FailedGeneration; | ||||||||||||||||||||||||||||||||||||||||||||
| inputMessages: ModelMessage[]; | ||||||||||||||||||||||||||||||||||||||||||||
| outputFileBlobs?: OutputFileBlob[]; | ||||||||||||||||||||||||||||||||||||||||||||
| export const trace = ({ | ||||||||||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Replacing Useful? React with 👍 / 👎. |
||||||||||||||||||||||||||||||||||||||||||||
| traceId, | ||||||||||||||||||||||||||||||||||||||||||||
| userId, | ||||||||||||||||||||||||||||||||||||||||||||
| sessionId, | ||||||||||||||||||||||||||||||||||||||||||||
| metadata, | ||||||||||||||||||||||||||||||||||||||||||||
| }: { | ||||||||||||||||||||||||||||||||||||||||||||
| traceId: string; | ||||||||||||||||||||||||||||||||||||||||||||
| userId?: string; | ||||||||||||||||||||||||||||||||||||||||||||
| sessionId?: string; | ||||||||||||||||||||||||||||||||||||||||||||
| userId: string; | ||||||||||||||||||||||||||||||||||||||||||||
| team: TeamForPlan; | ||||||||||||||||||||||||||||||||||||||||||||
| providerMetadata?: ProviderMetadata; | ||||||||||||||||||||||||||||||||||||||||||||
| requestId?: string; | ||||||||||||||||||||||||||||||||||||||||||||
| }) { | ||||||||||||||||||||||||||||||||||||||||||||
| const teamPlan = args.team.plan; | ||||||||||||||||||||||||||||||||||||||||||||
| const planTag = `plan:${teamPlan}`; | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| await traceGeneration({ | ||||||||||||||||||||||||||||||||||||||||||||
| generation: args.generation, | ||||||||||||||||||||||||||||||||||||||||||||
| outputFileBlobs: args.outputFileBlobs, | ||||||||||||||||||||||||||||||||||||||||||||
| inputMessages: args.inputMessages, | ||||||||||||||||||||||||||||||||||||||||||||
| userId: args.userId, | ||||||||||||||||||||||||||||||||||||||||||||
| tags: [planTag], | ||||||||||||||||||||||||||||||||||||||||||||
| metadata: { | ||||||||||||||||||||||||||||||||||||||||||||
| generationId: args.generation.id, | ||||||||||||||||||||||||||||||||||||||||||||
| teamPlan, | ||||||||||||||||||||||||||||||||||||||||||||
| userId: args.userId, | ||||||||||||||||||||||||||||||||||||||||||||
| subscriptionId: args.team.activeSubscriptionId ?? "", | ||||||||||||||||||||||||||||||||||||||||||||
| customerId: args.team.activeCustomerId ?? "", | ||||||||||||||||||||||||||||||||||||||||||||
| providerMetadata: args.providerMetadata, | ||||||||||||||||||||||||||||||||||||||||||||
| requestId: args.requestId, | ||||||||||||||||||||||||||||||||||||||||||||
| workspaceId: args.generation.context.origin.workspaceId, | ||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||
| sessionId: args.sessionId, | ||||||||||||||||||||||||||||||||||||||||||||
| metadata?: Record<string, unknown>; | ||||||||||||||||||||||||||||||||||||||||||||
| }) => { | ||||||||||||||||||||||||||||||||||||||||||||
| return traceGeneration({ | ||||||||||||||||||||||||||||||||||||||||||||
| langfuse, | ||||||||||||||||||||||||||||||||||||||||||||
| traceId, | ||||||||||||||||||||||||||||||||||||||||||||
| userId, | ||||||||||||||||||||||||||||||||||||||||||||
| sessionId, | ||||||||||||||||||||||||||||||||||||||||||||
| metadata, | ||||||||||||||||||||||||||||||||||||||||||||
| deploymentId: process.env.VERCEL_DEPLOYMENT_ID, | ||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+10
to
+29
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 2. Missing tracing export apps/studio.giselles.ai/lib/trace.ts no longer exports traceGenerationForTeam, but studio runtime code still imports and calls it, causing a compile-time error. This blocks all code paths that trace generationComplete/generationError and trigger jobs. Agent Prompt
Comment on lines
+10
to
+29
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "== References to removed/old API =="
rg -n -C2 '\btraceGenerationForTeam\b' --type ts --type tsx
echo
echo "== Exports from trace helper modules =="
fd 'trace\.ts$' | while read -r file; do
echo "-- $file"
rg -n 'export\s+(const|function|async function)\s+(trace|traceGenerationForTeam)\b' "$file" || true
doneRepository: giselles-ai/giselle Length of output: 143 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "== References to traceGenerationForTeam =="
rg -n -C2 'traceGenerationForTeam' --type ts || echo "No matches found"
echo
echo "== Checking trace.ts file =="
fd -e ts 'trace\.ts$' -x cat -n {}
echo
echo "== Checking generate-content-job.ts =="
fd -e ts 'generate-content-job\.ts$' -x cat -n {}Repository: giselles-ai/giselle Length of output: 7926 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "== Looking for traceGenerationForTeam definition/export =="
rg -n 'export.*traceGenerationForTeam|function traceGenerationForTeam|const traceGenerationForTeam' --type ts -A 3
echo
echo "== Full contents of trace.ts =="
cat apps/studio.giselles.ai/lib/trace.ts
echo
echo "== Search in repo for traceGenerationForTeam definition =="
rg -n 'traceGenerationForTeam\s*[=:({]' --type ts | head -20Repository: giselles-ai/giselle Length of output: 121 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "== Searching entire codebase for traceGenerationForTeam =="
rg 'traceGenerationForTeam' --type ts -l
echo
echo "== Check if trace.ts is the file under review =="
ls -la apps/studio.giselles.ai/lib/trace.tsRepository: giselles-ai/giselle Length of output: 351 Critical breaking API change: 6 active callsites still reference removed The
These callsites must be migrated to use the new 🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This import switches to
@repo/langfuse/trace-generation, butapps/studio.giselles.ai/tsconfig.jsononly maps@/*and@giselles-ai/*, so the module cannot be resolved during type-check/build. In this state the studio app fails to compile before telemetry runs, so the deploymentId change never reaches production.Useful? React with 👍 / 👎.