Skip to content

Commit

Permalink
fix: add otel instrumentation (#1900)
Browse files Browse the repository at this point in the history
  • Loading branch information
abvthecity authored Dec 21, 2024
1 parent b000987 commit a0c0923
Show file tree
Hide file tree
Showing 6 changed files with 204 additions and 2 deletions.
1 change: 1 addition & 0 deletions packages/fern-docs/bundle/next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ const nextConfig = {
],
experimental: {
scrollRestoration: true,
instrumentationHook: true,
hardNavigate404: true,
optimizePackageImports: [
"@fern-api/fdr-sdk",
Expand Down
5 changes: 5 additions & 0 deletions packages/fern-docs/bundle/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,14 @@
"@fern-docs/utils": "workspace:*",
"@fern-fern/fern-docs-sdk": "0.0.5",
"@fern-platform/fdr-utils": "workspace:*",
"@opentelemetry/api": "^1.9.0",
"@opentelemetry/api-logs": "^0.57.0",
"@opentelemetry/instrumentation": "^0.57.0",
"@opentelemetry/sdk-logs": "^0.57.0",
"@types/qs": "6.9.14",
"@upstash/qstash": "^2.7.16",
"@vercel/kv": "^2.0.0",
"@vercel/otel": "^1.10.0",
"@workos-inc/node": "^7.29.0",
"ai": "^4.0.18",
"algoliasearch": "^5.13.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,19 @@ export async function POST(req: NextRequest) {
},
}),
},
experimental_telemetry: {
isEnabled: true,
recordInputs: true,
recordOutputs: true,
functionId: "ask_ai_chat",
metadata: {
domain,
languageModel: languageModel.modelId,
embeddingModel: embeddingModel.modelId,
db: "turbopuffer",
namespace,
},
},
onFinish: async (e) => {
const end = Date.now();
await track("ask_ai", {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,17 @@ export async function POST(req: NextRequest): Promise<Response> {
.join("\n\n"),
maxRetries: 3,
schema: SuggestionsSchema,
experimental_telemetry: {
isEnabled: true,
recordInputs: true,
recordOutputs: true,
functionId: "ask_ai_suggest",
metadata: {
domain,
indexName: SEARCH_INDEX,
languageModel: languageModel.modelId,
},
},
onFinish: async (e) => {
const end = Date.now();
await track("ask_ai_suggestions", {
Expand Down
5 changes: 5 additions & 0 deletions packages/fern-docs/bundle/src/instrumentation.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { registerOTel } from "@vercel/otel";

export function register(): void {
registerOTel({ serviceName: "fern-docs" });
}
171 changes: 169 additions & 2 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a0c0923

Please sign in to comment.