@mastra/deployer 0.24.0 → 1.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +230 -95
- package/dist/build/analyze.cjs +2 -2
- package/dist/build/analyze.js +1 -1
- package/dist/build/bundler.cjs +3 -3
- package/dist/build/bundler.js +1 -1
- package/dist/build/index.cjs +10 -15
- package/dist/build/index.d.ts +0 -1
- package/dist/build/index.d.ts.map +1 -1
- package/dist/build/index.js +3 -4
- package/dist/bundler/index.cjs +2 -2
- package/dist/bundler/index.d.ts +2 -2
- package/dist/bundler/index.d.ts.map +1 -1
- package/dist/bundler/index.js +1 -1
- package/dist/{chunk-OART5HV7.cjs → chunk-AQAOWLJJ.cjs} +29 -124
- package/dist/chunk-AQAOWLJJ.cjs.map +1 -0
- package/dist/{chunk-IAEJ3C3J.cjs → chunk-C74EXQSL.cjs} +12 -12
- package/dist/chunk-C74EXQSL.cjs.map +1 -0
- package/dist/{chunk-CVRN2K4O.js → chunk-H3LLQ2MW.js} +12 -12
- package/dist/chunk-H3LLQ2MW.js.map +1 -0
- package/dist/{chunk-FD5X42ZU.js → chunk-HQJR52M7.js} +4 -4
- package/dist/{chunk-FD5X42ZU.js.map → chunk-HQJR52M7.js.map} +1 -1
- package/dist/{chunk-NSINCI76.cjs → chunk-IL2VLNIJ.cjs} +9 -9
- package/dist/{chunk-NSINCI76.cjs.map → chunk-IL2VLNIJ.cjs.map} +1 -1
- package/dist/{chunk-XHLN6E4D.js → chunk-OFUWEVGF.js} +3 -3
- package/dist/{chunk-XHLN6E4D.js.map → chunk-OFUWEVGF.js.map} +1 -1
- package/dist/{chunk-Z546LAA6.cjs → chunk-TDWIGFVF.cjs} +14 -14
- package/dist/{chunk-Z546LAA6.cjs.map → chunk-TDWIGFVF.cjs.map} +1 -1
- package/dist/{chunk-VDRZB7JQ.js → chunk-WBAWUM7Z.js} +23 -116
- package/dist/chunk-WBAWUM7Z.js.map +1 -0
- package/dist/index.cjs +5 -5
- package/dist/index.js +2 -2
- package/dist/server/handlers/health.d.ts +5 -0
- package/dist/server/handlers/health.d.ts.map +1 -0
- package/dist/server/handlers/prompt.d.ts.map +1 -1
- package/dist/server/handlers/routes/agent-builder/handlers.d.ts +5 -2
- package/dist/server/handlers/routes/agent-builder/handlers.d.ts.map +1 -1
- package/dist/server/handlers/routes/agent-builder/router.d.ts.map +1 -1
- package/dist/server/handlers/routes/agents/handlers.d.ts +21 -143
- package/dist/server/handlers/routes/agents/handlers.d.ts.map +1 -1
- package/dist/server/handlers/routes/agents/router.d.ts.map +1 -1
- package/dist/server/handlers/routes/logs/handlers.d.ts +3 -3
- package/dist/server/handlers/routes/logs/handlers.d.ts.map +1 -1
- package/dist/server/handlers/routes/mcp/handlers.d.ts +1 -1
- package/dist/server/handlers/routes/mcp/handlers.d.ts.map +1 -1
- package/dist/server/handlers/routes/memory/handlers.d.ts +2 -4
- package/dist/server/handlers/routes/memory/handlers.d.ts.map +1 -1
- package/dist/server/handlers/routes/memory/router.d.ts.map +1 -1
- package/dist/server/handlers/routes/observability/handlers.d.ts +3 -3
- package/dist/server/handlers/routes/observability/handlers.d.ts.map +1 -1
- package/dist/server/handlers/routes/observability/router.d.ts.map +1 -1
- package/dist/server/handlers/routes/scores/handlers.d.ts +8 -6
- package/dist/server/handlers/routes/scores/handlers.d.ts.map +1 -1
- package/dist/server/handlers/routes/tools/handlers.d.ts +1 -1
- package/dist/server/handlers/routes/tools/handlers.d.ts.map +1 -1
- package/dist/server/handlers/routes/workflows/handlers.d.ts +2 -4
- package/dist/server/handlers/routes/workflows/handlers.d.ts.map +1 -1
- package/dist/server/handlers/routes/workflows/router.d.ts.map +1 -1
- package/dist/server/handlers/utils/query-parsers.d.ts +15 -0
- package/dist/server/handlers/utils/query-parsers.d.ts.map +1 -1
- package/dist/server/index.cjs +1207 -1559
- package/dist/server/index.cjs.map +1 -1
- package/dist/server/index.d.ts +2 -2
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +1214 -1566
- package/dist/server/index.js.map +1 -1
- package/dist/server/welcome.d.ts +1 -1
- package/dist/server/welcome.d.ts.map +1 -1
- package/package.json +11 -15
- package/dist/build/babel/remove-all-options-telemetry.d.ts +0 -5
- package/dist/build/babel/remove-all-options-telemetry.d.ts.map +0 -1
- package/dist/build/customInstrumentation.d.ts +0 -10
- package/dist/build/customInstrumentation.d.ts.map +0 -1
- package/dist/build/telemetry.d.ts +0 -8
- package/dist/build/telemetry.d.ts.map +0 -1
- package/dist/chunk-AJX72IGP.cjs +0 -28
- package/dist/chunk-AJX72IGP.cjs.map +0 -1
- package/dist/chunk-B2Q76NIL.js +0 -26
- package/dist/chunk-B2Q76NIL.js.map +0 -1
- package/dist/chunk-CVRN2K4O.js.map +0 -1
- package/dist/chunk-IAEJ3C3J.cjs.map +0 -1
- package/dist/chunk-OART5HV7.cjs.map +0 -1
- package/dist/chunk-VDRZB7JQ.js.map +0 -1
- package/dist/server/handlers/routes/telemetry/handlers.d.ts +0 -4
- package/dist/server/handlers/routes/telemetry/handlers.d.ts.map +0 -1
- package/dist/server/handlers/routes/telemetry/router.d.ts +0 -3
- package/dist/server/handlers/routes/telemetry/router.d.ts.map +0 -1
- package/dist/server/handlers/routes/workflows/legacyWorkflows.d.ts +0 -11
- package/dist/server/handlers/routes/workflows/legacyWorkflows.d.ts.map +0 -1
- package/dist/templates/instrumentation-template.js +0 -172
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
import { getNodeAutoInstrumentations } from '@opentelemetry/auto-instrumentations-node';
|
|
2
|
-
import { ExportResultCode } from '@opentelemetry/core';
|
|
3
|
-
import { OTLPTraceExporter as OTLPGrpcExporter } from '@opentelemetry/exporter-trace-otlp-grpc';
|
|
4
|
-
import { OTLPTraceExporter as OTLPHttpExporter } from '@opentelemetry/exporter-trace-otlp-http';
|
|
5
|
-
import { resourceFromAttributes } from '@opentelemetry/resources';
|
|
6
|
-
import { NodeSDK } from '@opentelemetry/sdk-node';
|
|
7
|
-
import {
|
|
8
|
-
ParentBasedSampler,
|
|
9
|
-
TraceIdRatioBasedSampler,
|
|
10
|
-
AlwaysOnSampler,
|
|
11
|
-
AlwaysOffSampler,
|
|
12
|
-
} from '@opentelemetry/sdk-trace-base';
|
|
13
|
-
import { ATTR_SERVICE_NAME } from '@opentelemetry/semantic-conventions';
|
|
14
|
-
import { telemetry } from './telemetry-config.mjs';
|
|
15
|
-
|
|
16
|
-
globalThis.___MASTRA_TELEMETRY___ = true;
|
|
17
|
-
|
|
18
|
-
function parseHeaders(headerString) {
|
|
19
|
-
const headers = {}
|
|
20
|
-
if (!headerString) return headers;
|
|
21
|
-
|
|
22
|
-
const headersStringPairs = headerString.split(',');
|
|
23
|
-
for (const pair of headersStringPairs) {
|
|
24
|
-
const [key, value] = pair.split('=').map(s => s.trim());
|
|
25
|
-
if (key && value) headers[key] = value;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
return headers;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
class CompositeExporter {
|
|
32
|
-
constructor(exporters) {
|
|
33
|
-
this.exporters = exporters;
|
|
34
|
-
}
|
|
35
|
-
export(spans, resultCallback) {
|
|
36
|
-
const telemetryTraceIds = new Set(
|
|
37
|
-
spans.filter((span) => {
|
|
38
|
-
const attrs = span.attributes || {};
|
|
39
|
-
const httpTarget = attrs["http.target"];
|
|
40
|
-
return httpTarget === "/api/telemetry";
|
|
41
|
-
}).map((span) => span.spanContext().traceId)
|
|
42
|
-
);
|
|
43
|
-
|
|
44
|
-
const filteredSpans = spans.filter((span) => {
|
|
45
|
-
// instrumentation-http spans are the root spans for a trace.
|
|
46
|
-
// Other @opentelemetry spans are noisy and we do not display them.
|
|
47
|
-
// At the storage layer, we remove the HTTP instrumentation spans entirely.
|
|
48
|
-
// And promote their direct children to root spans.
|
|
49
|
-
return !(span.instrumentationScope?.name?.startsWith('@opentelemetry') &&
|
|
50
|
-
span.instrumentationScope?.name !== '@opentelemetry/instrumentation-http') &&
|
|
51
|
-
!telemetryTraceIds.has(span.spanContext().traceId)
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
if (filteredSpans.length === 0) {
|
|
55
|
-
resultCallback({ code: ExportResultCode.SUCCESS });
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
void Promise.all(
|
|
59
|
-
this.exporters.map(
|
|
60
|
-
(exporter) => new Promise((resolve) => {
|
|
61
|
-
if (exporter.export) {
|
|
62
|
-
exporter.export(filteredSpans, resolve);
|
|
63
|
-
} else {
|
|
64
|
-
resolve({ code: ExportResultCode.FAILED });
|
|
65
|
-
}
|
|
66
|
-
})
|
|
67
|
-
)
|
|
68
|
-
).then((results) => {
|
|
69
|
-
const hasError = results.some((r) => r.code === ExportResultCode.FAILED);
|
|
70
|
-
resultCallback({
|
|
71
|
-
code: hasError ? ExportResultCode.FAILED : ExportResultCode.SUCCESS
|
|
72
|
-
});
|
|
73
|
-
}).catch((error) => {
|
|
74
|
-
console.error("[CompositeExporter] Export error:", error);
|
|
75
|
-
resultCallback({ code: ExportResultCode.FAILED, error });
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
shutdown() {
|
|
79
|
-
return Promise.all(this.exporters.map((e) => e.shutdown?.() ?? Promise.resolve())).then(() => void 0);
|
|
80
|
-
}
|
|
81
|
-
forceFlush() {
|
|
82
|
-
return Promise.all(this.exporters.map((e) => e.forceFlush?.() ?? Promise.resolve())).then(() => void 0);
|
|
83
|
-
}
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
function getSampler(config) {
|
|
87
|
-
if (!config.sampling) {
|
|
88
|
-
return new AlwaysOnSampler();
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
if (!config.enabled) {
|
|
92
|
-
return new AlwaysOffSampler();
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
switch (config.sampling.type) {
|
|
96
|
-
case 'ratio':
|
|
97
|
-
return new TraceIdRatioBasedSampler(config.sampling.probability);
|
|
98
|
-
case 'always_on':
|
|
99
|
-
return new AlwaysOnSampler();
|
|
100
|
-
case 'always_off':
|
|
101
|
-
return new AlwaysOffSampler();
|
|
102
|
-
case 'parent_based':
|
|
103
|
-
const rootSampler = new TraceIdRatioBasedSampler(config.sampling.root?.probability || 1.0);
|
|
104
|
-
return new ParentBasedSampler({ root: rootSampler });
|
|
105
|
-
default:
|
|
106
|
-
return new AlwaysOnSampler();
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
async function getExporters(config) {
|
|
111
|
-
const exporters = [];
|
|
112
|
-
|
|
113
|
-
// Add local exporter by default
|
|
114
|
-
if (!config.disableLocalExport) {
|
|
115
|
-
exporters.push(new OTLPHttpExporter({
|
|
116
|
-
url: `http://localhost:${process.env.PORT ?? 4111}/api/telemetry`,
|
|
117
|
-
headers: process.env.MASTRA_DEV ? {
|
|
118
|
-
'x-mastra-dev-playground': 'true',
|
|
119
|
-
} : {},
|
|
120
|
-
}));
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
if (config.export?.type === 'otlp') {
|
|
124
|
-
if (config.export?.protocol === 'grpc') {
|
|
125
|
-
exporters.push(new OTLPGrpcExporter({
|
|
126
|
-
url: config.export.endpoint,
|
|
127
|
-
headers: config.export.headers,
|
|
128
|
-
}));
|
|
129
|
-
} else {
|
|
130
|
-
const exporterEndpoint = config.export.endpoint ?? process.env.OTEL_EXPORTER_OTLP_ENDPOINT
|
|
131
|
-
let exporterHeaders = config.export.headers
|
|
132
|
-
if (!exporterHeaders) {
|
|
133
|
-
exporterHeaders = parseHeaders(process.env.OTEL_EXPORTER_OTLP_HEADERS)
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
exporters.push(new OTLPHttpExporter({
|
|
137
|
-
url: exporterEndpoint,
|
|
138
|
-
headers: exporterHeaders,
|
|
139
|
-
}));
|
|
140
|
-
}
|
|
141
|
-
} else if (config.export?.type === 'custom') {
|
|
142
|
-
exporters.push(config.export.exporter);
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
return exporters
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
const sampler = getSampler(telemetry);
|
|
149
|
-
const exporters = await getExporters(telemetry);
|
|
150
|
-
const compositeExporter = new CompositeExporter(exporters);
|
|
151
|
-
|
|
152
|
-
const sdk = new NodeSDK({
|
|
153
|
-
resource: resourceFromAttributes({
|
|
154
|
-
[ATTR_SERVICE_NAME]: telemetry.serviceName || 'default-service',
|
|
155
|
-
}),
|
|
156
|
-
sampler,
|
|
157
|
-
traceExporter: compositeExporter,
|
|
158
|
-
instrumentations: [getNodeAutoInstrumentations()],
|
|
159
|
-
});
|
|
160
|
-
|
|
161
|
-
if (telemetry.enabled !== false) {
|
|
162
|
-
sdk.start();
|
|
163
|
-
|
|
164
|
-
// gracefully shut down the SDK on process exit
|
|
165
|
-
process.on('SIGTERM', () => {
|
|
166
|
-
sdk.shutdown().catch(() => {
|
|
167
|
-
// do nothing
|
|
168
|
-
});
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
|