Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow DelayedJob to be extended and JOB_CLASS_REGEXP redefined #243

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

tekkamanendless
Copy link

In our testing and use of this tool, we found that the value of
JOB_CLASS_REGEXP for the DelayedJob instrumentation didn't match
what our values looked like.

The original code is looking for something like this:

job_class: MyClass

However, in our environment, our values look something more like
this (YAML data with no "job_class" to be seen):

--- !ruby/struct:MyJob
endpoint_id:
payload:

Anyway, we wanted to just change the JOB_CLASS_REGEXP value by subclassing
DelayedJob and registering that plugin, but it didn't work because even
the subclass would use the original class's value of JOB_CLASS_REGEXP.

This update switches the use of JOB_CLASS_REGEXP to allow for a subclass
to override the value using self.class::JOB_CLASS_REGEXP.

Our desired workflow is to allow for this:

class MyDelayedJob < PrometheusExporter::Instrumentation::DelayedJob
  JOB_CLASS_REGEXP = %r{ruby/(?:object|struct):\s*(\w+)}.freeze
end
MyDelayedJob.register_plugin

In our testing and use of this tool, we found that the value of
JOB_CLASS_REGEXP for the DelayedJob instrumentation didn't match
what our values looked like.

The original code is looking for something like this:

```
job_class: MyClass
```

However, in our environment, our values look something more like
this (YAML data with no "job_class" to be seen):

```
--- !ruby/struct:MyJob
endpoint_id:
payload:
```

Anyway, we wanted to just change the JOB_CLASS_REGEXP value by subclassing
DelayedJob and registering that plugin, but it didn't work because even
the subclass would use the original class's value of JOB_CLASS_REGEXP.

This update switches the use of JOB_CLASS_REGEXP to allow for a subclass
to override the value using `self.class::JOB_CLASS_REGEXP`.

Our desired workflow is to allow for this:

```
class MyDelayedJob < PrometheusExporter::Instrumentation::DelayedJob
  JOB_CLASS_REGEXP = %r{ruby/(?:object|struct):\s*(\w+)}.freeze
end
MyDelayedJob.register_plugin
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant