Skip to content

Commit 512408c

Browse files
committed
add transaction name to tags
1 parent 8efde86 commit 512408c

File tree

2 files changed

+23
-6
lines changed

2 files changed

+23
-6
lines changed

sentry-ruby/lib/sentry/metrics/aggregator.rb

+18-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def add(type,
4949
# and buckets into 10 second intervals
5050
bucket_timestamp = (timestamp / ROLLUP_IN_SECONDS) * ROLLUP_IN_SECONDS
5151

52-
serialized_tags = serialize_tags(tags.merge(@default_tags))
52+
serialized_tags = serialize_tags(get_updated_tags(tags))
5353
bucket_key = [type, key, unit, serialized_tags]
5454

5555
@mutex.synchronize do
@@ -161,6 +161,23 @@ def sanitize_key(key)
161161
def sanitize_value(value)
162162
value.gsub(VALUE_SANITIZATION_REGEX, '')
163163
end
164+
165+
def get_transaction_name
166+
transaction = Sentry.get_current_scope&.get_transaction
167+
return nil unless transaction
168+
return nil if transaction.source_low_quality?
169+
170+
transaction.name
171+
end
172+
173+
def get_updated_tags(tags)
174+
updated_tags = @default_tags.merge(tags)
175+
176+
transaction_name = get_transaction_name
177+
updated_tags['transaction'] = transaction_name if transaction_name
178+
179+
updated_tags
180+
end
164181
end
165182
end
166183
end

sentry-ruby/lib/sentry/transaction.rb

+5-5
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,11 @@ def start_profiler!
302302
profiler.start
303303
end
304304

305+
# These are high cardinality and thus bad
306+
def source_low_quality?
307+
source == :url
308+
end
309+
305310
protected
306311

307312
def init_span_recorder(limit = 1000)
@@ -337,11 +342,6 @@ def populate_head_baggage
337342
@baggage = Baggage.new(items, mutable: false)
338343
end
339344

340-
# These are high cardinality and thus bad
341-
def source_low_quality?
342-
source == :url
343-
end
344-
345345
class SpanRecorder
346346
attr_reader :max_length, :spans
347347

0 commit comments

Comments
 (0)