@mastra/observability 1.11.1-alpha.1 → 1.12.0-alpha.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 +88 -0
- package/README.md +3 -2
- package/dist/config.d.ts +28 -6
- package/dist/config.d.ts.map +1 -1
- package/dist/default.d.ts.map +1 -1
- package/dist/index.cjs +43 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +43 -4
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,93 @@
|
|
|
1
1
|
# @mastra/observability
|
|
2
2
|
|
|
3
|
+
## 1.12.0-alpha.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Apply `SensitiveDataFilter` by default ([#16234](https://github.com/mastra-ai/mastra/pull/16234))
|
|
8
|
+
|
|
9
|
+
The `Observability` registry now auto-applies a `SensitiveDataFilter` span output processor to every configured instance, so secrets (API keys, tokens, passwords, etc.) are redacted before they reach exporters such as the Mastra cloud exporter. This protects against accidentally exporting sensitive data when the filter was not added manually.
|
|
10
|
+
|
|
11
|
+
A new top-level `sensitiveDataFilter` option on the `Observability` registry config controls this behavior:
|
|
12
|
+
- `true` (default): apply `SensitiveDataFilter` with default options.
|
|
13
|
+
- `false`: opt out of auto-applied filtering.
|
|
14
|
+
- a `SensitiveDataFilterOptions` object: customize the filter (sensitive fields, redaction token, redaction style).
|
|
15
|
+
|
|
16
|
+
If a config already includes a `SensitiveDataFilter` in `spanOutputProcessors`, the auto-applied filter is skipped to avoid double redaction. Pre-instantiated `ObservabilityInstance` values are not modified.
|
|
17
|
+
|
|
18
|
+
**Before:**
|
|
19
|
+
|
|
20
|
+
```typescript
|
|
21
|
+
import { Observability, DefaultExporter, CloudExporter, SensitiveDataFilter } from '@mastra/observability';
|
|
22
|
+
|
|
23
|
+
new Observability({
|
|
24
|
+
configs: {
|
|
25
|
+
default: {
|
|
26
|
+
serviceName: 'mastra',
|
|
27
|
+
exporters: [new DefaultExporter(), new CloudExporter()],
|
|
28
|
+
spanOutputProcessors: [new SensitiveDataFilter()],
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
**After:**
|
|
35
|
+
|
|
36
|
+
```typescript
|
|
37
|
+
import { Observability, DefaultExporter, CloudExporter } from '@mastra/observability';
|
|
38
|
+
|
|
39
|
+
new Observability({
|
|
40
|
+
configs: {
|
|
41
|
+
default: {
|
|
42
|
+
serviceName: 'mastra',
|
|
43
|
+
exporters: [new DefaultExporter(), new CloudExporter()],
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
// Optional: customize or disable the auto-applied filter.
|
|
47
|
+
// sensitiveDataFilter: false,
|
|
48
|
+
// sensitiveDataFilter: { sensitiveFields: ['myCustomSecret'] },
|
|
49
|
+
});
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## 1.11.1
|
|
53
|
+
|
|
54
|
+
### Patch Changes
|
|
55
|
+
|
|
56
|
+
- Fixed model step traces to show the final prompt sent to the model, including memory-injected system messages. ([#16029](https://github.com/mastra-ai/mastra/pull/16029))
|
|
57
|
+
|
|
58
|
+
- Added a new `DatadogBridge` integration for Mastra tracing so Datadog can keep auto-instrumented HTTP, database, and framework spans nested under the agent, workflow, model, and tool spans that triggered them. ([#15716](https://github.com/mastra-ai/mastra/pull/15716))
|
|
59
|
+
|
|
60
|
+
```typescript
|
|
61
|
+
import tracer from 'dd-trace';
|
|
62
|
+
|
|
63
|
+
tracer.init({
|
|
64
|
+
service: process.env.DD_SERVICE || 'my-mastra-app',
|
|
65
|
+
env: process.env.DD_ENV || 'production',
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
import { Mastra } from '@mastra/core';
|
|
69
|
+
import { Observability } from '@mastra/observability';
|
|
70
|
+
import { DatadogBridge } from '@mastra/datadog';
|
|
71
|
+
|
|
72
|
+
const mastra = new Mastra({
|
|
73
|
+
observability: new Observability({
|
|
74
|
+
configs: {
|
|
75
|
+
default: {
|
|
76
|
+
serviceName: 'my-mastra-app',
|
|
77
|
+
bridge: new DatadogBridge({
|
|
78
|
+
mlApp: process.env.DD_LLMOBS_ML_APP!,
|
|
79
|
+
}),
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
}),
|
|
83
|
+
});
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
- Reduced startup noise: CloudExporter missing-token message is now logged at debug level instead of warn, since being disabled is the expected state for local development ([#16070](https://github.com/mastra-ai/mastra/pull/16070))
|
|
87
|
+
|
|
88
|
+
- Updated dependencies [[`6dcd65f`](https://github.com/mastra-ai/mastra/commit/6dcd65f2a34069e6dc43ba35f1d11119b9b40bef), [`86c0298`](https://github.com/mastra-ai/mastra/commit/86c0298e647306423c842f9d5ac827bd616bd13d), [`c05c9a1`](https://github.com/mastra-ai/mastra/commit/c05c9a13230988cef6d438a62f37760f31927bc7), [`ca28c23`](https://github.com/mastra-ai/mastra/commit/ca28c232a2f18801a6cf20fe053479237b4d4fb0), [`e24aacb`](https://github.com/mastra-ai/mastra/commit/e24aacba07bd66f5d95b636dc24016fca26b52cf), [`7679a63`](https://github.com/mastra-ai/mastra/commit/7679a634eae8e8ca459fd87538fdf72b4389b07f), [`7fce309`](https://github.com/mastra-ai/mastra/commit/7fce30912b14170bfc41f0ac736cca0f39fe0cd4), [`1d64a76`](https://github.com/mastra-ai/mastra/commit/1d64a765861a0772ea187bab76e5ed37bf82d042), [`1c2dda8`](https://github.com/mastra-ai/mastra/commit/1c2dda805fbfccc0abf55d4cb20cc34402dc3f0c), [`c721164`](https://github.com/mastra-ai/mastra/commit/c7211643f7ac861f83b19a3757cc921487fc9d75), [`1b55954`](https://github.com/mastra-ai/mastra/commit/1b559541c1e08a10e49d01ffc51a634dfc37a286), [`7997c2e`](https://github.com/mastra-ai/mastra/commit/7997c2e55ddd121562a4098cd8d2b89c68433bf1), [`5adc55e`](https://github.com/mastra-ai/mastra/commit/5adc55e63407be8ee977914957d68bcc2a075ceb), [`7679a63`](https://github.com/mastra-ai/mastra/commit/7679a634eae8e8ca459fd87538fdf72b4389b07f), [`a0d9b6d`](https://github.com/mastra-ai/mastra/commit/a0d9b6d6b810aeaa9e177a0dcc99a4402e609634), [`e97ccb9`](https://github.com/mastra-ai/mastra/commit/e97ccb900f8b7a390ce82c9f8eb8d6eb2c5e3777), [`c5daf48`](https://github.com/mastra-ai/mastra/commit/c5daf48556e98c46ae06caf00f92c249912007e9), [`70017d7`](https://github.com/mastra-ai/mastra/commit/70017d72ab741b5d7040e2a15c251a317782e39e), [`cd96779`](https://github.com/mastra-ai/mastra/commit/cd9677937f113b2856dc8b9f3d4bdabcee58bb2e), [`b0c7022`](https://github.com/mastra-ai/mastra/commit/b0c70224f80dad7c0cdbfb22cbff22e0f75c064f), [`e4942bc`](https://github.com/mastra-ai/mastra/commit/e4942bc7fdc903572f7d84f26d5e15f9d39c763d)]:
|
|
89
|
+
- @mastra/core@1.32.0
|
|
90
|
+
|
|
3
91
|
## 1.11.1-alpha.1
|
|
4
92
|
|
|
5
93
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -12,7 +12,7 @@ npm install @mastra/observability
|
|
|
12
12
|
|
|
13
13
|
```typescript
|
|
14
14
|
import { Mastra } from '@mastra/core';
|
|
15
|
-
import { Observability, DefaultExporter, CloudExporter
|
|
15
|
+
import { Observability, DefaultExporter, CloudExporter } from '@mastra/observability';
|
|
16
16
|
|
|
17
17
|
export const mastra = new Mastra({
|
|
18
18
|
observability: new Observability({
|
|
@@ -23,13 +23,14 @@ export const mastra = new Mastra({
|
|
|
23
23
|
new DefaultExporter(), // Persists traces for Mastra Studio
|
|
24
24
|
new CloudExporter(), // Sends to Mastra platform
|
|
25
25
|
],
|
|
26
|
-
spanOutputProcessors: [new SensitiveDataFilter()],
|
|
27
26
|
},
|
|
28
27
|
},
|
|
29
28
|
}),
|
|
30
29
|
});
|
|
31
30
|
```
|
|
32
31
|
|
|
32
|
+
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.
|
|
33
|
+
|
|
33
34
|
## Features
|
|
34
35
|
|
|
35
36
|
- **Auto-instrumentation** - Traces agent runs, LLM calls, tool executions, and workflows
|
package/dist/config.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ import type { RequestContext } from '@mastra/core/di';
|
|
|
8
8
|
import type { ObservabilityInstance, ObservabilityExporter, ObservabilityBridge, SpanOutputProcessor, ConfigSelector, SerializationOptions, CardinalityConfig, LogLevel, AnyExportedSpan } from '@mastra/core/observability';
|
|
9
9
|
import { SpanType } from '@mastra/core/observability';
|
|
10
10
|
import { z } from 'zod/v4';
|
|
11
|
+
import type { SensitiveDataFilterOptions } from './span_processors/index.js';
|
|
11
12
|
/**
|
|
12
13
|
* Sampling strategy types
|
|
13
14
|
*/
|
|
@@ -130,6 +131,25 @@ export interface ObservabilityRegistryConfig {
|
|
|
130
131
|
configs?: Record<string, Omit<ObservabilityInstanceConfig, 'name'> | ObservabilityInstance>;
|
|
131
132
|
/** Optional selector function to choose which tracing instance to use */
|
|
132
133
|
configSelector?: ConfigSelector;
|
|
134
|
+
/**
|
|
135
|
+
* Controls whether a `SensitiveDataFilter` span output processor is automatically
|
|
136
|
+
* applied to every configured observability instance. This protects against
|
|
137
|
+
* accidentally exporting secrets (API keys, tokens, passwords, etc.) to
|
|
138
|
+
* exporters such as the Mastra cloud exporter.
|
|
139
|
+
*
|
|
140
|
+
* - `true` (default): apply `SensitiveDataFilter` with default options.
|
|
141
|
+
* - `false`: do not auto-apply the filter. You can still add it manually via
|
|
142
|
+
* `spanOutputProcessors` on a specific config.
|
|
143
|
+
* - an object: apply `SensitiveDataFilter` with the provided options.
|
|
144
|
+
*
|
|
145
|
+
* If a config already includes a `SensitiveDataFilter` in
|
|
146
|
+
* `spanOutputProcessors`, the auto-applied filter is skipped to avoid
|
|
147
|
+
* double redaction. The auto-applied filter runs last (after any
|
|
148
|
+
* user-provided processors) so that sensitive data introduced or
|
|
149
|
+
* surfaced by upstream processors is still redacted before export.
|
|
150
|
+
* Pre-instantiated `ObservabilityInstance` values are not modified.
|
|
151
|
+
*/
|
|
152
|
+
sensitiveDataFilter?: boolean | SensitiveDataFilterOptions;
|
|
133
153
|
}
|
|
134
154
|
/**
|
|
135
155
|
* Zod schema for SamplingStrategy
|
|
@@ -246,17 +266,19 @@ export declare const observabilityConfigValueSchema: z.ZodObject<{
|
|
|
246
266
|
}>>;
|
|
247
267
|
}, z.core.$strip>>;
|
|
248
268
|
}, z.core.$strip>;
|
|
249
|
-
/**
|
|
250
|
-
* Zod schema for ObservabilityRegistryConfig
|
|
251
|
-
* Note: Individual configs are validated separately in the constructor to allow for
|
|
252
|
-
* both plain config objects and pre-instantiated ObservabilityInstance objects.
|
|
253
|
-
* The schema is permissive to handle edge cases gracefully (arrays, null values).
|
|
254
|
-
*/
|
|
255
269
|
export declare const observabilityRegistryConfigSchema: z.ZodObject<{
|
|
256
270
|
default: z.ZodNullable<z.ZodOptional<z.ZodObject<{
|
|
257
271
|
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
258
272
|
}, z.core.$strip>>>;
|
|
259
273
|
configs: z.ZodOptional<z.ZodUnion<readonly [z.ZodRecord<z.ZodString, z.ZodAny>, z.ZodArray<z.ZodAny>, z.ZodNull]>>;
|
|
260
274
|
configSelector: z.ZodOptional<z.ZodFunction<z.core.$ZodFunctionArgs, z.core.$ZodFunctionOut>>;
|
|
275
|
+
sensitiveDataFilter: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodObject<{
|
|
276
|
+
sensitiveFields: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
277
|
+
redactionToken: z.ZodOptional<z.ZodString>;
|
|
278
|
+
redactionStyle: z.ZodOptional<z.ZodEnum<{
|
|
279
|
+
full: "full";
|
|
280
|
+
partial: "partial";
|
|
281
|
+
}>>;
|
|
282
|
+
}, z.core.$strict>]>>;
|
|
261
283
|
}, z.core.$loose>;
|
|
262
284
|
//# sourceMappingURL=config.d.ts.map
|
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,KAAK,EACV,qBAAqB,EACrB,qBAAqB,EACrB,mBAAmB,EACnB,mBAAmB,EACnB,cAAc,EACd,oBAAoB,EACpB,iBAAiB,EACjB,QAAQ,EACR,eAAe,EAChB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AACtD,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,KAAK,EACV,qBAAqB,EACrB,qBAAqB,EACrB,mBAAmB,EACnB,mBAAmB,EACnB,cAAc,EACd,oBAAoB,EACpB,iBAAiB,EACjB,QAAQ,EACR,eAAe,EAChB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AACtD,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAC3B,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,mBAAmB,CAAC;AAMpE;;GAEG;AACH,oBAAY,oBAAoB;IAC9B,MAAM,WAAW;IACjB,KAAK,UAAU;IACf,KAAK,UAAU;IACf,MAAM,WAAW;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACn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AC,EAAE,kBAAkB,CAAC;QACxC,KAAK,EAAE,UAAU,CAAC;KACnB,GAAG,OAAO,CAAC,IAAI,CAAC;IAsCX,WAAW,CAAC,IAAI,EAAE;QACtB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;QACxC,QAAQ,EAAE,aAAa,CAAC;KACzB,GAAG,OAAO,CAAC,IAAI,CAAC;IAsCjB,iFAAiF;IACjF,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,qBAAqB,EAAE,SAAS,UAAQ,GAAG,IAAI;IAWxF,yCAAyC;IACzC,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,qBAAqB,GAAG,SAAS;IAI5D,8CAA8C;IAC9C,kBAAkB,IAAI,qBAAqB,GAAG,SAAS;IAIvD,mDAAmD;IACnD,aAAa,IAAI,WAAW,CAAC,MAAM,EAAE,qBAAqB,CAAC;IAI3D,gFAAgF;IAChF,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAIzC,mEAAmE;IACnE,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAIlC,qEAAqE;IACrE,iBAAiB,CAAC,QAAQ,EAAE,cAAc,GAAG,IAAI;IAIjD,8DAA8D;IAC9D,KAAK,IAAI,IAAI;IAIb,qEAAqE;IAC/D,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;CAqDhC"}
|
package/dist/index.cjs
CHANGED
|
@@ -13905,12 +13905,18 @@ var observabilityConfigValueSchema = external_exports.object(observabilityInstan
|
|
|
13905
13905
|
message: "At least one exporter or a bridge is required"
|
|
13906
13906
|
}
|
|
13907
13907
|
);
|
|
13908
|
+
var sensitiveDataFilterOptionsSchema = external_exports.object({
|
|
13909
|
+
sensitiveFields: external_exports.array(external_exports.string()).optional(),
|
|
13910
|
+
redactionToken: external_exports.string().optional(),
|
|
13911
|
+
redactionStyle: external_exports.enum(["full", "partial"]).optional()
|
|
13912
|
+
}).strict();
|
|
13908
13913
|
var observabilityRegistryConfigSchema = external_exports.object({
|
|
13909
13914
|
default: external_exports.object({
|
|
13910
13915
|
enabled: external_exports.boolean().optional()
|
|
13911
13916
|
}).optional().nullable(),
|
|
13912
13917
|
configs: external_exports.union([external_exports.record(external_exports.string(), external_exports.any()), external_exports.array(external_exports.any()), external_exports.null()]).optional(),
|
|
13913
|
-
configSelector: external_exports.function().optional()
|
|
13918
|
+
configSelector: external_exports.function().optional(),
|
|
13919
|
+
sensitiveDataFilter: external_exports.union([external_exports.boolean(), sensitiveDataFilterOptionsSchema]).optional()
|
|
13914
13920
|
}).passthrough().refine(
|
|
13915
13921
|
(data) => {
|
|
13916
13922
|
const isDefaultEnabled = data.default?.enabled === true;
|
|
@@ -20887,23 +20893,56 @@ var Observability = class extends base.MastraBase {
|
|
|
20887
20893
|
}
|
|
20888
20894
|
}
|
|
20889
20895
|
}
|
|
20896
|
+
const sensitiveDataFilterSetting = config2.sensitiveDataFilter ?? true;
|
|
20897
|
+
const shouldAutoApplySensitiveFilter = sensitiveDataFilterSetting !== false;
|
|
20898
|
+
const sensitiveDataFilterOptions = typeof sensitiveDataFilterSetting === "object" && sensitiveDataFilterSetting !== null ? sensitiveDataFilterSetting : void 0;
|
|
20899
|
+
const buildAutoSensitiveFilter = () => {
|
|
20900
|
+
if (!shouldAutoApplySensitiveFilter) {
|
|
20901
|
+
return void 0;
|
|
20902
|
+
}
|
|
20903
|
+
return new SensitiveDataFilter(sensitiveDataFilterOptions);
|
|
20904
|
+
};
|
|
20890
20905
|
if (config2.default?.enabled) {
|
|
20891
20906
|
console.warn(
|
|
20892
|
-
'[Mastra Observability] The "default: { enabled: true }" configuration is deprecated and will be removed in a future version. Please use explicit configs with DefaultExporter
|
|
20907
|
+
'[Mastra Observability] The "default: { enabled: true }" configuration is deprecated and will be removed in a future version. Please use explicit configs with DefaultExporter and CloudExporter instead. Sensitive data filtering is applied by default and can be controlled via the top-level "sensitiveDataFilter" option. See https://mastra.ai/docs/observability/tracing/overview for the recommended configuration.'
|
|
20893
20908
|
);
|
|
20909
|
+
const autoFilter = buildAutoSensitiveFilter();
|
|
20894
20910
|
const defaultInstance = new DefaultObservabilityInstance({
|
|
20895
20911
|
serviceName: "mastra",
|
|
20896
20912
|
name: "default",
|
|
20897
20913
|
sampling: { type: "always" /* ALWAYS */ },
|
|
20898
20914
|
exporters: [new DefaultExporter(), new CloudExporter()],
|
|
20899
|
-
spanOutputProcessors: [
|
|
20915
|
+
spanOutputProcessors: autoFilter ? [autoFilter] : []
|
|
20900
20916
|
});
|
|
20901
20917
|
this.#registry.register("default", defaultInstance, true);
|
|
20902
20918
|
}
|
|
20903
20919
|
if (config2.configs) {
|
|
20904
20920
|
const instances = Object.entries(config2.configs);
|
|
20905
20921
|
instances.forEach(([name, tracingDef], index) => {
|
|
20906
|
-
|
|
20922
|
+
let instance;
|
|
20923
|
+
if (isInstance(tracingDef)) {
|
|
20924
|
+
instance = tracingDef;
|
|
20925
|
+
if (shouldAutoApplySensitiveFilter) {
|
|
20926
|
+
const processors = instance.getSpanOutputProcessors?.() ?? [];
|
|
20927
|
+
const hasFilter = processors.some((p) => p instanceof SensitiveDataFilter);
|
|
20928
|
+
if (!hasFilter) {
|
|
20929
|
+
this.logger?.warn(
|
|
20930
|
+
"[Mastra Observability] Pre-instantiated observability instance does not include a SensitiveDataFilter. Auto-applied filtering is skipped for pre-instantiated instances. Add a SensitiveDataFilter to spanOutputProcessors when constructing the instance to redact sensitive data.",
|
|
20931
|
+
{ instanceName: name }
|
|
20932
|
+
);
|
|
20933
|
+
}
|
|
20934
|
+
}
|
|
20935
|
+
} else {
|
|
20936
|
+
const userProcessors = tracingDef.spanOutputProcessors ?? [];
|
|
20937
|
+
const hasFilter = userProcessors.some((p) => p instanceof SensitiveDataFilter);
|
|
20938
|
+
const autoFilter = !hasFilter ? buildAutoSensitiveFilter() : void 0;
|
|
20939
|
+
const spanOutputProcessors = autoFilter ? [...userProcessors, autoFilter] : userProcessors;
|
|
20940
|
+
instance = new DefaultObservabilityInstance({
|
|
20941
|
+
...tracingDef,
|
|
20942
|
+
name,
|
|
20943
|
+
spanOutputProcessors
|
|
20944
|
+
});
|
|
20945
|
+
}
|
|
20907
20946
|
const isDefault = !config2.default?.enabled && index === 0;
|
|
20908
20947
|
this.#registry.register(name, instance, isDefault);
|
|
20909
20948
|
});
|