Skip to content
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

[feat] Add user tracking and enhance telemetry with execution context #286

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

toyamarinyon
Copy link
Contributor

Changes

  • Add userId to execution parameters for better user-specific tracking
  • Introduce execution context with userId for enhanced telemetry data
  • Modify performFlowExecution to include userId in experimental telemetry
  • Implement parseExecutionContextToTelemetryMetadata for consistent data formatting
  • Refactor waitForLangfuseFlush to improve execution scheduling
  • Update page functions to propagate userId from user context

Stacks

This repository stacked on #285

@toyamarinyon toyamarinyon requested a review from shige as a code owner January 6, 2025 00:36
Copy link

vercel bot commented Jan 6, 2025

@toyamarinyon is attempting to deploy a commit to the Edge Team on Vercel.

A member of the Team first needs to authorize it.

Copy link

vercel bot commented Jan 6, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
giselle ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 6, 2025 4:52am

@shige shige requested a review from Rindrics January 6, 2025 00:50
@shige
Copy link
Member

shige commented Jan 6, 2025

I would like to ask @Rindrics to review the code as well!

Copy link
Contributor

@Rindrics Rindrics left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

I understand that userId will be introduced to the Langfuse telemetry.

I left one should suggestion .

tsconfig.json Outdated
@@ -19,7 +19,11 @@
}
],
"paths": {
"@/*": ["./*"]
"@/*": ["./*"],
"@giselles-ai/*": ["./packages/*"],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

import { PropertiesPanelProvider } from "@giselles-ai/contexts/properties-panel";
import { ToastProvider } from "@giselles-ai/contexts/toast";
import { ToolbarContextProvider } from "@giselles-ai/contexts/toolbar";
import { persistGraph } from "@giselles-ai/giselle-provider/graph/persist";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@@ -347,7 +305,7 @@ export default async function Page({
<DeveloperModeProvider developerMode={developerMode}>
<GraphContextProvider
defaultGraph={graph}
onPersistAction={persistGraph}
onPersistAction={persistGraphAction}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

packages/lib/utils.ts Show resolved Hide resolved
@@ -335,6 +322,11 @@ async function performFlowExecution(
),
topP,
temperature,
experimental_telemetry: {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


registerOTel({
serviceName: "giselle",
spanProcessors: [noopSpanProcessor],
metricReader,
logRecordProcessor,
traceExporter: new LangfuseExporter({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't expect where the telemetry sent because this initialization does not contain target endpoint.
But reading the Langfuse documant, this configuration seems ok.
Let's merge and check that new fields are included in the telemetry arrived to our Langfuse account

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think having "staging" environment is good if we accept pull requests from forked repo: we can check new functionalities before merging them into main

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Rindrics It deployed to staging. please verify!

- Update background image import to use shared component
- Import `waitForLangfuseFlush` and implement it in node actions
- Add LangfuseExporter for OpenTelemetry integration
- Refactor execution telemetry logic to use experimental telemetry
- Enhance Tailwind config paths to include packages
- Upgrade langfuse dependencies in package.json

These changes introduce telemetry integration via Langfuse, enhancing
observability. LangfuseExporter is configured with a flushing mechanism
to ensure timely data export. Refactoring improves performance by reducing
overhead from previous Langfuse traces within execution logic.
- Moved persistGraph logic from page.tsx to a new module
  at giselle-provider/graph/persist.ts for better modularity
- Replaced inline persistGraph logic with import from new module
- Simplified graph handling in page.tsx by outsourcing blob deletion
  and graph URL update functionality

This refactor should make the codebase more maintainable by adhering
to the single responsibility principle, without introducing breaking
changes.
- Change waitForLangfuseFlush from a promise to a function that
  returns a promise in utils.ts for enhanced laziness
- Remove redundant import of after from page.tsx
- Call waitForLangfuseFlush using `after` in execution.ts to ensure
  proper scheduling of post-execution logic

This update aims to address more efficient handling of post-execution
scheduling and resolve potential memory overhead by improving how
flush timing is managed. No breaking changes introduced.
- Introduce userId to the execution context for enhanced telemetry
  data, allowing better user-specific tracking and debugging
- Modify performFlowExecution to include userId in experimental
  telemetry metadata
- Implement parseExecutionContextToTelemetryMetadata to structure
  metadata, ensuring consistent formatting across different
  telemetry actions

This change aims to improve telemetry insights by associating user
identifiers with execution flows, thereby assisting in user behavior
analysis and debugging. No breaking changes introduced.
- Add userId to execution parameters for executeStep and retryStep
  functions to capture user-specific telemetry data
- Modify page functions to pass userId from the user context for
  more granular tracking and user-driven analytics
- Ensure all execution paths maintain consistent userId propagation
  for future scalability in user data insights

This enhancement improves the ability to trace executions back to
specific users, enabling better analytics and debugging capabilities
with no breaking changes introduced.
@toyamarinyon toyamarinyon force-pushed the use-telemetry-integration branch from c13463e to 5725481 Compare January 6, 2025 04:32
@toyamarinyon
Copy link
Contributor Author

I force-pushed 5725481 to exclude diffs from #285

Copy link
Member

@shige shige left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check the errors occurring in Sentry, and SigNoz.

Route /p/[agentId] used "cookies" inside "after(...)". This is not supported. If you need this data inside an "after" callback, use "cookies" outside of the callback. See more info here: https://nextjs.org/docs/canary/app/api-reference/functions/after

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants