inst-jobs-statsd 1.2.2 → 1.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f299ba77daf29bef9b9a2f8f52710fd23029d3f122d723ec8c19518389ba10cf
4
- data.tar.gz: 38df7c0062ee2c19622e19e24377d853e05c55eb3d59253f470fb40668afb2c1
3
+ metadata.gz: b3de8c2ebb6a0209eece2b69f072091c760908020c2957334e34303dcf209305
4
+ data.tar.gz: 5fb37614c812c728b8448f447597d1b4b6d9c7f6856cdb5052ea36ea3d47cb40
5
5
  SHA512:
6
- metadata.gz: f45e0aea9f8e01b3e592754fd596d03a1123d74958803f3b6250964adbaa132fe1d5467fad6a9ac330b68f9df0225e9a1851662a08f29834d769d5020c3b3c47
7
- data.tar.gz: a1376daa61d0e4db5911c707dc2524af23fabca7788ee626cbfa7d0ca06fd6f77003d7ea2cbda9acff13bd4c0283f52f89ba4b3d64d9608a4a921db2eff96811
6
+ metadata.gz: 912a311942077658bed03600aa01cc2c5fd114ec381a04b38173a1573d1c956f5a76fdebdc2ff5b26707fe1ba4b0039748b225ce4647c7b0291849dbd8d7f980
7
+ data.tar.gz: e1ee70af317c0a531fb005be42541b5cb4a1813afa5d1d275314eb7bd1873e00edd07989fa546453b86786034952f01cdb5eeeed77272e79d404b34afe007170
@@ -8,6 +8,10 @@ module InstJobsStatsd
8
8
  BASENAME
9
9
  end
10
10
 
11
+ def self.configure(strand_filter: nil)
12
+ @strand_filter = strand_filter
13
+ end
14
+
11
15
  def self.qualified_names(stat_name, job)
12
16
  names = ["#{basename}.#{stat_name}"]
13
17
  tagged = tagged_stat(names[0], job)
@@ -31,14 +35,22 @@ module InstJobsStatsd
31
35
  end
32
36
 
33
37
  def self.dd_job_tags(job)
34
- return {} unless job
35
- return {} unless job.tag
36
- return {} if job.tag =~ /Class:0x/
38
+ tags = dd_region_tags
39
+ return tags unless job
40
+ tags = custom_tags(job, tags)
41
+ return tags unless job.tag
42
+ return tags if job.tag =~ /Class:0x/
37
43
 
38
44
  method_tag, obj_tag = split_to_tag(job)
39
45
  tag = obj_tag
40
46
  tag = [obj_tag, method_tag].join('.') if method_tag.present?
41
- {tag: tag}
47
+ tags[:tag] = tag
48
+ end
49
+
50
+ def self.custom_tags(job, tags)
51
+ tags[:jobshard] = job.shard.id if job.respond_to?(:shard)
52
+ tags[:strand] = job.strand if job&.strand && @strand_filter&.call(job)
53
+ tags
42
54
  end
43
55
 
44
56
  # this converts Foo#bar" or "Foo.bar" into "Foo and "bar",
@@ -67,6 +79,11 @@ module InstJobsStatsd
67
79
  end
68
80
  end
69
81
 
82
+ def self.dd_region_tags
83
+ return {} unless ENV['INST_JOBS_STATSD_NAMESPACE']
84
+ {namespace: ENV['INST_JOBS_STATSD_NAMESPACE']}
85
+ end
86
+
70
87
  private
71
88
 
72
89
  def self.split_to_tag(job)
@@ -1,3 +1,3 @@
1
1
  module InstJobsStatsd
2
- VERSION = '1.2.2'.freeze
2
+ VERSION = '1.2.3'.freeze
3
3
  end
@@ -1,6 +1,6 @@
1
1
  FactoryGirl.define do
2
2
  class JobFixture
3
- attr_accessor :tag, :run_at
3
+ attr_accessor :tag, :run_at, :strand
4
4
  end
5
5
 
6
6
  factory :job_fixture, aliases: [:job] do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: inst-jobs-statsd
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.2
4
+ version: 1.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Slade
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-02-25 00:00:00.000000000 Z
11
+ date: 2019-03-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: inst-jobs