@dxos/observability 0.8.4-main.74a063c4e0 → 0.8.4-main.765dc60934

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.
Files changed (98) hide show
  1. package/LICENSE +102 -5
  2. package/dist/lib/browser/{chunk-K4VFBKST.mjs → chunk-PSFTIG54.mjs} +9 -2
  3. package/dist/lib/browser/chunk-PSFTIG54.mjs.map +7 -0
  4. package/dist/lib/browser/index.mjs +123 -192
  5. package/dist/lib/browser/index.mjs.map +3 -3
  6. package/dist/lib/browser/{log-processor-FDLTDQEM.mjs → log-processor-HPHWNBOK.mjs} +11 -18
  7. package/dist/lib/browser/log-processor-HPHWNBOK.mjs.map +7 -0
  8. package/dist/lib/browser/{logs-ATTRIUTL.mjs → logs-UTNIFYHF.mjs} +7 -4
  9. package/dist/lib/browser/logs-UTNIFYHF.mjs.map +7 -0
  10. package/dist/lib/browser/meta.json +1 -1
  11. package/dist/lib/browser/{metrics-PKTV6IGF.mjs → metrics-PRGSYAZJ.mjs} +7 -21
  12. package/dist/lib/browser/metrics-PRGSYAZJ.mjs.map +7 -0
  13. package/dist/lib/browser/traces-browser-XRINKQUA.mjs +154 -0
  14. package/dist/lib/browser/traces-browser-XRINKQUA.mjs.map +7 -0
  15. package/dist/lib/node-esm/{chunk-FEVP3MK4.mjs → chunk-EDDZWPYV.mjs} +9 -2
  16. package/dist/lib/node-esm/chunk-EDDZWPYV.mjs.map +7 -0
  17. package/dist/lib/node-esm/index.mjs +112 -162
  18. package/dist/lib/node-esm/index.mjs.map +3 -3
  19. package/dist/lib/node-esm/{log-processor-TKJVJJSJ.mjs → log-processor-ZODHERST.mjs} +11 -18
  20. package/dist/lib/node-esm/log-processor-ZODHERST.mjs.map +7 -0
  21. package/dist/lib/node-esm/{logs-7J45KLM7.mjs → logs-ARJUVN3T.mjs} +7 -4
  22. package/dist/lib/node-esm/logs-ARJUVN3T.mjs.map +7 -0
  23. package/dist/lib/node-esm/meta.json +1 -1
  24. package/dist/lib/node-esm/{metrics-H7DDLYSG.mjs → metrics-DREJOOAC.mjs} +7 -21
  25. package/dist/lib/node-esm/metrics-DREJOOAC.mjs.map +7 -0
  26. package/dist/lib/node-esm/traces-74F7JUKF.mjs +125 -0
  27. package/dist/lib/node-esm/traces-74F7JUKF.mjs.map +7 -0
  28. package/dist/types/src/cli-observability-secrets.json +2 -2
  29. package/dist/types/src/extensions/otel/extension.d.ts.map +1 -1
  30. package/dist/types/src/extensions/otel/extension.js +97 -15
  31. package/dist/types/src/extensions/otel/extension.js.map +1 -1
  32. package/dist/types/src/extensions/otel/logs.d.ts.map +1 -1
  33. package/dist/types/src/extensions/otel/logs.js +6 -3
  34. package/dist/types/src/extensions/otel/logs.js.map +1 -1
  35. package/dist/types/src/extensions/otel/metrics.d.ts.map +1 -1
  36. package/dist/types/src/extensions/otel/metrics.js +2 -2
  37. package/dist/types/src/extensions/otel/metrics.js.map +1 -1
  38. package/dist/types/src/extensions/otel/otel.d.ts +7 -0
  39. package/dist/types/src/extensions/otel/otel.d.ts.map +1 -1
  40. package/dist/types/src/extensions/otel/otel.js +12 -0
  41. package/dist/types/src/extensions/otel/otel.js.map +1 -1
  42. package/dist/types/src/extensions/otel/span-processors.d.ts +25 -0
  43. package/dist/types/src/extensions/otel/span-processors.d.ts.map +1 -0
  44. package/dist/types/src/extensions/otel/span-processors.js +41 -0
  45. package/dist/types/src/extensions/otel/span-processors.js.map +1 -0
  46. package/dist/types/src/extensions/otel/traces-browser.d.ts +17 -0
  47. package/dist/types/src/extensions/otel/traces-browser.d.ts.map +1 -1
  48. package/dist/types/src/extensions/otel/traces-browser.js +55 -35
  49. package/dist/types/src/extensions/otel/traces-browser.js.map +1 -1
  50. package/dist/types/src/extensions/otel/traces.d.ts +17 -0
  51. package/dist/types/src/extensions/otel/traces.d.ts.map +1 -1
  52. package/dist/types/src/extensions/otel/traces.js +59 -9
  53. package/dist/types/src/extensions/otel/traces.js.map +1 -1
  54. package/dist/types/src/extensions/posthog/extension.d.ts +13 -3
  55. package/dist/types/src/extensions/posthog/extension.d.ts.map +1 -1
  56. package/dist/types/src/extensions/posthog/extension.js +7 -7
  57. package/dist/types/src/extensions/posthog/extension.js.map +1 -1
  58. package/dist/types/src/extensions/posthog/log-processor.d.ts.map +1 -1
  59. package/dist/types/src/extensions/posthog/log-processor.js +10 -19
  60. package/dist/types/src/extensions/posthog/log-processor.js.map +1 -1
  61. package/dist/types/src/extensions/posthog/log-processor.test.js +2 -2
  62. package/dist/types/src/extensions/posthog/log-processor.test.js.map +1 -1
  63. package/dist/types/src/observability.d.ts.map +1 -1
  64. package/dist/types/src/providers/client-observability.d.ts.map +1 -1
  65. package/dist/types/src/providers/client-observability.js +2 -0
  66. package/dist/types/src/providers/client-observability.js.map +1 -1
  67. package/dist/types/src/providers/ip-data.d.ts.map +1 -1
  68. package/dist/types/src/storage/browser.d.ts.map +1 -1
  69. package/dist/types/src/storage/browser.js +10 -0
  70. package/dist/types/src/storage/browser.js.map +1 -1
  71. package/dist/types/src/storage/node.d.ts.map +1 -1
  72. package/dist/types/tsconfig.tsbuildinfo +1 -1
  73. package/package.json +34 -31
  74. package/src/cli-observability-secrets.json +2 -2
  75. package/src/extensions/otel/extension.ts +102 -16
  76. package/src/extensions/otel/logs.ts +6 -3
  77. package/src/extensions/otel/metrics.ts +2 -2
  78. package/src/extensions/otel/otel.ts +13 -0
  79. package/src/extensions/otel/span-processors.ts +45 -0
  80. package/src/extensions/otel/traces-browser.ts +70 -41
  81. package/src/extensions/otel/traces.ts +76 -12
  82. package/src/extensions/posthog/extension.ts +21 -9
  83. package/src/extensions/posthog/log-processor.test.ts +7 -6
  84. package/src/extensions/posthog/log-processor.ts +10 -21
  85. package/src/providers/client-observability.ts +2 -0
  86. package/src/storage/browser.ts +9 -0
  87. package/dist/lib/browser/chunk-K4VFBKST.mjs.map +0 -7
  88. package/dist/lib/browser/log-processor-FDLTDQEM.mjs.map +0 -7
  89. package/dist/lib/browser/logs-ATTRIUTL.mjs.map +0 -7
  90. package/dist/lib/browser/metrics-PKTV6IGF.mjs.map +0 -7
  91. package/dist/lib/browser/traces-browser-PUNCJ5KV.mjs +0 -112
  92. package/dist/lib/browser/traces-browser-PUNCJ5KV.mjs.map +0 -7
  93. package/dist/lib/node-esm/chunk-FEVP3MK4.mjs.map +0 -7
  94. package/dist/lib/node-esm/log-processor-TKJVJJSJ.mjs.map +0 -7
  95. package/dist/lib/node-esm/logs-7J45KLM7.mjs.map +0 -7
  96. package/dist/lib/node-esm/metrics-H7DDLYSG.mjs.map +0 -7
  97. package/dist/lib/node-esm/traces-KMTHMYFX.mjs +0 -44
  98. package/dist/lib/node-esm/traces-KMTHMYFX.mjs.map +0 -7
