Skip to content

Commit 3bb4cc1

Browse files
committed
bugsnag: propagate cloud_provider into contextual logging for queued executions
Adds CLOUD_PROVIDER_ANNOTATION_KEY to common_annotations so the annotation key has a single definition in the OSS layer. In the queued-execution processing span, reads the cloud_provider value from task_spec annotations (already in memory) and adds it to the contextual logging context when present. The existing _before_notify hook then includes it automatically in the tangle_context tab on every Bugsnag event raised during that execution's processing.
1 parent abe0fb0 commit 3bb4cc1

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

cloud_pipelines_backend/launchers/common_annotations.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
### TaskSpec annotations that are relevant to multiple launchers.
22

33
# Annotations added by the Orchestrator
4+
CLOUD_PROVIDER_ANNOTATION_KEY = "cloud-pipelines.net/orchestration/cloud_provider"
45
PIPELINE_RUN_CREATED_BY_ANNOTATION_KEY = (
56
"cloud-pipelines.net/orchestration/pipeline_run.created_by"
67
)

cloud_pipelines_backend/orchestrator_sql.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ def internal_process_queued_executions_queue(self, session: orm.Session):
131131
self._queued_executions_queue_idle = False
132132
start_timestamp = time.monotonic_ns()
133133

134-
with contextual_logging.logging_context(execution_id=queued_execution.id):
134+
with _execution_logging_context(queued_execution):
135135
_logger.info("Before processing queued execution")
136136
try:
137137
self.internal_process_one_queued_execution(
@@ -1051,6 +1051,18 @@ def _calculate_container_execution_cache_key(
10511051
return cache_key
10521052

10531053

1054+
def _execution_logging_context(execution: bts.ExecutionNode):
1055+
ctx: dict[str, typing.Any] = {"execution_id": execution.id}
1056+
cloud_provider = (
1057+
(execution.task_spec or {})
1058+
.get("annotations", {})
1059+
.get(common_annotations.CLOUD_PROVIDER_ANNOTATION_KEY)
1060+
)
1061+
if cloud_provider is not None:
1062+
ctx["cloud_provider"] = cloud_provider
1063+
return contextual_logging.logging_context(**ctx)
1064+
1065+
10541066
def _get_current_time() -> datetime.datetime:
10551067
return datetime.datetime.now(tz=datetime.timezone.utc)
10561068

0 commit comments

Comments
 (0)