diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-11-18 16:16:36 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-11-18 16:16:36 +0300 |
commit | 311b0269b4eb9839fa63f80c8d7a58f32b8138a0 (patch) | |
tree | 07e7870bca8aed6d61fdcc810731c50d2c40af47 /lib/gitlab/instrumentation | |
parent | 27909cef6c4170ed9205afa7426b8d3de47cbb0c (diff) |
Add latest changes from gitlab-org/gitlab@14-5-stable-eev14.5.0-rc42
Diffstat (limited to 'lib/gitlab/instrumentation')
-rw-r--r-- | lib/gitlab/instrumentation/redis_interceptor.rb | 15 | ||||
-rw-r--r-- | lib/gitlab/instrumentation/uploads.rb | 32 |
2 files changed, 32 insertions, 15 deletions
diff --git a/lib/gitlab/instrumentation/redis_interceptor.rb b/lib/gitlab/instrumentation/redis_interceptor.rb index ba25e54ac9f..14474693ddf 100644 --- a/lib/gitlab/instrumentation/redis_interceptor.rb +++ b/lib/gitlab/instrumentation/redis_interceptor.rb @@ -5,10 +5,6 @@ module Gitlab module RedisInterceptor APDEX_EXCLUDE = %w[brpop blpop brpoplpush bzpopmin bzpopmax xread xreadgroup].freeze - # These are temporary to help with investigating - # https://gitlab.com/gitlab-com/gl-infra/scalability/-/issues/1183 - DURATION_ERROR_THRESHOLD = 1.25.seconds - class MysteryRedisDurationError < StandardError attr_reader :backtrace @@ -19,7 +15,6 @@ module Gitlab def call(*args, &block) start = Gitlab::Metrics::System.monotonic_time # must come first so that 'start' is always defined - start_real_time = Time.now instrumentation_class.instance_count_request instrumentation_class.redis_cluster_validate!(args.first) @@ -40,16 +35,6 @@ module Gitlab instrumentation_class.add_duration(duration) instrumentation_class.add_call_details(duration, args) end - - if duration > DURATION_ERROR_THRESHOLD && - instrumentation_class == ::Gitlab::Instrumentation::Redis::SharedState && - Feature.enabled?(:report_on_long_redis_durations, default_enabled: :yaml) - - Gitlab::ErrorTracking.track_exception(MysteryRedisDurationError.new(caller), - command: command_from_args(args), - duration: duration, - timestamp: start_real_time.iso8601(5)) - end end def write(command) diff --git a/lib/gitlab/instrumentation/uploads.rb b/lib/gitlab/instrumentation/uploads.rb new file mode 100644 index 00000000000..02e457453cd --- /dev/null +++ b/lib/gitlab/instrumentation/uploads.rb @@ -0,0 +1,32 @@ +# frozen_string_literal: true + +module Gitlab + module Instrumentation + class Uploads + UPLOAD_DURATION = :uploaded_file_upload_duration_s + UPLOADED_FILE_SIZE = :uploaded_file_size_bytes + + def self.track(uploaded_file) + if ::Gitlab::SafeRequestStore.active? + ::Gitlab::SafeRequestStore[UPLOAD_DURATION] = uploaded_file.upload_duration + ::Gitlab::SafeRequestStore[UPLOADED_FILE_SIZE] = uploaded_file.size + end + end + + def self.get_upload_duration + ::Gitlab::SafeRequestStore[UPLOAD_DURATION] + end + + def self.get_uploaded_file_size + ::Gitlab::SafeRequestStore[UPLOADED_FILE_SIZE] + end + + def self.payload + { + UPLOAD_DURATION => get_upload_duration, + UPLOADED_FILE_SIZE => get_uploaded_file_size + }.compact + end + end + end +end |