package/LICENSE CHANGED
@@ -1,8 +1,105 @@
1
- MIT License
2
- Copyright (c) 2023 DXOS
1
+ # Functional Source License, Version 1.1, ALv2 Future License
3
2
 
4
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
3
+ ## Abbreviation
5
4
 
6
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
5
+ FSL-1.1-Apache-2.0
7
6
 
8
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
7
+ ## Notice
8
+
9
+ Copyright 2026 DXOS
10
+
11
+ ## Terms and Conditions
12
+
13
+ ### Licensor ("We")
14
+
15
+ The party offering the Software under these Terms and Conditions.
16
+
17
+ ### The Software
18
+
19
+ The "Software" is each version of the software that we make available under
20
+ these Terms and Conditions, as indicated by our inclusion of these Terms and
21
+ Conditions with the Software.
22
+
23
+ ### License Grant
24
+
25
+ Subject to your compliance with this License Grant and the Patents,
26
+ Redistribution and Trademark clauses below, we hereby grant you the right to
27
+ use, copy, modify, create derivative works, publicly perform, publicly display
28
+ and redistribute the Software for any Permitted Purpose identified below.
29
+
30
+ ### Permitted Purpose
31
+
32
+ A Permitted Purpose is any purpose other than a Competing Use. A Competing Use
33
+ means making the Software available to others in a commercial product or
34
+ service that:
35
+
36
+ 1. substitutes for the Software;
37
+
38
+ 2. substitutes for any other product or service we offer using the Software
39
+ that exists as of the date we make the Software available; or
40
+
41
+ 3. offers the same or substantially similar functionality as the Software.
42
+
43
+ Permitted Purposes specifically include using the Software:
44
+
45
+ 1. for your internal use and access;
46
+
47
+ 2. for non-commercial education;
48
+
49
+ 3. for non-commercial research; and
50
+
51
+ 4. in connection with professional services that you provide to a licensee
52
+ using the Software in accordance with these Terms and Conditions.
53
+
54
+ ### Patents
55
+
56
+ To the extent your use for a Permitted Purpose would necessarily infringe our
57
+ patents, the license grant above includes a license under our patents. If you
58
+ make a claim against any party that the Software infringes or contributes to
59
+ the infringement of any patent, then your patent license to the Software ends
60
+ immediately.
61
+
62
+ ### Redistribution
63
+
64
+ The Terms and Conditions apply to all copies, modifications and derivatives of
65
+ the Software.
66
+
67
+ If you redistribute any copies, modifications or derivatives of the Software,
68
+ you must include a copy of or a link to these Terms and Conditions and not
69
+ remove any copyright notices provided in or with the Software.
70
+
71
+ ### Disclaimer
72
+
73
+ THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTIES OF ANY KIND, EXPRESS OR
74
+ IMPLIED, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR
75
+ PURPOSE, MERCHANTABILITY, TITLE OR NON-INFRINGEMENT.
76
+
77
+ IN NO EVENT WILL WE HAVE ANY LIABILITY TO YOU ARISING OUT OF OR RELATED TO THE
78
+ SOFTWARE, INCLUDING INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES,
79
+ EVEN IF WE HAVE BEEN INFORMED OF THEIR POSSIBILITY IN ADVANCE.
80
+
81
+ ### Trademarks
82
+
83
+ Except for displaying the License Details and identifying us as the origin of
84
+ the Software, you have no right under these Terms and Conditions to use our
85
+ trademarks, trade names, service marks or product names.
86
+
87
+ ## Grant of Future License
88
+
89
+ We hereby irrevocably grant you an additional license to use the Software under
90
+ the Apache License, Version 2.0 that is effective on the second anniversary of
91
+ the date we make the Software available. On or after that date, you may use the
92
+ Software under the Apache License, Version 2.0, in which case the following
93
+ will apply:
94
+
95
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use
96
+ this file except in compliance with the License.
97
+
98
+ You may obtain a copy of the License at
99
+
100
+ http://www.apache.org/licenses/LICENSE-2.0
101
+
102
+ Unless required by applicable law or agreed to in writing, software distributed
103
+ under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
104
+ CONDITIONS OF ANY KIND, either express or implied. See the License for the
105
+ specific language governing permissions and limitations under the License.
@@ -6,8 +6,15 @@ var setDiagLogger = (level) => {
6
6
  diag.setLogger(new DiagConsoleLogger(), logLevel);
7
7
  }
