New:Microsoft Teams Notifications Are Now Available in Socket.Learn more
Get Started

@mastra/observability

Package Overview
Dependencies
Maintainers
7
Versions
605
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
This package has malicious versions linked to the ongoing "Mastra AI framework compromise" supply chain attack.

Affected versions:

1.14.2
View campaign page

@mastra/observability

Core observability package for Mastra - includes tracing and scoring features

Source
npmnpm
Version
1.17.8-alpha.1
Version published
Weekly downloads
692K
41.86%
Maintainers
7
Weekly downloads
 
Created
Source

@mastra/observability

Monitor Mastra agents, workflows, tools, and model calls with hierarchical traces, automatically extracted metrics, and structured logs correlated to the active trace.

Installation

npm install @mastra/observability

Usage

import { Mastra } from '@mastra/core';
import { Observability, MastraStorageExporter, MastraPlatformExporter } from '@mastra/observability';

export const mastra = new Mastra({
  observability: new Observability({
    configs: {
      default: {
        serviceName: 'my-app',
        exporters: [new MastraStorageExporter(), new MastraPlatformExporter()],
      },
    },
  }),
});

Documentation

Observability instruments agent runs, model generations, tool and MCP calls, processor execution, workflow runs, and workflow steps. Each configured observability instance has its own service name, exporters, sampling strategy, and span processors.

Exporters receive tracing events through the central observability bus. MastraStorageExporter persists them to the configured Mastra storage so Studio can query them, while MastraPlatformExporter sends them to Mastra Platform. Additional packages provide exporters for services such as Arize, Braintrust, Langfuse, LangSmith, Sentry, and OpenTelemetry-compatible backends.

A SensitiveDataFilter output processor is enabled by default and redacts common secrets before spans reach exporters. Set sensitiveDataFilter: false to disable it, or provide filter options to customize its behavior. Sampling can retain every trace, use a ratio, or apply application-specific logic.

The package automatically derives duration, status, model token, and cache token metrics from span lifecycle events. Structured logs inherit trace and span IDs, tags, and entity metadata, while metric labels pass through cardinality filtering to prevent user IDs, trace IDs, and other unbounded values from overwhelming metrics backends.

  • Observability documentation

Changelog

See the package changelog for version history and release notes.

Support

We have an open community Discord. Come and say hello and let us know if you have any questions or need any help getting things running.

FAQs

Package last updated on 12 Sep 2026

Related posts