summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorYorick Peterse <yorickpeterse@gmail.com>2016-04-12 12:00:21 +0200
committerYorick Peterse <yorickpeterse@gmail.com>2016-04-13 11:22:37 +0200
commit3240ecfbefc7ae5994be6ef01b52c1cbdaa09057 (patch)
tree9689a2b2aa878947478681182030f0a29cc16dd9 /lib
parent8ea6c6d80c0942e0f2caee3caa0cd7503e51d45d (diff)
downloadgitlab-ce-3240ecfbefc7ae5994be6ef01b52c1cbdaa09057.tar.gz
Added ability to add custom tags to transactions
One use case for this is manually setting the "action" tag for Grape API calls. Due to Grape running blocks there are no human readable method names that can be used for the "action" tag, thus we have to set these manually on a case by case basis.
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/metrics.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/gitlab/metrics.rb b/lib/gitlab/metrics.rb
index 2a0a5629be5..484970c5a10 100644
--- a/lib/gitlab/metrics.rb
+++ b/lib/gitlab/metrics.rb
@@ -104,6 +104,16 @@ module Gitlab
retval
end
+ # Adds a tag to the current transaction (if any)
+ #
+ # name - The name of the tag to add.
+ # value - The value of the tag.
+ def self.tag_transaction(name, value)
+ trans = current_transaction
+
+ trans.add_tag(name, value) if trans
+ end
+
# When enabled this should be set before being used as the usual pattern
# "@foo ||= bar" is _not_ thread-safe.
if enabled?