Skip to content

Commit

Permalink
feat(backend): enable tracing for task workers
Browse files Browse the repository at this point in the history
This was previously enabled on git agents but got removed during the
transition to task workers.
Prefect 3.1 also adds instrumentation to workflow runs.

Signed-off-by: Fatih Acar <[email protected]>
  • Loading branch information
fatih-acar committed Jan 21, 2025
1 parent 7fb484e commit 527d418
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions backend/infrahub/workers/infrahub_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
from infrahub.services.adapters.workflow import InfrahubWorkflow
from infrahub.services.adapters.workflow.local import WorkflowLocalExecution
from infrahub.services.adapters.workflow.worker import WorkflowWorkerExecution
from infrahub.trace import configure_trace
from infrahub.workers.utils import inject_service_parameter, load_flow_function
from infrahub.workflows.models import TASK_RESULT_STORAGE_NAME

Expand Down Expand Up @@ -90,6 +91,16 @@ async def setup(

self._init_logger()

# Initialize trace
if config.SETTINGS.trace.enable:
configure_trace(
service="infrahub-task-worker",
version=infrahub_version,
exporter_type=config.SETTINGS.trace.exporter_type,
exporter_endpoint=config.SETTINGS.trace.exporter_endpoint,
exporter_protocol=config.SETTINGS.trace.exporter_protocol,
)

# Start metric endpoint
if metric_port is None or metric_port != 0:
metric_port = metric_port or int(os.environ.get("INFRAHUB_METRICS_PORT", 8000))
Expand Down

0 comments on commit 527d418

Please sign in to comment.