-
Notifications
You must be signed in to change notification settings - Fork 0
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 telemetry to the chat API route #26
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
@@ -0,0 +1,255 @@ | |||
import { |
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.
By breaking this out into a separate file we can write tests without needing to deal with Clerk / Middleware etc.
throw e; | ||
} | ||
|
||
export async function handleChatPostRequest( |
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.
The actual chat post request function now is much simpler and errors are handled in the above methods, which also report telemetry
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 function is now so easy to follow at a high level. A lot easier to understand the steps involved
apps/nextjs/src/app/api/chat/user.ts
Outdated
|
||
import { streamingJSON } from "./protocol"; | ||
|
||
export async function handleUserLookup(span: Span, id: string) { |
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.
The user lookup is now in a separate method that we can mock
@@ -0,0 +1,14 @@ | |||
export async function consumeStream(stream: ReadableStream): Promise<string> { |
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.
Helper for consuming the chat stream
Playwright e2e testsTo view traces locally, unzip the report and run: npx playwright show-report ~/Downloads/playwright-report |
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.
Looks good to me! I'd be keen to get this merged as soon as we can so we can be sure that there aren't any regressions and we don't have to make any changes to how we're recording
throw e; | ||
} | ||
|
||
export async function handleChatPostRequest( |
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 function is now so easy to follow at a high level. A lot easier to understand the steps involved
apps/nextjs/src/app/api/chat/user.ts
Outdated
if (!result) { | ||
userLookupSpan.setTag("error", true); | ||
userLookupSpan.setTag("error.message", "user lookup failed"); | ||
return { | ||
failureResponse: new Response("User lookup failed", { | ||
status: 400, | ||
}), | ||
}; | ||
} |
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.
I can't see how this state is possible. Can we just remove this clause?
…onfig to ignore the dependency warning
… is being initialised
Quality Gate passedIssues Measures |
🎉 This PR is included in version 1.3.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Description
Unfortunately it seems that Datadog relies on deploying the Datadog Agent in GCP. So until we have that, I've set up some log tracing and a log drain in Vercel to send logs to Datadog.
This means we get to see timings in Datadog, but we will need someone to set up the agent for us as a separate task. Once that's done, we will need to set up some environment variables in Doppler for the Datadog Agent URL etc.
When that's done, we can remove the logging and rely on the agent instead to send logs to the Tracing part of the Datadog UI instead of to the Logs part.