Module: InstJobsStatsd::Naming
- Defined in:
- lib/inst_jobs_statsd/naming.rb
Constant Summary collapse
- BASENAME =
'delayedjob'.freeze
Class Method Summary collapse
-
.basename ⇒ Object
The root prefix for all stat names TODO: Make this configurable.
- .configure(strand_filter: nil) ⇒ Object
- .custom_tags(job, tags) ⇒ Object
- .dd_job_tags(job) ⇒ Object
- .dd_region_tags ⇒ Object
-
.job_tags(job) ⇒ Object
this converts Foo#bar“ or ”Foo.bar“ into ”Foo and “bar”, and makes sure the values are valid to be used for statsd names.
- .qualified_names(stat_name, job) ⇒ Object
-
.region_tags(stat_names) ⇒ Object
We are using all existing stat names here because we do not want to break existing dependencies on the non-regioned data.
-
.tagged_stat(stat_name, job) ⇒ Object
Given a stat name, add a suffix to it to make it unique per job type – using the job’s class name and method name as appropriate.
Class Method Details
.basename ⇒ Object
The root prefix for all stat names TODO: Make this configurable
7 8 9 |
# File 'lib/inst_jobs_statsd/naming.rb', line 7 def self.basename BASENAME end |
.configure(strand_filter: nil) ⇒ Object
11 12 13 |
# File 'lib/inst_jobs_statsd/naming.rb', line 11 def self.configure(strand_filter: nil) @strand_filter = strand_filter end |
.custom_tags(job, tags) ⇒ Object
51 52 53 54 55 |
# File 'lib/inst_jobs_statsd/naming.rb', line 51 def self.(job, ) [:jobshard] = job.shard.id if job.respond_to?(:shard) [:strand] = job.strand if job&.strand && @strand_filter&.call(job) end |
.dd_job_tags(job) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/inst_jobs_statsd/naming.rb', line 37 def self.(job) = return unless job = (job, ) return unless job.tag return if job.tag =~ /Class:0x/ method_tag, obj_tag = split_to_tag(job) tag = obj_tag tag = [obj_tag, method_tag].join('.') if method_tag.present? [:tag] = tag end |
.dd_region_tags ⇒ Object
83 84 85 86 |
# File 'lib/inst_jobs_statsd/naming.rb', line 83 def self. return {} unless ENV['INST_JOBS_STATSD_NAMESPACE'] {namespace: ENV['INST_JOBS_STATSD_NAMESPACE']} end |
.job_tags(job) ⇒ Object
this converts Foo#bar“ or ”Foo.bar“ into ”Foo and “bar”, and makes sure the values are valid to be used for statsd names
59 60 61 62 63 64 65 66 67 68 |
# File 'lib/inst_jobs_statsd/naming.rb', line 59 def self.(job) return unless job return unless job.tag return if job.tag =~ /Class:0x/ method_tag, obj_tag = split_to_tag(job) = [obj_tag] << method_tag if method_tag.present? end |
.qualified_names(stat_name, job) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/inst_jobs_statsd/naming.rb', line 15 def self.qualified_names(stat_name, job) names = ["#{basename}.#{stat_name}"] tagged = tagged_stat(names[0], job) names << tagged if tagged.present? names << (names) names.flatten.compact end |
.region_tags(stat_names) ⇒ Object
We are using all existing stat names here because we do not want to break existing dependencies on the non-regioned data
72 73 74 75 76 77 78 79 80 81 |
# File 'lib/inst_jobs_statsd/naming.rb', line 72 def self.(stat_names) return unless ENV['INST_JOBS_STATSD_NAMESPACE'] stat_names.map do |name| name .split('.') .insert(2, ENV['INST_JOBS_STATSD_NAMESPACE']) .join('.') end end |
.tagged_stat(stat_name, job) ⇒ Object
Given a stat name, add a suffix to it to make it unique per job type – using the job’s class name and method name as appropriate
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/inst_jobs_statsd/naming.rb', line 26 def self.tagged_stat(stat_name, job) return unless job obj_tag, method_tag = (job) return if obj_tag.blank? tagged = "#{stat_name}.tag.#{obj_tag}" tagged += ".#{method_tag}" if method_tag.present? tagged end |