8
8
  };
9
+ var resolveOtlpUrl = (url) => {
10
+ if (typeof window !== "undefined" && url.startsWith("/")) {
11
+ return new URL(url, window.location.origin).toString();
12
+ }
13
+ return url;
14
+ };
9
15
 
10
16
  export {
11
- setDiagLogger
17
+ setDiagLogger,
18
+ resolveOtlpUrl
12
19
  };
13
- //# sourceMappingURL=chunk-K4VFBKST.mjs.map
20
+ //# sourceMappingURL=chunk-PSFTIG54.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/extensions/otel/otel.ts"],
4
+ "sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport { DiagConsoleLogger, DiagLogLevel, diag } from '@opentelemetry/api';\nimport { type Resource } from '@opentelemetry/resources';\n\nexport type OtelOptions = {\n endpoint: string;\n headers: Record<string, string>;\n resource: Resource;\n getTags: () => { [key: string]: string };\n consoleDiagLogLevel?: string;\n};\n\nexport const setDiagLogger = (level?: string) => {\n const logLevel = DiagLogLevel[level as keyof typeof DiagLogLevel];\n if (logLevel) {\n diag.setLogger(new DiagConsoleLogger(), logLevel);\n }\n};\n\n/**\n * Resolve a possibly-relative OTLP exporter URL to an absolute URL.\n * The OpenTelemetry browser HTTP exporter validates user-provided URLs with `new URL(url)`,\n * which throws on relative paths like `/api/otel/v1/logs`. In a browser context we resolve\n * against `window.location.origin`; outside the browser we return the input unchanged.\n */\nexport const resolveOtlpUrl = (url: string): string => {\n if (typeof window !== 'undefined' && url.startsWith('/')) {\n return new URL(url, window.location.origin).toString();\n }\n return url;\n};\n"],
5
+ "mappings": ";AAIA,SAASA,mBAAmBC,cAAcC,YAAY;AAW/C,IAAMC,gBAAgB,CAACC,UAAAA;AAC5B,QAAMC,WAAWJ,aAAaG,KAAAA;AAC9B,MAAIC,UAAU;AACZH,SAAKI,UAAU,IAAIN,kBAAAA,GAAqBK,QAAAA;EAC1C;AACF;AAQO,IAAME,iBAAiB,CAACC,QAAAA;AAC7B,MAAI,OAAOC,WAAW,eAAeD,IAAIE,WAAW,GAAA,GAAM;AACxD,WAAO,IAAIC,IAAIH,KAAKC,OAAOG,SAASC,MAAM,EAAEC,SAAQ;EACtD;AACA,SAAON;AACT;",
6
+ "names": ["DiagConsoleLogger", "DiagLogLevel", "diag", "setDiagLogger", "level", "logLevel", "setLogger", "resolveOtlpUrl", "url", "window", "startsWith", "URL", "location", "origin", "toString"]
7
+ }
@@ -30,23 +30,13 @@ var __dxlog_file = "/__w/dxos/dxos/packages/sdk/observability/src/storage/browse
30
30
  var OBSERVABILITY_DISABLED_KEY = "observability-disabled";
