()
| 9 | export const temporalNamespace = "HASH"; |
| 10 | |
| 11 | export const createTemporalClient = async () => { |
| 12 | const temporalServerHost = getRequiredEnv("HASH_TEMPORAL_SERVER_HOST"); |
| 13 | |
| 14 | const host = new URL(temporalServerHost).hostname; |
| 15 | // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing -- we don't want an empty string |
| 16 | const port = parseInt(process.env.HASH_TEMPORAL_SERVER_PORT || "7233", 10); |
| 17 | |
| 18 | const connection = await Connection.connect({ |
| 19 | address: `${host}:${port}`, |
| 20 | }); |
| 21 | |
| 22 | // When OTEL is configured the active trace context (e.g. an Express |
| 23 | // HTTP span) is injected into workflow start headers. The worker-side |
| 24 | // interceptors extract it and parent the workflow + activity spans |
| 25 | // off the caller's trace. |
| 26 | const interceptors = process.env.HASH_OTLP_ENDPOINT |
| 27 | ? { |
| 28 | workflow: [ |
| 29 | new OpenTelemetryWorkflowClientInterceptor({ |
| 30 | tracer: trace.getTracer("@temporalio/interceptors-opentelemetry"), |
| 31 | }), |
| 32 | ], |
| 33 | } |
| 34 | : undefined; |
| 35 | |
| 36 | return new TemporalClient({ |
| 37 | connection, |
| 38 | namespace: temporalNamespace, |
| 39 | interceptors, |
| 40 | }); |
| 41 | }; |
no test coverage detected