@intentius/chant-lexicon-otel 0.124.30 → 0.124.32

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.
Files changed (96) hide show
  1. package/dist/attribution.js +391 -0
  2. package/dist/catalog.js +42 -0
  3. package/dist/codegen/docs-cli.js +3 -0
  4. package/dist/codegen/docs.js +101 -0
  5. package/dist/codegen/generate-cli.js +7 -0
  6. package/dist/codegen/generate.js +43 -0
  7. package/dist/codegen/package.js +28 -0
  8. package/dist/collector.js +150 -0
  9. package/dist/components/common.js +50 -0
  10. package/dist/components/connectors.js +242 -0
  11. package/dist/components/exporters.js +57 -0
  12. package/dist/components/extensions.js +58 -0
  13. package/dist/components/filtering.js +106 -0
  14. package/dist/components/index.js +9 -0
  15. package/dist/components/k8s-receivers.js +36 -0
  16. package/dist/components/processors.js +103 -0
  17. package/dist/components/receivers.js +61 -0
  18. package/dist/components/sampling.js +257 -0
  19. package/dist/composites/catalog.js +368 -0
  20. package/dist/composites/genai-pipeline.js +28 -0
  21. package/dist/composites/index.js +8 -0
  22. package/dist/composites/node-agent.js +156 -0
  23. package/dist/composites/otlp-collector.js +57 -0
  24. package/dist/composites/red-metrics.js +95 -0
  25. package/dist/composites/tail-sampling-tier.js +132 -0
  26. package/dist/config-hygiene.js +464 -0
  27. package/dist/configmap.js +86 -0
  28. package/dist/define.js +204 -0
  29. package/dist/detect.js +22 -0
  30. package/dist/genai.js +569 -0
  31. package/dist/import/embedded.js +57 -0
  32. package/dist/import/generator.js +459 -0
  33. package/dist/import/parser.js +199 -0
  34. package/dist/index.js +34 -0
  35. package/dist/init-templates.js +119 -0
  36. package/dist/integrity.json +2 -2
  37. package/dist/lint/audit-catalog.js +49 -0
  38. package/dist/lint/post-synth/index.js +52 -0
  39. package/dist/lint/post-synth/otel-helpers.js +103 -0
  40. package/dist/lint/post-synth/otel101.js +13 -0
  41. package/dist/lint/post-synth/otel102.js +13 -0
  42. package/dist/lint/post-synth/otel103.js +13 -0
  43. package/dist/lint/post-synth/otel104.js +13 -0
  44. package/dist/lint/post-synth/otel105.js +13 -0
  45. package/dist/lint/post-synth/otel106.js +13 -0
  46. package/dist/lint/post-synth/otel107.js +13 -0
  47. package/dist/lint/post-synth/otel108.js +13 -0
  48. package/dist/lint/post-synth/otel109.js +13 -0
  49. package/dist/lint/post-synth/otel112.js +13 -0
  50. package/dist/lint/post-synth/otel113.js +13 -0
  51. package/dist/lint/post-synth/otel114.js +13 -0
  52. package/dist/lint/post-synth/otel115.js +13 -0
  53. package/dist/lint/post-synth/otel116.js +13 -0
  54. package/dist/lint/post-synth/otel117.js +13 -0
  55. package/dist/lint/post-synth/otel118.js +13 -0
  56. package/dist/lint/post-synth/otel119.js +13 -0
  57. package/dist/lint/post-synth/otel120.js +13 -0
  58. package/dist/lint/post-synth/otel121.js +13 -0
  59. package/dist/lint/post-synth/otel122.js +13 -0
  60. package/dist/lint/post-synth/otel123.js +13 -0
  61. package/dist/lint/post-synth/otel124.js +13 -0
  62. package/dist/lint/post-synth/otel125.js +13 -0
  63. package/dist/lint/post-synth/otel126.js +13 -0
  64. package/dist/lint/post-synth/otel127.js +13 -0
  65. package/dist/lint/rules/component-id-syntax.js +66 -0
  66. package/dist/lint/rules/index.js +6 -0
  67. package/dist/lint/rules/literal-credential.js +91 -0
  68. package/dist/lint/rules/otel-ast.js +30 -0
  69. package/dist/lsp/completions.js +11 -0
  70. package/dist/lsp/hover.js +23 -0
  71. package/dist/manifest.json +1 -1
  72. package/dist/metric-names.js +244 -0
  73. package/dist/model.js +90 -0
  74. package/dist/op/activities/collector-audit.js +213 -0
  75. package/dist/op/activities/collector-health.js +176 -0
  76. package/dist/op/activities/exec.js +16 -0
  77. package/dist/op/activities/github.js +110 -0
  78. package/dist/op/activities/index.js +16 -0
  79. package/dist/op/activities/otelcol.js +173 -0
  80. package/dist/op/activity-contracts.js +64 -0
  81. package/dist/op/audit-op.js +33 -0
  82. package/dist/op/builders.js +38 -0
  83. package/dist/package-cli.js +14 -0
  84. package/dist/pipeline.js +31 -0
  85. package/dist/platform.js +144 -0
  86. package/dist/plugin.js +126 -0
  87. package/dist/semconv.js +50 -0
  88. package/dist/serializer.js +26 -0
  89. package/dist/skill-defs.js +34 -0
  90. package/dist/topology.js +104 -0
  91. package/dist/validate-cli.js +7 -0
  92. package/dist/validate-config.js +706 -0
  93. package/dist/validate.js +85 -0
  94. package/dist/yaml.js +157 -0
  95. package/package.json +8 -8
  96. package/src/codegen/package.ts +2 -2
