-
Notifications
You must be signed in to change notification settings - Fork 8
This PR wires Mastra tracing to persistent PostgreSQL storage for local development #73
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,9 +1,33 @@ | ||
| import { Mastra } from "@mastra/core/mastra"; | ||
| import { inferSchemaWorkflow } from "./workflows/infer-schema.js"; | ||
| import { populateWorkflow } from "./workflows/populate.js"; | ||
| import { populateAgent } from "./agents/populate.js"; | ||
| import { Mastra } from '@mastra/core/mastra' | ||
| import { PostgresStore } from '@mastra/pg' | ||
| import { | ||
| Observability, | ||
| MastraStorageExporter, | ||
| SensitiveDataFilter, | ||
| } from '@mastra/observability' | ||
| import { inferSchemaWorkflow } from "./workflows/infer-schema.js" | ||
| import { populateWorkflow } from "./workflows/populate.js" | ||
| import { populateAgent } from "./agents/populate.js" | ||
|
|
||
| const storage = new PostgresStore({ | ||
| id: 'mastra-pg-storage', | ||
| connectionString: process.env.MASTRA_DATABASE_URL!, | ||
| }) | ||
|
|
||
| export const mastra = new Mastra({ | ||
| agents: { populateAgent }, | ||
| workflows: { inferSchemaWorkflow, populateWorkflow }, | ||
| }); | ||
| storage, | ||
| observability: new Observability({ | ||
|
|
||
| configs: { | ||
| default: { | ||
| serviceName: 'bigset', | ||
| exporters: [new MastraStorageExporter({ strategy: 'auto' })], | ||
| spanOutputProcessors: [ | ||
| new SensitiveDataFilter(), | ||
| ], | ||
| }, | ||
| }, | ||
| }), | ||
| }) | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -24,6 +24,7 @@ services: | |||||||||||||||||||||
| - "3501:3501" | ||||||||||||||||||||||
| volumes: | ||||||||||||||||||||||
| - ./backend/src:/app/src | ||||||||||||||||||||||
| - ./backend/.mastra:/app/.mastra | ||||||||||||||||||||||
| environment: | ||||||||||||||||||||||
| CLIENT_ORIGIN: http://localhost:3500 | ||||||||||||||||||||||
| CONVEX_URL: http://convex:3210 | ||||||||||||||||||||||
|
|
@@ -33,6 +34,7 @@ services: | |||||||||||||||||||||
| CLERK_PUBLISHABLE_KEY: ${NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY:-} | ||||||||||||||||||||||
| OPENROUTER_API_KEY: ${OPENROUTER_API_KEY:-} | ||||||||||||||||||||||
| TINYFISH_API_KEY: ${TINYFISH_API_KEY:-} | ||||||||||||||||||||||
| MASTRA_DATABASE_URL: postgresql://bigset:bigset@db:5432/bigset_internal | ||||||||||||||||||||||
| depends_on: | ||||||||||||||||||||||
| convex: | ||||||||||||||||||||||
| condition: service_healthy | ||||||||||||||||||||||
|
|
@@ -45,13 +47,15 @@ services: | |||||||||||||||||||||
| - "4111:4111" | ||||||||||||||||||||||
| volumes: | ||||||||||||||||||||||
| - ./backend/src:/app/src | ||||||||||||||||||||||
| - ./backend/.mastra:/app/.mastra | ||||||||||||||||||||||
| environment: | ||||||||||||||||||||||
| HOST: 0.0.0.0 | ||||||||||||||||||||||
| PORT: 4111 | ||||||||||||||||||||||
| OPENROUTER_API_KEY: ${OPENROUTER_API_KEY:-} | ||||||||||||||||||||||
| CONVEX_URL: http://convex:3210 | ||||||||||||||||||||||
| CONVEX_SELF_HOSTED_ADMIN_KEY: ${CONVEX_SELF_HOSTED_ADMIN_KEY:-} | ||||||||||||||||||||||
| TINYFISH_API_KEY: ${TINYFISH_API_KEY:-} | ||||||||||||||||||||||
| MASTRA_DATABASE_URL: postgresql://bigset:bigset@db:5432/bigset_internal | ||||||||||||||||||||||
| depends_on: | ||||||||||||||||||||||
| convex: | ||||||||||||||||||||||
| condition: service_healthy | ||||||||||||||||||||||
|
Comment on lines
+58
to
61
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.
The Proposed fix depends_on:
+ db:
+ condition: service_healthy
convex:
condition: service_healthy📝 Committable suggestion
Suggested change
🤖 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.
Missing validation for
MASTRA_DATABASE_URLenvironment variable.The non-null assertion (
!) onprocess.env.MASTRA_DATABASE_URLwill passundefinedtoPostgresStoreif the variable is missing, likely causing a cryptic connection error at runtime rather than a clear startup failure.Consider validating this in
env.tsalongside other required variables, or add a guard here:Proposed fix
📝 Committable suggestion
🤖 Prompt for AI Agents