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

Improve Oban plugin handler and fix error handling #195

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

Conversation

andrewhr
Copy link
Contributor

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).

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).
@tsloughter
Copy link
Member

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"
Copy link
Contributor

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.

Copy link
Contributor

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)
Copy link
Contributor

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

Copy link
Contributor

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.

Copy link
Contributor

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: %{}
Copy link
Contributor

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

Copy link
Contributor

@indrekj indrekj left a 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.

@tsloughter
Copy link
Member

@andrewhr any comments on @indrekj's notes?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants