@glasstrace/sdk 1.6.1 → 1.8.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/README.md CHANGED
@@ -83,7 +83,7 @@ init-hang cannot leave your installation in a broken state.
83
83
  | Exit code | Meaning |
84
84
  |-----------|---------|
85
85
  | `0` | Scaffolding succeeded AND the server confirmed the anon key. |
86
- | `1` | Scaffolding failed. No verification attempted. |
86
+ | `1` | Scaffolding failed, OR the static-discovery file at `public/.well-known/glasstrace.json` could not be written. The browser extension cannot discover the project until that file is written; rerun `glasstrace init` after fixing the underlying error (most commonly: the static root is missing or read-only). |
87
87
  | `2` | Scaffolding succeeded but server verification failed. Safe to re-run. |
88
88
 
89
89
  On a non-zero verification exit, the error message distinguishes three
@@ -98,6 +98,18 @@ total cap). HTTP 4xx/5xx and malformed responses are surfaced
98
98
  immediately. Set `GLASSTRACE_SKIP_INIT_VERIFY=1` to skip verification
99
99
  for offline installs.
100
100
 
101
+ ## Getting help
102
+
103
+ ```bash
104
+ glasstrace --help # or: glasstrace -h
105
+ glasstrace init --help # same; help short-circuits subcommand routing
106
+ ```
107
+
108
+ Help invocations print the command list and exit cleanly without
109
+ modifying the project. Help is detected anywhere in the argv slice,
110
+ including composite invocations like `glasstrace init --yes --help`
111
+ (the `--yes` is ignored — the user asked for help).
112
+
101
113
  ## Refreshing agent instruction guidance
102
114
 
103
115
  `glasstrace init` and `glasstrace mcp add` write a managed Glasstrace
@@ -190,7 +190,40 @@ declare class GlasstraceExporter implements SpanExporter {
190
190
  private pendingBatches;
191
191
  private pendingSpanCount;
192
192
  private overflowLogged;
193
+ /**
194
+ * Lazily-bound reference to the export-path circuit breaker
195
+ * (DISC-1568 / Wave 15C). Resolved on first export so this
196
+ * constructor stays side-effect-free. The breaker is a module-
197
+ * singleton — every `GlasstraceExporter` instance shares the same
198
+ * one so a rotation event observed in `init-client.ts` reaches
199
+ * every active exporter.
200
+ */
201
+ private circuitBreaker;
193
202
  constructor(options: GlasstraceExporterOptions);
203
+ /**
204
+ * Returns the export-path circuit breaker, lazily wiring it on
205
+ * first call. The breaker is a module-singleton so all exporter
206
+ * instances share state — a credential rotation observed once
207
+ * resets the breaker for every active exporter, and a single
208
+ * outage at the OTLP endpoint trips a single breaker rather than
209
+ * one per exporter copy.
210
+ *
211
+ * The wiring binds:
212
+ * - the lifecycle event sink to the SDK's lifecycle bus
213
+ * (`emitLifecycleEvent`) so the `otel:circuit_*` events surface
214
+ * to runtime-state, the CLI bridge, and any user-installed
215
+ * subscribers.
216
+ * - the dropped-span counter to {@link recordSpansDropped} so OPEN-
217
+ * state drops show up in the existing health surface.
218
+ * - the FSM hooks to {@link pushDegradationSource} /
219
+ * {@link clearDegradationSource} keyed on `"export-circuit"`,
220
+ * which routes the OPEN/CLOSED transitions through the
221
+ * centralised `recomputeCoreFromDegradationSources()` helper.
222
+ * That helper guards `ACTIVE ↔ ACTIVE_DEGRADED` so a circuit
223
+ * recovery never clobbers an unrelated `OtelState.COEXISTENCE_FAILED`
224
+ * degradation source.
225
+ */
226
+ private getCircuitBreaker;
194
227
  export(spans: ReadableSpan[], resultCallback: (result: ExportResult) => void): void;
195
228
  /**
196
229
  * Called when the API key transitions from "pending" to a resolved value.
@@ -234,6 +267,11 @@ declare class GlasstraceExporter implements SpanExporter {
234
267
  * Flushes all buffered spans through the delegate exporter.
235
268
  * Enriches spans at flush time (not buffer time) so that session IDs
236
269
  * are computed with the resolved API key instead of the "pending" sentinel.
270
+ *
271
+ * Honors the circuit breaker symmetrically with {@link export}: if the
272
+ * breaker is OPEN at flush time, every buffered batch is dropped via
273
+ * `recordSpansDropped` and its callback completed with `{ code: 0 }`,
274
+ * preserving the bounded-memory contract during outages.
237
275
  */
238
276
  private flushPending;
239
277
  }
@@ -190,7 +190,40 @@ declare class GlasstraceExporter implements SpanExporter {
190
190
  private pendingBatches;
191
191
  private pendingSpanCount;
192
192
  private overflowLogged;
193
+ /**
194
+ * Lazily-bound reference to the export-path circuit breaker
195
+ * (DISC-1568 / Wave 15C). Resolved on first export so this
196
+ * constructor stays side-effect-free. The breaker is a module-
197
+ * singleton — every `GlasstraceExporter` instance shares the same
198
+ * one so a rotation event observed in `init-client.ts` reaches
199
+ * every active exporter.
200
+ */
201
+ private circuitBreaker;
193
202
  constructor(options: GlasstraceExporterOptions);
203
+ /**
204
+ * Returns the export-path circuit breaker, lazily wiring it on
205
+ * first call. The breaker is a module-singleton so all exporter
206
+ * instances share state — a credential rotation observed once
207
+ * resets the breaker for every active exporter, and a single
208
+ * outage at the OTLP endpoint trips a single breaker rather than
209
+ * one per exporter copy.
210
+ *
211
+ * The wiring binds:
212
+ * - the lifecycle event sink to the SDK's lifecycle bus
213
+ * (`emitLifecycleEvent`) so the `otel:circuit_*` events surface
214
+ * to runtime-state, the CLI bridge, and any user-installed
215
+ * subscribers.
216
+ * - the dropped-span counter to {@link recordSpansDropped} so OPEN-
217
+ * state drops show up in the existing health surface.
218
+ * - the FSM hooks to {@link pushDegradationSource} /
219
+ * {@link clearDegradationSource} keyed on `"export-circuit"`,
220
+ * which routes the OPEN/CLOSED transitions through the
221
+ * centralised `recomputeCoreFromDegradationSources()` helper.
222
+ * That helper guards `ACTIVE ↔ ACTIVE_DEGRADED` so a circuit
223
+ * recovery never clobbers an unrelated `OtelState.COEXISTENCE_FAILED`
224
+ * degradation source.
225
+ */
226
+ private getCircuitBreaker;
194
227
  export(spans: ReadableSpan[], resultCallback: (result: ExportResult) => void): void;
195
228
  /**
196
229
  * Called when the API key transitions from "pending" to a resolved value.
@@ -234,6 +267,11 @@ declare class GlasstraceExporter implements SpanExporter {
234
267
  * Flushes all buffered spans through the delegate exporter.
235
268
  * Enriches spans at flush time (not buffer time) so that session IDs
236
269
  * are computed with the resolved API key instead of the "pending" sentinel.
270
+ *
271
+ * Honors the circuit breaker symmetrically with {@link export}: if the
272
+ * breaker is OPEN at flush time, every buffered batch is dropped via
273
+ * `recordSpansDropped` and its callback completed with `{ code: 0 }`,
274
+ * preserving the bounded-memory contract during outages.
237
275
  */
238
276
  private flushPending;
239
277
  }