opentelemetry-instrumentation-active_job 0.7.3 → 0.7.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/README.md +3 -2
- data/lib/opentelemetry/instrumentation/active_job/handlers/default.rb +16 -1
- data/lib/opentelemetry/instrumentation/active_job/handlers/enqueue.rb +3 -9
- data/lib/opentelemetry/instrumentation/active_job/handlers/perform.rb +2 -10
- data/lib/opentelemetry/instrumentation/active_job/handlers.rb +3 -1
- data/lib/opentelemetry/instrumentation/active_job/instrumentation.rb +5 -2
- data/lib/opentelemetry/instrumentation/active_job/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b2f611f3efbc3f35b9e0d58031844bc5d2ad060fc1e506b4a0725e28d376ea50
|
4
|
+
data.tar.gz: 65217a6e1ff43d6d3011581e9c811b8072e751b1cd49b873dabb1f1ac12ad9c2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fc1fddc77bd99891601c505684d7c418550b0b29067d5b0ffd030b41f7addaf8eec4f3419ae2cb0e2744622a9a38b1a395c2ec12f1dd93b4d1069079e9667097
|
7
|
+
data.tar.gz: 2e7250e62b5fac75799c73ca0b89e6217cac445b3cb477c9abb6a33197fa43682ce1533b0c7105dcd49dc2b71ea8496f524a870e293829cdd1b2ff1b8f7fcf83
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
# Release History: opentelemetry-instrumentation-active_job
|
2
2
|
|
3
|
+
### v0.7.5 / 2024-08-15
|
4
|
+
|
5
|
+
* FIXED: Use Active Support Lazy Load Hooks to avoid prematurely initializing ActiveRecord::Base and ActiveJob::Base
|
6
|
+
|
7
|
+
### v0.7.4 / 2024-07-30
|
8
|
+
|
9
|
+
* FIXED: Honour dynamic changes in configuration
|
10
|
+
|
3
11
|
### v0.7.3 / 2024-07-22
|
4
12
|
|
5
13
|
* FIXED: ActiveJob::Handlers.unsubscribe
|
data/README.md
CHANGED
@@ -6,7 +6,7 @@ The OpenTelemetry Active Job gem is a community maintained instrumentation for [
|
|
6
6
|
|
7
7
|
Install the gem using:
|
8
8
|
|
9
|
-
```
|
9
|
+
```console
|
10
10
|
gem install opentelemetry-instrumentation-active_job
|
11
11
|
```
|
12
12
|
|
@@ -96,7 +96,7 @@ Example usage can be seen in the `./example/active_job.rb` file [here](https://g
|
|
96
96
|
|
97
97
|
The `opentelemetry-instrumentation-active_job` gem source is [on github][repo-github], along with related gems including `opentelemetry-api` and `opentelemetry-sdk`.
|
98
98
|
|
99
|
-
The OpenTelemetry Ruby gems are maintained by the OpenTelemetry
|
99
|
+
The OpenTelemetry Ruby gems are maintained by the OpenTelemetry Ruby special interest group (SIG). You can get involved by joining us on our [GitHub Discussions][discussions-url], [Slack Channel][slack-channel] or attending our weekly meeting. See the [meeting calendar][community-meetings] for dates and times. For more information on this and other language SIGs, see the OpenTelemetry [community page][ruby-sig].
|
100
100
|
|
101
101
|
## License
|
102
102
|
|
@@ -108,4 +108,5 @@ The `opentelemetry-instrumentation-active_job` gem is distributed under the Apac
|
|
108
108
|
[license-github]: https://github.com/open-telemetry/opentelemetry-ruby-contrib/blob/main/LICENSE
|
109
109
|
[ruby-sig]: https://github.com/open-telemetry/community#ruby-sig
|
110
110
|
[community-meetings]: https://github.com/open-telemetry/community#community-meetings
|
111
|
+
[slack-channel]: https://cloud-native.slack.com/archives/C01NWKKMKMY
|
111
112
|
[discussions-url]: https://github.com/open-telemetry/opentelemetry-ruby/discussions
|
@@ -40,7 +40,10 @@ module OpenTelemetry
|
|
40
40
|
# @param payload [Hash] containing job run information
|
41
41
|
# @return [Hash] with the span and generated context tokens
|
42
42
|
def start_span(name, _id, payload)
|
43
|
-
|
43
|
+
job = payload.fetch(:job)
|
44
|
+
event_name = name.delete_suffix(".#{EVENT_NAMESPACE}")
|
45
|
+
span_name = span_name(job, event_name)
|
46
|
+
span = tracer.start_span(span_name, attributes: @mapper.call(payload))
|
44
47
|
token = OpenTelemetry::Context.attach(OpenTelemetry::Trace.context_with_span(span))
|
45
48
|
|
46
49
|
{ span: span, ctx_token: token }
|
@@ -106,6 +109,18 @@ module OpenTelemetry
|
|
106
109
|
def tracer
|
107
110
|
OpenTelemetry::Instrumentation::ActiveJob::Instrumentation.instance.tracer
|
108
111
|
end
|
112
|
+
|
113
|
+
private
|
114
|
+
|
115
|
+
def span_name(job, event_name)
|
116
|
+
prefix = if @config[:span_naming] == :job_class
|
117
|
+
job.class.name
|
118
|
+
else
|
119
|
+
job.queue_name
|
120
|
+
end
|
121
|
+
|
122
|
+
"#{prefix} #{event_name}"
|
123
|
+
end
|
109
124
|
end
|
110
125
|
end
|
111
126
|
end
|
@@ -10,14 +10,7 @@ module OpenTelemetry
|
|
10
10
|
module Handlers
|
11
11
|
# Handles `enqueue.active_job` and `enqueue_at.active_job` to generate egress spans
|
12
12
|
class Enqueue < Default
|
13
|
-
|
14
|
-
super
|
15
|
-
@span_name_formatter = if @config[:span_naming] == :job_class
|
16
|
-
->(job) { "#{job.class.name} publish" }
|
17
|
-
else
|
18
|
-
->(job) { "#{job.queue_name} publish" }
|
19
|
-
end
|
20
|
-
end
|
13
|
+
EVENT_NAME = 'publish'
|
21
14
|
|
22
15
|
# Overrides the `Default#start_span` method to create an egress span
|
23
16
|
# and registers it with the current context
|
@@ -28,7 +21,8 @@ module OpenTelemetry
|
|
28
21
|
# @return [Hash] with the span and generated context tokens
|
29
22
|
def start_span(name, _id, payload)
|
30
23
|
job = payload.fetch(:job)
|
31
|
-
|
24
|
+
span_name = span_name(job, EVENT_NAME)
|
25
|
+
span = tracer.start_span(span_name, kind: :producer, attributes: @mapper.call(payload))
|
32
26
|
OpenTelemetry.propagation.inject(job.__otel_headers) # This must be transmitted over the wire
|
33
27
|
{ span: span, ctx_token: OpenTelemetry::Context.attach(OpenTelemetry::Trace.context_with_span(span)) }
|
34
28
|
end
|
@@ -10,14 +10,7 @@ module OpenTelemetry
|
|
10
10
|
module Handlers
|
11
11
|
# Handles perform.active_job to generate ingress spans
|
12
12
|
class Perform < Default
|
13
|
-
|
14
|
-
super
|
15
|
-
@span_name_formatter = if @config[:span_naming] == :job_class
|
16
|
-
->(job) { "#{job.class.name} process" }
|
17
|
-
else
|
18
|
-
->(job) { "#{job.queue_name} process" }
|
19
|
-
end
|
20
|
-
end
|
13
|
+
EVENT_NAME = 'process'
|
21
14
|
|
22
15
|
# Overrides the `Default#start_span` method to create an ingress span
|
23
16
|
# and registers it with the current context
|
@@ -28,10 +21,9 @@ module OpenTelemetry
|
|
28
21
|
# @return [Hash] with the span and generated context tokens
|
29
22
|
def start_span(name, _id, payload)
|
30
23
|
job = payload.fetch(:job)
|
24
|
+
span_name = span_name(job, EVENT_NAME)
|
31
25
|
parent_context = OpenTelemetry.propagation.extract(job.__otel_headers)
|
32
26
|
|
33
|
-
span_name = @span_name_formatter.call(job)
|
34
|
-
|
35
27
|
# TODO: Refactor into a propagation strategy
|
36
28
|
propagation_style = @config[:propagation_style]
|
37
29
|
if propagation_style == :child
|
@@ -14,6 +14,8 @@ module OpenTelemetry
|
|
14
14
|
module ActiveJob
|
15
15
|
# Module that contains custom event handlers, which are used to generate spans per event
|
16
16
|
module Handlers
|
17
|
+
EVENT_NAMESPACE = 'active_job'
|
18
|
+
|
17
19
|
module_function
|
18
20
|
|
19
21
|
# Subscribes Event Handlers to relevant ActiveJob notifications
|
@@ -57,7 +59,7 @@ module OpenTelemetry
|
|
57
59
|
}
|
58
60
|
|
59
61
|
@subscriptions = handlers_by_pattern.map do |key, handler|
|
60
|
-
::ActiveSupport::Notifications.subscribe("#{key}
|
62
|
+
::ActiveSupport::Notifications.subscribe("#{key}.#{EVENT_NAMESPACE}", handler)
|
61
63
|
end
|
62
64
|
end
|
63
65
|
|
@@ -63,14 +63,17 @@ module OpenTelemetry
|
|
63
63
|
end
|
64
64
|
|
65
65
|
def require_dependencies
|
66
|
+
require 'active_support/lazy_load_hooks'
|
66
67
|
require_relative 'patches/base'
|
67
68
|
require_relative 'handlers'
|
68
69
|
end
|
69
70
|
|
70
71
|
def patch_activejob
|
71
|
-
::ActiveJob::Base.prepend(Patches::Base) unless ::ActiveJob::Base <= Patches::Base
|
72
|
-
|
73
72
|
Handlers.subscribe
|
73
|
+
|
74
|
+
ActiveSupport.on_load(:active_job) do
|
75
|
+
::ActiveJob::Base.prepend(Patches::Base) unless ::ActiveJob::Base <= Patches::Base
|
76
|
+
end
|
74
77
|
end
|
75
78
|
end
|
76
79
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: opentelemetry-instrumentation-active_job
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- OpenTelemetry Authors
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-08-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: opentelemetry-api
|
@@ -232,10 +232,10 @@ homepage: https://github.com/open-telemetry/opentelemetry-ruby-contrib
|
|
232
232
|
licenses:
|
233
233
|
- Apache-2.0
|
234
234
|
metadata:
|
235
|
-
changelog_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-active_job/0.7.
|
235
|
+
changelog_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-active_job/0.7.5/file/CHANGELOG.md
|
236
236
|
source_code_uri: https://github.com/open-telemetry/opentelemetry-ruby-contrib/tree/main/instrumentation/active_job
|
237
237
|
bug_tracker_uri: https://github.com/open-telemetry/opentelemetry-ruby-contrib/issues
|
238
|
-
documentation_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-active_job/0.7.
|
238
|
+
documentation_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-active_job/0.7.5
|
239
239
|
post_install_message:
|
240
240
|
rdoc_options: []
|
241
241
|
require_paths:
|