appydays 0.10.0 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d460b440b0d1e096ac8d1aa9d21da1b8de8b0147ae1698f65242a9d047db7f9b
4
- data.tar.gz: bb73da0a0a8dac1afd63ff66ff25427736f79e2ac3e6f16757a8643b04385885
3
+ metadata.gz: f7233dee300e207e49803a368896ad6b098641db88b703d54860002055609826
4
+ data.tar.gz: 8c1d7694c1ab1695526676690900f1d5d12facee1adb4b3a823d409af22606a2
5
5
  SHA512:
6
- metadata.gz: 645fcf14b44cf77ac41ad813b61be5fd0ffb957ed920e068d5bc277372a4b6aba567ed4a86e3017fbfbc76dba1eb3d9315fb5ade7fe4a412cf7903dfbbe8aec7
7
- data.tar.gz: 1b551951f4dca1bf41bebadbc0b2f49e84b7bd5a2e2797e8822e953e621624c95fd4db12605a3ae5093a99d7968416de928b94319147feda2bb785f4117ecdff
6
+ metadata.gz: b45d24f4ae6769ea2bd3b42b2985c404339d6b74238c33ae15d3413d8b04088137442dc4a62710b9ed8fdc215bc1bc98f2f91c14c6370550034e5a24a2b992f5
7
+ data.tar.gz: 27ac2dc1b1ee65373c807518df6a4cb0e2038b65f6ccababc20ba89a2b3cc3bd5a1042e06c838f69ebaa054f8c88ef6e4ce42e8e61a2be063aaad61a48989020
@@ -43,11 +43,13 @@ class Appydays::Loggable::SidekiqJobLogger < Sidekiq::JobLogger
43
43
  yield
44
44
  duration = self.elapsed(start)
45
45
  log_method = duration >= self.slow_job_seconds ? :warn : :info
46
- self.logger.send(log_method, "job_done", duration: duration * 1000)
46
+ self.logger.send(log_method, "job_done", duration: duration * 1000, **self.class.job_tags)
47
47
  rescue StandardError
48
48
  # Do not log the error since it is probably a sidekiq retry error
49
- self.logger.error("job_fail", duration: self.elapsed(start) * 1000)
49
+ self.logger.error("job_fail", duration: self.elapsed(start) * 1000, **self.class.job_tags)
50
50
  raise
51
+ ensure
52
+ self.class.job_tags.clear
51
53
  end
52
54
 
53
55
  protected def elapsed(start)
@@ -58,6 +60,18 @@ class Appydays::Loggable::SidekiqJobLogger < Sidekiq::JobLogger
58
60
  return ::Process.clock_gettime(::Process::CLOCK_MONOTONIC)
59
61
  end
60
62
 
63
+ # Set job tags that get logged out in the "job_done" and "job_fail" messages.
64
+ # See README for more info.
65
+ # We do NOT merge the job_tags in with critical errors (death and job_error),
66
+ # since those will log the job args, and they aren't properly tested right now.
67
+ # We may add support in the future.
68
+ def self.set_job_tags(**tags)
69
+ Thread.current[:appydays_sidekiq_job_logger_job_tags] ||= {}
70
+ Thread.current[:appydays_sidekiq_job_logger_job_tags].merge!(tags)
71
+ end
72
+
73
+ def self.job_tags = Thread.current[:appydays_sidekiq_job_logger_job_tags] || {}
74
+
61
75
  def self.error_handler(ex, ctx)
62
76
  # ctx looks like:
63
77
  # {
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Appydays
4
- VERSION = "0.10.0"
4
+ VERSION = "0.11.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: appydays
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0
4
+ version: 0.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lithic Tech
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-09-02 00:00:00.000000000 Z
11
+ date: 2024-10-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dotenv