@intentius/chant-lexicon-otel 0.124.45 → 0.124.48
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 +2 -2
- package/dist/build/capability-plugin.d.ts +10 -0
- package/dist/build/capability-plugin.d.ts.map +1 -0
- package/dist/build/capability-plugin.js +19 -0
- package/dist/build/ocb-build.d.ts +38 -0
- package/dist/build/ocb-build.d.ts.map +1 -0
- package/dist/build/ocb-build.js +49 -0
- package/dist/clickhouse-tables.d.ts +73 -0
- package/dist/clickhouse-tables.d.ts.map +1 -0
- package/dist/clickhouse-tables.js +199 -0
- package/dist/codegen/docs.d.ts.map +1 -1
- package/dist/codegen/docs.js +4 -2
- package/dist/codegen/generate.d.ts +29 -10
- package/dist/codegen/generate.d.ts.map +1 -1
- package/dist/codegen/generate.js +82 -17
- package/dist/components/common.d.ts +3 -1
- package/dist/components/common.d.ts.map +1 -1
- package/dist/components/common.js +2 -0
- package/dist/components/connectors.d.ts +25 -90
- package/dist/components/connectors.d.ts.map +1 -1
- package/dist/components/connectors.js +3 -0
- package/dist/components/exporters.d.ts +78 -34
- package/dist/components/exporters.d.ts.map +1 -1
- package/dist/components/exporters.js +26 -1
- package/dist/components/extensions.d.ts +16 -33
- package/dist/components/extensions.d.ts.map +1 -1
- package/dist/components/filtering.d.ts +13 -60
- package/dist/components/filtering.d.ts.map +1 -1
- package/dist/components/k8s-receivers.d.ts +5 -53
- package/dist/components/k8s-receivers.d.ts.map +1 -1
- package/dist/components/overlay.d.ts +25 -0
- package/dist/components/overlay.d.ts.map +1 -0
- package/dist/components/overlay.js +19 -0
- package/dist/components/processors.d.ts +18 -79
- package/dist/components/processors.d.ts.map +1 -1
- package/dist/components/receivers.d.ts +17 -71
- package/dist/components/receivers.d.ts.map +1 -1
- package/dist/components/receivers.js +3 -1
- package/dist/components/sampling.d.ts +19 -35
- package/dist/components/sampling.d.ts.map +1 -1
- package/dist/config-hygiene.d.ts +10 -8
- package/dist/config-hygiene.d.ts.map +1 -1
- package/dist/config-hygiene.js +36 -13
- package/dist/coverage.d.ts +50 -0
- package/dist/coverage.d.ts.map +1 -0
- package/dist/coverage.js +92 -0
- package/dist/define.d.ts +8 -5
- package/dist/define.d.ts.map +1 -1
- package/dist/define.js +10 -6
- package/dist/distribution.d.ts +125 -0
- package/dist/distribution.d.ts.map +1 -0
- package/dist/distribution.js +227 -0
- package/dist/generated/index.d.ts +4234 -0
- package/dist/generated/index.d.ts.map +1 -0
- package/dist/generated/index.js +23 -0
- package/dist/index.d.ts +7 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -1
- package/dist/init-templates.js +2 -2
- package/dist/integrity.json +11 -9
- package/dist/lint/audit-catalog.d.ts +3 -0
- package/dist/lint/audit-catalog.d.ts.map +1 -1
- package/dist/lint/audit-catalog.js +5 -0
- package/dist/lint/post-synth/index.d.ts.map +1 -1
- package/dist/lint/post-synth/index.js +4 -0
- package/dist/lint/post-synth/otel-helpers.d.ts +2 -1
- package/dist/lint/post-synth/otel-helpers.d.ts.map +1 -1
- package/dist/lint/post-synth/otel-helpers.js +1 -1
- package/dist/lint/post-synth/otel119.d.ts +1 -1
- package/dist/lint/post-synth/otel119.js +1 -1
- package/dist/lint/post-synth/otel125.d.ts +1 -1
- package/dist/lint/post-synth/otel125.js +1 -1
- package/dist/lint/post-synth/otel126.d.ts +1 -1
- package/dist/lint/post-synth/otel126.js +1 -1
- package/dist/lint/post-synth/otel127.d.ts +1 -1
- package/dist/lint/post-synth/otel127.js +1 -1
- package/dist/lint/post-synth/otel128.d.ts +8 -0
- package/dist/lint/post-synth/otel128.d.ts.map +1 -0
- package/dist/lint/post-synth/otel128.js +17 -0
- package/dist/lint/post-synth/otel129.d.ts +15 -0
- package/dist/lint/post-synth/otel129.d.ts.map +1 -0
- package/dist/lint/post-synth/otel129.js +92 -0
- package/dist/lsp/completions.d.ts +10 -1
- package/dist/lsp/completions.d.ts.map +1 -1
- package/dist/lsp/completions.js +29 -1
- package/dist/lsp/hover.d.ts +5 -1
- package/dist/lsp/hover.d.ts.map +1 -1
- package/dist/lsp/hover.js +16 -3
- package/dist/lsp/properties.d.ts +34 -0
- package/dist/lsp/properties.d.ts.map +1 -0
- package/dist/lsp/properties.js +135 -0
- package/dist/manifest.json +1 -1
- package/dist/meta.json +5 -0
- package/dist/metric-names.d.ts +36 -8
- package/dist/metric-names.d.ts.map +1 -1
- package/dist/metric-names.js +42 -9
- package/dist/model.d.ts +1 -1
- package/dist/model.js +1 -1
- package/dist/okf/index.md +3 -0
- package/dist/okf/rules/OTEL128.md +11 -0
- package/dist/okf/rules/OTEL129.md +11 -0
- package/dist/okf/types/ClickHouseExporter.md +9 -0
- package/dist/op/activities/collector-audit.d.ts +18 -6
- package/dist/op/activities/collector-audit.d.ts.map +1 -1
- package/dist/op/activities/collector-audit.js +37 -21
- package/dist/plugin.d.ts.map +1 -1
- package/dist/plugin.js +51 -8
- package/dist/rules/otel-helpers.ts +1 -1
- package/dist/rules/otel119.ts +1 -1
- package/dist/rules/otel125.ts +1 -1
- package/dist/rules/otel126.ts +1 -1
- package/dist/rules/otel127.ts +1 -1
- package/dist/rules/otel128.ts +22 -0
- package/dist/rules/otel129.ts +99 -0
- package/dist/serializer.d.ts +3 -0
- package/dist/serializer.d.ts.map +1 -1
- package/dist/serializer.js +12 -2
- package/dist/spec/builtins.d.ts +17 -0
- package/dist/spec/builtins.d.ts.map +1 -0
- package/dist/spec/builtins.js +45 -0
- package/dist/spec/fetch.d.ts +120 -0
- package/dist/spec/fetch.d.ts.map +1 -0
- package/dist/spec/fetch.js +282 -0
- package/dist/spec/parse.d.ts +77 -0
- package/dist/spec/parse.d.ts.map +1 -0
- package/dist/spec/parse.js +337 -0
- package/dist/spec/pin.d.ts +82 -0
- package/dist/spec/pin.d.ts.map +1 -0
- package/dist/spec/pin.js +126 -0
- package/dist/spec/snapshot-cli.d.ts +13 -0
- package/dist/spec/snapshot-cli.d.ts.map +1 -0
- package/dist/spec/snapshot-cli.js +31 -0
- package/dist/spec/snapshot.d.ts +9 -0
- package/dist/spec/snapshot.d.ts.map +1 -0
- package/dist/spec/snapshot.js +14 -0
- package/dist/types/index.d.ts +3 -2
- package/dist/validate-config.d.ts +1 -1
- package/dist/validate-config.d.ts.map +1 -1
- package/dist/validate.d.ts.map +1 -1
- package/dist/validate.js +1 -0
- package/dist/workspace-links.d.ts +25 -0
- package/dist/workspace-links.d.ts.map +1 -0
- package/dist/workspace-links.js +49 -0
- package/package.json +3 -2
- package/src/build/capability-plugin.ts +30 -0
- package/src/build/ocb-build.ts +73 -0
- package/src/clickhouse-exporter.e2e.test.ts +208 -0
- package/src/clickhouse-tables.test.ts +216 -0
- package/src/clickhouse-tables.ts +223 -0
- package/src/codegen/docs.ts +4 -2
- package/src/codegen/generate.ts +95 -19
- package/src/components/common.ts +4 -2
- package/src/components/connectors.ts +30 -77
- package/src/components/exporters.ts +128 -61
- package/src/components/extensions.ts +22 -36
- package/src/components/filtering.ts +17 -58
- package/src/components/k8s-receivers.test.ts +1 -1
- package/src/components/k8s-receivers.ts +3 -45
- package/src/components/overlay.ts +24 -0
- package/src/components/processors.ts +18 -63
- package/src/components/receivers.ts +20 -60
- package/src/components/sampling.ts +24 -37
- package/src/config-hygiene.ts +36 -13
- package/src/coverage.test.ts +37 -0
- package/src/coverage.ts +121 -0
- package/src/define.test.ts +2 -0
- package/src/define.ts +10 -6
- package/src/distribution.test.ts +250 -0
- package/src/distribution.ts +305 -0
- package/src/generated/index.ts +4576 -0
- package/src/generated/lexicon-otel.json +5 -0
- package/src/generated/properties.json +1 -0
- package/src/import/roundtrip.test.ts +16 -0
- package/src/import/testdata/clickhouse.yaml +37 -0
- package/src/import/testdata/fixtures.ts +17 -2
- package/src/import/testdata/upstream/clickhouse-exporter.yaml +60 -0
- package/src/index.ts +69 -0
- package/src/init-templates.ts +2 -2
- package/src/lint/audit-catalog.ts +15 -0
- package/src/lint/post-synth/index.ts +4 -0
- package/src/lint/post-synth/otel-helpers.ts +1 -1
- package/src/lint/post-synth/otel119.ts +1 -1
- package/src/lint/post-synth/otel125.ts +1 -1
- package/src/lint/post-synth/otel126.ts +1 -1
- package/src/lint/post-synth/otel127.ts +1 -1
- package/src/lint/post-synth/otel128.ts +22 -0
- package/src/lint/post-synth/otel129.ts +99 -0
- package/src/lsp/completions.ts +30 -1
- package/src/lsp/hover.ts +14 -3
- package/src/lsp/properties.test.ts +72 -0
- package/src/lsp/properties.ts +141 -0
- package/src/metric-names.test.ts +11 -0
- package/src/metric-names.ts +64 -16
- package/src/model.ts +1 -1
- package/src/op/activities/collector-audit.test.ts +29 -22
- package/src/op/activities/collector-audit.ts +38 -18
- package/src/plugin.test.ts +2 -0
- package/src/plugin.ts +57 -6
- package/src/serializer.ts +11 -2
- package/src/spec/builtins.ts +56 -0
- package/src/spec/fetch.ts +332 -0
- package/src/spec/otel-schemas.snapshot.json +13932 -0
- package/src/spec/parse.ts +364 -0
- package/src/spec/pin.ts +155 -0
- package/src/spec/snapshot-cli.ts +32 -0
- package/src/spec/snapshot.ts +19 -0
- package/src/spec/spec.test.ts +144 -0
- package/src/validate-config.ts +4 -3
- package/src/validate.ts +1 -0
- package/src/workspace-links.e2e.test.ts +91 -0
- package/src/workspace-links.ts +50 -0
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `Distribution`, the builder manifest `ocb` (the OpenTelemetry Collector
|
|
3
|
+
* Builder) builds a custom collector from (#3374).
|
|
4
|
+
*
|
|
5
|
+
* The fields are the builder's `Config` as read at v0.130.0
|
|
6
|
+
* (`cmd/builder/internal/builder/config.go` in opentelemetry-collector):
|
|
7
|
+
* `dist`, a module list per component kind, `providers`,
|
|
8
|
+
* `converters`, `replaces`, `excludes` and `conf_resolver`. `telemetry`
|
|
9
|
+
* (v0.146.0) is not in it, and `otelcol_version`, removed in v0.113.0, is
|
|
10
|
+
* not either.
|
|
11
|
+
*
|
|
12
|
+
* A component list takes a module (`{ gomod, import?, name?, path? }`) or a
|
|
13
|
+
* component class. A built-in class writes its module at `COLLECTOR_PIN`
|
|
14
|
+
* (`OtlpReceiver` is `go.opentelemetry.io/collector/receiver/otlpreceiver
|
|
15
|
+
* v0.162.0`), and a `defineComponent` class writes its own pin's source and
|
|
16
|
+
* version, so the manifest names the same versions the config was typed
|
|
17
|
+
* against.
|
|
18
|
+
*
|
|
19
|
+
* The serializer writes the manifest as `builder-config.yaml` beside the
|
|
20
|
+
* collector config when a project declares a `Distribution`. OTEL128 then
|
|
21
|
+
* checks that the collector config uses only components the distribution
|
|
22
|
+
* builds. A project without one sees no change.
|
|
23
|
+
*/
|
|
24
|
+
import { createResource } from "@intentius/chant/runtime";
|
|
25
|
+
import { dump } from "js-yaml";
|
|
26
|
+
import { COLLECTOR_PIN, isUsablePin } from "./define.js";
|
|
27
|
+
import { canonicalComponentType, canonicalTypeOf, COMPONENT_KINDS, SECTION_OF } from "./model.js";
|
|
28
|
+
export const DISTRIBUTION_TYPE = "OTel::Distribution";
|
|
29
|
+
/** Where the serializer writes the builder manifest, beside the collector config. */
|
|
30
|
+
export const DISTRIBUTION_MANIFEST_FILE = "builder-config.yaml";
|
|
31
|
+
/** A custom collector's builder manifest. Declare at most one per project. */
|
|
32
|
+
export const Distribution = createResource(DISTRIBUTION_TYPE, "otel", {});
|
|
33
|
+
export function isDistributionEntity(value) {
|
|
34
|
+
return typeof value === "object" && value !== null && value.entityType === DISTRIBUTION_TYPE;
|
|
35
|
+
}
|
|
36
|
+
const CORE = "go.opentelemetry.io/collector";
|
|
37
|
+
const CONTRIB = "github.com/open-telemetry/opentelemetry-collector-contrib";
|
|
38
|
+
/**
|
|
39
|
+
* The Go module of every built-in, by `kind:type`. The core collector's
|
|
40
|
+
* components are in opentelemetry-collector, the rest in contrib; both are
|
|
41
|
+
* released at `COLLECTOR_PIN`'s version. A built-in added to `./components`
|
|
42
|
+
* needs a row here (distribution.test.ts checks).
|
|
43
|
+
*/
|
|
44
|
+
export const BUILTIN_MODULES = Object.freeze({
|
|
45
|
+
"receiver:otlp": `${CORE}/receiver/otlpreceiver`,
|
|
46
|
+
"receiver:filelog": `${CONTRIB}/receiver/filelogreceiver`,
|
|
47
|
+
"receiver:hostmetrics": `${CONTRIB}/receiver/hostmetricsreceiver`,
|
|
48
|
+
"receiver:prometheus": `${CONTRIB}/receiver/prometheusreceiver`,
|
|
49
|
+
"receiver:k8s_cluster": `${CONTRIB}/receiver/k8sclusterreceiver`,
|
|
50
|
+
"receiver:kubeletstats": `${CONTRIB}/receiver/kubeletstatsreceiver`,
|
|
51
|
+
"processor:batch": `${CORE}/processor/batchprocessor`,
|
|
52
|
+
"processor:memory_limiter": `${CORE}/processor/memorylimiterprocessor`,
|
|
53
|
+
"processor:attributes": `${CONTRIB}/processor/attributesprocessor`,
|
|
54
|
+
"processor:deltatocumulative": `${CONTRIB}/processor/deltatocumulativeprocessor`,
|
|
55
|
+
"processor:k8sattributes": `${CONTRIB}/processor/k8sattributesprocessor`,
|
|
56
|
+
"processor:resourcedetection": `${CONTRIB}/processor/resourcedetectionprocessor`,
|
|
57
|
+
"processor:resource": `${CONTRIB}/processor/resourceprocessor`,
|
|
58
|
+
"processor:filter": `${CONTRIB}/processor/filterprocessor`,
|
|
59
|
+
"processor:redaction": `${CONTRIB}/processor/redactionprocessor`,
|
|
60
|
+
"processor:transform": `${CONTRIB}/processor/transformprocessor`,
|
|
61
|
+
"processor:probabilistic_sampler": `${CONTRIB}/processor/probabilisticsamplerprocessor`,
|
|
62
|
+
"processor:tail_sampling": `${CONTRIB}/processor/tailsamplingprocessor`,
|
|
63
|
+
"exporter:debug": `${CORE}/exporter/debugexporter`,
|
|
64
|
+
"exporter:otlp": `${CORE}/exporter/otlpexporter`,
|
|
65
|
+
"exporter:otlphttp": `${CORE}/exporter/otlphttpexporter`,
|
|
66
|
+
"exporter:googlecloud": `${CONTRIB}/exporter/googlecloudexporter`,
|
|
67
|
+
"exporter:prometheus": `${CONTRIB}/exporter/prometheusexporter`,
|
|
68
|
+
"exporter:loadbalancing": `${CONTRIB}/exporter/loadbalancingexporter`,
|
|
69
|
+
"exporter:clickhouse": `${CONTRIB}/exporter/clickhouseexporter`,
|
|
70
|
+
"connector:forward": `${CORE}/connector/forwardconnector`,
|
|
71
|
+
"connector:count": `${CONTRIB}/connector/countconnector`,
|
|
72
|
+
"connector:routing": `${CONTRIB}/connector/routingconnector`,
|
|
73
|
+
"connector:servicegraph": `${CONTRIB}/connector/servicegraphconnector`,
|
|
74
|
+
"connector:signaltometrics": `${CONTRIB}/connector/signaltometricsconnector`,
|
|
75
|
+
"connector:spanmetrics": `${CONTRIB}/connector/spanmetricsconnector`,
|
|
76
|
+
"connector:sum": `${CONTRIB}/connector/sumconnector`,
|
|
77
|
+
"extension:zpages": `${CORE}/extension/zpagesextension`,
|
|
78
|
+
"extension:health_check": `${CONTRIB}/extension/healthcheckextension`,
|
|
79
|
+
"extension:k8s_leader_elector": `${CONTRIB}/extension/k8sleaderelector`,
|
|
80
|
+
"extension:pprof": `${CONTRIB}/extension/pprofextension`,
|
|
81
|
+
});
|
|
82
|
+
const KIND_OF_LIST = {
|
|
83
|
+
receivers: "receiver",
|
|
84
|
+
processors: "processor",
|
|
85
|
+
exporters: "exporter",
|
|
86
|
+
connectors: "connector",
|
|
87
|
+
extensions: "extension",
|
|
88
|
+
};
|
|
89
|
+
const COMPONENT_LISTS = Object.keys(KIND_OF_LIST);
|
|
90
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
91
|
+
function isComponentClass(v) {
|
|
92
|
+
return typeof v === "function" && typeof v.definition === "object";
|
|
93
|
+
}
|
|
94
|
+
/** The module a component class is built from, at the version its config type follows. */
|
|
95
|
+
export function componentModule(def) {
|
|
96
|
+
if (def.builtin) {
|
|
97
|
+
const path = BUILTIN_MODULES[`${def.kind}:${def.type}`];
|
|
98
|
+
if (!path)
|
|
99
|
+
throw new Error(`otel: no Go module is recorded for the built-in ${def.kind} "${def.type}"`);
|
|
100
|
+
return { gomod: `${path} ${COLLECTOR_PIN.version}` };
|
|
101
|
+
}
|
|
102
|
+
if (!isUsablePin(def.pin)) {
|
|
103
|
+
throw new Error(`otel: the custom ${def.kind} "${def.type}" has no pin, so its Go module is unknown; list it as { gomod } instead`);
|
|
104
|
+
}
|
|
105
|
+
return { gomod: `${def.pin.source} ${def.pin.version}` };
|
|
106
|
+
}
|
|
107
|
+
function copyModule(entry) {
|
|
108
|
+
const out = { gomod: entry.gomod };
|
|
109
|
+
if (entry.import !== undefined)
|
|
110
|
+
out.import = entry.import;
|
|
111
|
+
if (entry.name !== undefined)
|
|
112
|
+
out.name = entry.name;
|
|
113
|
+
if (entry.path !== undefined)
|
|
114
|
+
out.path = entry.path;
|
|
115
|
+
return out;
|
|
116
|
+
}
|
|
117
|
+
function moduleOf(entry, list) {
|
|
118
|
+
if (isComponentClass(entry)) {
|
|
119
|
+
const def = entry.definition;
|
|
120
|
+
if (def.kind !== KIND_OF_LIST[list]) {
|
|
121
|
+
throw new Error(`otel: ${def.type} is a ${def.kind}, listed under the distribution's ${list}`);
|
|
122
|
+
}
|
|
123
|
+
return componentModule(def);
|
|
124
|
+
}
|
|
125
|
+
return copyModule(entry);
|
|
126
|
+
}
|
|
127
|
+
/** The builder manifest a distribution writes, as the object `ocb --config` reads. */
|
|
128
|
+
export function distributionManifest(dist) {
|
|
129
|
+
const p = isDistributionEntity(dist) ? dist.props : dist;
|
|
130
|
+
const out = {};
|
|
131
|
+
const d = {};
|
|
132
|
+
for (const [k, v] of Object.entries(p.dist ?? {}))
|
|
133
|
+
if (v !== undefined)
|
|
134
|
+
d[k] = v;
|
|
135
|
+
out.dist = d;
|
|
136
|
+
for (const list of COMPONENT_LISTS) {
|
|
137
|
+
const entries = p[list];
|
|
138
|
+
if (entries && entries.length > 0)
|
|
139
|
+
out[list] = entries.map((e) => moduleOf(e, list));
|
|
140
|
+
}
|
|
141
|
+
if (p.providers && p.providers.length > 0)
|
|
142
|
+
out.providers = p.providers.map(copyModule);
|
|
143
|
+
if (p.converters && p.converters.length > 0)
|
|
144
|
+
out.converters = p.converters.map(copyModule);
|
|
145
|
+
if (p.replaces && p.replaces.length > 0)
|
|
146
|
+
out.replaces = [...p.replaces];
|
|
147
|
+
if (p.excludes && p.excludes.length > 0)
|
|
148
|
+
out.excludes = [...p.excludes];
|
|
149
|
+
if (p.conf_resolver && p.conf_resolver.default_uri_scheme !== undefined) {
|
|
150
|
+
out.conf_resolver = { default_uri_scheme: p.conf_resolver.default_uri_scheme };
|
|
151
|
+
}
|
|
152
|
+
return out;
|
|
153
|
+
}
|
|
154
|
+
/** The builder manifest as the YAML `ocb --config` reads. */
|
|
155
|
+
export function distributionYaml(dist) {
|
|
156
|
+
return dump(distributionManifest(dist), { lineWidth: -1, noRefs: true });
|
|
157
|
+
}
|
|
158
|
+
/** The module path of a `gomod` line: everything before the version. */
|
|
159
|
+
function modulePath(gomod) {
|
|
160
|
+
return gomod.trim().split(/\s+/)[0];
|
|
161
|
+
}
|
|
162
|
+
const BUILTIN_BY_PATH = new Map(Object.entries(BUILTIN_MODULES).map(([key, path]) => [path, key.split(":")[1]]));
|
|
163
|
+
/**
|
|
164
|
+
* The component type a module builds, when it can be told: a built-in's
|
|
165
|
+
* module, or a module path ending `<type><kind>` as contrib's do
|
|
166
|
+
* (`.../exporter/datadogexporter` is `datadog`). Undefined otherwise.
|
|
167
|
+
*/
|
|
168
|
+
export function moduleComponentType(kind, gomod) {
|
|
169
|
+
const path = modulePath(gomod);
|
|
170
|
+
const builtin = BUILTIN_BY_PATH.get(path);
|
|
171
|
+
if (builtin !== undefined)
|
|
172
|
+
return builtin;
|
|
173
|
+
const last = path.split("/").pop() ?? "";
|
|
174
|
+
return last.endsWith(kind) && last.length > kind.length ? last.slice(0, -kind.length) : undefined;
|
|
175
|
+
}
|
|
176
|
+
export function distributionComponents(dist) {
|
|
177
|
+
const p = isDistributionEntity(dist) ? dist.props : dist;
|
|
178
|
+
const types = { receiver: new Set(), processor: new Set(), exporter: new Set(), connector: new Set(), extension: new Set() };
|
|
179
|
+
const unknown = { receiver: [], processor: [], exporter: [], connector: [], extension: [] };
|
|
180
|
+
for (const list of COMPONENT_LISTS) {
|
|
181
|
+
const kind = KIND_OF_LIST[list];
|
|
182
|
+
for (const entry of p[list] ?? []) {
|
|
183
|
+
if (isComponentClass(entry)) {
|
|
184
|
+
types[kind].add(canonicalComponentType(kind, entry.definition.type));
|
|
185
|
+
continue;
|
|
186
|
+
}
|
|
187
|
+
const type = moduleComponentType(kind, entry.gomod);
|
|
188
|
+
if (type === undefined)
|
|
189
|
+
unknown[kind].push(entry.gomod);
|
|
190
|
+
else
|
|
191
|
+
types[kind].add(canonicalComponentType(kind, type));
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
return { types, unknown };
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* OTEL128: the components `config` declares that `dist` does not build. A
|
|
198
|
+
* collector built from the distribution refuses such a config at start with
|
|
199
|
+
* "unknown type". When a kind lists a module whose type can't be told from
|
|
200
|
+
* its path, a missing component may be that module, so it is a warning
|
|
201
|
+
* naming the module rather than an error.
|
|
202
|
+
*/
|
|
203
|
+
export function distributionIssues(config, dist) {
|
|
204
|
+
const { types, unknown } = distributionComponents(dist);
|
|
205
|
+
const issues = [];
|
|
206
|
+
for (const kind of COMPONENT_KINDS) {
|
|
207
|
+
const section = config[SECTION_OF[kind]];
|
|
208
|
+
if (typeof section !== "object" || section === null)
|
|
209
|
+
continue;
|
|
210
|
+
for (const id of Object.keys(section)) {
|
|
211
|
+
const type = canonicalTypeOf(kind, id);
|
|
212
|
+
if (types[kind].has(type))
|
|
213
|
+
continue;
|
|
214
|
+
const unsure = unknown[kind];
|
|
215
|
+
issues.push({
|
|
216
|
+
code: "OTEL128",
|
|
217
|
+
severity: unsure.length > 0 ? "warning" : "error",
|
|
218
|
+
component: id,
|
|
219
|
+
message: `${kind} "${id}" is not in the Distribution, so a collector built from it does not know the type "${type}"` +
|
|
220
|
+
(unsure.length > 0
|
|
221
|
+
? `, unless it is built by ${unsure.map((m) => `"${modulePath(m)}"`).join(", ")}, whose type can't be read from its path`
|
|
222
|
+
: `. Add it to the Distribution's ${SECTION_OF[kind]}, or remove it from the config`),
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
return issues;
|
|
227
|
+
}
|