axonpush
TypeScript SDKIntegrations

Mastra

AxonPushMastraExporter plugs into Mastra 1.x observability and exports spans, logs, metrics, scores, and feedback with trace identity preserved.

AxonPushMastraExporter implements Mastra’s ObservabilityExporter interface. Register it once on your Mastra instance and every signal Mastra already produces, spans, logs, metrics, scores, feedback, arrives in axonpush with its trace and span identity intact. No lifecycle hooks, no wrapper around your agent runtime.

Requires @mastra/core in the 1.16–1.x range, which is an optional peer dependency of the SDK.

Install

npm install @axonpush/sdk @mastra/core @mastra/observability

Register the exporter

import { AxonPush } from "@axonpush/sdk";
import { AxonPushMastraExporter } from "@axonpush/sdk/integrations/mastra";
import { Mastra } from "@mastra/core/mastra";
import { Observability } from "@mastra/observability";

const axonpush = new AxonPush({
  apiKey: process.env.AXONPUSH_API_KEY,
  orgId: process.env.AXONPUSH_ORG_ID,
  environment: process.env.AXONPUSH_ENVIRONMENT ?? "development",
});

export const mastra = new Mastra({
  observability: new Observability({
    configs: {
      default: {
        serviceName: "support-agent",
        exporters: [
          new AxonPushMastraExporter({
            client: axonpush,
            channelId: process.env.AXONPUSH_CHANNEL_ID!,
            serviceName: "support-agent",
            serviceVersion: process.env.npm_package_version,
            release: process.env.GIT_SHA,
          }),
        ],
      },
    },
  }),
});

channelId is a channel UUID from the axonpush app. agentId defaults to "mastra"; serviceName defaults to "mastra" and is stamped on every payload’s resource block, alongside service.version and deployment.release when you supply them.

Signals exported

Mastra signalIdentifieraxonpush eventType
Ended span (span_ended)the span nameapp.span
Logthe log messageapp.log
Metricmetric.{name}custom
Scorescore.{scorerId}custom
Feedbackfeedback.{feedbackType}custom

Only span_ended is exported from the tracing stream; span-start events are ignored, so each span is published once with its full duration. startTime and endTime are converted to nanosecond strings, and parentSpanId is carried through both the payload and the event envelope, so hierarchy survives the round trip.

Metric, score, and feedback events carry metadata.signal set to metric, score, or feedback, which is how you separate them from ordinary custom traffic.

Span kinds

Mastra’s span type is mapped onto an axonpush semantic kind and written to attributes["openinference.span.kind"], with the original Mastra type kept in attributes["gen_ai.operation.name"] and metadata.mastraSpanType:

Mastra span type containsSemantic kind
agentAGENT
workflowWORKFLOW
modelLLM
toolTOOL
rag, memoryRETRIEVER
anything elseCUSTOM

Original span attributes are preserved untouched alongside the two derived keys.

Content capture

Span input and output are published as-is into the payload, then run through the client’s redactor. Under the SDK default contentCaptureMode: "metadata_only" that means prompts, messages, inputs, outputs, responses, and tool content are replaced with [REDACTED] before transport, and secret-looking keys always are.

Set contentCaptureMode: "redacted" on the client to keep non-secret content, and add project-specific keys through redactKeys. Use "full" only after checking your organisation’s telemetry policy.

Publishing behaviour

The exporter awaits each publish inside Mastra’s own exporter pipeline rather than queueing in the background, so backpressure is Mastra’s to manage. A failed publish is logged at warning level and swallowed. flush() and shutdown() are implemented as no-ops because there is no local queue to drain.

The deprecated hooks

AxonPushMastraHooks, beforeToolUse, afterToolUse, onWorkflowStart, onWorkflowEnd, onWorkflowError, is still exported for Mastra 0.10 installations, and emits tool.{name}.start / .end, workflow.start, workflow.end, and workflow.error. It is deprecated. On Mastra 1.x use the exporter: it covers more signal types and does not require you to find the right callsites by hand.