@intentius/chant-lexicon-fly 0.80.0 → 0.82.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/composites/fly-otel-collector.d.ts +64 -0
- package/dist/composites/fly-otel-collector.d.ts.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/integrity.json +3 -3
- package/dist/lint/rules/no-secret-literals.d.ts.map +1 -1
- package/dist/manifest.json +1 -1
- package/dist/op/activities/sprites.d.ts.map +1 -1
- package/dist/rules/no-secret-literals.ts +5 -3
- package/package.json +3 -2
- package/src/composites/fly-otel-collector.ts +124 -0
- package/src/index.ts +4 -0
- package/src/lint/rules/no-secret-literals.ts +5 -3
- package/src/lint/rules/rules.test.ts +5 -0
- package/src/op/activities/sprites.ts +5 -1
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FlyOtelCollector composite: an OpenTelemetry Collector on a Fly Machine.
|
|
3
|
+
*
|
|
4
|
+
* The collector config is declared with the otel lexicon
|
|
5
|
+
* (`@intentius/chant-lexicon-otel`), rendered with `collectorYaml`, and
|
|
6
|
+
* written into the machine as a file (`files[].raw_value`, base64). Other
|
|
7
|
+
* machines in the organization reach it over the private network at
|
|
8
|
+
* `<app>.internal` on the receiver ports. When the config serves a
|
|
9
|
+
* `health_check` endpoint, the machine gets an HTTP check on it.
|
|
10
|
+
*/
|
|
11
|
+
import type { Declarable } from "@intentius/chant/declarable";
|
|
12
|
+
import { type OTelComponent, type Signal } from "@intentius/chant-lexicon-otel";
|
|
13
|
+
export interface FlyOtelCollectorProps {
|
|
14
|
+
/** Machine name (default: "otel-collector"). */
|
|
15
|
+
name?: string;
|
|
16
|
+
/**
|
|
17
|
+
* The app the machine belongs to, as an app name. Default: the stack's
|
|
18
|
+
* only `App`, as for any machine.
|
|
19
|
+
*/
|
|
20
|
+
app?: string | Declarable;
|
|
21
|
+
/** Region (default: `Fly.Region`, which the build resolves from `FLY_REGION`). */
|
|
22
|
+
region?: string | Declarable;
|
|
23
|
+
/** Collector image (default: the contrib image at the otel lexicon's pinned collector version). */
|
|
24
|
+
image?: string;
|
|
25
|
+
/**
|
|
26
|
+
* The collector config, as otel lexicon entities (components and
|
|
27
|
+
* pipelines). Replaces the default config, and `exporters` and `signals`
|
|
28
|
+
* are then ignored.
|
|
29
|
+
*/
|
|
30
|
+
config?: Iterable<Declarable>;
|
|
31
|
+
/** Exporters for the default config (default: one `debug` exporter). */
|
|
32
|
+
exporters?: OTelComponent<"exporter", string, any>[];
|
|
33
|
+
/** Signals the default config has pipelines for (default: traces, metrics and logs). */
|
|
34
|
+
signals?: Signal[];
|
|
35
|
+
/** Guest CPU kind (default: "shared"). */
|
|
36
|
+
cpuKind?: string;
|
|
37
|
+
/** Guest CPUs (default: 1). */
|
|
38
|
+
cpus?: number;
|
|
39
|
+
/** Guest memory in MB (default: 512). */
|
|
40
|
+
memoryMb?: number;
|
|
41
|
+
/** Per-member defaults for fine-grained overrides. */
|
|
42
|
+
defaults?: {
|
|
43
|
+
machine?: Partial<Record<string, unknown>>;
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Create a FlyOtelCollector composite. Returns one Machine.
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```ts
|
|
51
|
+
* import { App } from "@intentius/chant-lexicon-fly";
|
|
52
|
+
* import { FlyOtelCollector } from "@intentius/chant-lexicon-fly";
|
|
53
|
+
* import { OtlpHttpExporter } from "@intentius/chant-lexicon-otel";
|
|
54
|
+
*
|
|
55
|
+
* export const app = new App({ name: "otel" });
|
|
56
|
+
* export const collector = FlyOtelCollector({
|
|
57
|
+
* exporters: [new OtlpHttpExporter({ endpoint: "https://otlp.example.com" })],
|
|
58
|
+
* });
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
export declare const FlyOtelCollector: import("@intentius/chant").CompositeDefinition<FlyOtelCollectorProps, {
|
|
62
|
+
machine: Declarable & Record<string, string>;
|
|
63
|
+
}>;
|
|
64
|
+
//# sourceMappingURL=fly-otel-collector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fly-otel-collector.d.ts","sourceRoot":"","sources":["../../src/composites/fly-otel-collector.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAOL,KAAK,aAAa,EAClB,KAAK,MAAM,EACZ,MAAM,+BAA+B,CAAC;AAIvC,MAAM,WAAW,qBAAqB;IACpC,gDAAgD;IAChD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,GAAG,CAAC,EAAE,MAAM,GAAG,UAAU,CAAC;IAC1B,kFAAkF;IAClF,MAAM,CAAC,EAAE,MAAM,GAAG,UAAU,CAAC;IAC7B,mGAAmG;IACnG,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;;OAIG;IACH,MAAM,CAAC,EAAE,QAAQ,CAAC,UAAU,CAAC,CAAC;IAC9B,wEAAwE;IACxE,SAAS,CAAC,EAAE,aAAa,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,CAAC;IACrD,wFAAwF;IACxF,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,0CAA0C;IAC1C,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,+BAA+B;IAC/B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,yCAAyC;IACzC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,sDAAsD;IACtD,QAAQ,CAAC,EAAE;QACT,OAAO,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;KAC5C,CAAC;CACH;AAOD;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,gBAAgB;;EA2CP,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -5,6 +5,8 @@ export { Fly, Region, OrgSlug, AppName, PseudoParameter } from "./pseudo.js";
|
|
|
5
5
|
export { FLY_METADATA_OWNERSHIP_KEYS } from "./ownership.js";
|
|
6
6
|
export { flyDeploy, flapsUp, flapsDown, flyApplyStep, LOCAL_FLAPS_ENDPOINT } from "./composites/fly-deploy.js";
|
|
7
7
|
export type { FlyDeployOpts, FlyApplyStepOpts, FlapsStepOpts } from "./composites/fly-deploy.js";
|
|
8
|
+
export { FlyOtelCollector } from "./composites/fly-otel-collector.js";
|
|
9
|
+
export type { FlyOtelCollectorProps } from "./composites/fly-otel-collector.js";
|
|
8
10
|
export { spriteCreate, spriteExec, spriteCheckpoint, spriteRestore, listCheckpoints, spriteDestroy, spriteWriteFile, spriteReadFile, spriteListDir, spriteRemove, spriteApplyNetworkPolicy, spriteApplyServices, spriteTaskCreate, spriteTaskRefresh, spriteTaskRelease, spritesUp, spritesDown, } from "./op/builders.js";
|
|
9
11
|
export * from "./generated/index.js";
|
|
10
12
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAKrC,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AAGxF,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAI7C,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAG1E,OAAO,EAAE,2BAA2B,EAAE,MAAM,aAAa,CAAC;AAK1D,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC5G,YAAY,EAAE,aAAa,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAKrC,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AAGxF,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAI7C,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAG1E,OAAO,EAAE,2BAA2B,EAAE,MAAM,aAAa,CAAC;AAK1D,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC5G,YAAY,EAAE,aAAa,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAG9F,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,YAAY,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AAY7E,OAAO,EACL,YAAY,EACZ,UAAU,EACV,gBAAgB,EAChB,aAAa,EACb,eAAe,EACf,aAAa,EACb,eAAe,EACf,cAAc,EACd,aAAa,EACb,YAAY,EACZ,wBAAwB,EACxB,mBAAmB,EACnB,gBAAgB,EAChB,iBAAiB,EACjB,iBAAiB,EACjB,SAAS,EACT,WAAW,GACZ,MAAM,eAAe,CAAC;AAKvB,cAAc,mBAAmB,CAAC"}
|
package/dist/integrity.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"algorithm": "sha256",
|
|
3
3
|
"artifacts": {
|
|
4
|
-
"manifest.json": "
|
|
4
|
+
"manifest.json": "d4f4c1f09c943fd24f9d3ecabb3ef93fd3a73773f984d40962104ae7e47db4d9",
|
|
5
5
|
"meta.json": "273f2a523b66f08ca91642dba2592c44765ab59ddf7329998884a0b08c6c3f24",
|
|
6
6
|
"types/index.d.ts": "63ec7f2eaa8dddd3abb273748c646c4870d99616db53fc04b53edd0588ccf260",
|
|
7
7
|
"rules/guest-sizing.ts": "bc749d218df8f3cc3d8fbe388205ae96e6b204ae0d6d77e8bf82cb936cc53ff6",
|
|
8
|
-
"rules/no-secret-literals.ts": "
|
|
8
|
+
"rules/no-secret-literals.ts": "ed08fe9256b75acaeffae575e3936d621700a3a8e29d96ea09a1f9d1ea4e16c2",
|
|
9
9
|
"rules/valid-region.ts": "674550b3b112aa1e526572b319601dce0c1a84f537c05b1e07828f8b84511c75",
|
|
10
10
|
"rules/fly-helpers.ts": "dd29d4b520727210a56ef604a89df380f91f8b35770bc28f5c51d0f99ca92dff",
|
|
11
11
|
"rules/fly010-machine-requires-image.ts": "dd9b70ee604867a9f02334013476afcf44a78b49bbba3d66296b8ccc2b02c8a0",
|
|
@@ -15,5 +15,5 @@
|
|
|
15
15
|
"skills/chant-fly-ops.md": "b8eef6504e203133e6a35c83aabb08404eec95060705395515a0046d42269cf1",
|
|
16
16
|
"skills/chant-fly-sprites.md": "3ebbbd9a2751b91fc573c21bafa9a8e490c53e1bdcee16cc61f4051c9e12e526"
|
|
17
17
|
},
|
|
18
|
-
"composite": "
|
|
18
|
+
"composite": "4d3e80c1f9b9024a7fc041466e20400e1b827971f14cf26e5987bbfa3cc66bd4"
|
|
19
19
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"no-secret-literals.d.ts","sourceRoot":"","sources":["../../../src/lint/rules/no-secret-literals.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAA+B,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"no-secret-literals.d.ts","sourceRoot":"","sources":["../../../src/lint/rules/no-secret-literals.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAA+B,MAAM,4BAA4B,CAAC;AAkBxF;;;;;;;;;GASG;AACH,eAAO,MAAM,oBAAoB,EAAE,QAwClC,CAAC"}
|
package/dist/manifest.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sprites.d.ts","sourceRoot":"","sources":["../../../src/op/activities/sprites.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;
|
|
1
|
+
{"version":3,"file":"sprites.d.ts","sourceRoot":"","sources":["../../../src/op/activities/sprites.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAOH,eAAO,MAAM,wBAAwB,4BAA4B,CAAC;AAIlE;;;;;GAKG;AACH,wBAAgB,sBAAsB,CACpC,IAAI,GAAE;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAO,EAChC,GAAG,GAAE,MAAM,CAAC,UAAwB,GACnC,MAAM,CAGR;AAwBD,eAAO,MAAM,YAAY,IAAI,CAAC;AAC9B,eAAO,MAAM,aAAa,IAAI,CAAC;AAC/B,eAAO,MAAM,aAAa,IAAI,CAAC;AAC/B,eAAO,MAAM,WAAW,IAAI,CAAC;AAC7B,eAAO,MAAM,gBAAgB,IAAI,CAAC;AAUlC;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,QAAQ,CAAC,UAAU,CAAC,GAAG,gBAAgB,CAkBnF;AAQD;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,CAoClD;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAS7E;AAID;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,sBAAsB,CAwB1E;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,UAAU,EAAE,EAAE,OAAO,EAAE,MAAM,G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pB,IAAI,GAAE,WAA4C,GACjD,OAAO,CAAC,kBAAkB,CAAC,CAO7B;AAED;;;;;;;GAOG;AACH,wBAAsB,UAAU,CAAC,IAAI,EAAE,cAAc,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAuDtG;AAED;;;;;GAKG;AACH,wBAAsB,gBAAgB,CACpC,IAAI,EAAE,oBAAoB,EAC1B,MAAM,CAAC,EAAE,WAAW,EACpB,IAAI,GAAE,WAA4C,GACjD,OAAO,CAAC,sBAAsB,CAAC,CAQjC;AAED;;;;GAIG;AACH,wBAAsB,eAAe,CACnC,IAAI,EAAE,mBAAmB,EACzB,MAAM,CAAC,EAAE,WAAW,EACpB,IAAI,GAAE,WAA4C,GACjD,OAAO,CAAC,UAAU,EAAE,CAAC,CAMvB;AAED;;;;;GAKG;AACH,wBAAsB,aAAa,CACjC,IAAI,EAAE,iBAAiB,EACvB,MAAM,CAAC,EAAE,WAAW,EACpB,IAAI,GAAE,WAA4C,GACjD,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAmBhC;AAED,kGAAkG;AAClG,wBAAsB,aAAa,CACjC,IAAI,EAAE,iBAAiB,EACvB,MAAM,CAAC,EAAE,WAAW,EACpB,IAAI,GAAE,WAA4C,GACjD,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAQhC"}
|
|
@@ -9,10 +9,12 @@ const SECRET_KEY_PATTERN = /(?:^|[_-])(?:password|passwd|secret|token|api[_-]?ke
|
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Values that are references or placeholders, not literal secrets:
|
|
12
|
-
* shell/interpolation references ($FOO, ${FOO}),
|
|
13
|
-
*
|
|
12
|
+
* shell/interpolation references ($FOO, ${FOO}), the OpenTelemetry
|
|
13
|
+
* Collector's environment substitution (${env:FOO}), and secret-manager
|
|
14
|
+
* style references. These are skipped so a `secrets` reference is never
|
|
15
|
+
* flagged.
|
|
14
16
|
*/
|
|
15
|
-
const REFERENCE_VALUE_PATTERN = /^(?:\$\{?[A-Za-z0-9_]+\}?|(?:secret|ref|env|vault):\S+)$/;
|
|
17
|
+
const REFERENCE_VALUE_PATTERN = /^(?:\$\{?(?:env:)?[A-Za-z0-9_]+\}?|(?:secret|ref|env|vault):\S+)$/;
|
|
16
18
|
|
|
17
19
|
/**
|
|
18
20
|
* FLY004: No secret literals in machine config
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intentius/chant-lexicon-fly",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.82.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"src/",
|
|
@@ -53,6 +53,7 @@
|
|
|
53
53
|
"build": "tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json && find dist -type f \\( -name \"*.js\" -o -name \"*.js.map\" \\) -delete"
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
|
+
"@intentius/chant-lexicon-otel": "*",
|
|
56
57
|
"ws": "^8.18.0"
|
|
57
58
|
},
|
|
58
59
|
"devDependencies": {
|
|
@@ -62,7 +63,7 @@
|
|
|
62
63
|
"typescript": "^5.9.3"
|
|
63
64
|
},
|
|
64
65
|
"peerDependencies": {
|
|
65
|
-
"@intentius/chant": "^0.
|
|
66
|
+
"@intentius/chant": "^0.82.0",
|
|
66
67
|
"typescript": "^5.9.3"
|
|
67
68
|
},
|
|
68
69
|
"description": "Fly.io Machines lexicon for chant — declarative IaC in TypeScript",
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FlyOtelCollector composite: an OpenTelemetry Collector on a Fly Machine.
|
|
3
|
+
*
|
|
4
|
+
* The collector config is declared with the otel lexicon
|
|
5
|
+
* (`@intentius/chant-lexicon-otel`), rendered with `collectorYaml`, and
|
|
6
|
+
* written into the machine as a file (`files[].raw_value`, base64). Other
|
|
7
|
+
* machines in the organization reach it over the private network at
|
|
8
|
+
* `<app>.internal` on the receiver ports. When the config serves a
|
|
9
|
+
* `health_check` endpoint, the machine gets an HTTP check on it.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { Composite, mergeDefaults } from "@intentius/chant";
|
|
13
|
+
import type { Declarable } from "@intentius/chant/declarable";
|
|
14
|
+
import {
|
|
15
|
+
buildCollectorConfig,
|
|
16
|
+
collectorEndpoints,
|
|
17
|
+
collectorYaml,
|
|
18
|
+
otlpCollector,
|
|
19
|
+
COLLECTOR_CONFIG_PATH,
|
|
20
|
+
COLLECTOR_IMAGE,
|
|
21
|
+
type OTelComponent,
|
|
22
|
+
type Signal,
|
|
23
|
+
} from "@intentius/chant-lexicon-otel";
|
|
24
|
+
import { Fly } from "../pseudo";
|
|
25
|
+
import { Machine, MachineConfig, MachineGuest, MachineInit, MachineCheck, MachineRestart, File } from "../generated/index";
|
|
26
|
+
|
|
27
|
+
export interface FlyOtelCollectorProps {
|
|
28
|
+
/** Machine name (default: "otel-collector"). */
|
|
29
|
+
name?: string;
|
|
30
|
+
/**
|
|
31
|
+
* The app the machine belongs to, as an app name. Default: the stack's
|
|
32
|
+
* only `App`, as for any machine.
|
|
33
|
+
*/
|
|
34
|
+
app?: string | Declarable;
|
|
35
|
+
/** Region (default: `Fly.Region`, which the build resolves from `FLY_REGION`). */
|
|
36
|
+
region?: string | Declarable;
|
|
37
|
+
/** Collector image (default: the contrib image at the otel lexicon's pinned collector version). */
|
|
38
|
+
image?: string;
|
|
39
|
+
/**
|
|
40
|
+
* The collector config, as otel lexicon entities (components and
|
|
41
|
+
* pipelines). Replaces the default config, and `exporters` and `signals`
|
|
42
|
+
* are then ignored.
|
|
43
|
+
*/
|
|
44
|
+
config?: Iterable<Declarable>;
|
|
45
|
+
/** Exporters for the default config (default: one `debug` exporter). */
|
|
46
|
+
exporters?: OTelComponent<"exporter", string, any>[];
|
|
47
|
+
/** Signals the default config has pipelines for (default: traces, metrics and logs). */
|
|
48
|
+
signals?: Signal[];
|
|
49
|
+
/** Guest CPU kind (default: "shared"). */
|
|
50
|
+
cpuKind?: string;
|
|
51
|
+
/** Guest CPUs (default: 1). */
|
|
52
|
+
cpus?: number;
|
|
53
|
+
/** Guest memory in MB (default: 512). */
|
|
54
|
+
memoryMb?: number;
|
|
55
|
+
/** Per-member defaults for fine-grained overrides. */
|
|
56
|
+
defaults?: {
|
|
57
|
+
machine?: Partial<Record<string, unknown>>;
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** Base64 of a UTF-8 string, the encoding flaps expects in `raw_value`. */
|
|
62
|
+
function base64(text: string): string {
|
|
63
|
+
return Buffer.from(text, "utf8").toString("base64");
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Create a FlyOtelCollector composite. Returns one Machine.
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* ```ts
|
|
71
|
+
* import { App } from "@intentius/chant-lexicon-fly";
|
|
72
|
+
* import { FlyOtelCollector } from "@intentius/chant-lexicon-fly";
|
|
73
|
+
* import { OtlpHttpExporter } from "@intentius/chant-lexicon-otel";
|
|
74
|
+
*
|
|
75
|
+
* export const app = new App({ name: "otel" });
|
|
76
|
+
* export const collector = FlyOtelCollector({
|
|
77
|
+
* exporters: [new OtlpHttpExporter({ endpoint: "https://otlp.example.com" })],
|
|
78
|
+
* });
|
|
79
|
+
* ```
|
|
80
|
+
*/
|
|
81
|
+
export const FlyOtelCollector = Composite((props: FlyOtelCollectorProps) => {
|
|
82
|
+
const {
|
|
83
|
+
name = "otel-collector",
|
|
84
|
+
image = COLLECTOR_IMAGE,
|
|
85
|
+
cpuKind = "shared",
|
|
86
|
+
cpus = 1,
|
|
87
|
+
memoryMb = 512,
|
|
88
|
+
defaults: defs,
|
|
89
|
+
} = props;
|
|
90
|
+
|
|
91
|
+
const entities = props.config ? [...props.config] : otlpCollector({ exporters: props.exporters, signals: props.signals });
|
|
92
|
+
const { healthCheck } = collectorEndpoints(buildCollectorConfig(entities).config);
|
|
93
|
+
|
|
94
|
+
const config = new MachineConfig({
|
|
95
|
+
image,
|
|
96
|
+
init: new MachineInit({ cmd: [`--config=${COLLECTOR_CONFIG_PATH}`] }),
|
|
97
|
+
files: [new File({ guest_path: COLLECTOR_CONFIG_PATH, raw_value: base64(collectorYaml(entities)) })],
|
|
98
|
+
guest: new MachineGuest({ cpu_kind: cpuKind, cpus, memory_mb: memoryMb }),
|
|
99
|
+
restart: new MachineRestart({ policy: "always" }),
|
|
100
|
+
...(healthCheck
|
|
101
|
+
? {
|
|
102
|
+
checks: {
|
|
103
|
+
health: new MachineCheck({
|
|
104
|
+
type: "http",
|
|
105
|
+
port: healthCheck.port,
|
|
106
|
+
path: healthCheck.path,
|
|
107
|
+
interval: "15s",
|
|
108
|
+
timeout: "5s",
|
|
109
|
+
grace_period: "10s",
|
|
110
|
+
}),
|
|
111
|
+
},
|
|
112
|
+
}
|
|
113
|
+
: {}),
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
const machine = new Machine(mergeDefaults({
|
|
117
|
+
name,
|
|
118
|
+
region: props.region ?? Fly.Region,
|
|
119
|
+
...(props.app !== undefined ? { app: props.app } : {}),
|
|
120
|
+
config,
|
|
121
|
+
} as Record<string, unknown>, defs?.machine) as ConstructorParameters<typeof Machine>[0]);
|
|
122
|
+
|
|
123
|
+
return { machine };
|
|
124
|
+
}, "FlyOtelCollector");
|
package/src/index.ts
CHANGED
|
@@ -22,6 +22,10 @@ export { FLY_METADATA_OWNERSHIP_KEYS } from "./ownership";
|
|
|
22
22
|
export { flyDeploy, flapsUp, flapsDown, flyApplyStep, LOCAL_FLAPS_ENDPOINT } from "./composites/fly-deploy";
|
|
23
23
|
export type { FlyDeployOpts, FlyApplyStepOpts, FlapsStepOpts } from "./composites/fly-deploy";
|
|
24
24
|
|
|
25
|
+
// OpenTelemetry Collector on a Machine, its config declared with the otel lexicon (#2613).
|
|
26
|
+
export { FlyOtelCollector } from "./composites/fly-otel-collector";
|
|
27
|
+
export type { FlyOtelCollectorProps } from "./composites/fly-otel-collector";
|
|
28
|
+
|
|
25
29
|
// Sprite Op step builders. chant #1288 Stage 2: these author
|
|
26
30
|
// `activity("spriteCreate", ...)` steps with authoring-time types derived
|
|
27
31
|
// from this lexicon's own `Sprite*Args` interfaces (`./op/builders.ts`),
|
|
@@ -9,10 +9,12 @@ const SECRET_KEY_PATTERN = /(?:^|[_-])(?:password|passwd|secret|token|api[_-]?ke
|
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Values that are references or placeholders, not literal secrets:
|
|
12
|
-
* shell/interpolation references ($FOO, ${FOO}),
|
|
13
|
-
*
|
|
12
|
+
* shell/interpolation references ($FOO, ${FOO}), the OpenTelemetry
|
|
13
|
+
* Collector's environment substitution (${env:FOO}), and secret-manager
|
|
14
|
+
* style references. These are skipped so a `secrets` reference is never
|
|
15
|
+
* flagged.
|
|
14
16
|
*/
|
|
15
|
-
const REFERENCE_VALUE_PATTERN = /^(?:\$\{?[A-Za-z0-9_]+\}?|(?:secret|ref|env|vault):\S+)$/;
|
|
17
|
+
const REFERENCE_VALUE_PATTERN = /^(?:\$\{?(?:env:)?[A-Za-z0-9_]+\}?|(?:secret|ref|env|vault):\S+)$/;
|
|
16
18
|
|
|
17
19
|
/**
|
|
18
20
|
* FLY004: No secret literals in machine config
|
|
@@ -113,6 +113,11 @@ describe("Fly lint rules", () => {
|
|
|
113
113
|
expect(noSecretLiteralsRule.check(ctx)).toHaveLength(0);
|
|
114
114
|
});
|
|
115
115
|
|
|
116
|
+
test("does not flag a collector ${env:...} substitution", () => {
|
|
117
|
+
const ctx = createContext('new OtlpHttpExporter({ headers: { "x-api-key": "${env:OTLP_API_KEY}" } });');
|
|
118
|
+
expect(noSecretLiteralsRule.check(ctx)).toHaveLength(0);
|
|
119
|
+
});
|
|
120
|
+
|
|
116
121
|
test("does not flag non-credential keys", () => {
|
|
117
122
|
const ctx = createContext(`new MachineConfig({ env: { LOG_LEVEL: "info" } });`);
|
|
118
123
|
expect(noSecretLiteralsRule.check(ctx)).toHaveLength(0);
|
|
@@ -22,7 +22,10 @@
|
|
|
22
22
|
* or the in-process fake with no code change.
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
// `ws` is loaded inside spriteExec, not at the top. It is a CommonJS package
|
|
26
|
+
// that requires "events", and a sandboxed build bundles the fly lexicon into
|
|
27
|
+
// ESM, where that require throws. The top-level import put it on the path of
|
|
28
|
+
// every project that imports the lexicon and needs the run fallback (#2613).
|
|
26
29
|
|
|
27
30
|
export const DEFAULT_SPRITES_BASE_URL = "https://api.sprites.dev";
|
|
28
31
|
|
|
@@ -393,6 +396,7 @@ export async function spriteExec(args: SpriteExecArgs, signal?: AbortSignal): Pr
|
|
|
393
396
|
const token = args.token ?? process.env.SPRITES_API_TOKEN;
|
|
394
397
|
const headers: Record<string, string> = {};
|
|
395
398
|
if (token) headers.Authorization = `Bearer ${token}`;
|
|
399
|
+
const { default: WebSocket } = await import("ws");
|
|
396
400
|
|
|
397
401
|
const result = await new Promise<SpriteExecResult>((resolve, reject) => {
|
|
398
402
|
const frames: Uint8Array[] = [];
|