@platformatic/telemetry 3.13.1 → 3.15.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.
@@ -106,6 +106,12 @@ const setupNodeHTTPTelemetry = async (opts, applicationDir) => {
106
106
  })
107
107
  }
108
108
 
109
+ // Create a promise that will be resolved when telemetry is initialized
110
+ // This allows other parts of the system to wait for telemetry to be ready
111
+ globalThis.platformatic = globalThis.platformatic || {}
112
+ const { promise: telemetryReadyPromise, resolve: resolveTelemetryReady } = Promise.withResolvers()
113
+ globalThis.platformatic.telemetryReady = telemetryReadyPromise
114
+
109
115
  async function main () {
110
116
  let data = null
111
117
  const useWorkerData = !!workerData
@@ -130,13 +136,18 @@ async function main () {
130
136
  const telemetryConfig = useWorkerData ? data?.applicationConfig?.telemetry : data?.telemetryConfig
131
137
  if (telemetryConfig) {
132
138
  debuglog('telemetryConfig %o', telemetryConfig)
133
- setupNodeHTTPTelemetry(telemetryConfig, applicationDir)
139
+ await setupNodeHTTPTelemetry(telemetryConfig, applicationDir)
140
+ resolveTelemetryReady()
141
+ } else {
142
+ resolveTelemetryReady()
134
143
  }
144
+ } else {
145
+ resolveTelemetryReady()
135
146
  }
136
147
  }
137
148
 
138
- try {
139
- main()
140
- } catch (e) {
149
+ main().catch(e => {
141
150
  debuglog('Error in main %o', e)
142
- }
151
+ // Always resolve the promise even on error to prevent hanging
152
+ resolveTelemetryReady()
153
+ })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platformatic/telemetry",
3
- "version": "3.13.1",
3
+ "version": "3.15.0",
4
4
  "description": "OpenTelemetry integration for Platformatic",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -36,7 +36,7 @@
36
36
  "@opentelemetry/semantic-conventions": "1.36.0",
37
37
  "fast-uri": "^3.0.6",
38
38
  "fastify-plugin": "^5.0.1",
39
- "@platformatic/foundation": "3.13.1"
39
+ "@platformatic/foundation": "3.15.0"
40
40
  },
41
41
  "engines": {
42
42
  "node": ">=22.19.0"