-
Hartley McGuire authored
Previously, the `Cache::Store` instrumentation would call `normalize_key` when adding a key to the log. However, this resulted in the logged key not always matching the actual key written/read from the cache: ```irb irb(main):004> cache.write("foo", "bar", namespace: "baz") D, [2023-11-10T12:44:59.286362 #169586] DEBUG -- : Cache write: baz:foo ({:compress=>false, :compress_threshold=>1024, :namespace=>"baz"}) => true irb(main):005> cache.delete("foo", namespace: "baz") D, [2023-11-10T12:45:03.071300 #169586] DEBUG -- : Cache delete: foo => true ``` In this example, `#write` would correctly log that the key written to was `baz:foo` because the `namespace` option would be passed to the `instrument` method. However, other methods like `#delete` would log that the `foo` key was deleted because the `namespace` option was _not_ passed to `instrument`. This commit fixes the issue by making the caller responsible for passing the correct key to `#instrument`. This allows `normalize_key` to be removed from the log generation which both prevents the key from being normalized a second time and removes the need to pass the full options hash into `#instrument`. Co-authored-by:
Jonathan Hefner <jonathan@hefner.pro>
Hartley McGuire authoredPreviously, the `Cache::Store` instrumentation would call `normalize_key` when adding a key to the log. However, this resulted in the logged key not always matching the actual key written/read from the cache: ```irb irb(main):004> cache.write("foo", "bar", namespace: "baz") D, [2023-11-10T12:44:59.286362 #169586] DEBUG -- : Cache write: baz:foo ({:compress=>false, :compress_threshold=>1024, :namespace=>"baz"}) => true irb(main):005> cache.delete("foo", namespace: "baz") D, [2023-11-10T12:45:03.071300 #169586] DEBUG -- : Cache delete: foo => true ``` In this example, `#write` would correctly log that the key written to was `baz:foo` because the `namespace` option would be passed to the `instrument` method. However, other methods like `#delete` would log that the `foo` key was deleted because the `namespace` option was _not_ passed to `instrument`. This commit fixes the issue by making the caller responsible for passing the correct key to `#instrument`. This allows `normalize_key` to be removed from the log generation which both prevents the key from being normalized a second time and removes the need to pass the full options hash into `#instrument`. Co-authored-by:
Jonathan Hefner <jonathan@hefner.pro>
Loading