Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYorick Peterse <yorickpeterse@gmail.com>2016-04-12 13:00:21 +0300
committerYorick Peterse <yorickpeterse@gmail.com>2016-04-13 12:22:37 +0300
commit3240ecfbefc7ae5994be6ef01b52c1cbdaa09057 (patch)
tree9689a2b2aa878947478681182030f0a29cc16dd9 /lib/gitlab/metrics.rb
parent8ea6c6d80c0942e0f2caee3caa0cd7503e51d45d (diff)
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/gitlab/metrics.rb')
-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?