mirror of
https://github.com/mastodon/mastodon.git
synced 2026-08-17 14:18:24 -05:00
19 lines
570 B
Ruby
19 lines
570 B
Ruby
# frozen_string_literal: true
|
|
|
|
module ActivityPub::OpenTelemetry
|
|
def self.decorate_current_span(payload:, namespace: 'activity')
|
|
decorate_span(span: OpenTelemetry::Trace.current_span, payload:, namespace:)
|
|
end
|
|
|
|
def self.decorate_span(span:, payload:, namespace: 'activity')
|
|
return unless span.recording?
|
|
return unless payload.is_a?(Hash)
|
|
|
|
id = payload['id']
|
|
type = payload['type']
|
|
|
|
span.set_attribute("activitypub.#{namespace}.id", id) if id.present?
|
|
span.set_attribute("activitypub.#{namespace}.type", type) if type.present?
|
|
end
|
|
end
|