Skip to content

Commit

Permalink
WCM-690: Record event type and uuid for tracing in webhooks (brightco…
Browse files Browse the repository at this point in the history
…ve, simplecast, speechbert)
  • Loading branch information
wosc committed Feb 3, 2025
1 parent ec2053e commit 58d596f
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 1 deletion.
1 change: 1 addition & 0 deletions core/docs/changelog/WCM-690.change
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
WCM-690: Record event type and uuid for tracing in webhooks (brightcove, simplecast, speechbert)
3 changes: 3 additions & 0 deletions core/src/zeit/brightcove/json/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ def __call__(self):
data = json.loads(body)
if data.get('event') != 'video-change' or not data.get('video'):
return
current_span.set_attributes(
{'app.event_type': data['event'], 'app.external_id': data['video']}
)

own_apikey = zeit.cms.config.required('zeit.brightcove', 'client-email')
origin = data.get('updated_by', {})
Expand Down
8 changes: 7 additions & 1 deletion core/src/zeit/simplecast/json/webhook.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,13 @@ def __call__(self):
self.execute_task(data)

current_span = opentelemetry.trace.get_current_span()
current_span.set_attributes({'http.body': body})
current_span.set_attributes(
{
'http.body': body,
'app.event_type': data.get('event', ''),
'app.external_id': data.get('episode_id'),
}
)

def execute_task(self, data: dict):
SIMPLECAST_WEBHOOK_TASK.delay(data, _principal_id_=self._principal)
Expand Down
7 changes: 7 additions & 0 deletions core/src/zeit/speech/json/webhook.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@ def __call__(self):
except InvalidSpeechMessageError as e:
self.request.response.setStatus(400, e)
return
current_span.set_attributes(
{
'app.event_type': payload['event'],
'app.uuid': payload.get('uuid') or payload.get('article_uuid'),
}
)

self.execute_task(payload)

def execute_task(self, payload: dict):
Expand Down

0 comments on commit 58d596f

Please sign in to comment.