autotel-schema 12.0.0 → 14.0.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/dist/index.cjs +2 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/{processor-C9NmN0wQ.cjs → processor-DQvVwsvP.cjs} +38 -0
- package/dist/{processor-Cn0HNUvw.js → processor-PQss56h3.js} +33 -1
- package/dist/processor.cjs +2 -1
- package/dist/processor.d.cts +33 -1
- package/dist/processor.d.ts +33 -1
- package/dist/processor.js +2 -2
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
const require_snapshot = require('./snapshot-BJmrOlMK.cjs');
|
|
3
|
-
const require_processor = require('./processor-
|
|
3
|
+
const require_processor = require('./processor-DQvVwsvP.cjs');
|
|
4
4
|
const require_diff = require('./diff.cjs');
|
|
5
5
|
|
|
6
6
|
//#region src/completeness.ts
|
|
@@ -356,6 +356,7 @@ exports.AGENT_SECURITY_TELEMETRY_CONTRACT = AGENT_SECURITY_TELEMETRY_CONTRACT;
|
|
|
356
356
|
exports.ATTRIBUTE_TYPES = require_processor.ATTRIBUTE_TYPES;
|
|
357
357
|
exports.GENAI_COMPLETENESS_FIELDS = GENAI_COMPLETENESS_FIELDS;
|
|
358
358
|
exports.SCHEMA_ATTRS = require_snapshot.SCHEMA_ATTRS;
|
|
359
|
+
exports.SCHEMA_VIOLATION_ATTRS = require_processor.SCHEMA_VIOLATION_ATTRS;
|
|
359
360
|
exports.SNAPSHOT_SPEC = require_snapshot.SNAPSHOT_SPEC;
|
|
360
361
|
exports.STABILITIES = require_processor.STABILITIES;
|
|
361
362
|
exports.SchemaValidationSpanProcessor = require_processor.SchemaValidationSpanProcessor;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { a as diffSnapshots, c as ContractSnapshot, d as contractToSnapshot, f as parseSnapshot, g as SchemaAttributeKey, h as SNAPSHOT_SPEC, i as SnapshotDiff, l as SnapshotAttribute, m as SCHEMA_ATTRS, n as ChangeType, o as formatDiff, p as serializeSnapshot, r as SnapshotChange, s as hasBreakingChanges, t as ChangeKind, u as SnapshotSpan } from "./diff-B9GL_E28.cjs";
|
|
2
2
|
import { A as validateScenarioSpec, C as ScenarioViolationCode, D as isScenarioClosed, E as formatScenarioResult, F as ViolationCode, I as ViolationSeverity, L as formatViolation, M as EmittedSpan, N as SchemaViolation, O as parseCardinality, P as ValidateOptions, R as hasErrors, S as ScenarioViolation, T as evaluateScenario, _ as ScenarioOutcome, a as SpanSpec, b as ScenarioSpan, c as allowsAdditionalAttributes, d as Cardinality, f as CheckScenarioOptions, g as ScenarioEventSpec, h as ScenarioAddition, i as STABILITIES, j as EmittedAttributeValue, k as proposeScenario, l as defineContract, m as EvaluateScenarioOptions, n as AttributeSpec, o as Stability, p as CompletionBoundary, r as AttributeType, s as TelemetryContract, t as ATTRIBUTE_TYPES, u as resolveAttributeSpec, v as ScenarioProposal, w as checkScenario, x as ScenarioSpec, y as ScenarioResult, z as validateSpan } from "./contract-CfOaZcD0.cjs";
|
|
3
|
-
import { OtelContext, ReadableSpanLike, SchemaProcessorMode, SchemaValidationProcessorOptions, SchemaValidationSpanProcessor, SpanLike, SpanProcessorLike, createSchemaValidationProcessor } from "./processor.cjs";
|
|
3
|
+
import { OtelContext, ReadableSpanLike, SCHEMA_VIOLATION_ATTRS, SchemaProcessorMode, SchemaValidationProcessorOptions, SchemaValidationSpanProcessor, SpanLike, SpanProcessorLike, createSchemaValidationProcessor } from "./processor.cjs";
|
|
4
4
|
//#region src/completeness.d.ts
|
|
5
5
|
/** The ten fields a GenAI trace is scored on. */
|
|
6
6
|
declare const GENAI_COMPLETENESS_FIELDS: readonly ["llm_input", "llm_output", "model_name", "token_usage", "cost_usd", "latency_per_span", "tool_call_args", "tool_call_results", "span_tree", "span_count"];
|
|
@@ -99,4 +99,4 @@ declare function isHighCardinalityKey(contract: TelemetryContract, key: string):
|
|
|
99
99
|
*/
|
|
100
100
|
declare const AGENT_SECURITY_TELEMETRY_CONTRACT: TelemetryContract;
|
|
101
101
|
//#endregion
|
|
102
|
-
export { AGENT_SECURITY_TELEMETRY_CONTRACT, ATTRIBUTE_TYPES, type AttributeSpec, type AttributeType, type Cardinality, type ChangeKind, type ChangeType, type CheckScenarioOptions, type CompletenessOptions, type CompletenessResult, type CompletenessVerdict, type CompletionBoundary, type ContractSnapshot, type EmittedAttributeValue, type EmittedSpan, type EvaluateScenarioOptions, type FieldScore, GENAI_COMPLETENESS_FIELDS, type GenAiCompletenessField, type OtelContext, type ReadableSpanLike, SCHEMA_ATTRS, SNAPSHOT_SPEC, STABILITIES, type ScenarioAddition, type ScenarioEventSpec, type ScenarioOutcome, type ScenarioProposal, type ScenarioResult, type ScenarioSpan, type ScenarioSpec, type ScenarioViolation, type ScenarioViolationCode, type SchemaAttributeKey, type SchemaProcessorMode, type SchemaValidationProcessorOptions, SchemaValidationSpanProcessor, type SchemaViolation, type SnapshotAttribute, type SnapshotChange, type SnapshotDiff, type SnapshotSpan, type SpanLike, type SpanProcessorLike, type SpanSpec, type Stability, type TelemetryContract, type ValidateOptions, type ViolationCode, type ViolationSeverity, allowsAdditionalAttributes, checkScenario, contractToSnapshot, createSchemaValidationProcessor, defineContract, diffSnapshots, evaluateScenario, formatCompleteness, formatDiff, formatScenarioResult, formatViolation, hasBreakingChanges, hasErrors, highCardinalityKeys, isHighCardinalityKey, isScenarioClosed, parseCardinality, parseSnapshot, proposeScenario, resolveAttributeSpec, scoreGenAiCompleteness, serializeSnapshot, validateScenarioSpec, validateSpan };
|
|
102
|
+
export { AGENT_SECURITY_TELEMETRY_CONTRACT, ATTRIBUTE_TYPES, type AttributeSpec, type AttributeType, type Cardinality, type ChangeKind, type ChangeType, type CheckScenarioOptions, type CompletenessOptions, type CompletenessResult, type CompletenessVerdict, type CompletionBoundary, type ContractSnapshot, type EmittedAttributeValue, type EmittedSpan, type EvaluateScenarioOptions, type FieldScore, GENAI_COMPLETENESS_FIELDS, type GenAiCompletenessField, type OtelContext, type ReadableSpanLike, SCHEMA_ATTRS, SCHEMA_VIOLATION_ATTRS, SNAPSHOT_SPEC, STABILITIES, type ScenarioAddition, type ScenarioEventSpec, type ScenarioOutcome, type ScenarioProposal, type ScenarioResult, type ScenarioSpan, type ScenarioSpec, type ScenarioViolation, type ScenarioViolationCode, type SchemaAttributeKey, type SchemaProcessorMode, type SchemaValidationProcessorOptions, SchemaValidationSpanProcessor, type SchemaViolation, type SnapshotAttribute, type SnapshotChange, type SnapshotDiff, type SnapshotSpan, type SpanLike, type SpanProcessorLike, type SpanSpec, type Stability, type TelemetryContract, type ValidateOptions, type ViolationCode, type ViolationSeverity, allowsAdditionalAttributes, checkScenario, contractToSnapshot, createSchemaValidationProcessor, defineContract, diffSnapshots, evaluateScenario, formatCompleteness, formatDiff, formatScenarioResult, formatViolation, hasBreakingChanges, hasErrors, highCardinalityKeys, isHighCardinalityKey, isScenarioClosed, parseCardinality, parseSnapshot, proposeScenario, resolveAttributeSpec, scoreGenAiCompleteness, serializeSnapshot, validateScenarioSpec, validateSpan };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { a as diffSnapshots, c as ContractSnapshot, d as contractToSnapshot, f as parseSnapshot, g as SchemaAttributeKey, h as SNAPSHOT_SPEC, i as SnapshotDiff, l as SnapshotAttribute, m as SCHEMA_ATTRS, n as ChangeType, o as formatDiff, p as serializeSnapshot, r as SnapshotChange, s as hasBreakingChanges, t as ChangeKind, u as SnapshotSpan } from "./diff-DenUg42T.js";
|
|
2
2
|
import { A as validateScenarioSpec, C as ScenarioViolationCode, D as isScenarioClosed, E as formatScenarioResult, F as ViolationCode, I as ViolationSeverity, L as formatViolation, M as EmittedSpan, N as SchemaViolation, O as parseCardinality, P as ValidateOptions, R as hasErrors, S as ScenarioViolation, T as evaluateScenario, _ as ScenarioOutcome, a as SpanSpec, b as ScenarioSpan, c as allowsAdditionalAttributes, d as Cardinality, f as CheckScenarioOptions, g as ScenarioEventSpec, h as ScenarioAddition, i as STABILITIES, j as EmittedAttributeValue, k as proposeScenario, l as defineContract, m as EvaluateScenarioOptions, n as AttributeSpec, o as Stability, p as CompletionBoundary, r as AttributeType, s as TelemetryContract, t as ATTRIBUTE_TYPES, u as resolveAttributeSpec, v as ScenarioProposal, w as checkScenario, x as ScenarioSpec, y as ScenarioResult, z as validateSpan } from "./contract-CfOaZcD0.js";
|
|
3
|
-
import { OtelContext, ReadableSpanLike, SchemaProcessorMode, SchemaValidationProcessorOptions, SchemaValidationSpanProcessor, SpanLike, SpanProcessorLike, createSchemaValidationProcessor } from "./processor.js";
|
|
3
|
+
import { OtelContext, ReadableSpanLike, SCHEMA_VIOLATION_ATTRS, SchemaProcessorMode, SchemaValidationProcessorOptions, SchemaValidationSpanProcessor, SpanLike, SpanProcessorLike, createSchemaValidationProcessor } from "./processor.js";
|
|
4
4
|
//#region src/completeness.d.ts
|
|
5
5
|
/** The ten fields a GenAI trace is scored on. */
|
|
6
6
|
declare const GENAI_COMPLETENESS_FIELDS: readonly ["llm_input", "llm_output", "model_name", "token_usage", "cost_usd", "latency_per_span", "tool_call_args", "tool_call_results", "span_tree", "span_count"];
|
|
@@ -99,4 +99,4 @@ declare function isHighCardinalityKey(contract: TelemetryContract, key: string):
|
|
|
99
99
|
*/
|
|
100
100
|
declare const AGENT_SECURITY_TELEMETRY_CONTRACT: TelemetryContract;
|
|
101
101
|
//#endregion
|
|
102
|
-
export { AGENT_SECURITY_TELEMETRY_CONTRACT, ATTRIBUTE_TYPES, type AttributeSpec, type AttributeType, type Cardinality, type ChangeKind, type ChangeType, type CheckScenarioOptions, type CompletenessOptions, type CompletenessResult, type CompletenessVerdict, type CompletionBoundary, type ContractSnapshot, type EmittedAttributeValue, type EmittedSpan, type EvaluateScenarioOptions, type FieldScore, GENAI_COMPLETENESS_FIELDS, type GenAiCompletenessField, type OtelContext, type ReadableSpanLike, SCHEMA_ATTRS, SNAPSHOT_SPEC, STABILITIES, type ScenarioAddition, type ScenarioEventSpec, type ScenarioOutcome, type ScenarioProposal, type ScenarioResult, type ScenarioSpan, type ScenarioSpec, type ScenarioViolation, type ScenarioViolationCode, type SchemaAttributeKey, type SchemaProcessorMode, type SchemaValidationProcessorOptions, SchemaValidationSpanProcessor, type SchemaViolation, type SnapshotAttribute, type SnapshotChange, type SnapshotDiff, type SnapshotSpan, type SpanLike, type SpanProcessorLike, type SpanSpec, type Stability, type TelemetryContract, type ValidateOptions, type ViolationCode, type ViolationSeverity, allowsAdditionalAttributes, checkScenario, contractToSnapshot, createSchemaValidationProcessor, defineContract, diffSnapshots, evaluateScenario, formatCompleteness, formatDiff, formatScenarioResult, formatViolation, hasBreakingChanges, hasErrors, highCardinalityKeys, isHighCardinalityKey, isScenarioClosed, parseCardinality, parseSnapshot, proposeScenario, resolveAttributeSpec, scoreGenAiCompleteness, serializeSnapshot, validateScenarioSpec, validateSpan };
|
|
102
|
+
export { AGENT_SECURITY_TELEMETRY_CONTRACT, ATTRIBUTE_TYPES, type AttributeSpec, type AttributeType, type Cardinality, type ChangeKind, type ChangeType, type CheckScenarioOptions, type CompletenessOptions, type CompletenessResult, type CompletenessVerdict, type CompletionBoundary, type ContractSnapshot, type EmittedAttributeValue, type EmittedSpan, type EvaluateScenarioOptions, type FieldScore, GENAI_COMPLETENESS_FIELDS, type GenAiCompletenessField, type OtelContext, type ReadableSpanLike, SCHEMA_ATTRS, SCHEMA_VIOLATION_ATTRS, SNAPSHOT_SPEC, STABILITIES, type ScenarioAddition, type ScenarioEventSpec, type ScenarioOutcome, type ScenarioProposal, type ScenarioResult, type ScenarioSpan, type ScenarioSpec, type ScenarioViolation, type ScenarioViolationCode, type SchemaAttributeKey, type SchemaProcessorMode, type SchemaValidationProcessorOptions, SchemaValidationSpanProcessor, type SchemaViolation, type SnapshotAttribute, type SnapshotChange, type SnapshotDiff, type SnapshotSpan, type SpanLike, type SpanProcessorLike, type SpanSpec, type Stability, type TelemetryContract, type ValidateOptions, type ViolationCode, type ViolationSeverity, allowsAdditionalAttributes, checkScenario, contractToSnapshot, createSchemaValidationProcessor, defineContract, diffSnapshots, evaluateScenario, formatCompleteness, formatDiff, formatScenarioResult, formatViolation, hasBreakingChanges, hasErrors, highCardinalityKeys, isHighCardinalityKey, isScenarioClosed, parseCardinality, parseSnapshot, proposeScenario, resolveAttributeSpec, scoreGenAiCompleteness, serializeSnapshot, validateScenarioSpec, validateSpan };
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { a as SNAPSHOT_SPEC, i as SCHEMA_ATTRS, n as parseSnapshot, r as serializeSnapshot, t as contractToSnapshot } from "./snapshot-BFIxChH0.js";
|
|
2
|
-
import { _ as
|
|
2
|
+
import { _ as proposeScenario, a as hasErrors, c as STABILITIES, d as resolveAttributeSpec, f as checkScenario, g as parseCardinality, h as isScenarioClosed, i as formatViolation, l as allowsAdditionalAttributes, m as formatScenarioResult, n as SchemaValidationSpanProcessor, o as validateSpan, p as evaluateScenario, r as createSchemaValidationProcessor, s as ATTRIBUTE_TYPES, t as SCHEMA_VIOLATION_ATTRS, u as defineContract, v as validateScenarioSpec } from "./processor-PQss56h3.js";
|
|
3
3
|
import { diffSnapshots, formatDiff, hasBreakingChanges } from "./diff.js";
|
|
4
4
|
|
|
5
5
|
//#region src/completeness.ts
|
|
@@ -351,4 +351,4 @@ const AGENT_SECURITY_TELEMETRY_CONTRACT = defineContract({
|
|
|
351
351
|
});
|
|
352
352
|
|
|
353
353
|
//#endregion
|
|
354
|
-
export { AGENT_SECURITY_TELEMETRY_CONTRACT, ATTRIBUTE_TYPES, GENAI_COMPLETENESS_FIELDS, SCHEMA_ATTRS, SNAPSHOT_SPEC, STABILITIES, SchemaValidationSpanProcessor, allowsAdditionalAttributes, checkScenario, contractToSnapshot, createSchemaValidationProcessor, defineContract, diffSnapshots, evaluateScenario, formatCompleteness, formatDiff, formatScenarioResult, formatViolation, hasBreakingChanges, hasErrors, highCardinalityKeys, isHighCardinalityKey, isScenarioClosed, parseCardinality, parseSnapshot, proposeScenario, resolveAttributeSpec, scoreGenAiCompleteness, serializeSnapshot, validateScenarioSpec, validateSpan };
|
|
354
|
+
export { AGENT_SECURITY_TELEMETRY_CONTRACT, ATTRIBUTE_TYPES, GENAI_COMPLETENESS_FIELDS, SCHEMA_ATTRS, SCHEMA_VIOLATION_ATTRS, SNAPSHOT_SPEC, STABILITIES, SchemaValidationSpanProcessor, allowsAdditionalAttributes, checkScenario, contractToSnapshot, createSchemaValidationProcessor, defineContract, diffSnapshots, evaluateScenario, formatCompleteness, formatDiff, formatScenarioResult, formatViolation, hasBreakingChanges, hasErrors, highCardinalityKeys, isHighCardinalityKey, isScenarioClosed, parseCardinality, parseSnapshot, proposeScenario, resolveAttributeSpec, scoreGenAiCompleteness, serializeSnapshot, validateScenarioSpec, validateSpan };
|
|
@@ -566,6 +566,20 @@ function formatViolation(v) {
|
|
|
566
566
|
* but `enabledInProduction` is there if you want a sampled canary in prod.
|
|
567
567
|
*/
|
|
568
568
|
const DEFAULT_WARN_INTERVAL_MS = 6e4;
|
|
569
|
+
/**
|
|
570
|
+
* How many violation codes a single span carries.
|
|
571
|
+
*
|
|
572
|
+
* The count attribute stays exact, so trimming the list loses detail but never
|
|
573
|
+
* misleads about scale. Without a cap, one span against a wide contract could
|
|
574
|
+
* carry hundreds of strings into every exporter downstream.
|
|
575
|
+
*/
|
|
576
|
+
const MAX_STAMPED_CODES = 20;
|
|
577
|
+
/** Attributes written onto a span carrying contract violations. */
|
|
578
|
+
const SCHEMA_VIOLATION_ATTRS = {
|
|
579
|
+
count: "autotel.schema.violations",
|
|
580
|
+
severity: "autotel.schema.violation.severity",
|
|
581
|
+
codes: "autotel.schema.violation.codes"
|
|
582
|
+
};
|
|
569
583
|
function isProduction() {
|
|
570
584
|
return process.env.NODE_ENV === "production";
|
|
571
585
|
}
|
|
@@ -600,12 +614,30 @@ var SchemaValidationSpanProcessor = class {
|
|
|
600
614
|
} catch {
|
|
601
615
|
return;
|
|
602
616
|
}
|
|
617
|
+
if (this.opts.stampViolations) this.stamp(span, violations);
|
|
603
618
|
for (const violation of violations) {
|
|
604
619
|
this.violationCount++;
|
|
605
620
|
this.opts.onViolation?.(violation, span);
|
|
606
621
|
this.handle(violation);
|
|
607
622
|
}
|
|
608
623
|
}
|
|
624
|
+
/**
|
|
625
|
+
* Record the violations on the span itself.
|
|
626
|
+
*
|
|
627
|
+
* A conforming span is left alone rather than marked with a zero: the
|
|
628
|
+
* presence of the attribute is what a reader filters on, and stamping every
|
|
629
|
+
* span would make `autotel.schema.violations` mean nothing while costing
|
|
630
|
+
* payload on the spans that are fine.
|
|
631
|
+
*/
|
|
632
|
+
stamp(span, violations) {
|
|
633
|
+
if (violations.length === 0) return;
|
|
634
|
+
try {
|
|
635
|
+
const worst = violations.some((v) => v.severity === "error") ? "error" : "warning";
|
|
636
|
+
span.attributes[SCHEMA_VIOLATION_ATTRS.count] = violations.length;
|
|
637
|
+
span.attributes[SCHEMA_VIOLATION_ATTRS.severity] = worst;
|
|
638
|
+
span.attributes[SCHEMA_VIOLATION_ATTRS.codes] = violations.slice(0, MAX_STAMPED_CODES).map((v) => v.attribute ? `${v.code}:${v.attribute}` : v.code);
|
|
639
|
+
} catch {}
|
|
640
|
+
}
|
|
609
641
|
handle(violation) {
|
|
610
642
|
const mode = this.opts.mode ?? "warn";
|
|
611
643
|
if (mode === "silent") return;
|
|
@@ -638,6 +670,12 @@ Object.defineProperty(exports, 'ATTRIBUTE_TYPES', {
|
|
|
638
670
|
return ATTRIBUTE_TYPES;
|
|
639
671
|
}
|
|
640
672
|
});
|
|
673
|
+
Object.defineProperty(exports, 'SCHEMA_VIOLATION_ATTRS', {
|
|
674
|
+
enumerable: true,
|
|
675
|
+
get: function () {
|
|
676
|
+
return SCHEMA_VIOLATION_ATTRS;
|
|
677
|
+
}
|
|
678
|
+
});
|
|
641
679
|
Object.defineProperty(exports, 'STABILITIES', {
|
|
642
680
|
enumerable: true,
|
|
643
681
|
get: function () {
|
|
@@ -565,6 +565,20 @@ function formatViolation(v) {
|
|
|
565
565
|
* but `enabledInProduction` is there if you want a sampled canary in prod.
|
|
566
566
|
*/
|
|
567
567
|
const DEFAULT_WARN_INTERVAL_MS = 6e4;
|
|
568
|
+
/**
|
|
569
|
+
* How many violation codes a single span carries.
|
|
570
|
+
*
|
|
571
|
+
* The count attribute stays exact, so trimming the list loses detail but never
|
|
572
|
+
* misleads about scale. Without a cap, one span against a wide contract could
|
|
573
|
+
* carry hundreds of strings into every exporter downstream.
|
|
574
|
+
*/
|
|
575
|
+
const MAX_STAMPED_CODES = 20;
|
|
576
|
+
/** Attributes written onto a span carrying contract violations. */
|
|
577
|
+
const SCHEMA_VIOLATION_ATTRS = {
|
|
578
|
+
count: "autotel.schema.violations",
|
|
579
|
+
severity: "autotel.schema.violation.severity",
|
|
580
|
+
codes: "autotel.schema.violation.codes"
|
|
581
|
+
};
|
|
568
582
|
function isProduction() {
|
|
569
583
|
return process.env.NODE_ENV === "production";
|
|
570
584
|
}
|
|
@@ -599,12 +613,30 @@ var SchemaValidationSpanProcessor = class {
|
|
|
599
613
|
} catch {
|
|
600
614
|
return;
|
|
601
615
|
}
|
|
616
|
+
if (this.opts.stampViolations) this.stamp(span, violations);
|
|
602
617
|
for (const violation of violations) {
|
|
603
618
|
this.violationCount++;
|
|
604
619
|
this.opts.onViolation?.(violation, span);
|
|
605
620
|
this.handle(violation);
|
|
606
621
|
}
|
|
607
622
|
}
|
|
623
|
+
/**
|
|
624
|
+
* Record the violations on the span itself.
|
|
625
|
+
*
|
|
626
|
+
* A conforming span is left alone rather than marked with a zero: the
|
|
627
|
+
* presence of the attribute is what a reader filters on, and stamping every
|
|
628
|
+
* span would make `autotel.schema.violations` mean nothing while costing
|
|
629
|
+
* payload on the spans that are fine.
|
|
630
|
+
*/
|
|
631
|
+
stamp(span, violations) {
|
|
632
|
+
if (violations.length === 0) return;
|
|
633
|
+
try {
|
|
634
|
+
const worst = violations.some((v) => v.severity === "error") ? "error" : "warning";
|
|
635
|
+
span.attributes[SCHEMA_VIOLATION_ATTRS.count] = violations.length;
|
|
636
|
+
span.attributes[SCHEMA_VIOLATION_ATTRS.severity] = worst;
|
|
637
|
+
span.attributes[SCHEMA_VIOLATION_ATTRS.codes] = violations.slice(0, MAX_STAMPED_CODES).map((v) => v.attribute ? `${v.code}:${v.attribute}` : v.code);
|
|
638
|
+
} catch {}
|
|
639
|
+
}
|
|
608
640
|
handle(violation) {
|
|
609
641
|
const mode = this.opts.mode ?? "warn";
|
|
610
642
|
if (mode === "silent") return;
|
|
@@ -631,4 +663,4 @@ function createSchemaValidationProcessor(opts) {
|
|
|
631
663
|
}
|
|
632
664
|
|
|
633
665
|
//#endregion
|
|
634
|
-
export {
|
|
666
|
+
export { proposeScenario as _, hasErrors as a, STABILITIES as c, resolveAttributeSpec as d, checkScenario as f, parseCardinality as g, isScenarioClosed as h, formatViolation as i, allowsAdditionalAttributes as l, formatScenarioResult as m, SchemaValidationSpanProcessor as n, validateSpan as o, evaluateScenario as p, createSchemaValidationProcessor as r, ATTRIBUTE_TYPES as s, SCHEMA_VIOLATION_ATTRS as t, defineContract as u, validateScenarioSpec as v };
|
package/dist/processor.cjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_processor = require('./processor-
|
|
2
|
+
const require_processor = require('./processor-DQvVwsvP.cjs');
|
|
3
3
|
|
|
4
|
+
exports.SCHEMA_VIOLATION_ATTRS = require_processor.SCHEMA_VIOLATION_ATTRS;
|
|
4
5
|
exports.SchemaValidationSpanProcessor = require_processor.SchemaValidationSpanProcessor;
|
|
5
6
|
exports.createSchemaValidationProcessor = require_processor.createSchemaValidationProcessor;
|
package/dist/processor.d.cts
CHANGED
|
@@ -45,7 +45,30 @@ interface SchemaValidationProcessorOptions extends ValidateOptions {
|
|
|
45
45
|
enabledInProduction?: boolean;
|
|
46
46
|
/** Throttle window for repeated identical warnings (ms). Default 60s. */
|
|
47
47
|
warnIntervalMs?: number;
|
|
48
|
+
/**
|
|
49
|
+
* Write the violations onto the span before it is exported. Default `false`.
|
|
50
|
+
*
|
|
51
|
+
* **This is the handoff to anything that reads the span later.** The app
|
|
52
|
+
* owns the contract, so the app is the only thing that can validate; a
|
|
53
|
+
* viewer or a backend reading exported spans has no contract and never
|
|
54
|
+
* can. Marking the span is what lets a violation travel to where someone
|
|
55
|
+
* will see it.
|
|
56
|
+
*
|
|
57
|
+
* Opt-in because it changes what gets exported, and because the attributes
|
|
58
|
+
* cost payload on every non-conforming span. Turn it on in development, and
|
|
59
|
+
* in CI if something downstream reads the result.
|
|
60
|
+
*
|
|
61
|
+
* Ordering matters: this processor has to run *before* the one that exports,
|
|
62
|
+
* or the stamp lands after the span has already gone.
|
|
63
|
+
*/
|
|
64
|
+
stampViolations?: boolean;
|
|
48
65
|
}
|
|
66
|
+
/** Attributes written onto a span carrying contract violations. */
|
|
67
|
+
declare const SCHEMA_VIOLATION_ATTRS: {
|
|
68
|
+
readonly count: "autotel.schema.violations";
|
|
69
|
+
readonly severity: "autotel.schema.violation.severity";
|
|
70
|
+
readonly codes: "autotel.schema.violation.codes";
|
|
71
|
+
};
|
|
49
72
|
/**
|
|
50
73
|
* Validates each ending span against a {@link TelemetryContract}. Bounded,
|
|
51
74
|
* deduplicated warnings; fail-open on any internal error.
|
|
@@ -61,6 +84,15 @@ declare class SchemaValidationSpanProcessor implements SpanProcessorLike {
|
|
|
61
84
|
get totalViolations(): number;
|
|
62
85
|
onStart(_span: SpanLike, _parentContext: OtelContext): void;
|
|
63
86
|
onEnd(span: ReadableSpanLike): void;
|
|
87
|
+
/**
|
|
88
|
+
* Record the violations on the span itself.
|
|
89
|
+
*
|
|
90
|
+
* A conforming span is left alone rather than marked with a zero: the
|
|
91
|
+
* presence of the attribute is what a reader filters on, and stamping every
|
|
92
|
+
* span would make `autotel.schema.violations` mean nothing while costing
|
|
93
|
+
* payload on the spans that are fine.
|
|
94
|
+
*/
|
|
95
|
+
private stamp;
|
|
64
96
|
private handle;
|
|
65
97
|
private maybeWarn;
|
|
66
98
|
forceFlush(): Promise<void>;
|
|
@@ -68,4 +100,4 @@ declare class SchemaValidationSpanProcessor implements SpanProcessorLike {
|
|
|
68
100
|
}
|
|
69
101
|
declare function createSchemaValidationProcessor(opts: SchemaValidationProcessorOptions): SchemaValidationSpanProcessor;
|
|
70
102
|
//#endregion
|
|
71
|
-
export { ContextValue, OtelContext, ReadableSpanLike, SchemaProcessorMode, SchemaValidationProcessorOptions, SchemaValidationSpanProcessor, SpanLike, SpanProcessorLike, createSchemaValidationProcessor };
|
|
103
|
+
export { ContextValue, OtelContext, ReadableSpanLike, SCHEMA_VIOLATION_ATTRS, SchemaProcessorMode, SchemaValidationProcessorOptions, SchemaValidationSpanProcessor, SpanLike, SpanProcessorLike, createSchemaValidationProcessor };
|
package/dist/processor.d.ts
CHANGED
|
@@ -45,7 +45,30 @@ interface SchemaValidationProcessorOptions extends ValidateOptions {
|
|
|
45
45
|
enabledInProduction?: boolean;
|
|
46
46
|
/** Throttle window for repeated identical warnings (ms). Default 60s. */
|
|
47
47
|
warnIntervalMs?: number;
|
|
48
|
+
/**
|
|
49
|
+
* Write the violations onto the span before it is exported. Default `false`.
|
|
50
|
+
*
|
|
51
|
+
* **This is the handoff to anything that reads the span later.** The app
|
|
52
|
+
* owns the contract, so the app is the only thing that can validate; a
|
|
53
|
+
* viewer or a backend reading exported spans has no contract and never
|
|
54
|
+
* can. Marking the span is what lets a violation travel to where someone
|
|
55
|
+
* will see it.
|
|
56
|
+
*
|
|
57
|
+
* Opt-in because it changes what gets exported, and because the attributes
|
|
58
|
+
* cost payload on every non-conforming span. Turn it on in development, and
|
|
59
|
+
* in CI if something downstream reads the result.
|
|
60
|
+
*
|
|
61
|
+
* Ordering matters: this processor has to run *before* the one that exports,
|
|
62
|
+
* or the stamp lands after the span has already gone.
|
|
63
|
+
*/
|
|
64
|
+
stampViolations?: boolean;
|
|
48
65
|
}
|
|
66
|
+
/** Attributes written onto a span carrying contract violations. */
|
|
67
|
+
declare const SCHEMA_VIOLATION_ATTRS: {
|
|
68
|
+
readonly count: "autotel.schema.violations";
|
|
69
|
+
readonly severity: "autotel.schema.violation.severity";
|
|
70
|
+
readonly codes: "autotel.schema.violation.codes";
|
|
71
|
+
};
|
|
49
72
|
/**
|
|
50
73
|
* Validates each ending span against a {@link TelemetryContract}. Bounded,
|
|
51
74
|
* deduplicated warnings; fail-open on any internal error.
|
|
@@ -61,6 +84,15 @@ declare class SchemaValidationSpanProcessor implements SpanProcessorLike {
|
|
|
61
84
|
get totalViolations(): number;
|
|
62
85
|
onStart(_span: SpanLike, _parentContext: OtelContext): void;
|
|
63
86
|
onEnd(span: ReadableSpanLike): void;
|
|
87
|
+
/**
|
|
88
|
+
* Record the violations on the span itself.
|
|
89
|
+
*
|
|
90
|
+
* A conforming span is left alone rather than marked with a zero: the
|
|
91
|
+
* presence of the attribute is what a reader filters on, and stamping every
|
|
92
|
+
* span would make `autotel.schema.violations` mean nothing while costing
|
|
93
|
+
* payload on the spans that are fine.
|
|
94
|
+
*/
|
|
95
|
+
private stamp;
|
|
64
96
|
private handle;
|
|
65
97
|
private maybeWarn;
|
|
66
98
|
forceFlush(): Promise<void>;
|
|
@@ -68,4 +100,4 @@ declare class SchemaValidationSpanProcessor implements SpanProcessorLike {
|
|
|
68
100
|
}
|
|
69
101
|
declare function createSchemaValidationProcessor(opts: SchemaValidationProcessorOptions): SchemaValidationSpanProcessor;
|
|
70
102
|
//#endregion
|
|
71
|
-
export { ContextValue, OtelContext, ReadableSpanLike, SchemaProcessorMode, SchemaValidationProcessorOptions, SchemaValidationSpanProcessor, SpanLike, SpanProcessorLike, createSchemaValidationProcessor };
|
|
103
|
+
export { ContextValue, OtelContext, ReadableSpanLike, SCHEMA_VIOLATION_ATTRS, SchemaProcessorMode, SchemaValidationProcessorOptions, SchemaValidationSpanProcessor, SpanLike, SpanProcessorLike, createSchemaValidationProcessor };
|
package/dist/processor.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { n as createSchemaValidationProcessor, t as
|
|
1
|
+
import { n as SchemaValidationSpanProcessor, r as createSchemaValidationProcessor, t as SCHEMA_VIOLATION_ATTRS } from "./processor-PQss56h3.js";
|
|
2
2
|
|
|
3
|
-
export { SchemaValidationSpanProcessor, createSchemaValidationProcessor };
|
|
3
|
+
export { SCHEMA_VIOLATION_ATTRS, SchemaValidationSpanProcessor, createSchemaValidationProcessor };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "autotel-schema",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "14.0.0",
|
|
4
4
|
"description": "Your telemetry surface as a typed, versioned contract — declare the spans and attributes your service emits, validate live spans against them, and diff the surface across commits to catch breaking trace changes before they ship.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"author": "Jag Reehal <jag@jagreehal.com> (https://jagreehal.com)",
|
|
45
45
|
"license": "Apache-2.0",
|
|
46
46
|
"peerDependencies": {
|
|
47
|
-
"autotel": "7.
|
|
47
|
+
"autotel": "7.3.0"
|
|
48
48
|
},
|
|
49
49
|
"peerDependenciesMeta": {
|
|
50
50
|
"autotel": {
|