opentelemetry-instrumentation-active_job 0.7.4 → 0.7.6
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 +4 -13
- data/lib/opentelemetry/instrumentation/active_job/handlers/perform.rb +3 -14
- 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: 89f474f0e98fb6f3481f608845f526887cae95e7c4b809ba10730b16ab7fe7f7
|
4
|
+
data.tar.gz: d5ae960715ee73afbc0d2fc6b899efdce4ce8bd4cb89f05392e09a37e2e58145
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a8e5f53d8c11594d339f749fd9e67b1dc8b298f180c5c9a0d2c0c4bed8b9e15fc5fcb649b59c94080cb58b810ba4c3780caf28bfd61eaed0f57928fce9e81c7e
|
7
|
+
data.tar.gz: 2e85cf90a1c65db191f45d614e03a0f3fe29065537f4401c0da1143860e32a0314174a90dfc1a40b1202b943a0a9c7b7131054eafdbb57db076cbf6beb944abb
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
# Release History: opentelemetry-instrumentation-active_job
|
2
2
|
|
3
|
+
### v0.7.6 / 2024-08-15
|
4
|
+
|
5
|
+
* FIXED: Prefix ::ActiveSupport when installing the instrumentation
|
6
|
+
|
7
|
+
### v0.7.5 / 2024-08-15
|
8
|
+
|
9
|
+
* FIXED: Use Active Support Lazy Load Hooks to avoid prematurely initializing ActiveRecord::Base and ActiveJob::Base
|
10
|
+
|
3
11
|
### v0.7.4 / 2024-07-30
|
4
12
|
|
5
13
|
* FIXED: Honour dynamic changes in configuration
|
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,6 +10,8 @@ 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
|
+
EVENT_NAME = 'publish'
|
14
|
+
|
13
15
|
# Overrides the `Default#start_span` method to create an egress span
|
14
16
|
# and registers it with the current context
|
15
17
|
#
|
@@ -19,22 +21,11 @@ module OpenTelemetry
|
|
19
21
|
# @return [Hash] with the span and generated context tokens
|
20
22
|
def start_span(name, _id, payload)
|
21
23
|
job = payload.fetch(:job)
|
22
|
-
|
24
|
+
span_name = span_name(job, EVENT_NAME)
|
25
|
+
span = tracer.start_span(span_name, kind: :producer, attributes: @mapper.call(payload))
|
23
26
|
OpenTelemetry.propagation.inject(job.__otel_headers) # This must be transmitted over the wire
|
24
27
|
{ span: span, ctx_token: OpenTelemetry::Context.attach(OpenTelemetry::Trace.context_with_span(span)) }
|
25
28
|
end
|
26
|
-
|
27
|
-
private
|
28
|
-
|
29
|
-
def span_name(job)
|
30
|
-
prefix = if @config[:span_naming] == :job_class
|
31
|
-
job.class.name
|
32
|
-
else
|
33
|
-
job.queue_name
|
34
|
-
end
|
35
|
-
|
36
|
-
"#{prefix} publish"
|
37
|
-
end
|
38
29
|
end
|
39
30
|
end
|
40
31
|
end
|
@@ -10,6 +10,8 @@ module OpenTelemetry
|
|
10
10
|
module Handlers
|
11
11
|
# Handles perform.active_job to generate ingress spans
|
12
12
|
class Perform < Default
|
13
|
+
EVENT_NAME = 'process'
|
14
|
+
|
13
15
|
# Overrides the `Default#start_span` method to create an ingress span
|
14
16
|
# and registers it with the current context
|
15
17
|
#
|
@@ -19,10 +21,9 @@ module OpenTelemetry
|
|
19
21
|
# @return [Hash] with the span and generated context tokens
|
20
22
|
def start_span(name, _id, payload)
|
21
23
|
job = payload.fetch(:job)
|
24
|
+
span_name = span_name(job, EVENT_NAME)
|
22
25
|
parent_context = OpenTelemetry.propagation.extract(job.__otel_headers)
|
23
26
|
|
24
|
-
span_name = span_name(job)
|
25
|
-
|
26
27
|
# TODO: Refactor into a propagation strategy
|
27
28
|
propagation_style = @config[:propagation_style]
|
28
29
|
if propagation_style == :child
|
@@ -48,18 +49,6 @@ module OpenTelemetry
|
|
48
49
|
|
49
50
|
OpenTelemetry::Context.attach(internal_context)
|
50
51
|
end
|
51
|
-
|
52
|
-
private
|
53
|
-
|
54
|
-
def span_name(job)
|
55
|
-
prefix = if @config[:span_naming] == :job_class
|
56
|
-
job.class.name
|
57
|
-
else
|
58
|
-
job.queue_name
|
59
|
-
end
|
60
|
-
|
61
|
-
"#{prefix} process"
|
62
|
-
end
|
63
52
|
end
|
64
53
|
end
|
65
54
|
end
|
@@ -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.6
|
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.6/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.6
|
239
239
|
post_install_message:
|
240
240
|
rdoc_options: []
|
241
241
|
require_paths:
|