31
31
  var OBSERVABILITY_GROUP_KEY = "observability-group";
32
32
  var showObservabilityBanner = () => {
33
- log.warn("showObservabilityBanner is not supported in browser contexts.", void 0, {
34
- F: __dxlog_file,
35
- L: 16,
36
- S: void 0,
37
- C: (f, a) => f(...a)
38
- });
33
+ log.warn("showObservabilityBanner is not supported in browser contexts.", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 11, S: void 0 });
39
34
  };
40
35
  var isObservabilityDisabled = async (namespace) => {
41
36
  try {
42
37
  return await localForage.getItem(compositeKey(namespace, OBSERVABILITY_DISABLED_KEY)) === "true";
43
38
  } catch (err) {
44
- log.catch("Failed to check if observability is disabled, assuming it is", err, {
45
- F: __dxlog_file,
46
- L: 26,
47
- S: void 0,
48
- C: (f, a) => f(...a)
49
- });
39
+ log.catch("Failed to check if observability is disabled, assuming it is", err, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 19, S: void 0 });
50
40
  return true;
51
41
  }
52
42
  };
@@ -54,36 +44,27 @@ var storeObservabilityDisabled = async (namespace, value2) => {
54
44
  try {
55
45
  await localForage.setItem(compositeKey(namespace, OBSERVABILITY_DISABLED_KEY), String(value2));
56
46
  } catch (err) {
57
- log.catch("Failed to store observability disabled", err, {
58
- F: __dxlog_file,
59
- L: 38,
60
- S: void 0,
61
- C: (f, a) => f(...a)
62
- });
47
+ log.catch("Failed to store observability disabled", err, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 29, S: void 0 });
48
+ }
49
+ try {
50
+ if (typeof localStorage !== "undefined") {
51
+ localStorage.setItem(`${namespace}/${OBSERVABILITY_DISABLED_KEY}`, String(value2));
52
+ }
53
+ } catch {
63
54
  }
64
55
  };
65
56
  var getObservabilityGroup = async (namespace) => {
66
57
  try {
67
58
  return await localForage.getItem(compositeKey(namespace, OBSERVABILITY_GROUP_KEY)) ?? void 0;
68
59
  } catch (err) {
69
- log.catch("Failed to get observability group", err, {
70
- F: __dxlog_file,
71
- L: 49,
72
- S: void 0,
73
- C: (f, a) => f(...a)
74
- });
60
+ log.catch("Failed to get observability group", err, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 47, S: void 0 });
75
61
  }
76
62
  };
77
63
  var storeObservabilityGroup = async (namespace, value2) => {
78
64
  try {
79
65
  await localForage.setItem(compositeKey(namespace, OBSERVABILITY_GROUP_KEY), value2);
80
66
  } catch (err) {
81
- log.catch("Failed to store observability group", err, {
82
- F: __dxlog_file,
83
- L: 60,
84
- S: void 0,
85
- C: (f, a) => f(...a)
86
- });
67
+ log.catch("Failed to store observability group", err, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 56, S: void 0 });
87
68
  }
88
69
  };
89
70
 
