@r_masseater/masseater-utils 0.12.0 → 0.13.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/workers-tracing/alchemy.d.mts +2 -0
- package/dist/workers-tracing/alchemy.mjs +6 -0
- package/dist/workers-tracing/alchemy.mjs.map +1 -1
- package/package.json +1 -1
- package/skills/add-scroll-chip-row/SKILL.md +1 -1
- package/skills/assert-exported-telemetry/SKILL.md +1 -1
- package/skills/build-tauri-app/SKILL.md +1 -1
- package/skills/find-cache-folder/SKILL.md +1 -1
- package/skills/import-custom-format/SKILL.md +1 -1
- package/skills/name-stack-resources/SKILL.md +1 -1
- package/skills/read-hook-input/SKILL.md +1 -1
- package/skills/read-node-ecosystem/SKILL.md +1 -1
- package/skills/run-effect-main/SKILL.md +1 -1
- package/skills/share-types-with-rust/SKILL.md +1 -1
- package/skills/trace-workers/SKILL.md +4 -1
- package/skills/use-model-server/SKILL.md +1 -1
- package/skills/write-actions-steps/SKILL.md +1 -1
|
@@ -13,6 +13,8 @@ export declare const DEFAULT_DESTINATION = "workers-tracing";
|
|
|
13
13
|
export declare const traceSink: (args_0?: TraceSinkProps | undefined) => Effect.Effect<Workers.ObservabilityDestination, never, import("alchemy").Provider<import("alchemy").Random> | import("@alchemy.run/cloudflare").Providers>;
|
|
14
14
|
export interface TracingOptions {
|
|
15
15
|
readonly destinations?: readonly string[];
|
|
16
|
+
readonly traceSampleRate?: number;
|
|
17
|
+
readonly logSampleRate?: number;
|
|
16
18
|
}
|
|
17
19
|
export declare const traced: (options?: TracingOptions) => (props: WorkerProps) => WorkerProps;
|
|
18
20
|
export type WorkerService = ProviderService<Worker>;
|
|
@@ -39,6 +39,10 @@ const traceSink = Effect.fn("traceSink")(function* traceSink({ destination = DEF
|
|
|
39
39
|
});
|
|
40
40
|
// src/app/workers-tracing-alchemy.ts
|
|
41
41
|
const laterDate = Order.max(Order.String);
|
|
42
|
+
const sampledAt = (rate) => pipe(Option.fromUndefinedOr(rate), Option.match({
|
|
43
|
+
onNone: () => ({}),
|
|
44
|
+
onSome: (headSamplingRate) => ({ headSamplingRate })
|
|
45
|
+
}));
|
|
42
46
|
const withDestinations = (added) => (own) => pipe(Option.fromNullishOr(own), Option.getOrElse(() => []), Array.appendAll(added), Array.dedupe);
|
|
43
47
|
const isVersionOfAnotherWorker = ({ version }) => pipe(Option.fromUndefinedOr(version), Option.exists(({ parent }) => Predicate.isNotUndefined(parent)));
|
|
44
48
|
const optsOutOfTraces = ({ observability }) => pipe(Option.fromUndefinedOr(observability), Option.flatMapNullishOr(({ traces }) => traces), Option.exists(({ enabled }) => enabled === false));
|
|
@@ -72,11 +76,13 @@ const withTraces = (options) => (props) => {
|
|
|
72
76
|
enabled: true,
|
|
73
77
|
invocationLogs: true,
|
|
74
78
|
persist: true,
|
|
79
|
+
...sampledAt(options.logSampleRate),
|
|
75
80
|
...logs
|
|
76
81
|
},
|
|
77
82
|
traces: {
|
|
78
83
|
enabled: true,
|
|
79
84
|
persist: true,
|
|
85
|
+
...sampledAt(options.traceSampleRate),
|
|
80
86
|
...traces,
|
|
81
87
|
destinations: withDestinations(options.destinations ?? [])(destinations)
|
|
82
88
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"alchemy.mjs","names":["Arr","Rec","providerLayer"],"sources":["../../src/shared/config/compatibility.ts","../../src/features/sink-traces/model/trace-sink.ts","../../src/app/workers-tracing-alchemy.ts"],"sourcesContent":["export const COMPATIBILITY_DATE = \"2026-08-25\";\n","import { Workers } from \"@alchemy.run/cloudflare\";\nimport { makeRandom } from \"alchemy\";\nimport { map } from \"alchemy/Output\";\nimport { Effect, Redacted } from \"effect\";\n\nimport { COMPATIBILITY_DATE } from \"#/shared/config/index.ts\";\n\nexport interface TraceSinkProps {\n readonly destination?: string;\n readonly workerName?: string;\n readonly logpush?: boolean;\n readonly cpuMs?: number;\n}\n\nexport const DEFAULT_DESTINATION = \"workers-tracing\";\n\nconst DEFAULT_CPU_MS = 1000;\n\nconst sinkMain = (): string =>\n decodeURIComponent(\n new URL(import.meta.resolve(\"@r_masseater/masseater-utils/workers-tracing/trace-sink-worker\"))\n .pathname,\n );\n\nexport const traceSink = Effect.fn(\"traceSink\")(function* traceSink({\n destination = DEFAULT_DESTINATION,\n workerName = `${destination}-sink`,\n logpush = true,\n cpuMs = DEFAULT_CPU_MS,\n}: TraceSinkProps = {}) {\n const token = yield* makeRandom(\"TraceSinkToken\");\n const sink = yield* Workers.Worker(\"TraceSink\", {\n name: workerName,\n main: sinkMain(),\n compatibility: { date: COMPATIBILITY_DATE },\n logpush,\n limits: { cpuMs },\n env: { TRACE_SINK_TOKEN: token },\n observability: {\n enabled: true,\n logs: { enabled: true, invocationLogs: false, persist: true },\n traces: { enabled: false },\n issues: { enabled: true },\n },\n });\n return yield* Workers.ObservabilityDestination(\"Traces\", {\n name: destination,\n url: map(sink.url, (url) => new URL(\"/v1/traces\", url).href),\n headers: {\n authorization: map(token, (value) => Redacted.make(`Bearer ${Redacted.value(value)}`)),\n },\n logpushDataset: \"opentelemetry-traces\",\n });\n});\n","import { Worker } from \"@alchemy.run/cloudflare/Workers/Worker\";\nimport type { WorkerProps } from \"@alchemy.run/cloudflare/Workers/Worker\";\nimport { effect as providerLayer, tryFindProviderRegistrationByType } from \"alchemy/Provider\";\nimport type { ProviderService } from \"alchemy/Provider\";\nimport { Array as Arr, Effect, Layer, Option, Order, Predicate, Record as Rec, pipe } from \"effect\";\n\nimport { COMPATIBILITY_DATE } from \"#/shared/config/index.ts\";\n\nconst laterDate = Order.max(Order.String);\n\nexport interface TracingOptions {\n readonly destinations?: readonly string[];\n}\n\nconst withDestinations =\n (added: readonly string[]) =>\n (own: readonly string[] | null | undefined): string[] =>\n pipe(\n Option.fromNullishOr(own),\n Option.getOrElse((): readonly string[] => []),\n Arr.appendAll(added),\n Arr.dedupe,\n );\n\nconst isVersionOfAnotherWorker = ({ version }: WorkerProps): boolean =>\n pipe(\n Option.fromUndefinedOr(version),\n Option.exists(({ parent }) => Predicate.isNotUndefined(parent)),\n );\n\nconst optsOutOfTraces = ({ observability }: WorkerProps): boolean =>\n pipe(\n Option.fromUndefinedOr(observability),\n Option.flatMapNullishOr(({ traces }) => traces),\n Option.exists(({ enabled }) => enabled === false),\n );\n\nconst withIssues = (props: WorkerProps): WorkerProps => {\n const { observability = {} } = props;\n return {\n ...props,\n observability: { ...observability, issues: { enabled: true, ...observability.issues } },\n };\n};\n\nconst withTraces =\n (options: TracingOptions) =>\n (props: WorkerProps): WorkerProps => {\n const { observability = {}, compatibility = {} } = props;\n const { logs, traces } = observability;\n const destinations = pipe(\n Option.fromNullishOr(traces),\n Option.flatMapNullishOr((own) => own.destinations),\n Option.getOrUndefined,\n );\n return {\n ...props,\n compatibility: {\n ...compatibility,\n date: laterDate(compatibility.date ?? COMPATIBILITY_DATE, COMPATIBILITY_DATE),\n },\n observability: {\n ...observability,\n enabled: true,\n logs: { enabled: true, invocationLogs: true, persist: true, ...logs },\n traces: {\n enabled: true,\n persist: true,\n ...traces,\n destinations: withDestinations(options.destinations ?? [])(destinations),\n },\n },\n };\n };\n\nexport const traced =\n (options: TracingOptions = {}) =>\n (props: WorkerProps): WorkerProps => {\n if (isVersionOfAnotherWorker(props)) {\n return props;\n }\n const issued = withIssues(props);\n if (optsOutOfTraces(props)) {\n return issued;\n }\n return withTraces(options)(issued);\n };\n\nexport type WorkerService = ProviderService<Worker>;\n\ntype Tunable = Readonly<{ news: WorkerProps; olds?: WorkerProps | undefined }>;\n\nconst tracedInput =\n (options: TracingOptions) =>\n <Input extends Tunable>(input: Input): Input => ({\n ...input,\n news: traced(options)(input.news),\n ...pipe(\n Option.fromUndefinedOr(input.olds),\n Option.match({ onNone: () => ({}), onSome: (olds) => ({ olds: traced(options)(olds) }) }),\n ),\n });\n\nconst tunedReconcile =\n (options: TracingOptions) =>\n <Input extends Tunable, Output>(\n service: Readonly<{ reconcile: (input: Input) => Output }>,\n ): Readonly<{ reconcile: (input: Input) => Output }> => ({\n reconcile: (input) => service.reconcile(tracedInput(options)(input)),\n });\n\nconst tunedPrecreate =\n (options: TracingOptions) =>\n <Input extends Tunable, Output>(\n service: Readonly<{ precreate?: ((input: Input) => Output) | undefined }>,\n ): Readonly<{ precreate?: (input: Input) => Output }> =>\n pipe(\n Option.fromUndefinedOr(service.precreate),\n Option.match({\n onNone: () => ({}),\n onSome: (precreate) => ({\n precreate: (input: Input): Output => precreate(tracedInput(options)(input)),\n }),\n }),\n );\n\nexport const tuneService =\n (options: TracingOptions) =>\n <Service extends WorkerService>(service: Service): Service => ({\n ...service,\n ...tunedReconcile(options)(service),\n ...tunedPrecreate(options)(service),\n ...pipe(\n Option.fromUndefinedOr(service.modes),\n Option.match({\n onNone: () => ({}),\n onSome: (modes) => {\n const tune = tuneService(options);\n return { modes: pipe(modes, Rec.map(Effect.map(tune))) };\n },\n }),\n ),\n });\n\nconst tracingProvider = (options: TracingOptions): Layer.Layer<never> => {\n const tune = tuneService(options);\n return providerLayer(\n Worker,\n tryFindProviderRegistrationByType<Worker>(Worker.Type).pipe(\n Effect.flatMap(Effect.fromOption),\n Effect.map(tune),\n Effect.orDie,\n ),\n );\n};\n\nexport const withWorkersTracing =\n (options: TracingOptions = {}) =>\n <Out, Error, In>(providers: Layer.Layer<Out, Error, In>): Layer.Layer<Out, Error, In> =>\n Layer.provideMerge(tracingProvider(options), providers);\n\nexport { COMPATIBILITY_DATE } from \"#/shared/config/index.ts\";\nexport { DEFAULT_DESTINATION, traceSink } from \"#/features/sink-traces/index.ts\";\nexport type { TraceSinkProps } from \"#/features/sink-traces/index.ts\";\n"],"mappings":";;;;;;;AAAA,MAAa,qBAAqB;;ACclC,MAAa,sBAAsB;AAEnC,MAAM,iBAAiB;AAEvB,MAAM,iBACJ,mBACE,IAAI,IAAI,YAAY,QAAQ,gEAAgE,CAAC,CAAC,CAC3F,QACL;AAEF,MAAa,YAAY,OAAO,GAAG,WAAW,CAAC,CAAC,UAAU,UAAU,EACl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ACE,OAAO,gBAAgB,QAAQ,SAAS,GACxC,OAAO,MAAM;CACX,eAAe,CAAC;CAChB,SAAS,eAAe,EACtB,YAAY,UAAyB,UAAU,YAAY,OAAO,CAAC,CAAC,KAAK,CAAC,EAC5E;AACF,CAAC,CACH;AAEJ,MAAa,eACV,aAC+B,aAA+B;CAC7D,GAAG;CACH,GAAG,eAAe,OAAO,CAAC,CAAC,OAAO;CAClC,GAAG,eAAe,OAAO,CAAC,CAAC,OAAO;CAClC,GAAG,KACD,OAAO,gBAAgB,QAAQ,KAAK,GACpC,OAAO,MAAM;EACX,eAAe,CAAC;EAChB,SAAS,UAAU;GACjB,MAAM,OAAO,YAAY,OAAO;GAChC,OAAO,EAAE,OAAO,KAAK,OAAOC,OAAI,IAAI,OAAO,IAAI,IAAI,CAAC,CAAC,EAAE;EACzD;CACF,CAAC,CACH;AACF;AAEF,MAAM,mBAAmB,YAAgD;CACvE,MAAM,OAAO,YAAY,OAAO;CAChC,OAAOC,OACL,QACA,kCAA0C,OAAO,IAAI,CAAC,CAAC,KACrD,OAAO,QAAQ,OAAO,UAAU,GAChC,OAAO,IAAI,IAAI,GACf,OAAO,KACT,CACF;AACF;AAEA,MAAa,sBACV,UAA0B,CAAC,OACX,cACf,MAAM,aAAa,gBAAgB,OAAO,GAAG,SAAS"}
|
|
1
|
+
{"version":3,"file":"alchemy.mjs","names":["Arr","Rec","providerLayer"],"sources":["../../src/shared/config/compatibility.ts","../../src/features/sink-traces/model/trace-sink.ts","../../src/app/workers-tracing-alchemy.ts"],"sourcesContent":["export const COMPATIBILITY_DATE = \"2026-08-25\";\n","import { Workers } from \"@alchemy.run/cloudflare\";\nimport { makeRandom } from \"alchemy\";\nimport { map } from \"alchemy/Output\";\nimport { Effect, Redacted } from \"effect\";\n\nimport { COMPATIBILITY_DATE } from \"#/shared/config/index.ts\";\n\nexport interface TraceSinkProps {\n readonly destination?: string;\n readonly workerName?: string;\n readonly logpush?: boolean;\n readonly cpuMs?: number;\n}\n\nexport const DEFAULT_DESTINATION = \"workers-tracing\";\n\nconst DEFAULT_CPU_MS = 1000;\n\nconst sinkMain = (): string =>\n decodeURIComponent(\n new URL(import.meta.resolve(\"@r_masseater/masseater-utils/workers-tracing/trace-sink-worker\"))\n .pathname,\n );\n\nexport const traceSink = Effect.fn(\"traceSink\")(function* traceSink({\n destination = DEFAULT_DESTINATION,\n workerName = `${destination}-sink`,\n logpush = true,\n cpuMs = DEFAULT_CPU_MS,\n}: TraceSinkProps = {}) {\n const token = yield* makeRandom(\"TraceSinkToken\");\n const sink = yield* Workers.Worker(\"TraceSink\", {\n name: workerName,\n main: sinkMain(),\n compatibility: { date: COMPATIBILITY_DATE },\n logpush,\n limits: { cpuMs },\n env: { TRACE_SINK_TOKEN: token },\n observability: {\n enabled: true,\n logs: { enabled: true, invocationLogs: false, persist: true },\n traces: { enabled: false },\n issues: { enabled: true },\n },\n });\n return yield* Workers.ObservabilityDestination(\"Traces\", {\n name: destination,\n url: map(sink.url, (url) => new URL(\"/v1/traces\", url).href),\n headers: {\n authorization: map(token, (value) => Redacted.make(`Bearer ${Redacted.value(value)}`)),\n },\n logpushDataset: \"opentelemetry-traces\",\n });\n});\n","import { Worker } from \"@alchemy.run/cloudflare/Workers/Worker\";\nimport type { WorkerProps } from \"@alchemy.run/cloudflare/Workers/Worker\";\nimport { effect as providerLayer, tryFindProviderRegistrationByType } from \"alchemy/Provider\";\nimport type { ProviderService } from \"alchemy/Provider\";\nimport { Array as Arr, Effect, Layer, Option, Order, Predicate, Record as Rec, pipe } from \"effect\";\n\nimport { COMPATIBILITY_DATE } from \"#/shared/config/index.ts\";\n\nconst laterDate = Order.max(Order.String);\n\nexport interface TracingOptions {\n readonly destinations?: readonly string[];\n readonly traceSampleRate?: number;\n readonly logSampleRate?: number;\n}\n\nconst sampledAt = (rate: number | undefined): Readonly<{ headSamplingRate?: number }> =>\n pipe(\n Option.fromUndefinedOr(rate),\n Option.match({ onNone: () => ({}), onSome: (headSamplingRate) => ({ headSamplingRate }) }),\n );\n\nconst withDestinations =\n (added: readonly string[]) =>\n (own: readonly string[] | null | undefined): string[] =>\n pipe(\n Option.fromNullishOr(own),\n Option.getOrElse((): readonly string[] => []),\n Arr.appendAll(added),\n Arr.dedupe,\n );\n\nconst isVersionOfAnotherWorker = ({ version }: WorkerProps): boolean =>\n pipe(\n Option.fromUndefinedOr(version),\n Option.exists(({ parent }) => Predicate.isNotUndefined(parent)),\n );\n\nconst optsOutOfTraces = ({ observability }: WorkerProps): boolean =>\n pipe(\n Option.fromUndefinedOr(observability),\n Option.flatMapNullishOr(({ traces }) => traces),\n Option.exists(({ enabled }) => enabled === false),\n );\n\nconst withIssues = (props: WorkerProps): WorkerProps => {\n const { observability = {} } = props;\n return {\n ...props,\n observability: { ...observability, issues: { enabled: true, ...observability.issues } },\n };\n};\n\nconst withTraces =\n (options: TracingOptions) =>\n (props: WorkerProps): WorkerProps => {\n const { observability = {}, compatibility = {} } = props;\n const { logs, traces } = observability;\n const destinations = pipe(\n Option.fromNullishOr(traces),\n Option.flatMapNullishOr((own) => own.destinations),\n Option.getOrUndefined,\n );\n return {\n ...props,\n compatibility: {\n ...compatibility,\n date: laterDate(compatibility.date ?? COMPATIBILITY_DATE, COMPATIBILITY_DATE),\n },\n observability: {\n ...observability,\n enabled: true,\n logs: {\n enabled: true,\n invocationLogs: true,\n persist: true,\n ...sampledAt(options.logSampleRate),\n ...logs,\n },\n traces: {\n enabled: true,\n persist: true,\n ...sampledAt(options.traceSampleRate),\n ...traces,\n destinations: withDestinations(options.destinations ?? [])(destinations),\n },\n },\n };\n };\n\nexport const traced =\n (options: TracingOptions = {}) =>\n (props: WorkerProps): WorkerProps => {\n if (isVersionOfAnotherWorker(props)) {\n return props;\n }\n const issued = withIssues(props);\n if (optsOutOfTraces(props)) {\n return issued;\n }\n return withTraces(options)(issued);\n };\n\nexport type WorkerService = ProviderService<Worker>;\n\ntype Tunable = Readonly<{ news: WorkerProps; olds?: WorkerProps | undefined }>;\n\nconst tracedInput =\n (options: TracingOptions) =>\n <Input extends Tunable>(input: Input): Input => ({\n ...input,\n news: traced(options)(input.news),\n ...pipe(\n Option.fromUndefinedOr(input.olds),\n Option.match({ onNone: () => ({}), onSome: (olds) => ({ olds: traced(options)(olds) }) }),\n ),\n });\n\nconst tunedReconcile =\n (options: TracingOptions) =>\n <Input extends Tunable, Output>(\n service: Readonly<{ reconcile: (input: Input) => Output }>,\n ): Readonly<{ reconcile: (input: Input) => Output }> => ({\n reconcile: (input) => service.reconcile(tracedInput(options)(input)),\n });\n\nconst tunedPrecreate =\n (options: TracingOptions) =>\n <Input extends Tunable, Output>(\n service: Readonly<{ precreate?: ((input: Input) => Output) | undefined }>,\n ): Readonly<{ precreate?: (input: Input) => Output }> =>\n pipe(\n Option.fromUndefinedOr(service.precreate),\n Option.match({\n onNone: () => ({}),\n onSome: (precreate) => ({\n precreate: (input: Input): Output => precreate(tracedInput(options)(input)),\n }),\n }),\n );\n\nexport const tuneService =\n (options: TracingOptions) =>\n <Service extends WorkerService>(service: Service): Service => ({\n ...service,\n ...tunedReconcile(options)(service),\n ...tunedPrecreate(options)(service),\n ...pipe(\n Option.fromUndefinedOr(service.modes),\n Option.match({\n onNone: () => ({}),\n onSome: (modes) => {\n const tune = tuneService(options);\n return { modes: pipe(modes, Rec.map(Effect.map(tune))) };\n },\n }),\n ),\n });\n\nconst tracingProvider = (options: TracingOptions): Layer.Layer<never> => {\n const tune = tuneService(options);\n return providerLayer(\n Worker,\n tryFindProviderRegistrationByType<Worker>(Worker.Type).pipe(\n Effect.flatMap(Effect.fromOption),\n Effect.map(tune),\n Effect.orDie,\n ),\n );\n};\n\nexport const withWorkersTracing =\n (options: TracingOptions = {}) =>\n <Out, Error, In>(providers: Layer.Layer<Out, Error, In>): Layer.Layer<Out, Error, In> =>\n Layer.provideMerge(tracingProvider(options), providers);\n\nexport { COMPATIBILITY_DATE } from \"#/shared/config/index.ts\";\nexport { DEFAULT_DESTINATION, traceSink } from \"#/features/sink-traces/index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CAAC,OACX,cACf,MAAM,aAAa,gBAAgB,OAAO,GAAG,SAAS"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@r_masseater/masseater-utils",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0",
|
|
4
4
|
"description": "The small shared libraries of masseater's repositories as subpaths of one package: a chip row for React, Claude Code plugin helpers, Effect entry points for Node.js and GitHub Actions, file import mapping, Node package readers, OTLP assertions for Vitest and Cloudflare Workers tracing, and what the Tauri desktop apps share: OpenTelemetry for the screens, Vite settings, the media-notes screens and the release commands.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"actions",
|
|
@@ -9,7 +9,7 @@ description: >
|
|
|
9
9
|
metadata:
|
|
10
10
|
type: core
|
|
11
11
|
library: "@r_masseater/masseater-utils"
|
|
12
|
-
library_version: 0.
|
|
12
|
+
library_version: 0.13.0
|
|
13
13
|
sources:
|
|
14
14
|
- src/app
|
|
15
15
|
- src/features/sink-traces
|
|
@@ -127,6 +127,9 @@ It fails with `WorkersAiError` and logs a cut-off answer. The msch preset report
|
|
|
127
127
|
Deploy `traceSink()` once per account as its own stack.
|
|
128
128
|
Then name its destination in `withWorkersTracing({ destinations: ["workers-tracing"] })`.
|
|
129
129
|
The sink logs every received span, and `workers-traces` reads them back through the Workers Observability API.
|
|
130
|
+
Every span becomes one Workers Logs event, so a busy Worker can exceed the monthly allowance of log events.
|
|
131
|
+
Pass `traceSampleRate` and `logSampleRate`, from 0 to 1, to `withWorkersTracing` to keep that share of the traces and invocation logs of every Worker in the stack that sets no `headSamplingRate` of its own.
|
|
132
|
+
A request that `workers-traces --expect` checks is kept only at the sampled share, so a Worker that CI checks this way keeps its own `headSamplingRate: 1`.
|
|
130
133
|
|
|
131
134
|
```sh
|
|
132
135
|
workers-traces --request https://app.example.com/ --expect "GET /" --expect invite.load --wait 60
|