datadog-queue-bus 2.0.0 → 2.1.0

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: 73a6175afd834e209f14ee348e5240be85778076d6bd64c680fa17e95e80f142
4
- data.tar.gz: e53de70efd6c0f20594996d9ec4ac58882eb7f544b88d65270bc8c2b0ef75476
3
+ metadata.gz: 3ae76c2ba3427f338d85658cdde7b8d29adadcd9c7969f28bb2664b60db78011
4
+ data.tar.gz: caf809805ead76cc0bbdc091b28f5fd744e633dd9395d44ece7815c73eae385a
5
5
  SHA512:
6
- metadata.gz: f12b7f475b4f23b3db949023360bf80b964c6c7d1382c2812bb72d96867ec3bcdf13bfd8b09e1e1eb91bb5bff7446252bfbd1934d776c4f0edbd34a928d5263c
7
- data.tar.gz: 425cc91c71b90d94a24ef983afe57aa40569bd8fc467e0242c317b755e452d3d7dbf774db24b8f9e757ce0dbcfdca5151c75db64ae1b75e8487940a58e23796b
6
+ metadata.gz: c4ff40b46826c17a26f9e32808c2592643d312039cf7b90bb98aaf122de477f9a9f77eecd1a3940250722f0e059b5f3b926e304d07593d73fdb778b1d6a47a5a
7
+ data.tar.gz: c8d07d52ec537ba9b1b7bf42ba56da32830b2bbd3929bd5fa51344dc0133c23a49d6e2f3da85a8d548ea6ee5aeddae07c1cc65b4c7eeac1355f07f34a5a23d88
data/CHANGELOG.md CHANGED
@@ -4,6 +4,9 @@ All notable changes to this project will be documented in this file.
4
4
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5
5
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
+ ## [2.1.0]
8
+ - Support for dynamic service names by setting `DatadogQueueBus.service_name` to a Callable
9
+
7
10
  ## [2.0.0]
8
11
  - Replaces ddtrace with the updated `datadog` gem
9
12
 
data/README.md CHANGED
@@ -32,6 +32,18 @@ To override the default service name (which will be `queue-bus` if not set):
32
32
  DatadogQueueBus.service_name = 'my-queue-bus-service'
33
33
  ```
34
34
 
35
+ You can also set the service name to a Callable that accepts the attributes hash and returns a String, granting you flexibility to monitor larger installations as separate services:
36
+
37
+ ```ruby
38
+ DatadogQueueBus.service_name = ->(attrs) do
39
+ if attrs['bus_rider_app_key'].nil? || attrs['bus_rider_app_key'].empty?
40
+ 'default-queue-bus-service'
41
+ else
42
+ "#{attrs['bus_rider_app_key']}-queue-bus-service"
43
+ end
44
+ end
45
+ ```
46
+
35
47
  ## Development
36
48
 
37
49
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -9,6 +9,7 @@ require 'datadog_queue_bus/middleware'
9
9
  module DatadogQueueBus
10
10
  class << self
11
11
  # Sets the service_name that will be used when reporting queue-bus spans.
12
+ # Set this to a String, or to a Callable that accepts an attributes hash and returns a String.
12
13
  attr_writer :service_name
13
14
 
14
15
  # Returns the service name that is used when reporting queue-bus spans.
@@ -13,9 +13,15 @@ module DatadogQueueBus
13
13
  resource += " event=#{event_type}" if event_type
14
14
  resource += " sub=#{sub_key}" if sub_key
15
15
 
16
+ service_name = if DatadogQueueBus.service_name.respond_to?(:call)
17
+ DatadogQueueBus.service_name.call(attrs)
18
+ else
19
+ DatadogQueueBus.service_name
20
+ end
21
+
16
22
  # def trace(name, continue_from: nil, **span_options, &block)
17
23
  Datadog::Tracing.trace('queue-bus.worker',
18
- service: DatadogQueueBus.service_name,
24
+ service: service_name,
19
25
  resource: resource) do |span|
20
26
  attrs.keys.grep(/^bus_/).each do |key|
21
27
  span.set_tag("queue-bus.#{key}", attrs[key])
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DatadogQueueBus
4
- VERSION = '2.0.0'
4
+ VERSION = '2.1.0'
5
5
  end
@@ -20,7 +20,7 @@ RSpec.describe DatadogQueueBus::Middleware do
20
20
  subject.call(attrs)
21
21
  end
22
22
 
23
- context 'with a service name' do
23
+ context 'with a static service name' do
24
24
  let(:name) { rand.to_s }
25
25
 
26
26
  before do
@@ -35,6 +35,22 @@ RSpec.describe DatadogQueueBus::Middleware do
35
35
  end
36
36
  end
37
37
 
38
+ context 'with a dynamic service name' do
39
+ let(:name) { rand.to_s }
40
+ let(:service_name) { ->(attrs) { name } }
41
+
42
+ before do
43
+ DatadogQueueBus.service_name = service_name
44
+ end
45
+
46
+ it 'sends the service name' do
47
+ expect(tracer)
48
+ .to receive(:trace)
49
+ .with('queue-bus.worker', hash_including(service: name))
50
+ subject.call(attrs)
51
+ end
52
+ end
53
+
38
54
  context 'with an event type' do
39
55
  let(:attrs) do
40
56
  super().merge('bus_event_type' => 'my_event')
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: datadog-queue-bus
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - kbacha
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2024-07-26 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: datadog
@@ -127,7 +126,6 @@ homepage: https://github.com/queue-bus/datadog-queue-bus
127
126
  licenses:
128
127
  - MIT
129
128
  metadata: {}
130
- post_install_message:
131
129
  rdoc_options: []
132
130
  require_paths:
133
131
  - lib
@@ -142,8 +140,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
142
140
  - !ruby/object:Gem::Version
143
141
  version: '0'
144
142
  requirements: []
145
- rubygems_version: 3.2.33
146
- signing_key:
143
+ rubygems_version: 3.6.9
147
144
  specification_version: 4
148
145
  summary: A Datadog APM integration for queue-bus
149
146
  test_files: