DocsHow toLogging and Telemetry

Logging and Telemetry

Logging

By default, Mastra emits logs locally to the /logs directory.

Log drains

To send logs to an external service, you can configure a log drain in your Mastra config file. Currently, we support Upstash.

mastra.config.ts
export const config: Config = {
  ...mastraConfig,
  logs: {
    provider: 'UPSTASH',
    config: {
      url: process.env.UPSTASH_URL!,
      token: process.env.UPSTASH_API_KEY!,
    },
  },
};

Tracing

Mastra emits tracing data using the OpenTelemetry Node.js SDK and following the OpenTelemetry standard. You can view in a variety of tools (Datadog, Honeycomb, etc.). You can add attributes to the telemetry section in your mastra.config.ts file.

mastra.config.ts
export const config: Config = {
  ...mastraConfig,
  telemetry: {
    serviceName: 'my-service',
    serviceVersion: '0.9.1', // defaults to 1.0.0
    environment: 'development', // defaults to 'production'
    attributes: {}, // optional, allows additional attributes
  },
};