@libo11y/spec 0.4.0 → 0.7.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/README.md +8 -3
- package/dist/appregistry.d.ts +16 -0
- package/dist/appregistry.js +63 -21
- package/dist/generated/spec.d.ts +5 -2
- package/dist/generated/spec.js +6 -3
- package/dist/generated/tables.js +4 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -23,7 +23,7 @@ import { ATTR_OUTCOME, SCHEMA_URL, SENSITIVITY_OF } from "@libo11y/spec";
|
|
|
23
23
|
|
|
24
24
|
SENSITIVITY_OF.get("o11y.tenant.id"); // "internal"
|
|
25
25
|
SENSITIVITY_OF.get(ATTR_OUTCOME); // "public", for o11y.outcome
|
|
26
|
-
SCHEMA_URL; // "https://schemas.o11y.ing/libo11y/1.
|
|
26
|
+
SCHEMA_URL; // "https://schemas.o11y.ing/libo11y/1.4.0"
|
|
27
27
|
```
|
|
28
28
|
|
|
29
29
|
## Application registries
|
|
@@ -51,6 +51,11 @@ if (!result.ok) for (const v of result.violations) console.error(v.toString());
|
|
|
51
51
|
const compiled = compileAppRegistry(registry); // throws AppRegistryError when invalid
|
|
52
52
|
```
|
|
53
53
|
|
|
54
|
+
`validateCompiledAppRegistry` checks a compiled registry that was built by
|
|
55
|
+
hand or read from JSON. It applies the rules that still apply to that form,
|
|
56
|
+
the namespace, each key's namespace and name, and each class, with the same
|
|
57
|
+
rule IDs and messages.
|
|
58
|
+
|
|
54
59
|
The `@libo11y/spec/yaml` subpath reads a registry file. It decodes the
|
|
55
60
|
YAML exactly as the Go implementation does, and it is the only module that
|
|
56
61
|
depends on a YAML parser:
|
|
@@ -80,6 +85,6 @@ npx libo11y registry check o11y-registry.yaml
|
|
|
80
85
|
## Reference
|
|
81
86
|
|
|
82
87
|
The specification itself is
|
|
83
|
-
[docs/SPEC.md](https://github.com/
|
|
84
|
-
[docs/PARITY.md](https://github.com/
|
|
88
|
+
[docs/SPEC.md](https://github.com/libo11y/libo11y/blob/main/docs/SPEC.md).
|
|
89
|
+
[docs/PARITY.md](https://github.com/libo11y/libo11y/blob/main/docs/PARITY.md)
|
|
85
90
|
lists where the TypeScript packages match Go and where they differ.
|
package/dist/appregistry.d.ts
CHANGED
|
@@ -53,6 +53,22 @@ export declare class AppRegistryError extends Error {
|
|
|
53
53
|
* in name order, each attribute's rules in a fixed order.
|
|
54
54
|
*/
|
|
55
55
|
export declare function validateAppRegistry(reg: AppRegistry): AppRegistryResult;
|
|
56
|
+
/** The result of validating a compiled registry: the registry itself, or every violation in rule order. */
|
|
57
|
+
export type CompiledAppRegistryResult = {
|
|
58
|
+
readonly ok: true;
|
|
59
|
+
readonly registry: CompiledAppRegistry;
|
|
60
|
+
} | {
|
|
61
|
+
readonly ok: false;
|
|
62
|
+
readonly violations: readonly AppRegistryViolation[];
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* Applies the rules that still apply to the compiled form, in validateAppRegistry's order and with its
|
|
66
|
+
* messages: the namespace, then each key in name order for its namespace, its naming and its class. A
|
|
67
|
+
* compiled registry is a plain structural type, so one built by hand or read from JSON may break them.
|
|
68
|
+
* A classes member that is not an object, or is empty, declares no attributes. Anything
|
|
69
|
+
* compileAppRegistry returned passes.
|
|
70
|
+
*/
|
|
71
|
+
export declare function validateCompiledAppRegistry(reg: CompiledAppRegistry): CompiledAppRegistryResult;
|
|
56
72
|
/**
|
|
57
73
|
* Validates reg and returns each attribute's sensitivity class, the form a browser build embeds. The
|
|
58
74
|
* classes object has no prototype, so a lookup never reaches Object.prototype, and both objects are
|
package/dist/appregistry.js
CHANGED
|
@@ -68,6 +68,36 @@ function compareCodePoints(a, b) {
|
|
|
68
68
|
return d;
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
|
+
// The registry-level rules on the namespace.
|
|
72
|
+
function checkNamespace(namespace, fail) {
|
|
73
|
+
if (!NAMESPACE_PATTERN.test(namespace)) {
|
|
74
|
+
fail("libo11y_app_namespace_invalid", undefined, `namespace ${goQuote(namespace)} is not one snake_case segment`);
|
|
75
|
+
}
|
|
76
|
+
else if (APP_RESERVED_NAMESPACES.has(namespace)) {
|
|
77
|
+
fail("libo11y_app_namespace_reserved", undefined, `namespace ${goQuote(namespace)} belongs to libo11y, OpenTelemetry, or semconv`);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
function failEmpty(fail) {
|
|
81
|
+
fail("libo11y_app_attributes_empty", undefined, "the registry declares no attributes");
|
|
82
|
+
}
|
|
83
|
+
// The rules on an attribute's name.
|
|
84
|
+
function checkName(namespace, name, fail) {
|
|
85
|
+
if (!name.startsWith(`${namespace}.`)) {
|
|
86
|
+
fail("libo11y_app_attr_outside_namespace", name, `not under the ${namespace} namespace`);
|
|
87
|
+
}
|
|
88
|
+
if (!NAME_PATTERN.test(name)) {
|
|
89
|
+
fail("libo11y_attr_naming", name, "not a dotted snake_case name with at least two segments");
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
// The rules on an attribute's sensitivity class.
|
|
93
|
+
function checkSensitivity(name, sensitivity, fail) {
|
|
94
|
+
if (sensitivity === "") {
|
|
95
|
+
fail("libo11y_sensitivity_missing", name, "no sensitivity class");
|
|
96
|
+
}
|
|
97
|
+
else if (!SENSITIVITIES.has(sensitivity)) {
|
|
98
|
+
fail("libo11y_sensitivity_unknown", name, `sensitivity ${goQuote(sensitivity)}`);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
71
101
|
/**
|
|
72
102
|
* Applies the policy rules and returns every violation: registry-level rules first, then each attribute
|
|
73
103
|
* in name order, each attribute's rules in a fixed order.
|
|
@@ -80,34 +110,18 @@ export function validateAppRegistry(reg) {
|
|
|
80
110
|
if (reg.schema !== APP_REGISTRY_SCHEMA) {
|
|
81
111
|
fail("libo11y_app_schema_unknown", undefined, `schema ${goQuote(reg.schema)}, want ${goQuote(APP_REGISTRY_SCHEMA)}`);
|
|
82
112
|
}
|
|
83
|
-
|
|
84
|
-
fail("libo11y_app_namespace_invalid", undefined, `namespace ${goQuote(reg.namespace)} is not one snake_case segment`);
|
|
85
|
-
}
|
|
86
|
-
else if (APP_RESERVED_NAMESPACES.has(reg.namespace)) {
|
|
87
|
-
fail("libo11y_app_namespace_reserved", undefined, `namespace ${goQuote(reg.namespace)} belongs to libo11y, OpenTelemetry, or semconv`);
|
|
88
|
-
}
|
|
113
|
+
checkNamespace(reg.namespace, fail);
|
|
89
114
|
const names = Object.keys(reg.attributes).sort(compareCodePoints);
|
|
90
|
-
if (names.length === 0)
|
|
91
|
-
fail
|
|
92
|
-
}
|
|
115
|
+
if (names.length === 0)
|
|
116
|
+
failEmpty(fail);
|
|
93
117
|
for (const name of names) {
|
|
94
118
|
const a = reg.attributes[name];
|
|
95
119
|
const values = a.values ?? [];
|
|
96
|
-
|
|
97
|
-
fail("libo11y_app_attr_outside_namespace", name, `not under the ${reg.namespace} namespace`);
|
|
98
|
-
}
|
|
99
|
-
if (!NAME_PATTERN.test(name)) {
|
|
100
|
-
fail("libo11y_attr_naming", name, "not a dotted snake_case name with at least two segments");
|
|
101
|
-
}
|
|
120
|
+
checkName(reg.namespace, name, fail);
|
|
102
121
|
if (!ATTRIBUTE_TYPES.has(a.type)) {
|
|
103
122
|
fail("libo11y_app_type_unknown", name, `type ${goQuote(a.type)}`);
|
|
104
123
|
}
|
|
105
|
-
|
|
106
|
-
fail("libo11y_sensitivity_missing", name, "no sensitivity class");
|
|
107
|
-
}
|
|
108
|
-
else if (!SENSITIVITIES.has(a.sensitivity)) {
|
|
109
|
-
fail("libo11y_sensitivity_unknown", name, `sensitivity ${goQuote(a.sensitivity)}`);
|
|
110
|
-
}
|
|
124
|
+
checkSensitivity(name, a.sensitivity, fail);
|
|
111
125
|
if (a.cardinality === "") {
|
|
112
126
|
fail("libo11y_cardinality_missing", name, "no cardinality budget");
|
|
113
127
|
}
|
|
@@ -134,6 +148,34 @@ export function validateAppRegistry(reg) {
|
|
|
134
148
|
}
|
|
135
149
|
return violations.length === 0 ? { ok: true, registry: reg } : { ok: false, violations };
|
|
136
150
|
}
|
|
151
|
+
/**
|
|
152
|
+
* Applies the rules that still apply to the compiled form, in validateAppRegistry's order and with its
|
|
153
|
+
* messages: the namespace, then each key in name order for its namespace, its naming and its class. A
|
|
154
|
+
* compiled registry is a plain structural type, so one built by hand or read from JSON may break them.
|
|
155
|
+
* A classes member that is not an object, or is empty, declares no attributes. Anything
|
|
156
|
+
* compileAppRegistry returned passes.
|
|
157
|
+
*/
|
|
158
|
+
export function validateCompiledAppRegistry(reg) {
|
|
159
|
+
const violations = [];
|
|
160
|
+
const fail = (rule, attr, detail) => {
|
|
161
|
+
violations.push(new AppRegistryViolation(rule, attr, detail));
|
|
162
|
+
};
|
|
163
|
+
// The input may be deserialized, so nothing about its shape is assumed.
|
|
164
|
+
const namespace = reg.namespace;
|
|
165
|
+
const ns = typeof namespace === "string" ? namespace : "";
|
|
166
|
+
checkNamespace(ns, fail);
|
|
167
|
+
const classes = reg.classes;
|
|
168
|
+
const isObject = typeof classes === "object" && classes !== null && !Array.isArray(classes);
|
|
169
|
+
const names = isObject ? Object.keys(classes).sort(compareCodePoints) : [];
|
|
170
|
+
if (names.length === 0)
|
|
171
|
+
failEmpty(fail);
|
|
172
|
+
for (const name of names) {
|
|
173
|
+
checkName(ns, name, fail);
|
|
174
|
+
const sensitivity = classes[name];
|
|
175
|
+
checkSensitivity(name, sensitivity === undefined || sensitivity === null ? "" : String(sensitivity), fail);
|
|
176
|
+
}
|
|
177
|
+
return violations.length === 0 ? { ok: true, registry: reg } : { ok: false, violations };
|
|
178
|
+
}
|
|
137
179
|
/**
|
|
138
180
|
* Validates reg and returns each attribute's sensitivity class, the form a browser build embeds. The
|
|
139
181
|
* classes object has no prototype, so a lookup never reaches Object.prototype, and both objects are
|
package/dist/generated/spec.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** The schema URL stamped on every resource libo11y builds. */
|
|
2
|
-
export declare const SCHEMA_URL = "https://schemas.o11y.ing/libo11y/1.
|
|
2
|
+
export declare const SCHEMA_URL = "https://schemas.o11y.ing/libo11y/1.4.0";
|
|
3
3
|
/** The libo11y specification version this package implements. */
|
|
4
|
-
export declare const SPEC_VERSION = "1.
|
|
4
|
+
export declare const SPEC_VERSION = "1.4.0";
|
|
5
5
|
/** The pinned OpenTelemetry semantic conventions version. */
|
|
6
6
|
export declare const SEMCONV_VERSION = "1.41.0";
|
|
7
7
|
/** The log attribute that carries an event's name. */
|
|
@@ -188,6 +188,9 @@ export declare const ATTR_RULE = "o11y.rule";
|
|
|
188
188
|
export declare const ATTR_DURATION = "o11y.duration";
|
|
189
189
|
export declare const ATTR_LOG_SOURCE = "o11y.log.source";
|
|
190
190
|
export declare const ATTR_RUM_ERROR_BREADCRUMBS = "o11y.rum.error.breadcrumbs";
|
|
191
|
+
export declare const ATTR_RUM_ERROR_BINARY_IMAGES = "o11y.rum.error.binary_images";
|
|
192
|
+
export declare const ATTR_RUM_ERROR_SIGNAL = "o11y.rum.error.signal";
|
|
193
|
+
export declare const ATTR_RUM_ERROR_HANG_DURATION = "o11y.rum.error.hang_duration";
|
|
191
194
|
export declare const ATTR_RUM_VITAL_ATTRIBUTION_INPUT_DELAY = "o11y.rum.vital.attribution.input_delay";
|
|
192
195
|
export declare const ATTR_RUM_VITAL_ATTRIBUTION_PROCESSING_DURATION = "o11y.rum.vital.attribution.processing_duration";
|
|
193
196
|
export declare const ATTR_RUM_VITAL_ATTRIBUTION_PRESENTATION_DELAY = "o11y.rum.vital.attribution.presentation_delay";
|
package/dist/generated/spec.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
// Code generated by specgen from spec/registry (spec 1.
|
|
1
|
+
// Code generated by specgen from spec/registry (spec 1.4.0). DO NOT EDIT.
|
|
2
2
|
/** The schema URL stamped on every resource libo11y builds. */
|
|
3
|
-
export const SCHEMA_URL = "https://schemas.o11y.ing/libo11y/1.
|
|
3
|
+
export const SCHEMA_URL = "https://schemas.o11y.ing/libo11y/1.4.0";
|
|
4
4
|
/** The libo11y specification version this package implements. */
|
|
5
|
-
export const SPEC_VERSION = "1.
|
|
5
|
+
export const SPEC_VERSION = "1.4.0";
|
|
6
6
|
/** The pinned OpenTelemetry semantic conventions version. */
|
|
7
7
|
export const SEMCONV_VERSION = "1.41.0";
|
|
8
8
|
/** The log attribute that carries an event's name. */
|
|
@@ -150,6 +150,9 @@ export const ATTR_RULE = "o11y.rule";
|
|
|
150
150
|
export const ATTR_DURATION = "o11y.duration";
|
|
151
151
|
export const ATTR_LOG_SOURCE = "o11y.log.source";
|
|
152
152
|
export const ATTR_RUM_ERROR_BREADCRUMBS = "o11y.rum.error.breadcrumbs";
|
|
153
|
+
export const ATTR_RUM_ERROR_BINARY_IMAGES = "o11y.rum.error.binary_images";
|
|
154
|
+
export const ATTR_RUM_ERROR_SIGNAL = "o11y.rum.error.signal";
|
|
155
|
+
export const ATTR_RUM_ERROR_HANG_DURATION = "o11y.rum.error.hang_duration";
|
|
153
156
|
export const ATTR_RUM_VITAL_ATTRIBUTION_INPUT_DELAY = "o11y.rum.vital.attribution.input_delay";
|
|
154
157
|
export const ATTR_RUM_VITAL_ATTRIBUTION_PROCESSING_DURATION = "o11y.rum.vital.attribution.processing_duration";
|
|
155
158
|
export const ATTR_RUM_VITAL_ATTRIBUTION_PRESENTATION_DELAY = "o11y.rum.vital.attribution.presentation_delay";
|
package/dist/generated/tables.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Code generated by specgen from spec/registry (spec 1.
|
|
1
|
+
// Code generated by specgen from spec/registry (spec 1.4.0). DO NOT EDIT.
|
|
2
2
|
/** The tiered resource-attribute taxonomy. */
|
|
3
3
|
export const RESOURCE = new Map([
|
|
4
4
|
["service.name", { tier: "tier0", requirement: "required", source: "option-or-env", role: "identifying" }],
|
|
@@ -109,8 +109,11 @@ export const SENSITIVITY_OF = new Map([
|
|
|
109
109
|
["o11y.rum.device.class", "public"],
|
|
110
110
|
["o11y.rum.element.selector", "internal"],
|
|
111
111
|
["o11y.rum.element.text", "pii"],
|
|
112
|
+
["o11y.rum.error.binary_images", "internal"],
|
|
112
113
|
["o11y.rum.error.breadcrumbs", "internal"],
|
|
113
114
|
["o11y.rum.error.fingerprint", "internal"],
|
|
115
|
+
["o11y.rum.error.hang_duration", "public"],
|
|
116
|
+
["o11y.rum.error.signal", "public"],
|
|
114
117
|
["o11y.rum.error.source", "public"],
|
|
115
118
|
["o11y.rum.frustration.type", "public"],
|
|
116
119
|
["o11y.rum.platform", "public"],
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@libo11y/spec",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "The libo11y telemetry specification for TypeScript: attribute keys, enums, event and metric names, and the sensitivity tables, generated from spec/registry.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
},
|
|
21
21
|
"repository": {
|
|
22
22
|
"type": "git",
|
|
23
|
-
"url": "git+https://github.com/
|
|
23
|
+
"url": "git+https://github.com/libo11y/libo11y.git",
|
|
24
24
|
"directory": "ts/packages/spec"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|