Skip to content

Commit 6f879c0

Browse files
enable metrics for harness worker
1 parent 1220a9e commit 6f879c0

4 files changed

Lines changed: 35 additions & 4 deletions

File tree

harness/README.md

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,32 @@ docker run -d \
4848
python-sdk-harness
4949
```
5050
51-
You can also run the harness locally without Docker (from the repo root):
51+
You can also run the harness locally without Docker (from the repo root).
52+
A virtual environment keeps dependencies isolated from your system Python:
5253

5354
```bash
54-
# Install the SDK in development mode (one-time)
55+
# Check if a .venv already exists
56+
ls .venv/bin/activate 2>/dev/null && echo "venv exists" || echo "no venv found"
57+
58+
# Create one if needed (one-time)
59+
python3 -m venv .venv
60+
61+
# Activate it (required every time you open a new terminal)
62+
source .venv/bin/activate # Windows: .venv\Scripts\activate
63+
64+
# Verify you're in the venv (should print the .venv path)
65+
which python3
66+
67+
# Install the SDK in development mode (one-time, or after pulling new deps)
5568
pip3 install -e .
5669

70+
# When you're done, deactivate the venv to restore your normal shell
71+
deactivate
72+
```
73+
74+
Once the venv is active and the SDK is installed:
75+
76+
```bash
5777
export CONDUCTOR_SERVER_URL=https://your-cluster.example.com/api
5878
export CONDUCTOR_AUTH_KEY=$CONDUCTOR_AUTH_KEY
5979
export CONDUCTOR_AUTH_SECRET=$CONDUCTOR_AUTH_SECRET

harness/main.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
from conductor.client.automator.task_handler import TaskHandler
88
from conductor.client.configuration.configuration import Configuration
9+
from conductor.client.configuration.settings.metrics_settings import MetricsSettings
910
from conductor.client.http.models.task_def import TaskDef
1011
from conductor.client.orkes_clients import OrkesClients
1112
from conductor.client.workflow.conductor_workflow import ConductorWorkflow
@@ -79,10 +80,15 @@ def main() -> None:
7980
worker = SimulatedTaskWorker(task_name, codename, sleep_seconds, batch_size, poll_interval_ms)
8081
workers.append(worker)
8182

83+
metrics_port = env_int_or_default("HARNESS_METRICS_PORT", 9991)
84+
metrics_settings = MetricsSettings(http_port=metrics_port)
85+
print(f"Prometheus metrics will be served on port {metrics_port}")
86+
8287
task_handler = TaskHandler(
8388
workers=workers,
8489
configuration=configuration,
8590
scan_for_annotated_workers=False,
91+
metrics_settings=metrics_settings,
8692
)
8793

8894
workflow_executor = clients.get_workflow_executor()

harness/manifests/configmap-gcp.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ metadata:
99
labels:
1010
app: python-sdk-harness-worker
1111
data:
12-
CONDUCTOR_SERVER_URL: "https://certification-gcp.orkesconductor.com/api"
13-
CONDUCTOR_AUTH_KEY: "e6c1ac61-286b-11f1-be01-c682b5750c3a"
12+
CONDUCTOR_SERVER_URL: "https://certification-gcp.orkesconductor.io/api"
13+
CONDUCTOR_AUTH_KEY: "25b681c1-34ec-11f1-b07a-9601c7a63373"

harness/manifests/deployment.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ spec:
5151
- name: HARNESS_POLL_INTERVAL_MS
5252
value: "100"
5353

54+
ports:
55+
- name: metrics
56+
containerPort: 9991
57+
protocol: TCP
58+
5459
resources:
5560
requests:
5661
memory: "256Mi"

0 commit comments

Comments
 (0)