Commit a0e8d58b authored by Bob Van Landuyt's avatar Bob Van Landuyt 💬
Browse files

Merge branch 'handle_non_matching_key' into 'master'

Resolve "Handle when redis key starts with {"

See merge request gitlab-org/labkit-ruby!33
parents fdbdf500 26b13d33
Loading
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -8,7 +8,7 @@ module Labkit
      # RedisInterceptorHelper is a helper for the RedisInterceptor. This is not a public API
      class RedisInterceptorHelper
        # For optimization, compile this once
        MASK_REDIS_RE = /^([\w-]+(?:\W+[\w-]+(?:\W+[\w-]+)?)?)(.?)/.freeze
        MASK_REDIS_RE = /^([\w{}-]+(?:\W+[\w{}-]+(?:\W+[\w{}-]+)?)?)(.?)/.freeze

        def self.call_with_tracing(command, client)
          Labkit::Tracing::TracingUtils.with_tracing(operation_name: "redis.call", tags: tags_from_command(command, client)) do |_span|
@@ -99,6 +99,7 @@ module Labkit
          return "" if argument.empty?

          matches = argument.match(MASK_REDIS_RE)

          matches[2].empty? ? matches[0] : matches[0] + "*****"
        end
        private_class_method :mask_redis_arg
+2 −0
Original line number Diff line number Diff line
@@ -43,6 +43,7 @@ describe Labkit::Tracing::Redis::RedisInterceptorHelper do
      %w(GET a:b) | "GET a:b"
      %w(GET a:b:c) | "GET a:b:c"
      %w(GET a:b:c:d) | "GET a:b:c:*****"
      %w(GET {keyhashtag}:{another}test:{third}:{four}l) | "GET {keyhashtag}:{another}test:{third}:*****"
      %w(GET users/key-count-service/12345) | "GET users/key-count-service/12345"
      %w(GET project_#123_metrics_dashboard_/dashboards) | "GET project_#123_metrics_dashboard_/dashboards"
      %w(GET project_#123_metrics_dashboard_/dashboards/123) | "GET project_#123_metrics_dashboard_/dashboards/*****"
@@ -81,6 +82,7 @@ describe Labkit::Tracing::Redis::RedisInterceptorHelper do
      where(:commands, :commands_tags) do
        [] | []
        [%w(GET moo)] | ["GET moo"]
        [%w(GET {keyhashtag}:{another}test:{third}:{four}l)] | ["GET {keyhashtag}:{another}test:{third}:*****"]
        [%w(GET moo), %w(SET moo)] | ["GET moo", "SET moo"]
        [%w(GET a:b:c), %w(SET a:b:c:d)] | ["GET a:b:c", "SET a:b:c:*****"]
      end