@mark1russell7/otel-ts 0.8.6 → 0.9.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
@@ -266,6 +266,30 @@ try {
266
266
  - Each text goes through the redaction of `@mark1russell7/text/redact`. A stack stays out, unless you give `stacks: true`.
267
267
  - Without an SDK, the record has no trace id, and the log record goes to the no-op logger of the API.
268
268
 
269
+ ### The view of an error
270
+
271
+ The entry `@mark1russell7/otel-ts/error-view` shows an error record. It is a custom element with no framework, so each front end can use it.
272
+
273
+ ```ts
274
+ import { reportError } from "@mark1russell7/otel-ts/error";
275
+ import { errorView } from "@mark1russell7/otel-ts/error-view";
276
+
277
+ const view = errorView(reportError(error, { procedure: { name: "items.save" } }), {
278
+ summary: "Your change was not saved.",
279
+ retry: true,
280
+ report: "Report",
281
+ traceUrl: "https://grafana.example/explore?trace={traceId}",
282
+ });
283
+ view.addEventListener("otel-error-retry", (event) => event.detail.waitUntil(save(item)));
284
+ view.addEventListener("otel-error-report", (event) => sendReport(event.detail.text));
285
+ slot.replaceChildren(view);
286
+ ```
287
+
288
+ - In HTML, call `defineErrorView()` one time, then use `<otel-error retry report trace-url="...">` and set its property `record`.
289
+ - The element keeps the redacted copy of the record (`redactErrorRecord`), so the view, the copy and a report hold no secret.
290
+ - The colors follow the `color-scheme` of the page. Set `--otel-error-bg`, `--otel-error-ink`, `--otel-error-muted`, `--otel-error-rule`, `--otel-error-accent` and `--otel-error-accent-ink` to use the colors of your page.
291
+ - With `init()`, the log record of `reportError()` goes to the export of the page, with the trace id and the session.
292
+
269
293
  ## Writer identity
270
294
 
271
295
  Prometheus and Mimir make the `instance` label from the `service.instance.id` resource attribute. Each SDK instance writes its own metric series. Two SDK instances with the same identity write to the same series. Then Mimir rejects samples, and `rate()` gives incorrect values.
@@ -112,9 +112,16 @@ export interface ReportErrorOptions extends ErrorRecordOptions {
112
112
  * span go to the no-op of the API, and the record stays.
113
113
  */
114
114
  export declare function reportError(error: unknown, options?: ReportErrorOptions): ErrorRecord;
115
+ /**
116
+ * A copy of `record` with each text through the redaction. `errorRecord()` already redacts. Use this function for a
117
+ * record from another place, for example the JSON of a server, before a view shows it or a person copies it.
118
+ * It is idempotent: a second pass changes nothing.
119
+ */
120
+ export declare function redactErrorRecord(record: ErrorRecord): ErrorRecord;
115
121
  /**
116
122
  * The record as a text to copy or to paste in a report: the message, then each id, then the cause chain, then the
117
- * record as JSON. A reader with no tool reads the top, and a tool reads the JSON.
123
+ * record as JSON. A reader with no tool reads the top, and a tool reads the JSON. The record goes through
124
+ * `redactErrorRecord()` first, so a record from another place gives no secret either.
118
125
  */
119
- export declare function errorRecordText(record: ErrorRecord): string;
126
+ export declare function errorRecordText(input: ErrorRecord): string;
120
127
  //# sourceMappingURL=error-record.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"error-record.d.ts","sourceRoot":"","sources":["../src/error-record.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAA4E,KAAK,UAAU,EAAE,KAAK,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAK7I,uFAAuF;AACvF,eAAO,MAAM,mBAAmB,oBAAoB,CAAC;AAErD,0GAA0G;AAC1G,eAAO,MAAM,gBAAgB,IAAI,CAAC;AAElC,mDAAmD;AACnD,eAAO,MAAM,gBAAgB,OAAO,CAAC;AAErC,mCAAmC;AACnC,MAAM,WAAW,UAAU;IACzB,mHAAmH;IACnH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,kCAAkC;IAClC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,sGAAsG;IACtG,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,6DAA6D;IAC7D,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,gGAAgG;IAChG,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,gCAAgC;AACh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;;GAIG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,GAAE,kBAAuB,GAAG,WAAW,CAkBzF;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,WAAW,GAAG,WAAW,CA8BlE;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,WAAW,GAAG,MAAM,CAgB1D"}
@@ -164,11 +164,48 @@ export function reportError(error, options = {}) {
164
164
  }
165
165
  return record;
166
166
  }
167
+ /**
168
+ * A copy of `record` with each text through the redaction. `errorRecord()` already redacts. Use this function for a
169
+ * record from another place, for example the JSON of a server, before a view shows it or a person copies it.
170
+ * It is idempotent: a second pass changes nothing.
171
+ */
172
+ export function redactErrorRecord(record) {
173
+ const text = (value) => redact(String(value ?? ""));
174
+ const strings = (values) => Object.fromEntries(Object.entries(values ?? {}).map(([key, value]) => [text(key), text(value)]));
175
+ const causes = Array.isArray(record.causes) ? record.causes : [];
176
+ return {
177
+ format: ERROR_RECORD_FORMAT,
178
+ id: text(record.id),
179
+ at: text(record.at),
180
+ name: text(record.name),
181
+ message: text(record.message),
182
+ ...(record.code === undefined ? {} : { code: text(record.code) }),
183
+ causes: causes.slice(0, MAX_ERROR_CAUSES).map((cause) => ({
184
+ name: text(cause.name),
185
+ message: text(cause.message),
186
+ ...(cause.code === undefined ? {} : { code: text(cause.code) }),
187
+ ...(cause.stack === undefined ? {} : { stack: text(cause.stack).slice(0, MAX_STACK_LENGTH) }),
188
+ ...(cause.via === undefined ? {} : { via: text(cause.via) }),
189
+ })),
190
+ ...(record.traceId === undefined ? {} : { traceId: text(record.traceId) }),
191
+ ...(record.spanId === undefined ? {} : { spanId: text(record.spanId) }),
192
+ ...(record.sampled === undefined ? {} : { sampled: record.sampled === true }),
193
+ context: strings(record.context),
194
+ ...(record.procedure
195
+ ? { procedure: { name: text(record.procedure.name), ...(record.procedure.inputDigest === undefined ? {} : { inputDigest: text(record.procedure.inputDigest) }) } }
196
+ : {}),
197
+ ...(record.attributes
198
+ ? { attributes: Object.fromEntries(Object.entries(record.attributes).map(([key, value]) => [text(key), typeof value === "string" ? text(value) : typeof value === "number" || typeof value === "boolean" ? value : text(value)])) }
199
+ : {}),
200
+ };
201
+ }
167
202
  /**
168
203
  * The record as a text to copy or to paste in a report: the message, then each id, then the cause chain, then the
169
- * record as JSON. A reader with no tool reads the top, and a tool reads the JSON.
204
+ * record as JSON. A reader with no tool reads the top, and a tool reads the JSON. The record goes through
205
+ * `redactErrorRecord()` first, so a record from another place gives no secret either.
170
206
  */
171
- export function errorRecordText(record) {
207
+ export function errorRecordText(input) {
208
+ const record = redactErrorRecord(input);
172
209
  const lines = [`${record.name}: ${record.message}`, ""];
173
210
  const row = (label, value) => {
174
211
  if (value !== undefined && value !== "")
@@ -1 +1 @@
1
- {"version":3,"file":"error-record.js","sourceRoot":"","sources":["../src/error-record.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,OAAO,EAAE,kBAAkB,EAAE,IAAI,EAAE,cAAc,EAAE,cAAc,EAAE,KAAK,EAAiC,MAAM,oBAAoB,CAAC;AAC7I,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC/F,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE7C,uFAAuF;AACvF,MAAM,CAAC,MAAM,mBAAmB,GAAG,iBAAiB,CAAC;AAErD,0GAA0G;AAC1G,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC;AAElC,mDAAmD;AACnD,MAAM,CAAC,MAAM,gBAAgB,GAAG,IAAI,CAAC;AAyErC,MAAM,MAAM,GAAG,CAAC,IAAY,EAAU,EAAE,CAAC,kBAAkB,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,CAAC,GAAG,aAAa,EAAE,GAAG,cAA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E,GAAG,CAAC,UAAU,KAAK,CAAC,GAAG,IAAI,OAAO,GAAG,EAAE,GAAG,KAAK,CAAC,IAAI,KAAK,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;IACtH,KAAK,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;IAChD,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
@@ -0,0 +1,91 @@
1
+ /**
2
+ * The entry `@mark1russell7/otel-ts/error-view`: one view of an error record, as a custom element with no framework.
3
+ *
4
+ * The element shows the record of `@mark1russell7/otel-ts/error`:
5
+ * - the message in plain words, the procedure and the time;
6
+ * - the actions: retry, copy the whole record, report it, and open its trace;
7
+ * - the details: each id, the context keys and the cause chain.
8
+ *
9
+ * The element does no network call. Retry and report are events: the page decides what they do. Copy writes the
10
+ * text of `errorRecordText()` to the clipboard. The trace link comes from the attribute `trace-url`, a template with
11
+ * `{traceId}` and `{spanId}`.
12
+ *
13
+ * The import registers nothing. Call `defineErrorView()` one time, or register `ErrorViewElement` with a name of
14
+ * your own.
15
+ *
16
+ * Colors follow the `color-scheme` of the page, with `light-dark()`. A page sets the custom properties
17
+ * `--otel-error-*` to use its own colors.
18
+ *
19
+ * @packageDocumentation
20
+ */
21
+ import { type ErrorRecord } from "./error-record.js";
22
+ /** The default name of the element */
23
+ export declare const ERROR_VIEW_TAG = "otel-error";
24
+ /** The detail of the event `otel-error-retry` */
25
+ export interface ErrorRetryDetail {
26
+ readonly record: ErrorRecord;
27
+ /** Keep the retry button busy until the promise settles */
28
+ waitUntil(promise: PromiseLike<unknown>): void;
29
+ }
30
+ /** The detail of the events `otel-error-report` and `otel-error-copy` */
31
+ export interface ErrorTextDetail {
32
+ readonly record: ErrorRecord;
33
+ /** The text of `errorRecordText(record)` */
34
+ readonly text: string;
35
+ }
36
+ /** The detail of the event `otel-error-copy` */
37
+ export interface ErrorCopyDetail extends ErrorTextDetail {
38
+ /** True when the clipboard took the text. Else the view opens the details with the text selected. */
39
+ readonly copied: boolean;
40
+ }
41
+ declare global {
42
+ interface HTMLElementEventMap {
43
+ "otel-error-retry": CustomEvent<ErrorRetryDetail>;
44
+ "otel-error-report": CustomEvent<ErrorTextDetail>;
45
+ "otel-error-copy": CustomEvent<ErrorCopyDetail>;
46
+ }
47
+ }
48
+ /**
49
+ * The link of a trace from a template, for example `https://grafana.example/explore?trace={traceId}`. It gives
50
+ * undefined with no trace id, and for a link that is not `http:` or `https:`.
51
+ */
52
+ export declare function traceLink(template: string | null | undefined, record: ErrorRecord, base?: string): string | undefined;
53
+ /** The base class: `HTMLElement` in a browser, a stand-in in Node.js, so that an import on a server does not throw */
54
+ declare const ElementBase: typeof HTMLElement;
55
+ /** The element of one error record. Set `record` to show it. */
56
+ export declare class ErrorViewElement extends ElementBase {
57
+ #private;
58
+ static get observedAttributes(): string[];
59
+ constructor();
60
+ /** The record that the element shows */
61
+ get record(): ErrorRecord | undefined;
62
+ /** The setter keeps the redacted copy of the record (`redactErrorRecord`), so the view, the copy and the report hold no secret. */
63
+ set record(record: ErrorRecord | undefined);
64
+ /** The text of the record, as the copy action gives it */
65
+ get text(): string;
66
+ connectedCallback(): void;
67
+ attributeChangedCallback(): void;
68
+ /** Copy the text of the record. It gives true when the clipboard took it. */
69
+ copy(): Promise<boolean>;
70
+ }
71
+ /** Register the element under `name`, one time. A second call with the same name does nothing. */
72
+ export declare function defineErrorView(name?: string): void;
73
+ /** The options of `errorView()` */
74
+ export interface ErrorViewOptions {
75
+ /** Show a retry button */
76
+ readonly retry?: boolean;
77
+ /** Show a report button, with this label (default: Report) */
78
+ readonly report?: boolean | string;
79
+ /** The template of the trace link */
80
+ readonly traceUrl?: string;
81
+ /** Where the trace link opens. Default: `_blank`. */
82
+ readonly traceTarget?: string;
83
+ /** A headline in plain words. The message of the record then goes in the line below it. */
84
+ readonly summary?: string;
85
+ /** The name of the element. Default: `ERROR_VIEW_TAG`. */
86
+ readonly tag?: string;
87
+ }
88
+ /** Make an element for `record`. It registers the element first, when it is not registered. */
89
+ export declare function errorView(record: ErrorRecord, options?: ErrorViewOptions): ErrorViewElement;
90
+ export {};
91
+ //# sourceMappingURL=error-view.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error-view.d.ts","sourceRoot":"","sources":["../src/error-view.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EAAsC,KAAK,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEzF,sCAAsC;AACtC,eAAO,MAAM,cAAc,eAAe,CAAC;AAE3C,iDAAiD;AACjD,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAC7B,2DAA2D;IAC3D,SAAS,CAAC,OAAO,EAAE,WAAW,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC;CAChD;AAED,yEAAyE;AACzE,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAC7B,4CAA4C;IAC5C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED,gDAAgD;AAChD,MAAM,WAAW,eAAgB,SAAQ,eAAe;IACtD,qGAAqG;IACrG,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;CAC1B;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,mBAAmB;QAC3B,kBAAkB,EAAE,WAAW,CAAC,gBAAgB,CAAC,CAAC;QAClD,mBAAmB,EAAE,WAAW,CAAC,eAAe,CAAC,CAAC;QAClD,iBAAiB,EAAE,WAAW,CAAC,eAAe,CAAC,CAAC;KACjD;CACF;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAWrH;AA4ED,sHAAsH;AACtH,QAAA,MAAM,WAAW,EAAE,OAAO,WAA6H,CAAC;AAExJ,gEAAgE;AAChE,qBAAa,gBAAiB,SAAQ,WAAW;;IAC/C,MAAM,KAAK,kBAAkB,IAAI,MAAM,EAAE,CAExC;;IAYD,wCAAwC;IACxC,IAAI,MAAM,IAAI,WAAW,GAAG,SAAS,CAEpC;IAED,mIAAmI;IACnI,IAAI,MAAM,CAAC,MAAM,EAAE,WAAW,GAAG,SAAS,EAKzC;IAED,0DAA0D;IAC1D,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,iBAAiB,IAAI,IAAI;IAKzB,wBAAwB,IAAI,IAAI;IAIhC,6EAA6E;IACvE,IAAI,IAAI,OAAO,CAAC,OAAO,CAAC;CAgK/B;AAED,kGAAkG;AAClG,wBAAgB,eAAe,CAAC,IAAI,GAAE,MAAuB,GAAG,IAAI,CAEnE;AAED,mCAAmC;AACnC,MAAM,WAAW,gBAAgB;IAC/B,0BAA0B;IAC1B,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;IACzB,8DAA8D;IAC9D,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IACnC,qCAAqC;IACrC,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,qDAAqD;IACrD,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,2FAA2F;IAC3F,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,0DAA0D;IAC1D,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,+FAA+F;AAC/F,wBAAgB,SAAS,CAAC,MAAM,EAAE,WAAW,EAAE,OAAO,GAAE,gBAAqB,GAAG,gBAAgB,CAW/F"}
@@ -0,0 +1,339 @@
1
+ /**
2
+ * The entry `@mark1russell7/otel-ts/error-view`: one view of an error record, as a custom element with no framework.
3
+ *
4
+ * The element shows the record of `@mark1russell7/otel-ts/error`:
5
+ * - the message in plain words, the procedure and the time;
6
+ * - the actions: retry, copy the whole record, report it, and open its trace;
7
+ * - the details: each id, the context keys and the cause chain.
8
+ *
9
+ * The element does no network call. Retry and report are events: the page decides what they do. Copy writes the
10
+ * text of `errorRecordText()` to the clipboard. The trace link comes from the attribute `trace-url`, a template with
11
+ * `{traceId}` and `{spanId}`.
12
+ *
13
+ * The import registers nothing. Call `defineErrorView()` one time, or register `ErrorViewElement` with a name of
14
+ * your own.
15
+ *
16
+ * Colors follow the `color-scheme` of the page, with `light-dark()`. A page sets the custom properties
17
+ * `--otel-error-*` to use its own colors.
18
+ *
19
+ * @packageDocumentation
20
+ */
21
+ import { errorRecordText, redactErrorRecord } from "./error-record.js";
22
+ /** The default name of the element */
23
+ export const ERROR_VIEW_TAG = "otel-error";
24
+ /**
25
+ * The link of a trace from a template, for example `https://grafana.example/explore?trace={traceId}`. It gives
26
+ * undefined with no trace id, and for a link that is not `http:` or `https:`.
27
+ */
28
+ export function traceLink(template, record, base) {
29
+ if (!template || record.traceId === undefined)
30
+ return undefined;
31
+ const href = template
32
+ .replaceAll("{traceId}", encodeURIComponent(record.traceId))
33
+ .replaceAll("{spanId}", encodeURIComponent(record.spanId ?? ""));
34
+ try {
35
+ const url = base === undefined ? new URL(href) : new URL(href, base);
36
+ return url.protocol === "https:" || url.protocol === "http:" ? url.href : undefined;
37
+ }
38
+ catch {
39
+ return undefined;
40
+ }
41
+ }
42
+ const STYLE = `
43
+ :host {
44
+ --_bg: var(--otel-error-bg, light-dark(#fff7f7, #241417));
45
+ --_ink: var(--otel-error-ink, light-dark(#1b1d24, #f1e9ea));
46
+ --_muted: var(--otel-error-muted, light-dark(#5b5f6b, #b9adb0));
47
+ --_rule: var(--otel-error-rule, light-dark(#efc9cb, #57323a));
48
+ --_accent: var(--otel-error-accent, light-dark(#b3261e, #ff8a85));
49
+ --_accent-ink: var(--otel-error-accent-ink, light-dark(#ffffff, #23090b));
50
+ --_focus: var(--otel-error-focus, light-dark(#2346c4, #93abff));
51
+ --_mono: var(--otel-error-mono, ui-monospace, "Cascadia Mono", Menlo, Consolas, monospace);
52
+ display: block;
53
+ container-type: inline-size;
54
+ font: inherit;
55
+ color: var(--_ink);
56
+ }
57
+ :host([hidden]) { display: none; }
58
+ .box {
59
+ background: var(--_bg);
60
+ border: 1px solid var(--_rule);
61
+ border-inline-start: 4px solid var(--_accent);
62
+ border-radius: var(--otel-error-radius, 8px);
63
+ padding: 14px 16px;
64
+ display: grid;
65
+ gap: 10px;
66
+ }
67
+ .head { display: grid; grid-template-columns: auto 1fr; gap: 10px; align-items: start; }
68
+ .icon { width: 22px; height: 22px; color: var(--_accent); flex: none; margin-top: 1px; }
69
+ .title { margin: 0; font-size: 1rem; font-weight: 650; line-height: 1.35; overflow-wrap: anywhere; }
70
+ .meta { margin: 2px 0 0; color: var(--_muted); font-size: 0.875rem; overflow-wrap: anywhere; }
71
+ .actions { display: flex; flex-wrap: wrap; gap: 8px; }
72
+ button, a.trace {
73
+ font: inherit; font-size: 0.875rem; line-height: 1.2;
74
+ min-height: 36px; padding: 8px 14px; border-radius: 6px;
75
+ border: 1px solid var(--_rule); background: transparent; color: var(--_ink);
76
+ cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px;
77
+ }
78
+ button.primary { background: var(--_accent); border-color: var(--_accent); color: var(--_accent-ink); font-weight: 600; }
79
+ button:hover, a.trace:hover { border-color: var(--_accent); }
80
+ button:focus-visible, a.trace:focus-visible, summary:focus-visible, textarea:focus-visible { outline: 2px solid var(--_focus); outline-offset: 2px; }
81
+ button[aria-disabled="true"] { opacity: 0.6; cursor: progress; }
82
+ .status { margin: 0; min-height: 1.2em; font-size: 0.8125rem; color: var(--_muted); }
83
+ .status:empty { display: none; }
84
+ details { border-top: 1px solid var(--_rule); padding-top: 8px; }
85
+ summary { cursor: pointer; font-size: 0.875rem; color: var(--_muted); width: fit-content; border-radius: 4px; }
86
+ dl { display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; margin: 10px 0 0; font-size: 0.8125rem; }
87
+ dt { color: var(--_muted); }
88
+ dd { margin: 0; font-family: var(--_mono); overflow-wrap: anywhere; }
89
+ ol { margin: 10px 0 0; padding-inline-start: 20px; font-size: 0.8125rem; display: grid; gap: 4px; }
90
+ ol .via { color: var(--_muted); }
91
+ textarea {
92
+ width: 100%; box-sizing: border-box; margin-top: 10px; min-height: 8em; resize: vertical;
93
+ font: 0.75rem/1.4 var(--_mono); color: var(--_ink); background: transparent;
94
+ border: 1px solid var(--_rule); border-radius: 6px; padding: 8px;
95
+ }
96
+ @container (max-width: 420px) {
97
+ dl { grid-template-columns: 1fr; gap: 0; }
98
+ dd { margin-bottom: 6px; }
99
+ .actions > * { flex: 1 1 auto; justify-content: center; }
100
+ }
101
+ @media (prefers-reduced-motion: no-preference) {
102
+ button, a.trace { transition: border-color 120ms ease; }
103
+ }
104
+ `;
105
+ const ICON = '<svg class="icon" viewBox="0 0 24 24" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="9.5"/><path d="M12 7.5v5.5"/><path d="M12 16.5h.01"/></svg>';
106
+ /** A local time for people, with the ISO text as its title */
107
+ function timeText(at) {
108
+ const date = new Date(at);
109
+ if (Number.isNaN(date.getTime()))
110
+ return at;
111
+ return date.toLocaleTimeString(undefined, { hour: "2-digit", minute: "2-digit", second: "2-digit" });
112
+ }
113
+ /** The base class: `HTMLElement` in a browser, a stand-in in Node.js, so that an import on a server does not throw */
114
+ const ElementBase = globalThis.HTMLElement ?? class {
115
+ };
116
+ /** The element of one error record. Set `record` to show it. */
117
+ export class ErrorViewElement extends ElementBase {
118
+ static get observedAttributes() {
119
+ return ["trace-url", "trace-target", "retry", "report", "summary", "open"];
120
+ }
121
+ #record;
122
+ #busy = false;
123
+ #status = "";
124
+ #root;
125
+ constructor() {
126
+ super();
127
+ this.#root = this.attachShadow({ mode: "open" });
128
+ }
129
+ /** The record that the element shows */
130
+ get record() {
131
+ return this.#record;
132
+ }
133
+ /** The setter keeps the redacted copy of the record (`redactErrorRecord`), so the view, the copy and the report hold no secret. */
134
+ set record(record) {
135
+ this.#record = record === undefined ? undefined : redactErrorRecord(record);
136
+ this.#busy = false;
137
+ this.#status = "";
138
+ this.#render();
139
+ }
140
+ /** The text of the record, as the copy action gives it */
141
+ get text() {
142
+ return this.#record ? errorRecordText(this.#record) : "";
143
+ }
144
+ connectedCallback() {
145
+ if (!this.hasAttribute("role"))
146
+ this.setAttribute("role", "alert");
147
+ this.#render();
148
+ }
149
+ attributeChangedCallback() {
150
+ this.#render();
151
+ }
152
+ /** Copy the text of the record. It gives true when the clipboard took it. */
153
+ async copy() {
154
+ const record = this.#record;
155
+ if (!record)
156
+ return false;
157
+ const text = errorRecordText(record);
158
+ let copied = false;
159
+ try {
160
+ await navigator.clipboard.writeText(text);
161
+ copied = true;
162
+ }
163
+ catch {
164
+ copied = false;
165
+ }
166
+ this.#setStatus(copied ? "The details are on the clipboard." : "The clipboard is not available. Select the text below and copy it.");
167
+ if (!copied)
168
+ this.#showText();
169
+ this.dispatchEvent(new CustomEvent("otel-error-copy", { detail: { record, text, copied }, bubbles: true, composed: true }));
170
+ return copied;
171
+ }
172
+ #setStatus(text) {
173
+ this.#status = text;
174
+ const status = this.#root.querySelector(".status");
175
+ if (status)
176
+ status.textContent = text;
177
+ }
178
+ #showText() {
179
+ const details = this.#root.querySelector("details");
180
+ const area = this.#root.querySelector("textarea");
181
+ if (details)
182
+ details.open = true;
183
+ if (area) {
184
+ area.hidden = false;
185
+ area.focus();
186
+ area.select();
187
+ }
188
+ }
189
+ #retry() {
190
+ const record = this.#record;
191
+ if (!record || this.#busy)
192
+ return;
193
+ let wait;
194
+ this.dispatchEvent(new CustomEvent("otel-error-retry", {
195
+ detail: { record, waitUntil: (promise) => void (wait = promise) },
196
+ bubbles: true,
197
+ composed: true,
198
+ }));
199
+ if (!wait)
200
+ return;
201
+ this.#busy = true;
202
+ this.#render();
203
+ const settle = () => {
204
+ // A new record during the retry already cleared the busy state
205
+ if (this.#record !== record)
206
+ return;
207
+ this.#busy = false;
208
+ this.#render();
209
+ };
210
+ wait.then(settle, settle);
211
+ }
212
+ #report() {
213
+ const record = this.#record;
214
+ if (!record)
215
+ return;
216
+ this.dispatchEvent(new CustomEvent("otel-error-report", { detail: { record, text: errorRecordText(record) }, bubbles: true, composed: true }));
217
+ }
218
+ #render() {
219
+ const root = this.#root;
220
+ const record = this.#record;
221
+ const wasOpen = root.querySelector("details")?.open ?? this.hasAttribute("open");
222
+ // A render keeps the focus on the same action, so a keyboard user does not lose the place
223
+ const focused = root.activeElement?.dataset?.["action"];
224
+ root.replaceChildren();
225
+ const style = document.createElement("style");
226
+ style.textContent = STYLE;
227
+ root.append(style);
228
+ if (!record)
229
+ return;
230
+ const make = (tag, props = {}, ...children) => {
231
+ const node = Object.assign(document.createElement(tag), props);
232
+ node.append(...children);
233
+ return node;
234
+ };
235
+ const box = make("div", { className: "box" });
236
+ box.setAttribute("part", "box");
237
+ const head = make("div", { className: "head" });
238
+ const icon = document.createElement("template");
239
+ icon.innerHTML = ICON;
240
+ const summary = this.getAttribute("summary");
241
+ const meta = [];
242
+ if (summary)
243
+ meta.push(record.message);
244
+ if (record.procedure)
245
+ meta.push(record.procedure.name);
246
+ meta.push(timeText(record.at));
247
+ if (record.code)
248
+ meta.push(record.code);
249
+ head.append(icon.content, make("div", {}, make("p", { className: "title", textContent: summary || record.message || record.name }), make("p", { className: "meta", textContent: meta.join(" · ") })));
250
+ box.append(head);
251
+ const actions = make("div", { className: "actions" });
252
+ if (this.hasAttribute("retry")) {
253
+ const retry = make("button", { type: "button", className: "primary", textContent: this.#busy ? "Retrying…" : "Retry" });
254
+ if (this.#busy)
255
+ retry.setAttribute("aria-disabled", "true");
256
+ retry.dataset["action"] = "retry";
257
+ retry.addEventListener("click", () => this.#retry());
258
+ actions.append(retry);
259
+ }
260
+ const copy = make("button", { type: "button", textContent: "Copy details" });
261
+ copy.dataset["action"] = "copy";
262
+ copy.addEventListener("click", () => void this.copy());
263
+ actions.append(copy);
264
+ if (this.hasAttribute("report")) {
265
+ const report = make("button", { type: "button", textContent: this.getAttribute("report") || "Report" });
266
+ report.dataset["action"] = "report";
267
+ report.addEventListener("click", () => this.#report());
268
+ actions.append(report);
269
+ }
270
+ const href = traceLink(this.getAttribute("trace-url"), record, document.baseURI);
271
+ if (href) {
272
+ // The default opens the trace in a new tab. `trace-target="_self"` opens it in the page, for example a view of the page.
273
+ const target = this.getAttribute("trace-target") || "_blank";
274
+ const link = make("a", { className: "trace", href, textContent: "Open the trace" });
275
+ if (target !== "_self")
276
+ Object.assign(link, { target, rel: "noopener noreferrer" });
277
+ link.dataset["action"] = "trace";
278
+ actions.append(link);
279
+ }
280
+ box.append(actions);
281
+ const status = make("p", { className: "status", textContent: this.#status });
282
+ status.setAttribute("role", "status");
283
+ box.append(status);
284
+ const rows = [
285
+ ["Trace", record.traceId],
286
+ ["Span", record.spanId],
287
+ ["Procedure", record.procedure?.name],
288
+ ["Input digest", record.procedure?.inputDigest],
289
+ ...Object.entries(record.context),
290
+ ...Object.entries(record.attributes ?? {}).map(([key, value]) => [key, String(value)]),
291
+ ["Time", record.at],
292
+ ["Record", record.id],
293
+ ];
294
+ const list = make("dl");
295
+ for (const [label, value] of rows)
296
+ if (value !== undefined && value !== "")
297
+ list.append(make("dt", { textContent: label }), make("dd", { textContent: value }));
298
+ const details = make("details", { open: wasOpen }, make("summary", { textContent: "Details" }), list);
299
+ if (record.causes.length > 1) {
300
+ const causes = make("ol");
301
+ causes.setAttribute("aria-label", "The causes");
302
+ for (const cause of record.causes.slice(1))
303
+ causes.append(make("li", {}, `${cause.name}: ${cause.message}`, make("span", { className: "via", textContent: cause.via ? ` (${cause.via})` : "" })));
304
+ details.append(causes);
305
+ }
306
+ const area = make("textarea", { readOnly: true, hidden: true, value: errorRecordText(record) });
307
+ area.setAttribute("aria-label", "The details as text");
308
+ details.append(area);
309
+ box.append(details);
310
+ root.append(box);
311
+ if (focused)
312
+ root.querySelector(`[data-action="${focused}"]`)?.focus();
313
+ }
314
+ }
315
+ /** Register the element under `name`, one time. A second call with the same name does nothing. */
316
+ export function defineErrorView(name = ERROR_VIEW_TAG) {
317
+ if (!customElements.get(name))
318
+ customElements.define(name, class extends ErrorViewElement {
319
+ });
320
+ }
321
+ /** Make an element for `record`. It registers the element first, when it is not registered. */
322
+ export function errorView(record, options = {}) {
323
+ const tag = options.tag ?? ERROR_VIEW_TAG;
324
+ defineErrorView(tag);
325
+ const element = document.createElement(tag);
326
+ if (options.retry)
327
+ element.setAttribute("retry", "");
328
+ if (options.report)
329
+ element.setAttribute("report", options.report === true ? "" : options.report);
330
+ if (options.traceUrl)
331
+ element.setAttribute("trace-url", options.traceUrl);
332
+ if (options.traceTarget)
333
+ element.setAttribute("trace-target", options.traceTarget);
334
+ if (options.summary)
335
+ element.setAttribute("summary", options.summary);
336
+ element.record = record;
337
+ return element;
338
+ }
339
+ //# sourceMappingURL=error-view.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error-view.js","sourceRoot":"","sources":["../src/error-view.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAoB,MAAM,mBAAmB,CAAC;AAEzF,sCAAsC;AACtC,MAAM,CAAC,MAAM,cAAc,GAAG,YAAY,CAAC;AA8B3C;;;GAGG;AACH,MAAM,UAAU,SAAS,CAAC,QAAmC,EAAE,MAAmB,EAAE,IAAa;IAC/F,IAAI,CAAC,QAAQ,IAAI,MAAM,CAAC,OAAO,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IAChE,MAAM,IAAI,GAAG,QAAQ;SAClB,UAAU,CAAC,WAAW,EAAE,kBAAkB,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;SAC3D,UAAU,CAAC,UAAU,EAAE,kBAAkB,CAAC,MAAM,CAAC,MAAM,IAAI,E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AO,CAAC,OAAO;QAAE,OAAO,CAAC,YAAY,CAAC,SAAS,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;IACtE,OAAO,CAAC,MAAM,GAAG,MAAM,CAAC;IACxB,OAAO,OAAO,CAAC;AACjB,CAAC"}
package/dist/init.js CHANGED
@@ -1,4 +1,4 @@
1
- import { context, propagation, trace } from "@opentelemetry/api";
1
+ import { context, logs, propagation, trace } from "@opentelemetry/api";
2
2
  import { MeterProvider } from "@opentelemetry/sdk-metrics";
3
3
  import { LoggerProvider } from "@opentelemetry/sdk-logs";
4
4
  import { buildResource } from "./resource.js";
@@ -91,7 +91,7 @@ export function initWith(managers, config) {
91
91
  function releaseContext(releaseRegistration) {
92
92
  if (!releaseRegistration)
93
93
  return;
94
- for (const api of [trace, propagation, context])
94
+ for (const api of [trace, propagation, context, logs])
95
95
  api.disable();
96
96
  releaseRegistration();
97
97
  }
@@ -117,6 +117,11 @@ function startInstance(resolved, contextManager, releaseRegistration, providers)
117
117
  ? setupLogs(resource, resolved, getSessionId)
118
118
  : new LoggerProvider();
119
119
  providers.push(loggerProvider);
120
+ // The owner of the globals also registers its logger provider, so a library
121
+ // that logs through the API (for example reportError of /error) reaches it
122
+ if (releaseRegistration && resolved.logs) {
123
+ logs.setGlobalLoggerProvider(loggerProvider);
124
+ }
120
125
  // After the tracing, so Faro reads the context of otel-ts
121
126
  if (faroUrl) {
122
127
  setupFaro(resolved, faroUrl);
package/dist/init.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"init.js","sourceRoot":"","sources":["../src/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAEzD,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,o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,QAAQ;KACT,CAAC,CAAC;IAEH,IAAI,QAAQ,CAAC,KAAK,EAAE,CAAC;QACnB,OAAO,CAAC,GAAG,CAAC,uBAAuB,EAAE;YACnC,QAAQ,EAAE,QAAQ,CAAC,QAAQ;YAC3B,WAAW,EAAE,QAAQ,CAAC,WAAW;YACjC,iBAAiB,EAAE,QAAQ,CAAC,iBAAiB;YAC7C,SAAS;YACT,OAAO,EAAE,QAAQ,CAAC,OAAO;YACzB,OAAO,EAAE,QAAQ,CAAC,OAAO;YACzB,IAAI,EAAE,QAAQ,CAAC,IAAI;YACnB,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC;SACvB,CAAC,CAAC;IACL,CAAC;IAED,OAAO;QACL,sCAAsC;QACtC,QAAQ,EAAE,GAAG,EAAE,CAAC,QAAQ,EAAE;QAC1B,UAAU,EAAE,GAAG,EAAE,CAAC,UAAU,EAAE;QAC9B,aAAa,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,WAAW,CAAC,GAAG,CAAC,QAAQ,CAAC;QACtD,YAAY;QACZ,QAAQ,EAAE,CAAC,IAAY,EAAE,EAAE,CAAC,aAAa,CAAC,QAAQ,CAAC,IAAI,CAAC;QACxD,SAAS,EAAE,CAAC,IAAY,EAAE,EAAE,CAAC,cAAc,CAAC,SAAS,CAAC,IAAI,CAAC;KAC5D,CAAC;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package",
3
3
  "name": "@mark1russell7/otel-ts",
4
- "version": "0.8.6",
4
+ "version": "0.9.0",
5
5
  "description": "Frontend observability in one init() call — OpenTelemetry + Grafana Faro for any TypeScript web app",
6
6
  "license": "MIT",
7
7
  "author": "Mark Russell (https://github.com/mark1russell7)",
@@ -59,6 +59,10 @@
59
59
  "./error": {
60
60
  "types": "./dist/error-record.d.ts",
61
61
  "import": "./dist/error-record.js"
62
+ },
63
+ "./error-view": {
64
+ "types": "./dist/error-view.d.ts",
65
+ "import": "./dist/error-view.js"
62
66
  }
63
67
  },
64
68
  "files": [
@@ -68,7 +72,7 @@
68
72
  ],
69
73
  "sideEffects": false,
70
74
  "dependencies": {
71
- "@mark1russell7/text": "^0.0.18",
75
+ "@mark1russell7/text": "^0.0.19",
72
76
  "@grafana/faro-web-sdk": "^2.13.0",
73
77
  "@opentelemetry/api": "^1.10.0",
74
78
  "@opentelemetry/auto-instrumentations-web": "^0.70.1",
@@ -245,11 +245,50 @@ export function reportError(error: unknown, options: ReportErrorOptions = {}): E
245
245
  return record;
246
246
  }
247
247
 
248
+ /**
249
+ * A copy of `record` with each text through the redaction. `errorRecord()` already redacts. Use this function for a
250
+ * record from another place, for example the JSON of a server, before a view shows it or a person copies it.
251
+ * It is idempotent: a second pass changes nothing.
252
+ */
253
+ export function redactErrorRecord(record: ErrorRecord): ErrorRecord {
254
+ const text = (value: unknown): string => redact(String(value ?? ""));
255
+ const strings = (values: Readonly<Record<string, unknown>> | undefined): Record<string, string> =>
256
+ Object.fromEntries(Object.entries(values ?? {}).map(([key, value]) => [text(key), text(value)]));
257
+ const causes = Array.isArray(record.causes) ? record.causes : [];
258
+ return {
259
+ format: ERROR_RECORD_FORMAT,
260
+ id: text(record.id),
261
+ at: text(record.at),
262
+ name: text(record.name),
263
+ message: text(record.message),
264
+ ...(record.code === undefined ? {} : { code: text(record.code) }),
265
+ causes: causes.slice(0, MAX_ERROR_CAUSES).map((cause) => ({
266
+ name: text(cause.name),
267
+ message: text(cause.message),
268
+ ...(cause.code === undefined ? {} : { code: text(cause.code) }),
269
+ ...(cause.stack === undefined ? {} : { stack: text(cause.stack).slice(0, MAX_STACK_LENGTH) }),
270
+ ...(cause.via === undefined ? {} : { via: text(cause.via) }),
271
+ })),
272
+ ...(record.traceId === undefined ? {} : { traceId: text(record.traceId) }),
273
+ ...(record.spanId === undefined ? {} : { spanId: text(record.spanId) }),
274
+ ...(record.sampled === undefined ? {} : { sampled: record.sampled === true }),
275
+ context: strings(record.context),
276
+ ...(record.procedure
277
+ ? { procedure: { name: text(record.procedure.name), ...(record.procedure.inputDigest === undefined ? {} : { inputDigest: text(record.procedure.inputDigest) }) } }
278
+ : {}),
279
+ ...(record.attributes
280
+ ? { attributes: Object.fromEntries(Object.entries(record.attributes).map(([key, value]) => [text(key), typeof value === "string" ? text(value) : typeof value === "number" || typeof value === "boolean" ? value : text(value)])) }
281
+ : {}),
282
+ };
283
+ }
284
+
248
285
  /**
249
286
  * The record as a text to copy or to paste in a report: the message, then each id, then the cause chain, then the
250
- * record as JSON. A reader with no tool reads the top, and a tool reads the JSON.
287
+ * record as JSON. A reader with no tool reads the top, and a tool reads the JSON. The record goes through
288
+ * `redactErrorRecord()` first, so a record from another place gives no secret either.
251
289
  */
252
- export function errorRecordText(record: ErrorRecord): string {
290
+ export function errorRecordText(input: ErrorRecord): string {
291
+ const record = redactErrorRecord(input);
253
292
  const lines = [`${record.name}: ${record.message}`, ""];
254
293
  const row = (label: string, value: string | undefined): void => {
255
294
  if (value !== undefined && value !== "") lines.push(`${label}: ${value}`);
@@ -0,0 +1,387 @@
1
+ /**
2
+ * The entry `@mark1russell7/otel-ts/error-view`: one view of an error record, as a custom element with no framework.
3
+ *
4
+ * The element shows the record of `@mark1russell7/otel-ts/error`:
5
+ * - the message in plain words, the procedure and the time;
6
+ * - the actions: retry, copy the whole record, report it, and open its trace;
7
+ * - the details: each id, the context keys and the cause chain.
8
+ *
9
+ * The element does no network call. Retry and report are events: the page decides what they do. Copy writes the
10
+ * text of `errorRecordText()` to the clipboard. The trace link comes from the attribute `trace-url`, a template with
11
+ * `{traceId}` and `{spanId}`.
12
+ *
13
+ * The import registers nothing. Call `defineErrorView()` one time, or register `ErrorViewElement` with a name of
14
+ * your own.
15
+ *
16
+ * Colors follow the `color-scheme` of the page, with `light-dark()`. A page sets the custom properties
17
+ * `--otel-error-*` to use its own colors.
18
+ *
19
+ * @packageDocumentation
20
+ */
21
+ import { errorRecordText, redactErrorRecord, type ErrorRecord } from "./error-record.js";
22
+
23
+ /** The default name of the element */
24
+ export const ERROR_VIEW_TAG = "otel-error";
25
+
26
+ /** The detail of the event `otel-error-retry` */
27
+ export interface ErrorRetryDetail {
28
+ readonly record: ErrorRecord;
29
+ /** Keep the retry button busy until the promise settles */
30
+ waitUntil(promise: PromiseLike<unknown>): void;
31
+ }
32
+
33
+ /** The detail of the events `otel-error-report` and `otel-error-copy` */
34
+ export interface ErrorTextDetail {
35
+ readonly record: ErrorRecord;
36
+ /** The text of `errorRecordText(record)` */
37
+ readonly text: string;
38
+ }
39
+
40
+ /** The detail of the event `otel-error-copy` */
41
+ export interface ErrorCopyDetail extends ErrorTextDetail {
42
+ /** True when the clipboard took the text. Else the view opens the details with the text selected. */
43
+ readonly copied: boolean;
44
+ }
45
+
46
+ declare global {
47
+ interface HTMLElementEventMap {
48
+ "otel-error-retry": CustomEvent<ErrorRetryDetail>;
49
+ "otel-error-report": CustomEvent<ErrorTextDetail>;
50
+ "otel-error-copy": CustomEvent<ErrorCopyDetail>;
51
+ }
52
+ }
53
+
54
+ /**
55
+ * The link of a trace from a template, for example `https://grafana.example/explore?trace={traceId}`. It gives
56
+ * undefined with no trace id, and for a link that is not `http:` or `https:`.
57
+ */
58
+ export function traceLink(template: string | null | undefined, record: ErrorRecord, base?: string): string | undefined {
59
+ if (!template || record.traceId === undefined) return undefined;
60
+ const href = template
61
+ .replaceAll("{traceId}", encodeURIComponent(record.traceId))
62
+ .replaceAll("{spanId}", encodeURIComponent(record.spanId ?? ""));
63
+ try {
64
+ const url = base === undefined ? new URL(href) : new URL(href, base);
65
+ return url.protocol === "https:" || url.protocol === "http:" ? url.href : undefined;
66
+ } catch {
67
+ return undefined;
68
+ }
69
+ }
70
+
71
+ const STYLE = `
72
+ :host {
73
+ --_bg: var(--otel-error-bg, light-dark(#fff7f7, #241417));
74
+ --_ink: var(--otel-error-ink, light-dark(#1b1d24, #f1e9ea));
75
+ --_muted: var(--otel-error-muted, light-dark(#5b5f6b, #b9adb0));
76
+ --_rule: var(--otel-error-rule, light-dark(#efc9cb, #57323a));
77
+ --_accent: var(--otel-error-accent, light-dark(#b3261e, #ff8a85));
78
+ --_accent-ink: var(--otel-error-accent-ink, light-dark(#ffffff, #23090b));
79
+ --_focus: var(--otel-error-focus, light-dark(#2346c4, #93abff));
80
+ --_mono: var(--otel-error-mono, ui-monospace, "Cascadia Mono", Menlo, Consolas, monospace);
81
+ display: block;
82
+ container-type: inline-size;
83
+ font: inherit;
84
+ color: var(--_ink);
85
+ }
86
+ :host([hidden]) { display: none; }
87
+ .box {
88
+ background: var(--_bg);
89
+ border: 1px solid var(--_rule);
90
+ border-inline-start: 4px solid var(--_accent);
91
+ border-radius: var(--otel-error-radius, 8px);
92
+ padding: 14px 16px;
93
+ display: grid;
94
+ gap: 10px;
95
+ }
96
+ .head { display: grid; grid-template-columns: auto 1fr; gap: 10px; align-items: start; }
97
+ .icon { width: 22px; height: 22px; color: var(--_accent); flex: none; margin-top: 1px; }
98
+ .title { margin: 0; font-size: 1rem; font-weight: 650; line-height: 1.35; overflow-wrap: anywhere; }
99
+ .meta { margin: 2px 0 0; color: var(--_muted); font-size: 0.875rem; overflow-wrap: anywhere; }
100
+ .actions { display: flex; flex-wrap: wrap; gap: 8px; }
101
+ button, a.trace {
102
+ font: inherit; font-size: 0.875rem; line-height: 1.2;
103
+ min-height: 36px; padding: 8px 14px; border-radius: 6px;
104
+ border: 1px solid var(--_rule); background: transparent; color: var(--_ink);
105
+ cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px;
106
+ }
107
+ button.primary { background: var(--_accent); border-color: var(--_accent); color: var(--_accent-ink); font-weight: 600; }
108
+ button:hover, a.trace:hover { border-color: var(--_accent); }
109
+ button:focus-visible, a.trace:focus-visible, summary:focus-visible, textarea:focus-visible { outline: 2px solid var(--_focus); outline-offset: 2px; }
110
+ button[aria-disabled="true"] { opacity: 0.6; cursor: progress; }
111
+ .status { margin: 0; min-height: 1.2em; font-size: 0.8125rem; color: var(--_muted); }
112
+ .status:empty { display: none; }
113
+ details { border-top: 1px solid var(--_rule); padding-top: 8px; }
114
+ summary { cursor: pointer; font-size: 0.875rem; color: var(--_muted); width: fit-content; border-radius: 4px; }
115
+ dl { display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; margin: 10px 0 0; font-size: 0.8125rem; }
116
+ dt { color: var(--_muted); }
117
+ dd { margin: 0; font-family: var(--_mono); overflow-wrap: anywhere; }
118
+ ol { margin: 10px 0 0; padding-inline-start: 20px; font-size: 0.8125rem; display: grid; gap: 4px; }
119
+ ol .via { color: var(--_muted); }
120
+ textarea {
121
+ width: 100%; box-sizing: border-box; margin-top: 10px; min-height: 8em; resize: vertical;
122
+ font: 0.75rem/1.4 var(--_mono); color: var(--_ink); background: transparent;
123
+ border: 1px solid var(--_rule); border-radius: 6px; padding: 8px;
124
+ }
125
+ @container (max-width: 420px) {
126
+ dl { grid-template-columns: 1fr; gap: 0; }
127
+ dd { margin-bottom: 6px; }
128
+ .actions > * { flex: 1 1 auto; justify-content: center; }
129
+ }
130
+ @media (prefers-reduced-motion: no-preference) {
131
+ button, a.trace { transition: border-color 120ms ease; }
132
+ }
133
+ `;
134
+
135
+ const ICON =
136
+ '<svg class="icon" viewBox="0 0 24 24" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="9.5"/><path d="M12 7.5v5.5"/><path d="M12 16.5h.01"/></svg>';
137
+
138
+ /** A local time for people, with the ISO text as its title */
139
+ function timeText(at: string): string {
140
+ const date = new Date(at);
141
+ if (Number.isNaN(date.getTime())) return at;
142
+ return date.toLocaleTimeString(undefined, { hour: "2-digit", minute: "2-digit", second: "2-digit" });
143
+ }
144
+
145
+ /** The base class: `HTMLElement` in a browser, a stand-in in Node.js, so that an import on a server does not throw */
146
+ const ElementBase: typeof HTMLElement = (globalThis as { HTMLElement?: typeof HTMLElement }).HTMLElement ?? (class {} as unknown as typeof HTMLElement);
147
+
148
+ /** The element of one error record. Set `record` to show it. */
149
+ export class ErrorViewElement extends ElementBase {
150
+ static get observedAttributes(): string[] {
151
+ return ["trace-url", "trace-target", "retry", "report", "summary", "open"];
152
+ }
153
+
154
+ #record: ErrorRecord | undefined;
155
+ #busy = false;
156
+ #status = "";
157
+ readonly #root: ShadowRoot;
158
+
159
+ constructor() {
160
+ super();
161
+ this.#root = this.attachShadow({ mode: "open" });
162
+ }
163
+
164
+ /** The record that the element shows */
165
+ get record(): ErrorRecord | undefined {
166
+ return this.#record;
167
+ }
168
+
169
+ /** The setter keeps the redacted copy of the record (`redactErrorRecord`), so the view, the copy and the report hold no secret. */
170
+ set record(record: ErrorRecord | undefined) {
171
+ this.#record = record === undefined ? undefined : redactErrorRecord(record);
172
+ this.#busy = false;
173
+ this.#status = "";
174
+ this.#render();
175
+ }
176
+
177
+ /** The text of the record, as the copy action gives it */
178
+ get text(): string {
179
+ return this.#record ? errorRecordText(this.#record) : "";
180
+ }
181
+
182
+ connectedCallback(): void {
183
+ if (!this.hasAttribute("role")) this.setAttribute("role", "alert");
184
+ this.#render();
185
+ }
186
+
187
+ attributeChangedCallback(): void {
188
+ this.#render();
189
+ }
190
+
191
+ /** Copy the text of the record. It gives true when the clipboard took it. */
192
+ async copy(): Promise<boolean> {
193
+ const record = this.#record;
194
+ if (!record) return false;
195
+ const text = errorRecordText(record);
196
+ let copied = false;
197
+ try {
198
+ await navigator.clipboard.writeText(text);
199
+ copied = true;
200
+ } catch {
201
+ copied = false;
202
+ }
203
+ this.#setStatus(copied ? "The details are on the clipboard." : "The clipboard is not available. Select the text below and copy it.");
204
+ if (!copied) this.#showText();
205
+ this.dispatchEvent(new CustomEvent<ErrorCopyDetail>("otel-error-copy", { detail: { record, text, copied }, bubbles: true, composed: true }));
206
+ return copied;
207
+ }
208
+
209
+ #setStatus(text: string): void {
210
+ this.#status = text;
211
+ const status = this.#root.querySelector(".status");
212
+ if (status) status.textContent = text;
213
+ }
214
+
215
+ #showText(): void {
216
+ const details = this.#root.querySelector("details");
217
+ const area = this.#root.querySelector("textarea");
218
+ if (details) details.open = true;
219
+ if (area) {
220
+ area.hidden = false;
221
+ area.focus();
222
+ area.select();
223
+ }
224
+ }
225
+
226
+ #retry(): void {
227
+ const record = this.#record;
228
+ if (!record || this.#busy) return;
229
+ let wait: PromiseLike<unknown> | undefined;
230
+ this.dispatchEvent(
231
+ new CustomEvent<ErrorRetryDetail>("otel-error-retry", {
232
+ detail: { record, waitUntil: (promise) => void (wait = promise) },
233
+ bubbles: true,
234
+ composed: true,
235
+ }),
236
+ );
237
+ if (!wait) return;
238
+ this.#busy = true;
239
+ this.#render();
240
+ const settle = (): void => {
241
+ // A new record during the retry already cleared the busy state
242
+ if (this.#record !== record) return;
243
+ this.#busy = false;
244
+ this.#render();
245
+ };
246
+ wait.then(settle, settle);
247
+ }
248
+
249
+ #report(): void {
250
+ const record = this.#record;
251
+ if (!record) return;
252
+ this.dispatchEvent(
253
+ new CustomEvent<ErrorTextDetail>("otel-error-report", { detail: { record, text: errorRecordText(record) }, bubbles: true, composed: true }),
254
+ );
255
+ }
256
+
257
+ #render(): void {
258
+ const root = this.#root;
259
+ const record = this.#record;
260
+ const wasOpen = root.querySelector("details")?.open ?? this.hasAttribute("open");
261
+ // A render keeps the focus on the same action, so a keyboard user does not lose the place
262
+ const focused = (root.activeElement as HTMLElement | null)?.dataset?.["action"];
263
+ root.replaceChildren();
264
+ const style = document.createElement("style");
265
+ style.textContent = STYLE;
266
+ root.append(style);
267
+ if (!record) return;
268
+
269
+ const make = <K extends keyof HTMLElementTagNameMap>(tag: K, props: Partial<HTMLElementTagNameMap[K]> = {}, ...children: (Node | string)[]): HTMLElementTagNameMap[K] => {
270
+ const node = Object.assign(document.createElement(tag), props);
271
+ node.append(...children);
272
+ return node;
273
+ };
274
+
275
+ const box = make("div", { className: "box" });
276
+ box.setAttribute("part", "box");
277
+
278
+ const head = make("div", { className: "head" });
279
+ const icon = document.createElement("template");
280
+ icon.innerHTML = ICON;
281
+ const summary = this.getAttribute("summary");
282
+ const meta: string[] = [];
283
+ if (summary) meta.push(record.message);
284
+ if (record.procedure) meta.push(record.procedure.name);
285
+ meta.push(timeText(record.at));
286
+ if (record.code) meta.push(record.code);
287
+ head.append(
288
+ icon.content,
289
+ make("div", {}, make("p", { className: "title", textContent: summary || record.message || record.name }), make("p", { className: "meta", textContent: meta.join(" · ") })),
290
+ );
291
+ box.append(head);
292
+
293
+ const actions = make("div", { className: "actions" });
294
+ if (this.hasAttribute("retry")) {
295
+ const retry = make("button", { type: "button", className: "primary", textContent: this.#busy ? "Retrying…" : "Retry" });
296
+ if (this.#busy) retry.setAttribute("aria-disabled", "true");
297
+ retry.dataset["action"] = "retry";
298
+ retry.addEventListener("click", () => this.#retry());
299
+ actions.append(retry);
300
+ }
301
+ const copy = make("button", { type: "button", textContent: "Copy details" });
302
+ copy.dataset["action"] = "copy";
303
+ copy.addEventListener("click", () => void this.copy());
304
+ actions.append(copy);
305
+ if (this.hasAttribute("report")) {
306
+ const report = make("button", { type: "button", textContent: this.getAttribute("report") || "Report" });
307
+ report.dataset["action"] = "report";
308
+ report.addEventListener("click", () => this.#report());
309
+ actions.append(report);
310
+ }
311
+ const href = traceLink(this.getAttribute("trace-url"), record, document.baseURI);
312
+ if (href) {
313
+ // The default opens the trace in a new tab. `trace-target="_self"` opens it in the page, for example a view of the page.
314
+ const target = this.getAttribute("trace-target") || "_blank";
315
+ const link = make("a", { className: "trace", href, textContent: "Open the trace" });
316
+ if (target !== "_self") Object.assign(link, { target, rel: "noopener noreferrer" });
317
+ link.dataset["action"] = "trace";
318
+ actions.append(link);
319
+ }
320
+ box.append(actions);
321
+
322
+ const status = make("p", { className: "status", textContent: this.#status });
323
+ status.setAttribute("role", "status");
324
+ box.append(status);
325
+
326
+ const rows: [string, string | undefined][] = [
327
+ ["Trace", record.traceId],
328
+ ["Span", record.spanId],
329
+ ["Procedure", record.procedure?.name],
330
+ ["Input digest", record.procedure?.inputDigest],
331
+ ...Object.entries(record.context),
332
+ ...Object.entries(record.attributes ?? {}).map(([key, value]): [string, string] => [key, String(value)]),
333
+ ["Time", record.at],
334
+ ["Record", record.id],
335
+ ];
336
+ const list = make("dl");
337
+ for (const [label, value] of rows) if (value !== undefined && value !== "") list.append(make("dt", { textContent: label }), make("dd", { textContent: value }));
338
+ const details = make("details", { open: wasOpen }, make("summary", { textContent: "Details" }), list);
339
+ if (record.causes.length > 1) {
340
+ const causes = make("ol");
341
+ causes.setAttribute("aria-label", "The causes");
342
+ for (const cause of record.causes.slice(1)) causes.append(make("li", {}, `${cause.name}: ${cause.message}`, make("span", { className: "via", textContent: cause.via ? ` (${cause.via})` : "" })));
343
+ details.append(causes);
344
+ }
345
+ const area = make("textarea", { readOnly: true, hidden: true, value: errorRecordText(record) });
346
+ area.setAttribute("aria-label", "The details as text");
347
+ details.append(area);
348
+ box.append(details);
349
+ root.append(box);
350
+ if (focused) root.querySelector<HTMLElement>(`[data-action="${focused}"]`)?.focus();
351
+ }
352
+ }
353
+
354
+ /** Register the element under `name`, one time. A second call with the same name does nothing. */
355
+ export function defineErrorView(name: string = ERROR_VIEW_TAG): void {
356
+ if (!customElements.get(name)) customElements.define(name, class extends ErrorViewElement {});
357
+ }
358
+
359
+ /** The options of `errorView()` */
360
+ export interface ErrorViewOptions {
361
+ /** Show a retry button */
362
+ readonly retry?: boolean;
363
+ /** Show a report button, with this label (default: Report) */
364
+ readonly report?: boolean | string;
365
+ /** The template of the trace link */
366
+ readonly traceUrl?: string;
367
+ /** Where the trace link opens. Default: `_blank`. */
368
+ readonly traceTarget?: string;
369
+ /** A headline in plain words. The message of the record then goes in the line below it. */
370
+ readonly summary?: string;
371
+ /** The name of the element. Default: `ERROR_VIEW_TAG`. */
372
+ readonly tag?: string;
373
+ }
374
+
375
+ /** Make an element for `record`. It registers the element first, when it is not registered. */
376
+ export function errorView(record: ErrorRecord, options: ErrorViewOptions = {}): ErrorViewElement {
377
+ const tag = options.tag ?? ERROR_VIEW_TAG;
378
+ defineErrorView(tag);
379
+ const element = document.createElement(tag) as ErrorViewElement;
380
+ if (options.retry) element.setAttribute("retry", "");
381
+ if (options.report) element.setAttribute("report", options.report === true ? "" : options.report);
382
+ if (options.traceUrl) element.setAttribute("trace-url", options.traceUrl);
383
+ if (options.traceTarget) element.setAttribute("trace-target", options.traceTarget);
384
+ if (options.summary) element.setAttribute("summary", options.summary);
385
+ element.record = record;
386
+ return element;
387
+ }
package/src/init.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { context, propagation, trace } from "@opentelemetry/api";
1
+ import { context, logs, propagation, trace } from "@opentelemetry/api";
2
2
  import { MeterProvider } from "@opentelemetry/sdk-metrics";
3
3
  import { LoggerProvider } from "@opentelemetry/sdk-logs";
4
4
  import type { FlushCause, OtelTsConfig, OtelTsInstance, ResolvedConfig } from "./types.js";
@@ -117,7 +117,7 @@ type Provider = { forceFlush(): Promise<void>; shutdown(): Promise<void> };
117
117
  */
118
118
  function releaseContext(releaseRegistration: (() => void) | undefined): void {
119
119
  if (!releaseRegistration) return;
120
- for (const api of [trace, propagation, context]) api.disable();
120
+ for (const api of [trace, propagation, context, logs]) api.disable();
121
121
  releaseRegistration();
122
122
  }
123
123
 
@@ -160,6 +160,12 @@ function startInstance(
160
160
 
161
161
  providers.push(loggerProvider);
162
162
 
163
+ // The owner of the globals also registers its logger provider, so a library
164
+ // that logs through the API (for example reportError of /error) reaches it
165
+ if (releaseRegistration && resolved.logs) {
166
+ logs.setGlobalLoggerProvider(loggerProvider);
167
+ }
168
+
163
169
  // After the tracing, so Faro reads the context of otel-ts
164
170
  if (faroUrl) {
165
171
  setupFaro(resolved, faroUrl);