@@ -0,0 +1,85 @@
1
+ /**
2
+ * Validate the otel lexicon's own artifacts: every built-in class is in the
3
+ * registry, every built-in definition carries the collector pin, and every
4
+ * built-in constructs and serializes.
5
+ */
6
+ import { BUILTIN_CATALOG, lexiconRegistry } from "./catalog.js";
7
+ import * as components from "./components/index.js";
8
+ import { COLLECTOR_PIN } from "./define.js";
9
+ import { collectorYaml } from "./collector.js";
10
+ /** Every entity class the package must keep exporting. */
11
+ export const REQUIRED_NAMES = [
12
+ "OtlpReceiver",
13
+ "PrometheusReceiver",
14
+ "HostMetricsReceiver",
15
+ "FileLogReceiver",
16
+ "K8sClusterReceiver",
17
+ "KubeletStatsReceiver",
18
+ "BatchProcessor",
19
+ "MemoryLimiterProcessor",
20
+ "ResourceProcessor",
21
+ "AttributesProcessor",
22
+ "K8sAttributesProcessor",
23
+ "ResourceDetectionProcessor",
24
+ "FilterProcessor",
25
+ "TransformProcessor",
26
+ "RedactionProcessor",
27
+ "TailSamplingProcessor",
28
+ "ProbabilisticSamplerProcessor",
29
+ "DeltaToCumulativeProcessor",
30
+ "OtlpExporter",
31
+ "OtlpHttpExporter",
32
+ "DebugExporter",
33
+ "PrometheusExporter",
34
+ "GoogleCloudExporter",
35
+ "LoadBalancingExporter",
36
+ "SpanMetricsConnector",
37
+ "ServiceGraphConnector",
38
+ "RoutingConnector",
39
+ "ForwardConnector",
40
+ "CountConnector",
41
+ "SumConnector",
42
+ "SignalToMetricsConnector",
43
+ "HealthCheckExtension",
44
+ "PprofExtension",
45
+ "ZPagesExtension",
46
+ "K8sLeaderElectorExtension",
47
+ "Pipeline",
48
+ "Service",
49
+ ];
50
+ export async function validate() {
51
+ const checks = [];
52
+ const registry = lexiconRegistry();
53
+ const missing = REQUIRED_NAMES.filter((n) => !(n in registry));
54
+ checks.push(missing.length === 0
55
+ ? { name: "required-names", ok: true }
56
+ : { name: "required-names", ok: false, error: `Missing required names: ${missing.join(", ")}` });
57
+ // The list names every entity the registry has, so a new built-in is held to it from the start.
58
+ const unlisted = Object.keys(registry).filter((n) => !REQUIRED_NAMES.includes(n));
59
+ checks.push(unlisted.length === 0
60
+ ? { name: "required-names-complete", ok: true }
61
+ : { name: "required-names-complete", ok: false, error: `In the registry but not in REQUIRED_NAMES: ${unlisted.join(", ")}` });
62
+ const classes = Object.entries(components).filter((e) => typeof e[1] === "function" && "definition" in e[1]);
63
+ const unpinned = classes.filter(([, c]) => c.definition.pin !== COLLECTOR_PIN || !c.definition.builtin).map(([n]) => n);
64
+ checks.push(unpinned.length === 0
65
+ ? { name: "builtins-pinned", ok: true }
66
+ : { name: "builtins-pinned", ok: false, error: `Not pinned to the collector release: ${unpinned.join(", ")}` });
67
+ const broken = [];
68
+ for (const [name, Cls] of classes) {
69
+ try {
70
+ const yaml = collectorYaml([new Cls({})]);
71
+ if (!yaml.includes(Cls.definition.type))
72
+ broken.push(name);
73
+ }
74
+ catch (err) {
75
+ broken.push(`${name} (${err instanceof Error ? err.message : String(err)})`);
76
+ }
77
+ }
78
+ checks.push(broken.length === 0
79
+ ? { name: "builtins-serialize", ok: true }
80
+ : { name: "builtins-serialize", ok: false, error: `Failed to serialize: ${broken.join(", ")}` });
81
+ checks.push(BUILTIN_CATALOG.length === Object.keys(registry).length
82
+ ? { name: "catalog-matches-registry", ok: true }
83
+ : { name: "catalog-matches-registry", ok: false, error: "catalog and registry disagree" });
84
+ return { success: checks.every((c) => c.ok), checks };
85
+ }
package/dist/yaml.js ADDED
@@ -0,0 +1,157 @@
1
+ /**
2
+ * The collector YAML emitter.
3
+ *
4
+ * Its style is the one collector configs are usually written in, and the one
5
+ * the k8s lexicon's `GkeOtelCollector` wrote by hand before it moved onto this
6
+ * lexicon:
7
+ *
8
+ * - top-level sections in the order receivers, processors, exporters,
9
+ * connectors, extensions, service, separated by a blank line;
10
+ * - two-space indent;
11
+ * - a list of scalars in flow style (`receivers: [otlp, batch]`), any other
12
+ * list in block style with `- ` indented under its key;
13
+ * - strings plain where YAML reads them back as the same string, double-quoted
14
+ * otherwise (`"true"`, `"8080"`, `"a: b"`, `"${env:X}"` inside a flow list).
15
+ *
16
+ * The output always parses back to the value it was given.
17
+ */
18
+ const SECTION_ORDER = ["receivers", "processors", "exporters", "connectors", "extensions", "service"];
19
+ const RESERVED = new Set(["true", "false", "null", "yes", "no", "on", "off", "y", "n", "~"]);
20
+ const LEADING_INDICATOR = /^[-?:,[\]{}#&*!|>'"%@`]/;
21
+ function isPlainObject(v) {
22
+ return typeof v === "object" && v !== null && !Array.isArray(v);
23
+ }
24
+ function isScalar(v) {
25
+ return v === null || typeof v === "string" || typeof v === "number" || typeof v === "boolean";
26
+ }
27
+ /** True when `s` can be written unquoted and still read back as the string `s`. */
28
+ export function isPlainSafe(s, flow) {
29
+ if (s === "")
30
+ return false;
31
+ if (/^\s|\s$/.test(s))
32
+ return false;
33
+ if (/[\n\r\t\u0000-\u001f\u007f]/.test(s))
34
+ return false;
35
+ if (RESERVED.has(s.toLowerCase()))
36
+ return false;
37
+ if (!Number.isNaN(Number(s)))
38
+ return false;
39
+ if (/^[-+]?\.(inf|nan)$/i.test(s))
40
+ return false;
41
+ if (/^0[xob]/i.test(s))
42
+ return false;
43
+ if (/^\d+(:\d+)+$/.test(s))
44
+ return false;
45
+ if (LEADING_INDICATOR.test(s))
46
+ return false;
47
+ if (s.includes(": ") || s.includes(" #") || s.endsWith(":"))
48
+ return false;
49
+ if (flow && /[,[\]{}]/.test(s))
50
+ return false;
51
+ return true;
52
+ }
53
+ function scalar(v, flow) {
54
+ if (v === null)
55
+ return "null";
56
+ if (typeof v === "boolean")
57
+ return v ? "true" : "false";
58
+ if (typeof v === "number")
59
+ return Number.isFinite(v) ? String(v) : JSON.stringify(String(v));
60
+ if (typeof v === "string")
61
+ return isPlainSafe(v, flow) ? v : JSON.stringify(v);
62
+ return JSON.stringify(String(v));
63
+ }
64
+ function key(k) {
65
+ return isPlainSafe(k, false) ? k : JSON.stringify(k);
66
+ }
67
+ function emitMap(obj, indent, out) {
68
+ const pad = " ".repeat(indent);
69
+ for (const [k, v] of Object.entries(obj)) {
70
+ if (v === undefined)
71
+ continue;
72
+ const kk = key(k);
73
+ if (v === null) {
74
+ out.push(`${pad}${kk}:`);
75
+ }
76
+ else if (isPlainObject(v)) {
77
+ if (Object.values(v).every((x) => x === undefined)) {
78
+ out.push(`${pad}${kk}: {}`);
79
+ }
80
+ else {
81
+ out.push(`${pad}${kk}:`);
82
+ emitMap(v, indent + 2, out);
83
+ }
84
+ }
85
+ else if (Array.isArray(v)) {
86
+ emitList(kk, v, indent, out);
87
+ }
88
+ else {
89
+ out.push(`${pad}${kk}: ${scalar(v, false)}`);
90
+ }
91
+ }
92
+ }
93
+ function emitList(kk, list, indent, out) {
94
+ const pad = " ".repeat(indent);
95
+ if (list.length === 0) {
96
+ out.push(`${pad}${kk}: []`);
97
+ return;
98
+ }
99
+ if (list.every((x) => isScalar(x))) {
100
+ out.push(`${pad}${kk}: [${list.map((x) => scalar(x, true)).join(", ")}]`);
101
+ return;
102
+ }
103
+ out.push(`${pad}${kk}:`);
104
+ for (const item of list)
105
+ emitItem(item, indent + 2, out);
106
+ }
107
+ function emitItem(item, indent, out) {
108
+ const pad = " ".repeat(indent);
109
+ if (isPlainObject(item) && Object.values(item).some((x) => x !== undefined)) {
110
+ const lines = [];
111
+ emitMap(item, indent + 2, lines);
112
+ lines[0] = `${pad}- ${lines[0].slice(indent + 2)}`;
113
+ out.push(...lines);
114
+ }
115
+ else if (isPlainObject(item)) {
116
+ out.push(`${pad}- {}`);
117
+ }
118
+ else if (Array.isArray(item)) {
119
+ if (item.length === 0) {
120
+ out.push(`${pad}- []`);
121
+ }
122
+ else if (item.every((x) => isScalar(x))) {
123
+ out.push(`${pad}- [${item.map((x) => scalar(x, true)).join(", ")}]`);
124
+ }
125
+ else {
126
+ out.push(`${pad}-`);
127
+ for (const inner of item)
128
+ emitItem(inner, indent + 2, out);
129
+ }
130
+ }
131
+ else {
132
+ out.push(`${pad}- ${scalar(item, false)}`);
133
+ }
134
+ }
135
+ /** Print a collector config as YAML. Empty sections are left out. */
136
+ export function emitCollectorYaml(config, options = {}) {
137
+ const blocks = [];
138
+ if (options.header && options.header.length > 0) {
139
+ blocks.push(options.header.map((l) => `# ${l}`).join("\n"));
140
+ }
141
+ const cfg = config;
142
+ const known = new Set(SECTION_ORDER);
143
+ const order = [...SECTION_ORDER, ...Object.keys(cfg).filter((k) => !known.has(k))];
144
+ for (const section of order) {
145
+ const value = cfg[section];
146
+ if (value === undefined)
147
+ continue;
148
+ if (isPlainObject(value) && Object.values(value).every((x) => x === undefined))
149
+ continue;
150
+ const lines = [];
151
+ emitMap({ [section]: value }, 0, lines);
152
+ blocks.push(lines.join("\n"));
153
+ }
154
+ if (blocks.length === 0)
155
+ return "";
156
+ return `${blocks.join("\n\n")}\n`;
157
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intentius/chant-lexicon-otel",
3
- "version": "0.124.30",
3
+ "version": "0.124.32",
4
4
  "description": "OpenTelemetry Collector lexicon for chant — typed receivers, processors, exporters, connectors, extensions and pipelines, serialized to collector YAML",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://intentius.io/chant",
@@ -34,27 +34,27 @@
34
34
  ".": {
35
35
  "development": "./src/index.ts",
36
36
  "types": "./dist/index.d.ts",
37
- "default": "./src/index.ts"
37
+ "default": "./dist/index.js"
38
38
  },
39
39
  "./*": {
40
40
  "development": "./src/*.ts",
41
41
  "types": "./dist/*.d.ts",
42
- "default": "./src/*.ts"
42
+ "default": "./dist/*.js"
43
43
  },
44
44
  "./op/activities": {
45
45
  "development": "./src/op/activities/index.ts",
46
46
  "types": "./dist/op/activities/index.d.ts",
47
- "default": "./src/op/activities/index.ts"
47
+ "default": "./dist/op/activities/index.js"
48
48
  },
49
49
  "./op/activity-contracts": {
50
50
  "development": "./src/op/activity-contracts.ts",
51
51
  "types": "./dist/op/activity-contracts.d.ts",
52
- "default": "./src/op/activity-contracts.ts"
52
+ "default": "./dist/op/activity-contracts.js"
53
53
  },
54
54
  "./lint/post-synth": {
55
55
  "development": "./src/lint/post-synth/index.ts",
56
56
  "types": "./dist/lint/post-synth/index.d.ts",
57
- "default": "./src/lint/post-synth/index.ts"
57
+ "default": "./dist/lint/post-synth/index.js"
58
58
  },
59
59
  "./manifest": "./dist/manifest.json",
60
60
  "./meta": "./dist/meta.json",
@@ -66,7 +66,7 @@
66
66
  "validate": "tsx src/validate-cli.ts",
67
67
  "docs": "tsx src/codegen/docs-cli.ts",
68
68
  "prepack": "npm run generate && npm run bundle && npm run validate && npm run build",
69
- "build": "../../scripts/tsc7.sh -p tsconfig.build.json && tsc-alias -p tsconfig.build.json && find dist -type f \\( -name \"*.js\" -o -name \"*.js.map\" \\) -delete"
69
+ "build": "../../scripts/tsc7.sh -p tsconfig.build.json --sourceMap false && tsc-alias -p tsconfig.build.json"
70
70
  },
71
71
  "dependencies": {
72
72
  "js-yaml": "^4.3.1",
@@ -79,6 +79,6 @@
79
79
  "typescript": "^5.9.3"
80
80
  },
81
81
  "peerDependencies": {
82
- "@intentius/chant": "^0.124.30"
82
+ "@intentius/chant": "^0.124.32"
83
83
  }
84
84
  }
@@ -4,7 +4,7 @@
4
4
 
5
5
  import { readFileSync } from "fs";
6
6
  import { join, dirname } from "path";
7
- import { fileURLToPath } from "url";
7
+ import { moduleSourceDir } from "@intentius/chant/module-source";
8
8
  import {
9
9
  packagePipeline,
10
10
  collectSkills,
@@ -17,7 +17,7 @@ import { otelSkills } from "../skill-defs";
17
17
  export type { PackageOptions, PackageResult };
18
18
 
19
19
  // src/codegen/package.ts -> src/
20
- const srcDir = dirname(dirname(fileURLToPath(import.meta.url)));
20
+ const srcDir = dirname(moduleSourceDir(import.meta.url));
21
21
 
22
22
  export async function packageLexicon(opts: PackageOptions = {}): Promise<PackageResult> {
23
23
  const pkgJson = JSON.parse(readFileSync(join(srcDir, "..", "package.json"), "utf-8"));