
Research
/Security News
Mini Shai-Hulud Campaign Hits Red Hat Cloud Services npm Packages
A mini Shai-Hulud campaign compromised Red Hat Cloud Services npm packages to steal developer and CI/CD secrets during installation.
@mastra/observability
Advanced tools
Core observability package for Mastra - includes tracing and scoring features
Tracing, metrics, and structured logging for AI operations in Mastra.
npm install @mastra/observability
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(), // Persists observability events to Mastra Storage
new MastraPlatformExporter(), // Sends observability events to Mastra Platform
],
},
},
}),
});
A SensitiveDataFilter span output processor is auto-applied to every configured instance by default, redacting secrets (API keys, tokens, passwords, etc.) before they reach exporters. Set sensitiveDataFilter: false on the Observability config to opt out, or pass a SensitiveDataFilterOptions object to customize it.
Central event router that dispatches tracing, metric, and log events to registered exporters. All handler promises are tracked for reliable flush and shutdown — no events are silently dropped.
Exporters register via registerExporter() and can optionally implement onLogEvent and onMetricEvent handlers alongside the existing exportTracingEvent.
Metrics are automatically extracted from span lifecycle events by AutoExtractedMetrics:
mastra_agent_duration_msmastra_tool_duration_msmastra_workflow_duration_msmastra_model_duration_msmastra_model_total_input_tokens / mastra_model_total_output_tokensmastra_model_input_text_tokens / mastra_model_input_cache_read_tokens / mastra_model_input_cache_write_tokens / mastra_model_input_audio_tokens / mastra_model_input_image_tokensmastra_model_output_text_tokens / mastra_model_output_reasoning_tokens / mastra_model_output_audio_tokens / mastra_model_output_image_tokensAuto-extracted metrics carry labels: entity_type, entity_name, status, plus model and provider on model generation spans.
LoggerContextImpl emits log events with automatic trace correlation (traceId, spanId), inherited tags, and entity metadata. Supports minimum log level filtering (debug/info/warn/error/fatal).
MetricsContextImpl provides counter, gauge, and histogram instruments. All labels pass through a CardinalityFilter that blocks high-cardinality keys (trace_id, user_id, etc.) to protect metric backends.
WORKFLOW_RUN - Workflow executionWORKFLOW_STEP - Individual workflow stepAGENT_RUN - Agent processingMODEL_GENERATION - LLM API callsTOOL_CALL - Tool executionMCP_TOOL_CALL - MCP tool executionPROCESSOR_RUN - Processor executionGENERIC - Custom operations| Label | Description | Cardinality |
|---|---|---|
entity_type | What is being measured (e.g., agent, tool, workflow_run) | Small enum (~9 values) |
entity_name | Name of the entity (e.g., researcher, search) | Bounded by defined entities |
model | LLM model ID (only on model generation spans) | Bounded by LLM providers |
provider | LLM provider (only on model generation spans) | Bounded by LLM providers |
status | Outcome of the operation (ok or error), on _ended metrics only | 2 values |
User-emitted metrics inherit additional context labels from the active span:
| Label | Description | Cardinality |
|---|---|---|
parent_type | Entity type of the nearest parent | Same small enum |
parent_name | Name of the nearest parent entity | Bounded by defined entities |
root_type | Entity type of the outermost ancestor (only set when different from parent) | Same small enum |
root_name | Name of the outermost ancestor entity | Bounded by defined entities |
service_name | Service name from observability config | Single value per deployment |
entity_name where entity_type=agentparent_nameroot_namemodel where entity_name=XFor configuration options, exporters, sampling strategies, and more, see the full documentation.
FAQs
Core observability package for Mastra - includes tracing and scoring features
The npm package @mastra/observability receives a total of 330,958 weekly downloads. As such, @mastra/observability popularity was classified as popular.
We found that @mastra/observability demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 9 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Research
/Security News
A mini Shai-Hulud campaign compromised Red Hat Cloud Services npm packages to steal developer and CI/CD secrets during installation.

Research
/Security News
The North Korean malware loader hides in a Packagist-listed package and its GitHub branch to fetch and execute remote code in a likely Contagious Interview-style lure.

Security News
The Rust project is moving toward formal rules on LLM use in contributions after months of internal debate over maintainer burden, code quality, and contributor experience.