SIENTIAPDE-1169

Enable SDK metrics service in values.yaml and update worker.py to initialize SDK metrics server with Prometheus configuration, enhancing observability of the application.
This commit is contained in:
vitor-aignosi
2025-08-18 13:45:20 -03:00
parent 4bbd937b7f
commit 9480495155
2 changed files with 31 additions and 12 deletions

View File

@@ -1,5 +1,6 @@
from temporalio import workflow, client from temporalio import workflow, client
from temporalio.worker import Worker from temporalio.worker import Worker
from temporalio.runtime import Runtime, TelemetryConfig, PrometheusConfig
with workflow.unsafe.imports_passed_through(): with workflow.unsafe.imports_passed_through():
import sys import sys
@@ -21,6 +22,7 @@ with workflow.unsafe.imports_passed_through():
) )
POD_ID = os.getenv("HOSTNAME", "localhost") POD_ID = os.getenv("HOSTNAME", "localhost")
SDK_METRICS_PORT = int(os.getenv('HTTP_SDK_METRICS_PORT', "9091"))
async def main(): async def main():
@@ -62,11 +64,21 @@ async def main():
'KAFKA_BOOTSTRAP_SERVERS', 'localhost:9092') 'KAFKA_BOOTSTRAP_SERVERS', 'localhost:9092')
) )
logger.info(f'Starting SDK Metrics Server on port {SDK_METRICS_PORT}...')
new_runtime = Runtime(
telemetry=TelemetryConfig(
metrics=PrometheusConfig(
bind_address=f"0.0.0.0:{SDK_METRICS_PORT}")
)
)
logger.info('Starting Temporal Client...') logger.info('Starting Temporal Client...')
temporal_client = await client.Client.connect( temporal_client = await client.Client.connect(
target_host=host, target_host=host,
namespace=os.getenv('TEMPORAL_NAMESPACE', 'default') namespace=os.getenv('TEMPORAL_NAMESPACE', 'laborious'),
runtime=new_runtime
) )
logger.info('Starting Workers...') logger.info('Starting Workers...')

View File

@@ -112,6 +112,13 @@ tolerations: []
affinity: {} affinity: {}
services: services:
sdk-metrics:
enabled: true
type: ClusterIP
port: 9091
targetPort: 9091
name: sdk-metrics
metrics: metrics:
enabled: true enabled: true
type: ClusterIP type: ClusterIP
@@ -125,18 +132,18 @@ serviceMonitor:
# Se true, um recurso ServiceMonitor será criado. # Se true, um recurso ServiceMonitor será criado.
enabled: true enabled: true
# O intervalo no qual as métricas devem ser coletadas (ex: 30s, 1m). # O intervalo no qual as métricas devem ser coletadas (ex: 30s, 1m).
interval: 30s endpoints:
# O path do endpoint de métricas na sua aplicação. - port: metrics
path: /metrics path: /metrics
# Labels adicionais para o recurso ServiceMonitor. interval: 30s
# Essencial para que o Prometheus Operator o descubra. Se você usa o helm chart kube-prometheus-stack, relabelings: []
# ele procura por ServiceMonitors com o label "release: kube-prometheus-stack". - port: sdk-metrics
path: /metrics
interval: 30s
relabelings: []
additionalLabels: additionalLabels:
release: kube-prometheus-stack release: kube-prometheus-stack
# Configurações de relabeling adicionais, se necessário.
# ref: https://prometheus.io/docs/prometheus/latest/configuration/configuration/#relabel_config
relabelings: []
port: metrics
env: env:
# Entrypoint variables # Entrypoint variables
@@ -217,7 +224,7 @@ ssh:
# kubectl create secret docker-registry docker-hub-secret --namespace sientia --docker-server=http://aignosi.azurecr.io --docker-username=aignosi --docker-password=5I5zpQ6sRaHqX1hD3dr+2mo647yO3FRc359/wu6gsP+ACRDRz5mp # kubectl create secret docker-registry docker-hub-secret --namespace sientia --docker-server=http://aignosi.azurecr.io --docker-username=aignosi --docker-password=5I5zpQ6sRaHqX1hD3dr+2mo647yO3FRc359/wu6gsP+ACRDRz5mp
# helm upgrade --install sientia-scouter-worker sientia/sientia-module -n sientia --create-namespace -f ./values.yaml --version 0.4.0 # helm upgrade --install sientia-scouter-worker sientia/sientia-module -n sientia --create-namespace -f ./values.yaml --version 0.5.0
# kubectl create secret generic git-ssh-key-sientia-scouter-worker \ # kubectl create secret generic git-ssh-key-sientia-scouter-worker \
# --namespace sientia \ # --namespace sientia \