FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

feat(worker): add optional metrics_headers param to AgentexWorker and get_temporal_client by alvinkam2001 · Pull Request #501 · scaleapi/scale-agentex-python · GitHub

feat(worker): add optional metrics_headers param to AgentexWorker and get_temporal_client - #501

Open
alvinkam2001 wants to merge 2 commits into
nextfrom
akam/temporal-metrics-headers
Open

feat(worker): add optional metrics_headers param to AgentexWorker and get_temporal_client#501
alvinkam2001 wants to merge 2 commits into
nextfrom
akam/temporal-metrics-headers

Conversation

alvinkam2001 commented Aug 25, 2026
edited by greptile-apps Bot
Loading

Copy link
Copy Markdown
Contributor

Problem

Temporal SDK internal metrics (workflow task latency, activity schedule-to-start latency, worker slot availability, sticky cache hit/miss rate, etc.) are emitted by the Temporal Rust bridge via OTLP. AgentexWorker already exposed a metrics_url parameter to configure the export endpoint, but had no way to pass authentication headers — making it impossible to export to backends that require them.

Rocket context

Rocket's SGP deployment uses Dynatrace (not the standard LGTM stack) for metrics and performance monitoring. Dynatrace OneAgent is injected into every pod via CSI driver and automatically provides two env vars:

  • OTEL_EXPORTER_OTLP_ENDPOINT — the DT SaaS OTLP endpoint (https://<env>.live.dynatrace.com/api/v2/otlp)
  • DT_API_TOKEN — an API token scoped for OTLP ingest

Application-level OTel (traces + custom metrics) already flows to Dynatrace via init_opentelemetry() which reads these env vars. Temporal SDK internal metrics were the only signal not reaching Dynatrace — specifically because the Rust bridge's OpenTelemetryConfig requires auth headers to be passed explicitly and there was no way to thread them through AgentexWorker.

Change

Adds an optional metrics_headers parameter to both AgentexWorker and get_temporal_client, passed through to OpenTelemetryConfig.headers in the Temporal runtime.

Behavior

  • metrics_headers=None (default): identical to current behavior, no impact on existing deployments
  • metrics_headers={...}: headers are forwarded to the Rust bridge's OTel exporter alongside metrics_url

Usage

worker = AgentexWorker(
    task_queue=task_queue_name,
    metrics_url=f"{os.environ['OTEL_EXPORTER_OTLP_ENDPOINT']}/v1/metrics",
    metrics_headers={"Authorization": f"Api-Token {os.environ['DT_API_TOKEN']}"},
)

Once wired up on the caller side, metrics like temporal_workflow_task_execution_latency, temporal_activity_schedule_to_start_latency, and temporal_worker_task_slots_available will appear in Dynatrace alongside the existing application traces.

Greptile Summary

The PR adds optional authentication headers for Temporal SDK OTLP metric exports while preserving existing positional API compatibility.

  • Appends metrics_headers to both public call signatures.
  • Forwards worker-supplied headers into OpenTelemetryConfig.
  • Leaves existing behavior unchanged when no headers are supplied.

Confidence Score: 5/5

The PR appears safe to merge.

The previously reported positional compatibility issue is fixed by appending the new parameter after all existing parameters, and no blocking failure remains.

Important Files Changed

Filename Overview
src/agentex/lib/core/temporal/workers/worker.py Adds optional OTLP metrics headers at the end of both signatures and forwards them through the worker startup path without retaining the previously reported positional-binding break.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart LR
    A[AgentexWorker metrics_headers] --> B[get_temporal_client]
    B --> C[OpenTelemetryConfig headers]
    C --> D[Temporal OTLP metrics exporter]
Loading

Reviews (2): Last reviewed commit: "fix param ordering" | Re-trigger Greptile

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant


Back | FazBrowse Home | New Git URL