-
Notifications
You must be signed in to change notification settings - Fork 118
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
Improve Oban plugin handler and fix error handling #195
base: main
Are you sure you want to change the base?
Improve Oban plugin handler and fix error handling #195
Conversation
The main purpose of this patch is to introduce plugin aware attributes - mostly counts of processed jobs. Plugins cover all the offerings of Oban 2.15 and Oban Pro 1.0, the current versions at time of writing. While testing this in a real app, I've noticed issues with exception handlers for plugin. Decided to slip in this patch changes to both job and plugin event handlers to rely on standard :telemetry.span/3 attributes instead of :error key (which seems like an artifact of earlier versions).
I don't know anything about Oban plugins. @indrekj can you comment on this? @bryannaegele any thoughts? |
) | ||
end | ||
def handle_event(@plugin_start, _measurements, %{plugin: plugin} = metadata, _config) do | ||
span_name = "#{inspect(plugin)} process" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the inspect intentional? It will add quotes around the plugin name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually no. This is an atom right, so there wouldn't be extra quotes.
%{} | ||
) | ||
attributes = %{ | ||
"messaging.oban.plugin": inspect(plugin) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand why do we need inspect here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it. This is an atom right, so there wouldn't be extra quotes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe Atom.to_string()
or "#{plugin}"
would be more intuitive though
} | ||
end | ||
|
||
defp plugin_work_attributes(%{plugin: Oban.Plugins.Reindexer}), do: %{} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could also remove this line and let it go to the default case
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't set up things to get it working on my computer and fully test it, but I went through the changes and they seem to make sense to me.
The main purpose of this patch is to introduce plugin aware attributes - mostly counts of processed jobs.
Plugins cover all the offerings of Oban 2.15 and Oban Pro 1.0, the current versions at time of writing.
While testing this in a real app, I've noticed issues with exception handlers for plugin. Decided to slip in this patch changes to both job and plugin event handlers to rely on standard :telemetry.span/3 attributes instead of :error key (which seems like an artifact of earlier versions).