Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions typescript/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
FROM node:lts AS builder
FROM node:18.16-bullseye-slim AS builder
USER node
WORKDIR /home/node/app
COPY --chown=node:node . .
RUN npm ci \
&& npm run build
CMD [ "npm", "run", "worker:watch" ]

FROM node:lts-slim
FROM node:18.16-bullseye-slim
WORKDIR /home/node/app
COPY --from=builder /home/node/app/lib lib
COPY --from=builder /home/node/app/package.json package.json
Expand Down
22 changes: 22 additions & 0 deletions typescript/compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,32 @@ services:
target: builder
environment:
TEMPORAL_ADDRESS: temporal:7233
OTEL_EXPORTER_OTLP_ENDPOINT: grpc://datadog-agent:4317
# Tag your metrics for dashboards & filters
OTEL_SERVICE_NAME: temporal-worker
OTEL_RESOURCE_ATTRIBUTES: deployment.environment=prod,service.version=1.2.3
# (Optional) if you also send traces via OTel SDKs, keep same endpoint
# OTEL_TRACES_EXPORTER: otlp
# OTEL_METRICS_EXPORTER: otlp
volumes:
- .:/home/node/app
links:
- temporal
depends_on:
datadog-agent:
condition: service_started
temporal:
condition: service_healthy

datadog-agent:
image: gcr.io/datadoghq/agent:latest
environment:
DD_API_KEY: ${DD_API_KEY} # set in your shell or .env
DD_SITE: datadoghq.com # or datadoghq.com, us3, us5, etc.
# Enable OTLP receiver on HTTP 4318 (or use GRPC 4317, see below)
DD_OTLP_CONFIG_RECEIVER_PROTOCOLS_GRPC_ENDPOINT: "0.0.0.0:4317"
# Optional: enable logs ingest via OTLP if you also send logs
# DD_LOGS_ENABLED: "true"
# DD_OTLP_CONFIG_LOGS_ENABLED: "true"
ports:
- 4317:4317
89 changes: 89 additions & 0 deletions typescript/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"dependencies": {
"@temporalio/activity": "^1.13.0",
"@temporalio/client": "^1.13.0",
"@temporalio/interceptors-opentelemetry": "^1.13.0",
"@temporalio/worker": "^1.13.0",
"@temporalio/workflow": "^1.13.0",
"nanoid": "^5.1.5"
Expand Down
33 changes: 32 additions & 1 deletion typescript/src/worker.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,29 @@
import { NativeConnection, Worker } from '@temporalio/worker';
import {
OpenTelemetryActivityInboundInterceptor,
OpenTelemetryActivityOutboundInterceptor,
} from '@temporalio/interceptors-opentelemetry';
import {
NativeConnection,
Runtime,
Worker,
bundleWorkflowCode,

Check failure on line 9 in typescript/src/worker.ts

View workflow job for this annotation

GitHub Actions / test

'bundleWorkflowCode' is defined but never used
} from '@temporalio/worker';

import { createActivities } from './activities';
import { TASK_QUEUE_NAME } from './shared';

async function run() {
Runtime.install({
telemetryOptions: {
metrics: {
otel: {
url: process.env.OTEL_EXPORTER_OTLP_ENDPOINT ?? '',
temporality: 'delta',
},
},
},
});

const connection = await NativeConnection.connect({
address: process.env.TEMPORAL_ADDRESS,
tls: process.env.TEMPORAL_TLS === 'true',
Expand All @@ -18,8 +38,19 @@
taskQueue: TASK_QUEUE_NAME,
// Workflows are registered using a path as they run in a separate JS context.
workflowsPath: require.resolve('./workflows'),
// workflowBundle: await bundleWorkflowCode({
// workflowsPath: require.resolve('./workflows'),
// }),
// Register the activities - you may need to inject dependencies in here
activities: createActivities(),
interceptors: {
activity: [
(ctx) => ({
inbound: new OpenTelemetryActivityInboundInterceptor(ctx),
outbound: new OpenTelemetryActivityOutboundInterceptor(ctx),
}),
],
},
});

await worker.run();
Expand Down
Loading