@intentius/chant-lexicon-otel 0.124.46 → 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
package/README.md
CHANGED
|
@@ -23,7 +23,7 @@ export { otlp, batch, backend, traces };
|
|
|
23
23
|
| connectors | spanmetrics, servicegraph, routing, forward, count, sum, signaltometrics |
|
|
24
24
|
| extensions | health_check, pprof, zpages, k8s_leader_elector |
|
|
25
25
|
|
|
26
|
-
The config types
|
|
26
|
+
The config types are generated from upstream `config.schema.yaml` at the collector-contrib release in `COLLECTOR_PIN` (v0.162.0), scoped by the `otelcol-contrib` distribution manifest, with hand-written overlays where a schema falls short. `coverageReport()` says which components of `otelcol-contrib` and `otelcol-k8s` are built in.
|
|
27
27
|
|
|
28
28
|
Sampling and routing: `tail_sampling` takes its policies as a discriminated union (`status_code`, `latency`, `probabilistic`, `and`, `composite` and the rest), and `loadbalancing` takes a `static`, `dns`, `k8s` or `aws_cloud_map` resolver. Content handling: `filter`, `transform` (OTTL statement groups per context) and `redaction`. Cluster metrics: `k8s_cluster` and `kubeletstats`.
|
|
29
29
|
|
|
@@ -58,7 +58,7 @@ Each connector supports fixed signal pairs (`spanmetrics`: traces to metrics). O
|
|
|
58
58
|
|
|
59
59
|
## Checks
|
|
60
60
|
|
|
61
|
-
OTEL001 and OTEL002 run on source (id syntax, literal credentials). OTEL101 to OTEL109 and OTEL112 to
|
|
61
|
+
OTEL001 and OTEL002 run on source (id syntax, literal credentials). OTEL101 to OTEL109 and OTEL112 to OTEL128 run after a build: undeclared or unused components (a connector must be on both sides), empty pipelines, extension wiring, `memory_limiter` placement, id syntax, each component's own config rules, duplicate ids, missing schema pins, connector signal pairs, cycles through connectors, connector ids shared with a receiver or exporter, `routing` targets that don't receive from the connector, metrics split by a per-request GenAI id or content key, two started components listening on the same address, fields deprecated before the pinned release, literal credentials in the config, credentials sent in plaintext, zpages or pprof off loopback, detailed debug output beside a backend, an exporter's queue or retries turned off, a remote OTLP exporter with no batching, and k8sattributes fields or resourcedetection detectors the collector doesn't know. OTEL128 runs only when the project declares a `Distribution` (an ocb builder manifest), and reports a component the config uses that the distribution doesn't build. OTEL118 runs only in a build that stamps telemetry attribution, and warns about a processor that can remove or replace one of the attribution's resource attributes.
|
|
62
62
|
|
|
63
63
|
## Plain-data API
|
|
64
64
|
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { BuildSpec } from "@intentius/chant/components/component";
|
|
2
|
+
import { type CapabilityPlugin } from "@intentius/chant/components/capability-plugin";
|
|
3
|
+
import { type OcbBuildInput } from "./ocb-build.js";
|
|
4
|
+
export declare const OTEL_VERB_FAMILIES: {
|
|
5
|
+
readonly build: readonly ["ocb-build"];
|
|
6
|
+
};
|
|
7
|
+
export declare const otelCapabilityPlugin: CapabilityPlugin;
|
|
8
|
+
/** A component's `build` field for `ocb-build`: `build: ocbBuild({ config: "dist/builder-config.yaml" })`. */
|
|
9
|
+
export declare function ocbBuild(input: OcbBuildInput): BuildSpec;
|
|
10
|
+
//# sourceMappingURL=capability-plugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capability-plugin.d.ts","sourceRoot":"","sources":["../../src/build/capability-plugin.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uCAAuC,CAAC;AACvE,OAAO,EAAqB,KAAK,gBAAgB,EAAE,MAAM,+CAA+C,CAAC;AACzG,OAAO,EAAsB,KAAK,aAAa,EAAE,MAAM,aAAa,CAAC;AAErE,eAAO,MAAM,kBAAkB;aAC7B,KAAK,YAAG,WAAW;CACX,CAAC;AAEX,eAAO,MAAM,oBAAoB,EAAE,gBASlC,CAAC;AAEF,8GAA8G;AAC9G,wBAAgB,QAAQ,CAAC,KAAK,EAAE,aAAa,GAAG,SAAS,CAExD"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ownPackageVersion } from "@intentius/chant/components/capability-plugin";
|
|
2
|
+
import { ocbBuildCapability } from "./ocb-build.js";
|
|
3
|
+
export const OTEL_VERB_FAMILIES = {
|
|
4
|
+
build: ["ocb-build"],
|
|
5
|
+
};
|
|
6
|
+
export const otelCapabilityPlugin = {
|
|
7
|
+
name: "otel",
|
|
8
|
+
version: ownPackageVersion(import.meta.url),
|
|
9
|
+
capabilities() {
|
|
10
|
+
return [ocbBuildCapability];
|
|
11
|
+
},
|
|
12
|
+
families() {
|
|
13
|
+
return OTEL_VERB_FAMILIES;
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
/** A component's `build` field for `ocb-build`: `build: ocbBuild({ config: "dist/builder-config.yaml" })`. */
|
|
17
|
+
export function ocbBuild(input) {
|
|
18
|
+
return { kind: "ocb-build", ...input };
|
|
19
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `ocb-build`, the build verb for a custom collector (#3374): run the
|
|
3
|
+
* OpenTelemetry Collector Builder over the `builder-config.yaml` a
|
|
4
|
+
* `Distribution` writes, and hand the directory it generates on as a `dir`
|
|
5
|
+
* artifact. That directory holds the generated sources and the binary, so a
|
|
6
|
+
* `docker-build` step whose `context` is the directory (with a Dockerfile the
|
|
7
|
+
* component provides) builds the collector image, and the rest of the
|
|
8
|
+
* component's path (SBOM, sign, attest, publish by digest, deploy) is the
|
|
9
|
+
* one any image takes.
|
|
10
|
+
*
|
|
11
|
+
* The output directory is the manifest's `dist.output_path`. ocb's own
|
|
12
|
+
* default is a fresh temporary directory, which a later step could not name,
|
|
13
|
+
* so a manifest without one is refused before ocb runs.
|
|
14
|
+
*/
|
|
15
|
+
import type { Capability } from "@intentius/chant/components/capability";
|
|
16
|
+
import { type ProcessRunner } from "@intentius/chant/components/verbs/process-runner";
|
|
17
|
+
export interface OcbBuildInput {
|
|
18
|
+
/** The builder manifest, e.g. `dist/builder-config.yaml`. */
|
|
19
|
+
config: string;
|
|
20
|
+
/** The builder binary. Default: `ocb`. */
|
|
21
|
+
ocb?: string;
|
|
22
|
+
/** Generate the sources without compiling them (`--skip-compilation`). */
|
|
23
|
+
skipCompilation?: boolean;
|
|
24
|
+
}
|
|
25
|
+
export interface OcbBuildOutput {
|
|
26
|
+
/** The artifact kind: a directory, for `docker-build`'s `context`. */
|
|
27
|
+
kind: "dir";
|
|
28
|
+
/** The directory ocb wrote, the manifest's `dist.output_path` resolved against the manifest's directory. */
|
|
29
|
+
dir: string;
|
|
30
|
+
/** `sha256:` over the manifest's bytes: the same manifest names the same build. */
|
|
31
|
+
manifestDigest: string;
|
|
32
|
+
}
|
|
33
|
+
/** The output directory a manifest names, resolved the way ocb resolves it: relative to the working directory ocb runs in. */
|
|
34
|
+
export declare function ocbOutputPath(manifestText: string, cwd: string): string | undefined;
|
|
35
|
+
export declare function createOcbBuildCapability(runner?: ProcessRunner): Capability<OcbBuildInput, OcbBuildOutput>;
|
|
36
|
+
/** Default `ocb-build` capability, backed by the real process runner. */
|
|
37
|
+
export declare const ocbBuildCapability: Capability<OcbBuildInput, OcbBuildOutput>;
|
|
38
|
+
//# sourceMappingURL=ocb-build.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ocb-build.d.ts","sourceRoot":"","sources":["../../src/build/ocb-build.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAMH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wCAAwC,CAAC;AACzE,OAAO,EAAwC,KAAK,aAAa,EAAE,MAAM,kDAAkD,CAAC;AAE5H,MAAM,WAAW,aAAa;IAC5B,6DAA6D;IAC7D,MAAM,EAAE,MAAM,CAAC;IACf,0CAA0C;IAC1C,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,0EAA0E;IAC1E,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED,MAAM,WAAW,cAAc;IAC7B,sEAAsE;IACtE,IAAI,EAAE,KAAK,CAAC;IACZ,4GAA4G;IAC5G,GAAG,EAAE,MAAM,CAAC;IACZ,mFAAmF;IACnF,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,8HAA8H;AAC9H,wBAAgB,aAAa,CAAC,YAAY,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAKnF;AAED,wBAAgB,wBAAwB,CAAC,MAAM,GAAE,aAAsC,GAAG,UAAU,CAAC,aAAa,EAAE,cAAc,CAAC,CAqBlI;AAED,yEAAyE;AACzE,eAAO,MAAM,kBAAkB,EAAE,UAAU,CAAC,aAAa,EAAE,cAAc,CAA8B,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `ocb-build`, the build verb for a custom collector (#3374): run the
|
|
3
|
+
* OpenTelemetry Collector Builder over the `builder-config.yaml` a
|
|
4
|
+
* `Distribution` writes, and hand the directory it generates on as a `dir`
|
|
5
|
+
* artifact. That directory holds the generated sources and the binary, so a
|
|
6
|
+
* `docker-build` step whose `context` is the directory (with a Dockerfile the
|
|
7
|
+
* component provides) builds the collector image, and the rest of the
|
|
8
|
+
* component's path (SBOM, sign, attest, publish by digest, deploy) is the
|
|
9
|
+
* one any image takes.
|
|
10
|
+
*
|
|
11
|
+
* The output directory is the manifest's `dist.output_path`. ocb's own
|
|
12
|
+
* default is a fresh temporary directory, which a later step could not name,
|
|
13
|
+
* so a manifest without one is refused before ocb runs.
|
|
14
|
+
*/
|
|
15
|
+
import { readFileSync } from "node:fs";
|
|
16
|
+
import { createHash } from "node:crypto";
|
|
17
|
+
import { dirname, isAbsolute, resolve } from "node:path";
|
|
18
|
+
import { load } from "js-yaml";
|
|
19
|
+
import { defaultProcessRunner, q, requireTool } from "@intentius/chant/components/verbs/process-runner";
|
|
20
|
+
/** The output directory a manifest names, resolved the way ocb resolves it: relative to the working directory ocb runs in. */
|
|
21
|
+
export function ocbOutputPath(manifestText, cwd) {
|
|
22
|
+
const doc = load(manifestText);
|
|
23
|
+
const out = doc?.dist?.output_path;
|
|
24
|
+
if (typeof out !== "string" || out.trim() === "")
|
|
25
|
+
return undefined;
|
|
26
|
+
return isAbsolute(out) ? out : resolve(cwd, out);
|
|
27
|
+
}
|
|
28
|
+
export function createOcbBuildCapability(runner = defaultProcessRunner()) {
|
|
29
|
+
return {
|
|
30
|
+
kind: "ocb-build",
|
|
31
|
+
async run(_ctx, input) {
|
|
32
|
+
const text = readFileSync(input.config, "utf8");
|
|
33
|
+
// ocb resolves output_path against its working directory; run it in the manifest's.
|
|
34
|
+
const cwd = dirname(resolve(input.config));
|
|
35
|
+
const dir = ocbOutputPath(text, cwd);
|
|
36
|
+
if (!dir) {
|
|
37
|
+
throw new Error(`ocb-build: ${input.config} sets no dist.output_path, so ocb would write to a temporary directory no later step can name. Set dist.output_path on the Distribution.`);
|
|
38
|
+
}
|
|
39
|
+
const ocb = input.ocb ?? "ocb";
|
|
40
|
+
await requireTool(runner, ocb, "build a custom collector from a Distribution");
|
|
41
|
+
const flags = input.skipCompilation ? " --skip-compilation" : "";
|
|
42
|
+
await runner.run(`${q(ocb)} --config ${q(resolve(input.config))}${flags}`, { cwd });
|
|
43
|
+
const manifestDigest = `sha256:${createHash("sha256").update(text).digest("hex")}`;
|
|
44
|
+
return { kind: "dir", dir, manifestDigest };
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
/** Default `ocb-build` capability, backed by the real process runner. */
|
|
49
|
+
export const ocbBuildCapability = createOcbBuildCapability();
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The ClickHouse tables a `clickhouse` exporter writes (#4397), read from its
|
|
3
|
+
* config the way the exporter reads it at `COLLECTOR_PIN` (contrib v0.130.0).
|
|
4
|
+
* OTEL129 and the otel lexicon's `workspaceLinks` hook share this, so the
|
|
5
|
+
* check in one build root and the link across workspace members agree on
|
|
6
|
+
* which tables and columns an exporter needs.
|
|
7
|
+
*
|
|
8
|
+
* Sources in opentelemetry-collector-contrib at v0.130.0,
|
|
9
|
+
* `exporter/clickhouseexporter/`:
|
|
10
|
+
*
|
|
11
|
+
* - Default names: `createDefaultConfig` and `buildMetricTableNames` in
|
|
12
|
+
* `config.go`. The exponential histogram table is
|
|
13
|
+
* `otel_metrics_exponential_histogram` there; the README says
|
|
14
|
+
* `otel_metrics_exp_histogram`, and the code is what runs.
|
|
15
|
+
* - Database: `Config.database()` in `config.go`. `database` wins unless it
|
|
16
|
+
* is `default`, then the endpoint DSN's database, then `default`.
|
|
17
|
+
* - Columns: the column lists of the insert statements in
|
|
18
|
+
* `internal/sqltemplates/*_insert.sql`. A `Nested` field such as
|
|
19
|
+
* `Events.Timestamp` is listed under its column, `Events`.
|
|
20
|
+
* - Which tables a signal touches: each signal's exporter writes only its own
|
|
21
|
+
* tables (`exporter_logs.go`, `exporter_traces.go`, `exporter_metrics.go`),
|
|
22
|
+
* and only when a pipeline of that signal uses the exporter.
|
|
23
|
+
* - `create_schema` defaults to true and makes the exporter run
|
|
24
|
+
* `CREATE TABLE IF NOT EXISTS` for its tables at start.
|
|
25
|
+
*
|
|
26
|
+
* The trace-id lookup table and its materialized view, which the traces
|
|
27
|
+
* exporter creates beside the traces table when `create_schema` is true, are
|
|
28
|
+
* not written by the exporter: the view fills the table from the traces
|
|
29
|
+
* table's inserts. They are not part of what an exporter needs here.
|
|
30
|
+
*/
|
|
31
|
+
import type { CollectorConfig } from "./model.js";
|
|
32
|
+
/** One table an exporter writes. */
|
|
33
|
+
export interface ClickHouseExporterTable {
|
|
34
|
+
/** The signal whose pipeline writes it. */
|
|
35
|
+
signal: "logs" | "traces" | "metrics";
|
|
36
|
+
/** The config key that names it: `logs_table_name`, `metrics_tables.gauge.name`. */
|
|
37
|
+
key: string;
|
|
38
|
+
/** The table, as the exporter resolves it. */
|
|
39
|
+
name: string;
|
|
40
|
+
/** The columns its insert statement names. */
|
|
41
|
+
columns: readonly string[];
|
|
42
|
+
}
|
|
43
|
+
/** What one `clickhouse` exporter writes. */
|
|
44
|
+
export interface ClickHouseExporterTargets {
|
|
45
|
+
/** The exporter's id: `clickhouse` or `clickhouse/<name>`. */
|
|
46
|
+
id: string;
|
|
47
|
+
database: string;
|
|
48
|
+
/** Whether the exporter creates its database and tables at start (`create_schema`, default true). */
|
|
49
|
+
createSchema: boolean;
|
|
50
|
+
tables: ClickHouseExporterTable[];
|
|
51
|
+
/** Values chant can't read without the environment, such as `${env:CH_DB}`: the tables they name are left out. */
|
|
52
|
+
unread: string[];
|
|
53
|
+
}
|
|
54
|
+
/** The columns each insert statement names, at v0.130.0. */
|
|
55
|
+
export declare const CLICKHOUSE_EXPORTER_COLUMNS: {
|
|
56
|
+
readonly logs: readonly ["Timestamp", "TraceId", "SpanId", "TraceFlags", "SeverityText", "SeverityNumber", "ServiceName", "Body", "ResourceSchemaUrl", "ResourceAttributes", "ScopeSchemaUrl", "ScopeName", "ScopeVersion", "ScopeAttributes", "LogAttributes"];
|
|
57
|
+
readonly traces: readonly ["Timestamp", "TraceId", "SpanId", "ParentSpanId", "TraceState", "SpanName", "SpanKind", "ServiceName", "ResourceAttributes", "ScopeName", "ScopeVersion", "SpanAttributes", "Duration", "StatusCode", "StatusMessage", "Events", "Links"];
|
|
58
|
+
readonly gauge: readonly ["ResourceAttributes", "ResourceSchemaUrl", "ScopeName", "ScopeVersion", "ScopeAttributes", "ScopeDroppedAttrCount", "ScopeSchemaUrl", "ServiceName", "MetricName", "MetricDescription", "MetricUnit", "Attributes", "StartTimeUnix", "TimeUnix", "Value", "Flags", "Exemplars"];
|
|
59
|
+
readonly sum: readonly ["ResourceAttributes", "ResourceSchemaUrl", "ScopeName", "ScopeVersion", "ScopeAttributes", "ScopeDroppedAttrCount", "ScopeSchemaUrl", "ServiceName", "MetricName", "MetricDescription", "MetricUnit", "Attributes", "StartTimeUnix", "TimeUnix", "Value", "Flags", "Exemplars", "AggregationTemporality", "IsMonotonic"];
|
|
60
|
+
readonly summary: readonly ["ResourceAttributes", "ResourceSchemaUrl", "ScopeName", "ScopeVersion", "ScopeAttributes", "ScopeDroppedAttrCount", "ScopeSchemaUrl", "ServiceName", "MetricName", "MetricDescription", "MetricUnit", "Attributes", "StartTimeUnix", "TimeUnix", "Count", "Sum", "ValueAtQuantiles", "Flags"];
|
|
61
|
+
readonly histogram: readonly ["ResourceAttributes", "ResourceSchemaUrl", "ScopeName", "ScopeVersion", "ScopeAttributes", "ScopeDroppedAttrCount", "ScopeSchemaUrl", "ServiceName", "MetricName", "MetricDescription", "MetricUnit", "Attributes", "StartTimeUnix", "TimeUnix", "Count", "Sum", "BucketCounts", "ExplicitBounds", "Exemplars", "Flags", "Min", "Max", "AggregationTemporality"];
|
|
62
|
+
readonly exponential_histogram: readonly ["ResourceAttributes", "ResourceSchemaUrl", "ScopeName", "ScopeVersion", "ScopeAttributes", "ScopeDroppedAttrCount", "ScopeSchemaUrl", "ServiceName", "MetricName", "MetricDescription", "MetricUnit", "Attributes", "StartTimeUnix", "TimeUnix", "Count", "Sum", "Scale", "ZeroCount", "PositiveOffset", "PositiveBucketCounts", "NegativeOffset", "NegativeBucketCounts", "Exemplars", "Flags", "Min", "Max", "AggregationTemporality"];
|
|
63
|
+
};
|
|
64
|
+
/** The signals whose pipelines list exporter `id`. */
|
|
65
|
+
export declare function exporterSignals(config: CollectorConfig, id: string): Set<string>;
|
|
66
|
+
/**
|
|
67
|
+
* The tables one `clickhouse` exporter writes, for the signals whose
|
|
68
|
+
* pipelines use it. `raw` is its config block.
|
|
69
|
+
*/
|
|
70
|
+
export declare function clickhouseExporterTargets(id: string, raw: unknown, signals: ReadonlySet<string>): ClickHouseExporterTargets;
|
|
71
|
+
/** Every `clickhouse` exporter a pipeline uses in `config`, with what it writes. */
|
|
72
|
+
export declare function clickhouseExportersOf(config: CollectorConfig): ClickHouseExporterTargets[];
|
|
73
|
+
//# sourceMappingURL=clickhouse-tables.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clickhouse-tables.d.ts","sourceRoot":"","sources":["../src/clickhouse-tables.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAG/C,oCAAoC;AACpC,MAAM,WAAW,uBAAuB;IACtC,2CAA2C;IAC3C,MAAM,EAAE,MAAM,GAAG,QAAQ,GAAG,SAAS,CAAC;IACtC,oFAAoF;IACpF,GAAG,EAAE,MAAM,CAAC;IACZ,8CAA8C;IAC9C,IAAI,EAAE,MAAM,CAAC;IACb,8CAA8C;IAC9C,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;CAC5B;AAED,6CAA6C;AAC7C,MAAM,WAAW,yBAAyB;IACxC,8DAA8D;IAC9D,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,qGAAqG;IACrG,YAAY,EAAE,OAAO,CAAC;IACtB,MAAM,EAAE,uBAAuB,EAAE,CAAC;IAClC,kHAAkH;IAClH,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB;AAmBD,4DAA4D;AAC5D,eAAO,MAAM,2BAA2B;;;;;;;;CAyDc,CAAC;AA8BvD,sDAAsD;AACtD,wBAAgB,eAAe,CAAC,MAAM,EAAE,eAAe,EAAE,EAAE,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,CAOhF;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CAAC,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,yBAAyB,CAiC3H;AAED,oFAAoF;AACpF,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,eAAe,GAAG,yBAAyB,EAAE,CAS1F"}
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The ClickHouse tables a `clickhouse` exporter writes (#4397), read from its
|
|
3
|
+
* config the way the exporter reads it at `COLLECTOR_PIN` (contrib v0.130.0).
|
|
4
|
+
* OTEL129 and the otel lexicon's `workspaceLinks` hook share this, so the
|
|
5
|
+
* check in one build root and the link across workspace members agree on
|
|
6
|
+
* which tables and columns an exporter needs.
|
|
7
|
+
*
|
|
8
|
+
* Sources in opentelemetry-collector-contrib at v0.130.0,
|
|
9
|
+
* `exporter/clickhouseexporter/`:
|
|
10
|
+
*
|
|
11
|
+
* - Default names: `createDefaultConfig` and `buildMetricTableNames` in
|
|
12
|
+
* `config.go`. The exponential histogram table is
|
|
13
|
+
* `otel_metrics_exponential_histogram` there; the README says
|
|
14
|
+
* `otel_metrics_exp_histogram`, and the code is what runs.
|
|
15
|
+
* - Database: `Config.database()` in `config.go`. `database` wins unless it
|
|
16
|
+
* is `default`, then the endpoint DSN's database, then `default`.
|
|
17
|
+
* - Columns: the column lists of the insert statements in
|
|
18
|
+
* `internal/sqltemplates/*_insert.sql`. A `Nested` field such as
|
|
19
|
+
* `Events.Timestamp` is listed under its column, `Events`.
|
|
20
|
+
* - Which tables a signal touches: each signal's exporter writes only its own
|
|
21
|
+
* tables (`exporter_logs.go`, `exporter_traces.go`, `exporter_metrics.go`),
|
|
22
|
+
* and only when a pipeline of that signal uses the exporter.
|
|
23
|
+
* - `create_schema` defaults to true and makes the exporter run
|
|
24
|
+
* `CREATE TABLE IF NOT EXISTS` for its tables at start.
|
|
25
|
+
*
|
|
26
|
+
* The trace-id lookup table and its materialized view, which the traces
|
|
27
|
+
* exporter creates beside the traces table when `create_schema` is true, are
|
|
28
|
+
* not written by the exporter: the view fills the table from the traces
|
|
29
|
+
* table's inserts. They are not part of what an exporter needs here.
|
|
30
|
+
*/
|
|
31
|
+
import { parseComponentId, pipelineSignal } from "./model.js";
|
|
32
|
+
const METRIC_HEAD = [
|
|
33
|
+
"ResourceAttributes",
|
|
34
|
+
"ResourceSchemaUrl",
|
|
35
|
+
"ScopeName",
|
|
36
|
+
"ScopeVersion",
|
|
37
|
+
"ScopeAttributes",
|
|
38
|
+
"ScopeDroppedAttrCount",
|
|
39
|
+
"ScopeSchemaUrl",
|
|
40
|
+
"ServiceName",
|
|
41
|
+
"MetricName",
|
|
42
|
+
"MetricDescription",
|
|
43
|
+
"MetricUnit",
|
|
44
|
+
"Attributes",
|
|
45
|
+
"StartTimeUnix",
|
|
46
|
+
"TimeUnix",
|
|
47
|
+
];
|
|
48
|
+
/** The columns each insert statement names, at v0.130.0. */
|
|
49
|
+
export const CLICKHOUSE_EXPORTER_COLUMNS = {
|
|
50
|
+
logs: [
|
|
51
|
+
"Timestamp",
|
|
52
|
+
"TraceId",
|
|
53
|
+
"SpanId",
|
|
54
|
+
"TraceFlags",
|
|
55
|
+
"SeverityText",
|
|
56
|
+
"SeverityNumber",
|
|
57
|
+
"ServiceName",
|
|
58
|
+
"Body",
|
|
59
|
+
"ResourceSchemaUrl",
|
|
60
|
+
"ResourceAttributes",
|
|
61
|
+
"ScopeSchemaUrl",
|
|
62
|
+
"ScopeName",
|
|
63
|
+
"ScopeVersion",
|
|
64
|
+
"ScopeAttributes",
|
|
65
|
+
"LogAttributes",
|
|
66
|
+
],
|
|
67
|
+
traces: [
|
|
68
|
+
"Timestamp",
|
|
69
|
+
"TraceId",
|
|
70
|
+
"SpanId",
|
|
71
|
+
"ParentSpanId",
|
|
72
|
+
"TraceState",
|
|
73
|
+
"SpanName",
|
|
74
|
+
"SpanKind",
|
|
75
|
+
"ServiceName",
|
|
76
|
+
"ResourceAttributes",
|
|
77
|
+
"ScopeName",
|
|
78
|
+
"ScopeVersion",
|
|
79
|
+
"SpanAttributes",
|
|
80
|
+
"Duration",
|
|
81
|
+
"StatusCode",
|
|
82
|
+
"StatusMessage",
|
|
83
|
+
"Events",
|
|
84
|
+
"Links",
|
|
85
|
+
],
|
|
86
|
+
gauge: [...METRIC_HEAD, "Value", "Flags", "Exemplars"],
|
|
87
|
+
sum: [...METRIC_HEAD, "Value", "Flags", "Exemplars", "AggregationTemporality", "IsMonotonic"],
|
|
88
|
+
summary: [...METRIC_HEAD, "Count", "Sum", "ValueAtQuantiles", "Flags"],
|
|
89
|
+
histogram: [...METRIC_HEAD, "Count", "Sum", "BucketCounts", "ExplicitBounds", "Exemplars", "Flags", "Min", "Max", "AggregationTemporality"],
|
|
90
|
+
exponential_histogram: [
|
|
91
|
+
...METRIC_HEAD,
|
|
92
|
+
"Count",
|
|
93
|
+
"Sum",
|
|
94
|
+
"Scale",
|
|
95
|
+
"ZeroCount",
|
|
96
|
+
"PositiveOffset",
|
|
97
|
+
"PositiveBucketCounts",
|
|
98
|
+
"NegativeOffset",
|
|
99
|
+
"NegativeBucketCounts",
|
|
100
|
+
"Exemplars",
|
|
101
|
+
"Flags",
|
|
102
|
+
"Min",
|
|
103
|
+
"Max",
|
|
104
|
+
"AggregationTemporality",
|
|
105
|
+
],
|
|
106
|
+
};
|
|
107
|
+
/** The metric types in `metrics_tables`, with the suffix each default name takes. */
|
|
108
|
+
const METRIC_TYPES = [
|
|
109
|
+
["gauge", "_gauge"],
|
|
110
|
+
["sum", "_sum"],
|
|
111
|
+
["summary", "_summary"],
|
|
112
|
+
["histogram", "_histogram"],
|
|
113
|
+
["exponential_histogram", "_exponential_histogram"],
|
|
114
|
+
];
|
|
115
|
+
const DEFAULT_DATABASE = "default";
|
|
116
|
+
const DEFAULT_METRICS_PREFIX = "otel_metrics";
|
|
117
|
+
const isRecord = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
118
|
+
const str = (v) => (typeof v === "string" && v !== "" ? v : undefined);
|
|
119
|
+
/** A value the collector expands from the environment or another config source. */
|
|
120
|
+
const expanded = (v) => v.includes("${");
|
|
121
|
+
/** The database in the endpoint DSN's path, or undefined when it has none or can't be read. */
|
|
122
|
+
function dsnDatabase(endpoint) {
|
|
123
|
+
if (!endpoint || expanded(endpoint))
|
|
124
|
+
return undefined;
|
|
125
|
+
try {
|
|
126
|
+
const path = new URL(endpoint).pathname.replace(/^\/+/, "");
|
|
127
|
+
return path === "" ? undefined : decodeURIComponent(path);
|
|
128
|
+
}
|
|
129
|
+
catch {
|
|
130
|
+
return undefined;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
/** The signals whose pipelines list exporter `id`. */
|
|
134
|
+
export function exporterSignals(config, id) {
|
|
135
|
+
const out = new Set();
|
|
136
|
+
for (const [pid, p] of Object.entries(config.service?.pipelines ?? {})) {
|
|
137
|
+
const exporters = isRecord(p) && Array.isArray(p.exporters) ? p.exporters : [];
|
|
138
|
+
if (exporters.includes(id))
|
|
139
|
+
out.add(pipelineSignal(pid));
|
|
140
|
+
}
|
|
141
|
+
return out;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* The tables one `clickhouse` exporter writes, for the signals whose
|
|
145
|
+
* pipelines use it. `raw` is its config block.
|
|
146
|
+
*/
|
|
147
|
+
export function clickhouseExporterTargets(id, raw, signals) {
|
|
148
|
+
const c = isRecord(raw) ? raw : {};
|
|
149
|
+
const unread = [];
|
|
150
|
+
let database = DEFAULT_DATABASE;
|
|
151
|
+
const configured = str(c.database);
|
|
152
|
+
if (configured && expanded(configured))
|
|
153
|
+
unread.push(`database ${configured}`);
|
|
154
|
+
else if (configured && configured !== DEFAULT_DATABASE)
|
|
155
|
+
database = configured;
|
|
156
|
+
else {
|
|
157
|
+
const endpoint = str(c.endpoint);
|
|
158
|
+
if (endpoint && expanded(endpoint))
|
|
159
|
+
unread.push(`endpoint ${endpoint}, whose path may name the database`);
|
|
160
|
+
database = dsnDatabase(endpoint) ?? DEFAULT_DATABASE;
|
|
161
|
+
}
|
|
162
|
+
if (unread.length > 0)
|
|
163
|
+
return { id, database, createSchema: c.create_schema !== false, tables: [], unread };
|
|
164
|
+
const tables = [];
|
|
165
|
+
const add = (signal, key, name, columns) => {
|
|
166
|
+
if (expanded(name))
|
|
167
|
+
unread.push(`${key} ${name}`);
|
|
168
|
+
else
|
|
169
|
+
tables.push({ signal, key, name, columns });
|
|
170
|
+
};
|
|
171
|
+
if (signals.has("logs"))
|
|
172
|
+
add("logs", "logs_table_name", str(c.logs_table_name) ?? "otel_logs", CLICKHOUSE_EXPORTER_COLUMNS.logs);
|
|
173
|
+
if (signals.has("traces"))
|
|
174
|
+
add("traces", "traces_table_name", str(c.traces_table_name) ?? "otel_traces", CLICKHOUSE_EXPORTER_COLUMNS.traces);
|
|
175
|
+
if (signals.has("metrics")) {
|
|
176
|
+
const mt = isRecord(c.metrics_tables) ? c.metrics_tables : {};
|
|
177
|
+
const nameOf = (type) => (isRecord(mt[type]) ? str(mt[type].name) : undefined);
|
|
178
|
+
// The deprecated metrics_table_name is a prefix, used only when no metrics_tables name is set.
|
|
179
|
+
const anySet = METRIC_TYPES.some(([type]) => nameOf(type) !== undefined);
|
|
180
|
+
const prefix = !anySet ? (str(c.metrics_table_name) ?? DEFAULT_METRICS_PREFIX) : DEFAULT_METRICS_PREFIX;
|
|
181
|
+
for (const [type, suffix] of METRIC_TYPES) {
|
|
182
|
+
add("metrics", `metrics_tables.${type}.name`, nameOf(type) ?? `${prefix}${suffix}`, CLICKHOUSE_EXPORTER_COLUMNS[type]);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
return { id, database, createSchema: c.create_schema !== false, tables, unread };
|
|
186
|
+
}
|
|
187
|
+
/** Every `clickhouse` exporter a pipeline uses in `config`, with what it writes. */
|
|
188
|
+
export function clickhouseExportersOf(config) {
|
|
189
|
+
const out = [];
|
|
190
|
+
for (const [id, raw] of Object.entries(config.exporters ?? {})) {
|
|
191
|
+
if (parseComponentId(id)?.type !== "clickhouse")
|
|
192
|
+
continue;
|
|
193
|
+
const signals = exporterSignals(config, id);
|
|
194
|
+
if (signals.size === 0)
|
|
195
|
+
continue;
|
|
196
|
+
out.push(clickhouseExporterTargets(id, raw, signals));
|
|
197
|
+
}
|
|
198
|
+
return out;
|
|
199
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"docs.d.ts","sourceRoot":"","sources":["../../src/codegen/docs.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"docs.d.ts","sourceRoot":"","sources":["../../src/codegen/docs.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAoFH,wBAAsB,YAAY,CAAC,IAAI,CAAC,EAAE;IAAE,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAuB9E"}
|
package/dist/codegen/docs.js
CHANGED
|
@@ -56,8 +56,10 @@ on the same address (OTEL117), and a literal credential in source (OTEL002)
|
|
|
56
56
|
or in the config (OTEL120). Others report deprecated fields (OTEL119),
|
|
57
57
|
credentials sent in plaintext (OTEL121), zpages or pprof off loopback
|
|
58
58
|
(OTEL122), detailed debug output beside a backend (OTEL123), delivery and
|
|
59
|
-
batching settings (OTEL124, OTEL125),
|
|
60
|
-
resourcedetection detectors the collector doesn't know (OTEL126, OTEL127)
|
|
59
|
+
batching settings (OTEL124, OTEL125), k8sattributes fields or
|
|
60
|
+
resourcedetection detectors the collector doesn't know (OTEL126, OTEL127),
|
|
61
|
+
and, when the project declares a \`Distribution\`, a component the config uses
|
|
62
|
+
that the distribution doesn't build (OTEL128). In
|
|
61
63
|
a build that stamps telemetry attribution, OTEL118 reports a processor that can
|
|
62
64
|
drop or overwrite one of the attribution's resource attributes.
|
|
63
65
|
`;
|
|
@@ -1,19 +1,38 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The otel lexicon's
|
|
2
|
+
* The otel lexicon's generation step (#3361).
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
4
|
+
* The built-in components' config types are generated from upstream
|
|
5
|
+
* `config.schema.yaml`, the documents `schemagen` writes next to each
|
|
6
|
+
* component's `config.go`, at the collector-contrib release `COLLECTOR_PIN`
|
|
7
|
+
* names and scoped by the `otelcol-contrib` distribution manifest. Generation
|
|
8
|
+
* reads the committed snapshot (`src/spec/otel-schemas.snapshot.json`, refreshed
|
|
9
|
+
* by `just snapshot`), refuses one that does not match `OTEL_SPEC_PIN`, and
|
|
10
|
+
* writes, into the gitignored `src/generated/`:
|
|
11
|
+
*
|
|
12
|
+
* - `index.ts`: a type alias per schema definition the built-ins reach, and
|
|
13
|
+
* `<ClassName>SchemaConfig` for each built-in that has a schema. The
|
|
14
|
+
* hand-written `defineBuiltin` files build their config types on these,
|
|
15
|
+
* overlaying only what a schema lacks (see `src/components/overlay.ts`);
|
|
16
|
+
* - `properties.json`: each built-in's property tree with upstream's
|
|
17
|
+
* descriptions, for LSP completion and hover;
|
|
18
|
+
* - `lexicon-otel.json`: the registry, derived from the exported classes.
|
|
19
|
+
*
|
|
20
|
+
* A built-in with no upstream schema (`forward`, which has no config) keeps its
|
|
21
|
+
* hand-written type.
|
|
10
22
|
*/
|
|
11
23
|
import type { GenerateResult } from "@intentius/chant/codegen/generate";
|
|
24
|
+
import type { OtelSpecSnapshot } from "../spec/fetch.js";
|
|
12
25
|
export type { GenerateResult };
|
|
26
|
+
/** The upstream schema document behind each built-in, by class name, from the contrib index. */
|
|
27
|
+
export declare function builtinSchemaDocs(snapshot: OtelSpecSnapshot): Map<string, string>;
|
|
28
|
+
export interface OtelGenerated extends GenerateResult {
|
|
29
|
+
/** Built-in class name → its property tree. */
|
|
30
|
+
propertiesJSON: string;
|
|
31
|
+
}
|
|
13
32
|
export declare function generate(opts?: {
|
|
14
33
|
verbose?: boolean;
|
|
15
34
|
force?: boolean;
|
|
16
|
-
}): Promise<
|
|
17
|
-
/** Write the
|
|
18
|
-
export declare function writeGeneratedFiles(result:
|
|
35
|
+
}): Promise<OtelGenerated>;
|
|
36
|
+
/** Write the generated files to src/generated/. */
|
|
37
|
+
export declare function writeGeneratedFiles(result: OtelGenerated): void;
|
|
19
38
|
//# sourceMappingURL=generate.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../src/codegen/generate.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../src/codegen/generate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAKH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AAKxE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEtD,YAAY,EAAE,cAAc,EAAE,CAAC;AAS/B,gGAAgG;AAChG,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,gBAAgB,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAQjF;AAED,MAAM,WAAW,aAAc,SAAQ,cAAc;IACnD,+CAA+C;IAC/C,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,wBAAsB,QAAQ,CAAC,IAAI,CAAC,EAAE;IAAE,OAAO,CAAC,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,OAAO,CAAC,aAAa,CAAC,CAyDpG;AAED,mDAAmD;AACnD,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,aAAa,GAAG,IAAI,CAO/D"}
|
package/dist/codegen/generate.js
CHANGED
|
@@ -1,43 +1,108 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The otel lexicon's
|
|
2
|
+
* The otel lexicon's generation step (#3361).
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
4
|
+
* The built-in components' config types are generated from upstream
|
|
5
|
+
* `config.schema.yaml`, the documents `schemagen` writes next to each
|
|
6
|
+
* component's `config.go`, at the collector-contrib release `COLLECTOR_PIN`
|
|
7
|
+
* names and scoped by the `otelcol-contrib` distribution manifest. Generation
|
|
8
|
+
* reads the committed snapshot (`src/spec/otel-schemas.snapshot.json`, refreshed
|
|
9
|
+
* by `just snapshot`), refuses one that does not match `OTEL_SPEC_PIN`, and
|
|
10
|
+
* writes, into the gitignored `src/generated/`:
|
|
11
|
+
*
|
|
12
|
+
* - `index.ts`: a type alias per schema definition the built-ins reach, and
|
|
13
|
+
* `<ClassName>SchemaConfig` for each built-in that has a schema. The
|
|
14
|
+
* hand-written `defineBuiltin` files build their config types on these,
|
|
15
|
+
* overlaying only what a schema lacks (see `src/components/overlay.ts`);
|
|
16
|
+
* - `properties.json`: each built-in's property tree with upstream's
|
|
17
|
+
* descriptions, for LSP completion and hover;
|
|
18
|
+
* - `lexicon-otel.json`: the registry, derived from the exported classes.
|
|
19
|
+
*
|
|
20
|
+
* A built-in with no upstream schema (`forward`, which has no config) keeps its
|
|
21
|
+
* hand-written type.
|
|
10
22
|
*/
|
|
11
23
|
import { dirname, join } from "path";
|
|
12
24
|
import { fileURLToPath } from "url";
|
|
13
25
|
import { mkdirSync, writeFileSync } from "fs";
|
|
14
|
-
import {
|
|
26
|
+
import { loadSnapshot } from "../spec/snapshot.js";
|
|
27
|
+
import { assertPinnedSnapshot, assertSnapshotVersions } from "../spec/pin.js";
|
|
28
|
+
import { generateTypes, propertyDocs } from "../spec/parse.js";
|
|
29
|
+
import { BUILTIN_SPECS } from "../spec/builtins.js";
|
|
15
30
|
/** The packaged types entry re-exports the compiled declarations, which carry every config type. */
|
|
16
|
-
const TYPES_DTS = `// The otel lexicon's entity classes and config types are
|
|
17
|
-
//
|
|
31
|
+
const TYPES_DTS = `// The otel lexicon's entity classes and config types are compiled to
|
|
32
|
+
// dist/index.d.ts (config types generated from upstream config.schema.yaml);
|
|
33
|
+
// this entry re-exports them.
|
|
18
34
|
export * from "../index.js";
|
|
19
35
|
`;
|
|
36
|
+
/** The upstream schema document behind each built-in, by class name, from the contrib index. */
|
|
37
|
+
export function builtinSchemaDocs(snapshot) {
|
|
38
|
+
const out = new Map();
|
|
39
|
+
const index = snapshot.distributions["otelcol-contrib"];
|
|
40
|
+
for (const b of BUILTIN_SPECS) {
|
|
41
|
+
const hit = index.find((c) => c.kind === b.kind && (c.type === b.type || c.deprecatedType === b.type));
|
|
42
|
+
if (hit?.schema && snapshot.schemas[hit.schema])
|
|
43
|
+
out.set(b.className, hit.schema);
|
|
44
|
+
}
|
|
45
|
+
return out;
|
|
46
|
+
}
|
|
20
47
|
export async function generate(opts) {
|
|
48
|
+
// The registry is derived from the classes, which import the generated
|
|
49
|
+
// types; types are erased at runtime, so this import does not need them.
|
|
50
|
+
const { BUILTIN_CATALOG, lexiconRegistry } = await import("../catalog.js");
|
|
51
|
+
const snapshot = loadSnapshot();
|
|
52
|
+
assertSnapshotVersions(snapshot.versions);
|
|
53
|
+
assertPinnedSnapshot(snapshot);
|
|
54
|
+
const roots = builtinSchemaDocs(snapshot);
|
|
55
|
+
const generated = generateTypes(snapshot.schemas, [...new Set(roots.values())]);
|
|
56
|
+
const aliases = [...roots]
|
|
57
|
+
.sort(([a], [b]) => a.localeCompare(b))
|
|
58
|
+
.map(([className, doc]) => `/** \`${className}\`'s config, from \`${doc}\`. */\nexport type ${className}SchemaConfig = ${generated.roots.get(doc)};\n`)
|
|
59
|
+
.join("\n");
|
|
60
|
+
const unresolved = [...generated.unresolved.keys()].sort();
|
|
61
|
+
const indexTS = [
|
|
62
|
+
"// Generated by `npm run generate` from src/spec/otel-schemas.snapshot.json. Do not edit.",
|
|
63
|
+
`// Versions: ${Object.entries(snapshot.versions).map(([k, v]) => `${k} ${v}`).join(", ")}.`,
|
|
64
|
+
...(unresolved.length > 0
|
|
65
|
+
? ["// Upstream publishes no schema for these $refs, so they are typed `unknown`:", ...unresolved.map((u) => `// ${u}`)]
|
|
66
|
+
: []),
|
|
67
|
+
"",
|
|
68
|
+
'import type { Duration } from "../components/common.js";',
|
|
69
|
+
"",
|
|
70
|
+
generated.declarations,
|
|
71
|
+
"// ── Built-in config types ──────────────────────────────────────────",
|
|
72
|
+
"",
|
|
73
|
+
aliases,
|
|
74
|
+
].join("\n");
|
|
75
|
+
const properties = {};
|
|
76
|
+
let propertyCount = 0;
|
|
77
|
+
for (const [className, doc] of [...roots].sort(([a], [b]) => a.localeCompare(b))) {
|
|
78
|
+
properties[className] = propertyDocs(snapshot.schemas, doc);
|
|
79
|
+
propertyCount += Object.keys(properties[className]).length;
|
|
80
|
+
}
|
|
21
81
|
const registry = lexiconRegistry();
|
|
22
|
-
const lexiconJSON = `${JSON.stringify(registry, null, 2)}\n`;
|
|
23
|
-
const components = BUILTIN_CATALOG.filter((c) => c.type !== undefined).length;
|
|
24
82
|
if (opts?.verbose) {
|
|
25
|
-
|
|
83
|
+
const components = BUILTIN_CATALOG.filter((c) => c.type !== undefined).length;
|
|
84
|
+
console.error(`otel: ${components} built-in components, ${roots.size} typed from upstream config.schema.yaml ` +
|
|
85
|
+
`(${snapshot.versions["otelcol-contrib"]}), plus Pipeline and Service (${BUILTIN_CATALOG.length} entities)`);
|
|
86
|
+
if (unresolved.length > 0)
|
|
87
|
+
console.error(`otel: ${unresolved.length} upstream $refs have no schema and are typed unknown`);
|
|
26
88
|
}
|
|
27
89
|
return {
|
|
28
|
-
lexiconJSON,
|
|
90
|
+
lexiconJSON: `${JSON.stringify(registry, null, 2)}\n`,
|
|
29
91
|
typesDTS: TYPES_DTS,
|
|
30
|
-
indexTS
|
|
92
|
+
indexTS,
|
|
93
|
+
propertiesJSON: `${JSON.stringify(properties)}\n`,
|
|
31
94
|
resources: BUILTIN_CATALOG.length,
|
|
32
|
-
properties:
|
|
95
|
+
properties: propertyCount,
|
|
33
96
|
enums: 0,
|
|
34
97
|
warnings: [],
|
|
35
98
|
};
|
|
36
99
|
}
|
|
37
|
-
/** Write the
|
|
100
|
+
/** Write the generated files to src/generated/. */
|
|
38
101
|
export function writeGeneratedFiles(result) {
|
|
39
102
|
const pkgDir = dirname(dirname(dirname(fileURLToPath(import.meta.url))));
|
|
40
103
|
const dir = join(pkgDir, "src", "generated");
|
|
41
104
|
mkdirSync(dir, { recursive: true });
|
|
42
105
|
writeFileSync(join(dir, "lexicon-otel.json"), result.lexiconJSON);
|
|
106
|
+
writeFileSync(join(dir, "index.ts"), result.indexTS);
|
|
107
|
+
writeFileSync(join(dir, "properties.json"), result.propertiesJSON);
|
|
43
108
|
}
|