@libo11y/spec 0.0.0-stage → 0.1.2

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.
@@ -0,0 +1,176 @@
1
+ // Code generated by specgen from spec/registry (spec 1.2.0). DO NOT EDIT.
2
+ /** The tiered resource-attribute taxonomy. */
3
+ export const RESOURCE = new Map([
4
+ ["service.name", { tier: "tier0", requirement: "required", source: "option-or-env", role: "identifying" }],
5
+ ["service.version", { tier: "tier0", requirement: "required", source: "option-or-env-or-buildinfo", role: "descriptive" }],
6
+ ["deployment.environment.name", { tier: "tier0", requirement: "required", source: "option-or-env", role: "descriptive" }],
7
+ ["telemetry.sdk.name", { tier: "tier0", requirement: "required", source: "sdk", role: "identifying" }],
8
+ ["telemetry.sdk.language", { tier: "tier0", requirement: "required", source: "sdk", role: "identifying" }],
9
+ ["telemetry.sdk.version", { tier: "tier0", requirement: "required", source: "sdk", role: "identifying" }],
10
+ ["telemetry.distro.name", { tier: "tier0", requirement: "recommended", source: "sdk", role: "descriptive" }],
11
+ ["telemetry.distro.version", { tier: "tier0", requirement: "recommended", source: "sdk", role: "descriptive" }],
12
+ ["service.instance.id", { tier: "tier1", requirement: "required", source: "derived", role: "identifying" }],
13
+ ["service.namespace", { tier: "tier1", requirement: "conditionally_required", source: "option-or-env", role: "identifying" }],
14
+ ["k8s.namespace.name", { tier: "tier1", requirement: "conditionally_required", source: "downward-api", role: "identifying" }],
15
+ ["k8s.pod.name", { tier: "tier1", requirement: "conditionally_required", source: "downward-api", role: "descriptive" }],
16
+ ["k8s.pod.uid", { tier: "tier1", requirement: "conditionally_required", source: "downward-api", role: "identifying" }],
17
+ ["k8s.cluster.name", { tier: "tier1", requirement: "recommended", source: "collector", role: "identifying" }],
18
+ ["k8s.deployment.name", { tier: "tier1", requirement: "recommended", source: "collector", role: "descriptive" }],
19
+ ["k8s.container.name", { tier: "tier1", requirement: "recommended", source: "collector", role: "descriptive" }],
20
+ ["k8s.node.name", { tier: "tier1", requirement: "recommended", source: "collector", role: "descriptive" }],
21
+ ["container.id", { tier: "tier1", requirement: "conditionally_required", source: "detector", role: "identifying" }],
22
+ ["cloud.provider", { tier: "tier1", requirement: "opt_in", source: "detector-or-collector", role: "descriptive" }],
23
+ ["cloud.platform", { tier: "tier1", requirement: "opt_in", source: "detector-or-collector", role: "descriptive" }],
24
+ ["cloud.region", { tier: "tier1", requirement: "opt_in", source: "detector-or-collector", role: "descriptive" }],
25
+ ["cloud.availability_zone", { tier: "tier1", requirement: "opt_in", source: "detector-or-collector", role: "descriptive" }],
26
+ ["cloud.account.id", { tier: "tier1", requirement: "opt_in", source: "detector-or-collector", role: "descriptive" }],
27
+ ["host.id", { tier: "tier1", requirement: "conditionally_required", source: "detector", role: "identifying" }],
28
+ ["host.name", { tier: "tier1", requirement: "recommended", source: "detector", role: "descriptive" }],
29
+ ["faas.name", { tier: "tier1", requirement: "conditionally_required", source: "detector", role: "identifying" }],
30
+ ["faas.instance", { tier: "tier1", requirement: "conditionally_required", source: "detector", role: "identifying" }],
31
+ ["faas.version", { tier: "tier1", requirement: "recommended", source: "detector", role: "descriptive" }],
32
+ ["vcs.ref.head.revision", { tier: "tier2", requirement: "recommended", source: "buildinfo", role: "identifying" }],
33
+ ["vcs.ref.head.name", { tier: "tier2", requirement: "opt_in", source: "buildinfo", role: "descriptive" }],
34
+ ["o11y.build.modified", { tier: "tier2", requirement: "recommended", source: "buildinfo", role: "descriptive" }],
35
+ ["o11y.build.time", { tier: "tier2", requirement: "recommended", source: "buildinfo", role: "descriptive" }],
36
+ ["o11y.team.name", { tier: "tier2", requirement: "recommended", source: "option-or-collector", role: "descriptive" }],
37
+ ["process.pid", { tier: "tier2", requirement: "opt_in", source: "detector", role: "identifying" }],
38
+ ["os.type", { tier: "tier2", requirement: "opt_in", source: "detector", role: "identifying" }],
39
+ ["host.arch", { tier: "tier2", requirement: "opt_in", source: "detector", role: "descriptive" }],
40
+ ["process.runtime.name", { tier: "tier2", requirement: "recommended", source: "detector", role: "descriptive" }],
41
+ ["process.runtime.version", { tier: "tier2", requirement: "recommended", source: "detector", role: "descriptive" }],
42
+ ["o11y.tenant.id", { tier: "tier3", requirement: "opt_in", source: "option", role: "descriptive" }],
43
+ ["o11y.cost_center", { tier: "tier3", requirement: "opt_in", source: "option-or-collector", role: "descriptive" }],
44
+ ["o11y.data.classification", { tier: "tier3", requirement: "opt_in", source: "option", role: "descriptive" }],
45
+ ["o11y.label", { tier: "tier3", requirement: "opt_in", source: "option", role: "descriptive" }],
46
+ ]);
47
+ /** The attributes setup requires at init. */
48
+ export const REQUIRED_TIER0 = ["service.name", "service.version", "deployment.environment.name", "telemetry.sdk.name", "telemetry.sdk.language", "telemetry.sdk.version"];
49
+ /** The base allowed set for deployment.environment.name. */
50
+ export const ENVIRONMENT_VALUES = new Set(["production", "staging", "development", "test"]);
51
+ /** Classifies every attribute the spec has an opinion on. */
52
+ export const SENSITIVITY_OF = new Map([
53
+ ["cloud.account.id", "internal"],
54
+ ["cloud.availability_zone", "internal"],
55
+ ["cloud.platform", "internal"],
56
+ ["cloud.provider", "internal"],
57
+ ["cloud.region", "internal"],
58
+ ["code.file.path", "internal"],
59
+ ["code.function.name", "public"],
60
+ ["code.line.number", "public"],
61
+ ["container.id", "internal"],
62
+ ["deployment.environment.name", "public"],
63
+ ["device.id", "pii"],
64
+ ["error.type", "public"],
65
+ ["exception.message", "internal"],
66
+ ["exception.stacktrace", "internal"],
67
+ ["exception.type", "public"],
68
+ ["faas.instance", "internal"],
69
+ ["faas.name", "internal"],
70
+ ["faas.version", "internal"],
71
+ ["geo.country.iso_code", "public"],
72
+ ["host.arch", "public"],
73
+ ["host.id", "internal"],
74
+ ["host.ip", "pii"],
75
+ ["host.mac", "pii"],
76
+ ["host.name", "internal"],
77
+ ["http.request.header.authorization", "secret"],
78
+ ["http.request.header.cookie", "secret"],
79
+ ["http.request.header.proxy-authorization", "secret"],
80
+ ["http.response.header.set-cookie", "secret"],
81
+ ["k8s.cluster.name", "internal"],
82
+ ["k8s.container.name", "internal"],
83
+ ["k8s.deployment.name", "internal"],
84
+ ["k8s.namespace.name", "internal"],
85
+ ["k8s.node.name", "internal"],
86
+ ["k8s.pod.name", "internal"],
87
+ ["k8s.pod.uid", "internal"],
88
+ ["o11y.build.modified", "public"],
89
+ ["o11y.build.time", "public"],
90
+ ["o11y.config", "public"],
91
+ ["o11y.cost_center", "internal"],
92
+ ["o11y.data.classification", "internal"],
93
+ ["o11y.deprecated.vcs.modified", "public"],
94
+ ["o11y.deprecated.vcs.revision", "public"],
95
+ ["o11y.deprecated.vcs.time", "public"],
96
+ ["o11y.duration", "public"],
97
+ ["o11y.label", "internal"],
98
+ ["o11y.log.source", "public"],
99
+ ["o11y.outcome", "public"],
100
+ ["o11y.record.class", "public"],
101
+ ["o11y.rule", "public"],
102
+ ["o11y.rum.action.name", "internal"],
103
+ ["o11y.rum.action.type", "public"],
104
+ ["o11y.rum.browser.family", "public"],
105
+ ["o11y.rum.config.version", "public"],
106
+ ["o11y.rum.connection.effective", "public"],
107
+ ["o11y.rum.connection.type", "public"],
108
+ ["o11y.rum.device.class", "public"],
109
+ ["o11y.rum.element.selector", "internal"],
110
+ ["o11y.rum.element.text", "pii"],
111
+ ["o11y.rum.error.fingerprint", "internal"],
112
+ ["o11y.rum.error.source", "public"],
113
+ ["o11y.rum.frustration.type", "public"],
114
+ ["o11y.rum.platform", "public"],
115
+ ["o11y.rum.replay.segment", "public"],
116
+ ["o11y.rum.session.retained", "public"],
117
+ ["o11y.rum.view.id", "internal"],
118
+ ["o11y.rum.view.kind", "public"],
119
+ ["o11y.rum.view.name", "public"],
120
+ ["o11y.rum.vital.rating", "public"],
121
+ ["o11y.signal", "public"],
122
+ ["o11y.team.name", "public"],
123
+ ["o11y.tenant.id", "internal"],
124
+ ["os.type", "public"],
125
+ ["process.command_args", "pii"],
126
+ ["process.command_line", "pii"],
127
+ ["process.pid", "internal"],
128
+ ["process.runtime.name", "public"],
129
+ ["process.runtime.version", "public"],
130
+ ["service.instance.id", "internal"],
131
+ ["service.name", "public"],
132
+ ["service.namespace", "public"],
133
+ ["service.version", "public"],
134
+ ["session.id", "internal"],
135
+ ["telemetry.distro.name", "public"],
136
+ ["telemetry.distro.version", "public"],
137
+ ["telemetry.sdk.language", "public"],
138
+ ["telemetry.sdk.name", "public"],
139
+ ["telemetry.sdk.version", "public"],
140
+ ["url.path", "internal"],
141
+ ["vcs.ref.head.name", "public"],
142
+ ["vcs.ref.head.revision", "public"],
143
+ ]);
144
+ /** Maps each key a pre-spec release emitted to the spec key that replaces it. */
145
+ export const LEGACY_KEYS = new Map([
146
+ ["vcs.modified", "o11y.build.modified"],
147
+ ["vcs.revision", "vcs.ref.head.revision"],
148
+ ["vcs.time", "o11y.build.time"],
149
+ ]);
150
+ /** The only resource attributes permitted as effective metric labels. */
151
+ export const METRIC_RESOURCE_LABELS = ["service.name", "service.namespace", "service.instance.id", "deployment.environment.name", "service.version"];
152
+ /** Registered event names mapped to their contracts. */
153
+ export const EVENTS = new Map([
154
+ ["o11y.telemetry.configured", { required: [], requiredTemplates: ["o11y.config"] }],
155
+ ["o11y.request.summary", { required: ["http.request.method", "http.response.status_code", "o11y.outcome", "o11y.duration"], requiredTemplates: [] }],
156
+ ["o11y.telemetry.dropped", { required: ["o11y.signal", "error.type"], requiredTemplates: [] }],
157
+ ["o11y.rum.error", { required: ["o11y.rum.error.source", "exception.type", "session.id", "o11y.rum.view.id"], requiredTemplates: [] }],
158
+ ["o11y.rum.frustration", { required: ["o11y.rum.frustration.type", "session.id", "o11y.rum.view.id"], requiredTemplates: [] }],
159
+ ["o11y.rum.session.start", { required: ["session.id", "o11y.rum.platform"], requiredTemplates: [] }],
160
+ ["o11y.rum.session.end", { required: ["session.id", "o11y.rum.session.retained"], requiredTemplates: [] }],
161
+ ]);
162
+ /** Span kinds registered by the spec mapped to their required attributes. */
163
+ export const SPAN_REQUIRED = new Map([
164
+ ["server", ["http.request.method", "url.path", "url.scheme"]],
165
+ ["client", ["http.request.method", "server.address", "server.port", "url.full"]],
166
+ ]);
167
+ /** The schema an application registry file declares. */
168
+ export const APP_REGISTRY_SCHEMA = "libo11y.app-registry/v1";
169
+ /** Namespaces an application registry may not claim: libo11y's, OpenTelemetry's and the pinned semconv release's. */
170
+ export const APP_RESERVED_NAMESPACES = new Set(["android", "app", "artifact", "aspnetcore", "aws", "az", "azure", "browser", "cassandra", "cicd", "cli", "client", "cloud", "cloudevents", "cloudfoundry", "code", "container", "cpu", "cpython", "db", "deployment", "destination", "device", "disk", "dns", "dotnet", "elasticsearch", "enduser", "error", "event", "exception", "faas", "feature_flag", "file", "gcp", "gen_ai", "geo", "go", "graphql", "hardware", "heroku", "host", "http", "hw", "ios", "jsonrpc", "jvm", "k8s", "kestrel", "linux", "log", "mainframe", "mcp", "message", "messaging", "net", "network", "nfs", "nodejs", "o11y", "oci", "onc_rpc", "openai", "openshift", "opentracing", "oracle", "oracle_cloud", "oracledb", "os", "otel", "peer", "pool", "pprof", "process", "profile", "rpc", "security_rule", "server", "service", "session", "signalr", "source", "system", "telemetry", "test", "thread", "tls", "url", "user", "user_agent", "v8js", "vcs", "webengine", "zos"]);
171
+ /** RUM span shapes mapped to their required attributes. */
172
+ export const RUM_SPAN_REQUIRED = new Map([
173
+ ["view", ["o11y.rum.platform", "o11y.rum.view.name", "o11y.rum.view.id", "o11y.rum.view.kind", "session.id"]],
174
+ ["action", ["o11y.rum.action.type", "o11y.rum.view.id", "session.id"]],
175
+ ["app_load", ["o11y.rum.platform", "o11y.rum.view.id", "session.id"]],
176
+ ]);
@@ -0,0 +1,2 @@
1
+ /** Quotes s as Go's fmt %q verb does for a string. */
2
+ export declare function goQuote(s: string): string;
@@ -0,0 +1,59 @@
1
+ /**
2
+ * Go's %q quoting (strconv.Quote), so messages that quote a value match the Go implementation byte for
3
+ * byte. Printable characters stay as they are; everything else is escaped the way Go escapes it.
4
+ * "Printable" is Go's unicode.IsPrint, read from a table specgen generates, because JavaScript's
5
+ * \p{...} classes follow the runtime's Unicode version rather than the Go toolchain's.
6
+ */
7
+ import { GO_PRINT_RANGES } from "./generated/goprint.js";
8
+ // isPrint reports whether cp lies in one of GO_PRINT_RANGES' inclusive [lo, hi] pairs.
9
+ function isPrint(cp) {
10
+ // Find the first bound >= cp. cp is inside a pair when that bound is a hi, or is the lo it equals.
11
+ let lo = 0;
12
+ let hi = GO_PRINT_RANGES.length;
13
+ while (lo < hi) {
14
+ const mid = (lo + hi) >>> 1;
15
+ if (GO_PRINT_RANGES[mid] < cp)
16
+ lo = mid + 1;
17
+ else
18
+ hi = mid;
19
+ }
20
+ return lo < GO_PRINT_RANGES.length && (lo % 2 === 1 || GO_PRINT_RANGES[lo] === cp);
21
+ }
22
+ const SHORT_ESCAPES = {
23
+ "\u0007": "\\a",
24
+ "\b": "\\b",
25
+ "\f": "\\f",
26
+ "\n": "\\n",
27
+ "\r": "\\r",
28
+ "\t": "\\t",
29
+ "\v": "\\v",
30
+ };
31
+ function hex(cp, width) {
32
+ return cp.toString(16).padStart(width, "0");
33
+ }
34
+ /** Quotes s as Go's fmt %q verb does for a string. */
35
+ export function goQuote(s) {
36
+ let out = '"';
37
+ for (const ch of s) {
38
+ const cp = ch.codePointAt(0) ?? 0;
39
+ if (ch === '"' || ch === "\\") {
40
+ out += `\\${ch}`;
41
+ }
42
+ else if (isPrint(cp)) {
43
+ out += ch;
44
+ }
45
+ else if (SHORT_ESCAPES[ch] !== undefined) {
46
+ out += SHORT_ESCAPES[ch];
47
+ }
48
+ else if (cp < 0x20 || cp === 0x7f) {
49
+ out += `\\x${hex(cp, 2)}`;
50
+ }
51
+ else if (cp < 0x10000) {
52
+ out += `\\u${hex(cp, 4)}`;
53
+ }
54
+ else {
55
+ out += `\\U${hex(cp, 8)}`;
56
+ }
57
+ }
58
+ return `${out}"`;
59
+ }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * The libo11y telemetry specification for TypeScript. Everything here is generated from spec/registry by
3
+ * specgen (make spec-generate); edit the registry, never the generated files.
4
+ */
5
+ export * from "./appregistry.ts";
6
+ export * from "./generated/spec.ts";
7
+ export * from "./generated/tables.ts";
8
+ export { goQuote } from "./goquote.ts";
package/dist/index.js ADDED
@@ -0,0 +1,8 @@
1
+ /**
2
+ * The libo11y telemetry specification for TypeScript. Everything here is generated from spec/registry by
3
+ * specgen (make spec-generate); edit the registry, never the generated files.
4
+ */
5
+ export * from "./appregistry.js";
6
+ export * from "./generated/spec.js";
7
+ export * from "./generated/tables.js";
8
+ export { goQuote } from "./goquote.js";
package/dist/yaml.d.ts ADDED
@@ -0,0 +1,19 @@
1
+ import type { AppRegistry } from "./appregistry.ts";
2
+ export type { AppRegistry, AppRegistryAttribute } from "./appregistry.ts";
3
+ /** Why a registry file did not decode. The names match the conformance cases' `parse:` kinds. */
4
+ export type AppRegistryParseKind = "empty" | "second-document" | "duplicate-key" | "unknown-key" | "type" | "syntax";
5
+ /** Thrown by parseAppRegistry for a file that does not decode. */
6
+ export declare class AppRegistryParseError extends Error {
7
+ readonly kind: AppRegistryParseKind;
8
+ constructor(kind: AppRegistryParseKind, detail?: string);
9
+ }
10
+ /**
11
+ * Decodes a registry file strictly. It does not apply the policy rules; validateAppRegistry does.
12
+ * Throws AppRegistryParseError when the file does not decode.
13
+ */
14
+ export declare function parseAppRegistry(text: string): AppRegistry;
15
+ /**
16
+ * Decodes registry file bytes: UTF-8, or UTF-16 after a byte order mark, as yaml.v3 reads them. Invalid
17
+ * encoding is a `syntax` error.
18
+ */
19
+ export declare function parseAppRegistryBytes(bytes: Uint8Array): AppRegistry;