@@ -110,12 +91,7 @@ var ObservabilityImpl = class {
110
91
  this._subscriptions.add(...cleanups.filter((cleanup) => cleanup !== void 0));
111
92
  this._initialized = true;
112
93
  }).pipe(Effect.catchAll((error) => Effect.gen(this, function* () {
113
- log2.catch(error, void 0, {
114
- F: __dxlog_file2,
115
- L: 85,
116
- S: this,
117
- C: (f, a) => f(...a)
118
- });
94
+ log2.catch(error, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 32, S: this });
119
95
  for (const extension of initializedExtensions) {
120
96
  if (extension.close) {
121
97
  yield* extension.close().pipe(Effect.catchAll(() => Effect.succeed(void 0)));
@@ -164,27 +140,11 @@ var ObservabilityImpl = class {
164
140
  });
165
141
  }
166
142
  _addExtension(extension) {
167
- invariant(!this._initialized, "Observability is already initialized", {
168
- F: __dxlog_file2,
169
- L: 142,
170
- S: this,
171
- A: [
172
- "!this._initialized",
173
- "'Observability is already initialized'"
174
- ]
175
- });
143
+ invariant(!this._initialized, "Observability is already initialized", { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 82, S: this, A: ["!this._initialized", "'Observability is already initialized'"] });
176
144
  this._extensions.push(extension);
177
145
  }
178
146
  _addDataProvider(dataProvider) {
179
- invariant(!this._initialized, "Observability is already initialized", {
180
- F: __dxlog_file2,
181
- L: 147,
182
- S: this,
183
- A: [
184
- "!this._initialized",
185
- "'Observability is already initialized'"
186
- ]
187
- });
147
+ invariant(!this._initialized, "Observability is already initialized", { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 86, S: this, A: ["!this._initialized", "'Observability is already initialized'"] });
188
148
  this._dataProviders.push(dataProvider);
189
149
  }
190
150
  /**
@@ -293,29 +253,13 @@ var make = () => Effect.succeed(new ObservabilityImpl());
293
253
  var addExtension = (_extension) => Effect.fn(function* (_observability) {
294
254
  const observability = yield* _observability;
295
255
  const extension = yield* _extension;
296
- invariant("_addExtension" in observability && typeof observability._addExtension === "function", void 0, {
297
- F: __dxlog_file2,
298
- L: 276,
299
- S: this,
300
- A: [
301
- "'_addExtension' in observability && typeof observability._addExtension === 'function'",
302
- ""
303
- ]
304
- });
256
+ invariant("_addExtension" in observability && typeof observability._addExtension === "function", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 194, S: this, A: ["'_addExtension' in observability && typeof observability._addExtension === 'function'", ""] });
305
257
  observability._addExtension(extension);
306
258
  return observability;
307
259
  });
308
260
  var addDataProvider = (dataProvider) => Effect.fn(function* (_observability) {
309
261
  const observability = yield* _observability;
310
- invariant("_addDataProvider" in observability && typeof observability._addDataProvider === "function", void 0, {
311
- F: __dxlog_file2,
312
- L: 284,
313
- S: this,
314
- A: [
315
- "'_addDataProvider' in observability && typeof observability._addDataProvider === 'function'",
316
- ""
317
- ]
318
- });
262
+ invariant("_addDataProvider" in observability && typeof observability._addDataProvider === "function", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 200, S: this, A: ["'_addDataProvider' in observability && typeof observability._addDataProvider === 'function'", ""] });
319
263
  observability._addDataProvider(dataProvider);
320
264
  return observability;
321
265
  });
@@ -345,6 +289,7 @@ import * as Effect3 from "effect/Effect";
345
289
  import * as Match from "effect/Match";
346
290
  import * as Option from "effect/Option";
347
291
  import * as Ref from "effect/Ref";
292
+ import { resolveTelemetryTag } from "@dxos/config";
348
293
  import { LogLevel, log as log3 } from "@dxos/log";
349
294
  import { isNode, isNonNullable } from "@dxos/util";
350
295
 
@@ -352,8 +297,8 @@ import { isNode, isNonNullable } from "@dxos/util";
352
297
  var cli_observability_secrets_default = {
353
298
  POSTHOG_API_KEY: null,
354
299
  IPDATA_API_KEY: "73dfdecdf979c18f07d50cf841bbdd9e589f237256326ac8cca23786",
355
- OTEL_ENDPOINT: "https://ingest.eu.signoz.cloud:443",
356
- OTEL_HEADERS: "signoz-ingestion-key: 5300e0c9-a5e8-4a10-9c61-f473e539c0b7"
300
+ OTEL_ENDPOINT: "/api/otel",
301
+ OTEL_HEADERS: null
357
302
  };
358
303
 
359
304
  // src/extensions/stub.ts
@@ -388,49 +333,59 @@ var extensions = Effect3.fn(function* ({
388
333
  metrics: metricsEnabled = false,
389
334
  traces: tracesEnabled = false
390
335
  }) {
391
- const { OtelLogs } = yield* Effect3.promise(() => import("./logs-ATTRIUTL.mjs"));
392
- const { OtelMetrics } = yield* Effect3.promise(() => import("./metrics-PKTV6IGF.mjs"));
393
- const { OtelTraces } = yield* Effect3.promise(() => import("./traces-browser-PUNCJ5KV.mjs"));
336
+ const { OtelLogs } = yield* Effect3.promise(() => import("./logs-UTNIFYHF.mjs"));
337
+ const { OtelMetrics } = yield* Effect3.promise(() => import("./metrics-PRGSYAZJ.mjs"));
338
+ const { OtelTraces } = yield* Effect3.promise(() => import("./traces-browser-XRINKQUA.mjs"));
394
339
  const cachedDisabled = yield* Effect3.promise(() => isObservabilityDisabled(serviceName));
395
- const enabledRef = yield* Ref.make(!cachedDisabled);
340
+ const disabled = cachedDisabled || isObservabilityDisabledSync(serviceName);
341
+ const enabledRef = yield* Ref.make(!disabled);
396
342
  const tags = /* @__PURE__ */ new Map();
397
- const endpoint = isNode() ? process.env.DX_OTEL_ENDPOINT ?? _endpoint ?? cli_observability_secrets_default.OTEL_ENDPOINT : config.values.runtime?.app?.env?.DX_OTEL_ENDPOINT;
343
+ const endpoint = isNode() ? process.env.DX_OTEL_ENDPOINT ?? _endpoint ?? cli_observability_secrets_default.OTEL_ENDPOINT : config.values.runtime?.app?.env?.DX_OTEL_ENDPOINT ?? _endpoint;
398
344
  const headers = _headers ?? Match.value(isNode()).pipe(Match.when(true, () => Option.fromNullable(process.env.DX_OTEL_HEADERS ?? cli_observability_secrets_default.OTEL_HEADERS)), Match.when(false, () => Option.fromNullable(config.values.runtime?.app?.env?.DX_OTEL_HEADERS)), Match.exhaustive, Option.map((raw) => parseHeaders(raw)), Option.getOrElse(() => void 0));
399
- if (!endpoint || !headers) {
400
- log3.info("Missing OTEL_ENDPOINT or OTEL_HEADERS", void 0, {
401
- F: __dxlog_file3,
402
- L: 77,
403
- S: this,
404
- C: (f, a) => f(...a)
405
- });
345
+ if (!endpoint) {
346
+ log3.info("Missing OTEL_ENDPOINT", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 31, S: this });
406
347
  return stubExtension;
407
348
  }
349
+ const resolvedHeaders = headers ?? {};
350
+ const resolvedEndpoint = !isNode() && endpoint.startsWith("/") ? `${globalThis.location.origin}${endpoint}` : endpoint;
351
+ const clientTag = resolveTelemetryTag(config);
352
+ if (clientTag) {
353
+ tags.set("ctx.tag", clientTag);
354
+ }
408
355
  const resource = defaultResource().merge(resourceFromAttributes({
409
356
  [ATTR_SERVICE_NAME]: serviceName,
410
357
  [ATTR_SERVICE_VERSION]: serviceVersion,
411
- "deployment.environment": environment
358
+ "session.id": crypto.randomUUID(),
359
+ "deployment.environment": environment,
360
+ "dxos.process.type": detectProcessType(),
361
+ ...clientTag ? {
362
+ "ctx.tag": clientTag
363
+ } : {}
412
364
  }));
413
365
  const logs = logsEnabled ? new OtelLogs({
414
- endpoint,
415
- headers,
366
+ endpoint: resolvedEndpoint,
367
+ headers: resolvedHeaders,
416
368
  resource,
417
369
  getTags: () => Object.fromEntries(tags),
418
370
  logLevel
419
371
  }) : void 0;
420
372
  const metrics = metricsEnabled ? new OtelMetrics({
421
- endpoint,
422
- headers,
373
+ endpoint: resolvedEndpoint,
374
+ headers: resolvedHeaders,
423
375
  resource,
424
376
  getTags: () => Object.fromEntries(tags)
425
377
  }) : void 0;
426
378
  const traces = tracesEnabled ? new OtelTraces({
427
- endpoint,
428
- headers,
379
+ endpoint: resolvedEndpoint,
380
+ headers: resolvedHeaders,
429
381
  resource,
430
382
  getTags: () => Object.fromEntries(tags)
431
383
  }) : void 0;
432
- return {
384
+ const extension = {
433
385
  initialize: () => Effect3.sync(() => {
386
+ if (disabled) {
387
+ return;
388
+ }
434
389
  if (logs) {
435
390
  log3.runtimeConfig.processors.push(logs.logProcessor);
436
391
  }
@@ -447,12 +402,28 @@ var extensions = Effect3.fn(function* ({
447
402
  yield* Ref.update(enabledRef, () => false);
448
403
  }),
449
404
  close: () => Effect3.promise(async () => {
450
- await logs?.close();
451
- await metrics?.close();
405
+ const results = await Promise.allSettled([
406
+ logs?.close(),
407
+ metrics?.close()
408
+ ]);
409
+ for (const result of results) {
410
+ if (result.status === "rejected") {
411
+ log3.catch(result.reason, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 116, S: this });
412
+ }
413
+ }
414
+ await traces?.close();
452
415
  }),
453
416
  flush: () => Effect3.promise(async () => {
454
- await logs?.flush();
455
- await metrics?.flush();
417
+ const results = await Promise.allSettled([
418
+ logs?.flush(),
419
+ metrics?.flush()
420
+ ]);
421
+ for (const result of results) {
422
+ if (result.status === "rejected") {
423
+ log3.catch(result.reason, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 131, S: this });
424
+ }
425
+ }
426
+ await traces?.flush();
456
427
  }),
457
428
  setTags: (incomingTags) => {
458
429
  for (const [key, value2] of Object.entries(incomingTags)) {
@@ -480,7 +451,35 @@ var extensions = Effect3.fn(function* ({
480
451
  } : void 0
481
452
  ].filter(isNonNullable)
482
453
  };
454
+ return extension;
483
455
  });
456
+ var isObservabilityDisabledSync = (serviceName) => {
457
+ if (isNode()) {
458
+ return process.env.DX_DISABLE_OBSERVABILITY === "true";
459
+ }
460
+ try {
461
+ if (typeof localStorage !== "undefined") {
462
+ return localStorage.getItem(`${serviceName}/observability-disabled`) === "true";
463
+ }
464
+ } catch {
465
+ }
466
+ return false;
467
+ };
468
+ var detectProcessType = () => {
469
+ if (isNode()) {
470
+ return "node";
471
+ }
472
+ if (typeof window !== "undefined") {
473
+ return "browser";
474
+ }
475
+ if (typeof globalThis.ServiceWorkerGlobalScope !== "undefined") {
476
+ return "service-worker";
477
+ }
478
+ if (typeof globalThis.SharedWorkerGlobalScope !== "undefined") {
479
+ return "shared-worker";
480
+ }
481
+ return "dedicated-worker";
482
+ };
484
483
  var parseHeaders = (unparsedHeaders) => {
485
484
  return unparsedHeaders.split(";").reduce((acc, header) => {
486
485
  const [key, ...rest] = header.split(":");
@@ -499,7 +498,7 @@ __export(posthog_exports, {
499
498
 
500
499
  // src/extensions/posthog/extension.ts
501
500
  import * as Effect4 from "effect/Effect";
502
- import { LogBuffer, log as log4 } from "@dxos/log";
501
+ import { log as log4 } from "@dxos/log";
503
502
  var __dxlog_file4 = "/__w/dxos/dxos/packages/sdk/observability/src/extensions/posthog/extension.ts";
504
503
  var uploadLogs = async (body) => {
505
504
  try {
@@ -513,12 +512,7 @@ var uploadLogs = async (body) => {
513
512
  if (!response.ok) {
514
513
  log4.warn("feedback log upload failed", {
515
514
  status: response.status
516
- }, {
517
- F: __dxlog_file4,
518
- L: 34,
519
- S: void 0,
520
- C: (f, a) => f(...a)
521
- });
515
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 17, S: void 0 });
522
516
  return void 0;
523
517
  }
524
518
  const { key } = await response.json();
@@ -526,40 +520,24 @@ var uploadLogs = async (body) => {
526
520
  } catch (err) {
527
521
  log4.warn("feedback log upload error", {
528
522
  error: err
529
- }, {
530
- F: __dxlog_file4,
531
- L: 40,
532
- S: void 0,
533
- C: (f, a) => f(...a)
534
- });
523
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 25, S: void 0 });
535
524
  return void 0;
536
525
  }
537
526
  };
538
- var extensions2 = Effect4.fn(function* ({ config, release, environment, posthog: posthogConfig, logBuffer: externalLogBuffer }) {
527
+ var extensions2 = Effect4.fn(function* ({ config, release, environment, posthog: posthogConfig, logStore, feedbackLogMaxSize }) {
539
528
  if (typeof window === "undefined") {
540
- log4("PostHog is being stubbed because it is running in a worker.", void 0, {
541
- F: __dxlog_file4,
542
- L: 54,
543
- S: this,
544
- C: (f, a) => f(...a)
545
- });
529
+ log4("PostHog is being stubbed because it is running in a worker.", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 33, S: this });
546
530
  return stubExtension;
547
531
  }
548
532
  const feedbackSurveyId = config.get("runtime.app.env.DX_POSTHOG_FEEDBACK_SURVEY_ID");
549
533
  const apiKey = config.get("runtime.app.env.DX_POSTHOG_API_KEY");
550
534
  const api_host = config.get("runtime.app.env.DX_POSTHOG_API_HOST");
551
535
  if (!apiKey || !api_host) {
552
- log4.info("Missing POSTHOG_API_KEY or POSTHOG_API_HOST", void 0, {
553
- F: __dxlog_file4,
554
- L: 62,
555
- S: this,
556
- C: (f, a) => f(...a)
557
- });
536
+ log4.info("Missing POSTHOG_API_KEY or POSTHOG_API_HOST", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 40, S: this });
558
537
  return stubExtension;
559
538
  }
560
539
  const { default: posthog } = yield* Effect4.promise(() => import("posthog-js"));
561
- const { logProcessor } = yield* Effect4.promise(() => import("./log-processor-FDLTDQEM.mjs"));
562
- const logBuffer = externalLogBuffer ?? new LogBuffer();
540
+ const { logProcessor } = yield* Effect4.promise(() => import("./log-processor-HPHWNBOK.mjs"));
563
541
  let feedbackSurveyAvailable = null;
564
542
  let unregisterPosthogProcessors;
565
543
  const checkFeedbackSurveyAvailable = () => feedbackSurveyId ? Effect4.promise(() => {
@@ -593,21 +571,9 @@ var extensions2 = Effect4.fn(function* ({ config, release, environment, posthog:
593
571
  });
594
572
  }
595
573
  unregisterPosthogProcessors?.();
596
- const removePosthogLog = log4.addProcessor(logProcessor, void 0, {
597
- F: __dxlog_file4,
598
- L: 105,
599
- S: this,
600
- C: (f, a) => f(...a)
601
- });
602
- const removeLogBuffer = log4.addProcessor(logBuffer.logProcessor, void 0, {
603
- F: __dxlog_file4,
604
- L: 106,
605
- S: this,
606
- C: (f, a) => f(...a)
607
- });
574
+ const removePosthogLog = log4.addProcessor(logProcessor, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 79, S: this });
608
575
  unregisterPosthogProcessors = () => {
609
576
  removePosthogLog();
610
- removeLogBuffer();
611
577
  };
612
578
  }),
613
579
  close: () => Effect4.sync(() => {
@@ -652,17 +618,17 @@ var extensions2 = Effect4.fn(function* ({ config, release, environment, posthog:
652
618
  if (!survey || survey.questions.length === 0) {
653
619
  log4.error("Missing feedback survey or survey has no questions", {
654
620
  feedbackSurveyId
655
- }, {
656
- F: __dxlog_file4,
657
- L: 153,
658
- S: this,
659
- C: (f, a) => f(...a)
660
- });
621
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 124, S: this });
661
622
  return;
662
623
  }
663
624
  let debugLogDumpKey = null;
664
- if (form.includeLogs !== false && logBuffer.size > 0) {
665
- debugLogDumpKey = await uploadLogs(logBuffer.serialize()) ?? "failed";
625
+ if (form.includeLogs !== false && logStore !== void 0) {
626
+ const ndjson = await logStore.export({
627
+ maxSize: feedbackLogMaxSize
628
+ });
629
+ if (ndjson.length > 0) {
630
+ debugLogDumpKey = await uploadLogs(ndjson) ?? "failed";
631
+ }
666
632
  }
667
633
  const question = survey.questions[0];
668
634
  posthog.capture("survey sent", {
@@ -740,19 +706,11 @@ var identityProvider = (clientServices) => Effect5.fn(function* (observability)
740
706
  });
741
707
  });
742
708
  var networkMetricsProvider = (clientServices) => Effect5.fn(function* (observability) {
743
- const ctx = new Context(void 0, {
744
- F: __dxlog_file5,
745
- L: 61
746
- });
709
+ const ctx = new Context(void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 50 });
747
710
  let lastNetworkStatus;
748
711
  const updateSignalMetrics = new Event().debounce(NETWORK_METRICS_MIN_INTERVAL);
749
712
  updateSignalMetrics.on(ctx, async () => {
750
- log5("send signal metrics", void 0, {
751
- F: __dxlog_file5,
752
- L: 67,
753
- S: this,
754
- C: (f, a) => f(...a)
755
- });
713
+ log5("send signal metrics", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 55, S: this });
756
714
  lastNetworkStatus?.signaling?.forEach(({ server, state }) => {
757
715
  observability.metrics.gauge("dxos.client.network.signal.connectionState", state, {
758
716
  server
@@ -797,20 +755,11 @@ var networkMetricsProvider = (clientServices) => Effect5.fn(function* (observabi
797
755
  };
798
756
  });
799
757
  var runtimeMetricsProvider = (clientServices) => Effect5.fn(function* (observability) {
800
- const ctx = new Context(void 0, {
801
- F: __dxlog_file5,
802
- L: 121
803
- });
758
+ const ctx = new Context(void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 100 });
759
+ log5("runtimeMetricsProvider: requesting platform from SystemService", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 101, S: this });
804
760
  const platform = yield* Effect5.promise(() => clientServices.SystemService.getPlatform());
805
- invariant2(platform, "platform is required", {
806
- F: __dxlog_file5,
807
- L: 123,
808
- S: this,
809
- A: [
810
- "platform",
811
- "'platform is required'"
812
- ]
813
- });
761
+ log5("runtimeMetricsProvider: platform received", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 103, S: this });
762
+ invariant2(platform, "platform is required", { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 104, S: this, A: ["platform", "'platform is required'"] });
814
763
  observability.setTags({
815
764
  platformType: Platform.PLATFORM_TYPE[platform.type].toLowerCase(),
816
765
  platform: platform.platform,
@@ -834,33 +783,20 @@ var runtimeMetricsProvider = (clientServices) => Effect5.fn(function* (observabi
834
783
  }
835
784
  }).catch((error) => log5("platform error", {
836
785
  error
837
- }, {
838
- F: __dxlog_file5,
839
- L: 152,
840
- S: this,
841
- C: (f, a) => f(...a)
842
- }));
786
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 126, S: this }));
843
787
  }, RUNTIME_METRICS_MIN_INTERVAL);
844
788
  return async () => {
845
789
  await ctx.dispose();
846
790
  };
847
791
  });
848
792
  var spacesMetricsProvider = (client) => Effect5.fn(function* (observability) {
849
- const ctx = new Context(void 0, {
850
- F: __dxlog_file5,
851
- L: 165
852
- });
793
+ const ctx = new Context(void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 135 });
853
794
  const spaces = client.spaces.get();
854
795
  const subscriptions = /* @__PURE__ */ new Map();
855
796
  ctx.onDispose(() => subscriptions.forEach((subscription) => subscription.unsubscribe()));
856
797
  const updateSpaceMetrics = new Event().debounce(SPACE_METRICS_MIN_INTERVAL);
857
798
  updateSpaceMetrics.on(ctx, async () => {
858
- log5("send space metrics", void 0, {
859
- F: __dxlog_file5,
860
- L: 173,
861
- S: this,
862
- C: (f, a) => f(...a)
863
- });
799
+ log5("send space metrics", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 142, S: this });
864
800
  for (const data of mapSpaces(spaces, {
865
801
  truncateKeys: true
866
802
  })) {
@@ -981,12 +917,7 @@ var provider = (config) => (observability) => Effect6.gen(function* () {
981
917
  }).pipe(Effect6.provide(FetchHttpClient.layer), Effect6.catchAll((err) => Effect6.sync(() => {
982
918
  log6.verbose("ipdata fetch failed", {
983
919
  err
984
- }, {
985
- F: __dxlog_file6,
986
- L: 88,
987
- S: void 0,
988
- C: (f, a) => f(...a)
989
- });
920
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 54, S: void 0 });
990
921
  })));
991
922
 
992
923
  // src/providers/storage.ts