nexus_semantic_logger 1.2.0 → 1.3.2

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: 5fb3fba7b28b1b186a3e601dc9901c94acf9db07c5f40b2a4c2357104fcda507
4
- data.tar.gz: d32b561ab333d7240b4d752e3a3faffa1ad95102882644eb045224f3bb493f44
3
+ metadata.gz: e650ec4b4c57cb7d85a5abde066ef34219502ff5d995e37fdf2b431833b2a086
4
+ data.tar.gz: 6285058765fa7ff89bf071714bcdd1978c83b4f64dfd17c2ddffc5a3843e190b
5
5
  SHA512:
6
- metadata.gz: 23af7bf651c2f48db0411ae861d36a81d652de9af6da5c275b04f66781d45657abecbf31521cb825a7977a90fa32dac3872f3fe47fc3ec07396928b717abb648
7
- data.tar.gz: 9523b13f81fb98da9712e0af779f3b59ff85ae7ba23269c3c2f2845ac91b2ec77674e4cf5985334c1445273d1f12f81dbdba6049d6270ccfb5a6ff454ec30136
6
+ metadata.gz: dfbe1816ddd0f82a9009e863b94d4efe76551a35511df893a74ef328b1fee41964b2b0bdeaa219355da3e3fa03e00e9e2fb3b129d2459bbea1332ba37069c6f4
7
+ data.tar.gz: 70bc5a9ba7bc1d24b8dbac2fc84afbf7bb94c39a48d34036ca6b59446d1293778802984268f38ef7b80adcb74397a04225edfc3173be481d830d0180c79b2e25
data/README.md CHANGED
@@ -2,6 +2,27 @@
2
2
 
3
3
  Configures a [semantic_logger](https://rubygems.org/gems/rails_semantic_logger) as required for NexusMods components.
4
4
 
5
+ ## Telemetry
6
+
7
+ As well as providing a semantic logger, this gem handles datadog telemetry associated with the logging approach:
8
+
9
+ * logs
10
+ * traces
11
+ * metrics
12
+ * statsd is automatically attached to datadog runtime metrics and may also be used for custom metrics.
13
+
14
+ ### Sending metrics
15
+
16
+ Ensure the metric name is in the format: `nexus.{component}.{major}.{minor}`
17
+
18
+ Where _major and minor_ are specific to the component logic e.g. `nexus.uploads.clamscan.pass`
19
+
20
+ For example, to increment a count:
21
+
22
+ ```
23
+ NexusSemanticLogger.metrics.increment('nexus.users.registration.complete')
24
+ ```
25
+
5
26
  # Local gem development
6
27
 
7
28
  Steps to run this gem from local sources in one the nexus 'staged build' rails components:
@@ -3,7 +3,8 @@ require 'singleton'
3
3
 
4
4
  module NexusSemanticLogger
5
5
  # Application wide location to get datadog objects.
6
- # Can be moved to its own gem in future, and there is scope to make the usage code even leaner.
6
+ # dogstatsd-ruby maintains its own queue and thread for flushing, so the client code should never create its
7
+ # own statsd instance.
7
8
  class DatadogSingleton
8
9
  include Singleton
9
10
  attr_accessor :statsd, :tags
@@ -12,8 +13,18 @@ module NexusSemanticLogger
12
13
  statsd&.flush(sync: Rails.env.development?) # Force flush sync in development, speed up checks.
13
14
  end
14
15
 
15
- def increment(metric_name)
16
- statsd&.increment(metric_name, tags: tags)
16
+ # Delegate to statsd (if available).
17
+ # @param [String] metric Metric name.
18
+ def increment(metric)
19
+ statsd&.increment(metric, tags: tags)
20
+ flush
21
+ end
22
+
23
+ # Delegate to statsd (if available).
24
+ # @param [String] metric Metric name.
25
+ # @param [Integer] ms Timing in milliseconds.
26
+ def timing(metric, ms)
27
+ statsd&.timing(metric, ms, tags: tags)
17
28
  flush
18
29
  end
19
30
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
  module NexusSemanticLogger
3
- # Leave this as 1.2.0 in order for CI process to replace with the tagged version.
4
- VERSION = '1.2.0'
3
+ # Leave this as 1.3.2 in order for CI process to replace with the tagged version.
4
+ VERSION = '1.3.2'
5
5
  end
@@ -6,4 +6,8 @@ require 'nexus_semantic_logger/datadog_singleton'
6
6
  require 'nexus_semantic_logger/datadog_tracer'
7
7
 
8
8
  module NexusSemanticLogger
9
+ # Get application wide object for sending metrics.
10
+ def self.metrics
11
+ DatadogSingleton.instance
12
+ end
9
13
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nexus_semantic_logger
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Johnathon Harris
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-07-20 00:00:00.000000000 Z
11
+ date: 2022-09-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: amazing_print
@@ -102,7 +102,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
102
102
  - !ruby/object:Gem::Version
103
103
  version: '0'
104
104
  requirements: []
105
- rubygems_version: 3.3.18
105
+ rubygems_version: 3.3.21
106
106
  signing_key:
107
107
  specification_version: 4
108
108
  summary: semantic_logger usage for nexus