Skip to content

Commit d92a080

Browse files
committed
Remove the possibility of KeyError exception being thrown if rw.environment is truthy but ID isn't present
1 parent 4202c21 commit d92a080

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

src/workflows/recipe/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ def unwrap_recipe(header, message):
7272
message = mangle_for_receiving(message)
7373
if header.get("workflows-recipe") in {True, "True", "true", 1}:
7474
rw = RecipeWrapper(message=message, transport=transport_layer)
75-
76-
if log_extender and rw.environment["ID"]:
75+
76+
if log_extender and rw.environment.get("ID"):
7777
# Extract recipe ID from environment and add to current span
7878
span = trace.get_current_span()
7979
recipe_id = rw.environment["ID"]

src/workflows/services/common_service.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -194,12 +194,8 @@ def start_transport(self):
194194
)
195195

196196
# Configure OTELTracing if configuration is available
197-
otel_config = (
198-
self.config._opentelemetry
199-
if self.config and hasattr(self.config, "_opentelemetry")
200-
else None
201-
)
202-
if otel_config:
197+
otel_config = getattr(self.config, "_opentelemetry", None)
198+
if otel_config and self.transport.connect:
203199
# Configure OTELTracing
204200
resource = Resource.create(
205201
{

0 commit comments

Comments
 (0)