Skip to content

Commit

Permalink
Add integration_meta key to Sentry.Event (#771)
Browse files Browse the repository at this point in the history
Co-authored-by: Andrea Leopardi <an.leopardi@gmail.com>
  • Loading branch information
savhappy and whatyouhide authored Aug 18, 2024
1 parent 9ec8e89 commit c1c5e97
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
10 changes: 9 additions & 1 deletion lib/sentry/event.ex
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ defmodule Sentry.Event do
modules: %{optional(String.t()) => String.t()},
extra: map(),
fingerprint: [String.t()],
integration_meta: map(),

# Interfaces.
breadcrumbs: [Interfaces.Breadcrumb.t()],
Expand Down Expand Up @@ -117,6 +118,7 @@ defmodule Sentry.Event do
transaction: nil,
threads: nil,
user: %{},
integration_meta: %{},

# "Culprit" is not documented anymore and we should move to transactions at some point.
# https://forum.sentry.io/t/culprit-deprecated-in-favor-of-what/4871/9
Expand Down Expand Up @@ -255,6 +257,11 @@ defmodule Sentry.Event do
`Sentry.capture_message/2`. *Available since v10.1.0*.
"""
],
integration_meta: [
type: :map,
default: %{},
doc: false
],

## Internal options
handled: [
Expand Down Expand Up @@ -360,7 +367,8 @@ defmodule Sentry.Event do
source: source,
tags: tags,
timestamp: timestamp,
user: user
user: user,
integration_meta: Keyword.fetch!(opts, :integration_meta)
}

# If we have a message *and* a stacktrace, but no exception, we need to store the stacktrace
Expand Down
4 changes: 3 additions & 1 deletion lib/sentry/integrations/oban/error_reporter.ex
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ defmodule Sentry.Integrations.Oban.ErrorReporter do
inspect(job.worker),
Exception.message(exception)
],
extra: Map.take(job, [:args, :attempt, :id, :max_attempts, :meta, :queue, :tags, :worker])
extra:
Map.take(job, [:args, :attempt, :id, :max_attempts, :meta, :queue, :tags, :worker]),
integration_meta: %{oban: %{job_meta: job}}
)

:ok
Expand Down
1 change: 1 addition & 0 deletions test/sentry/integrations/oban/error_reporter_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ defmodule Sentry.Integrations.Oban.ErrorReporterTest do
assert event.tags.oban_queue == "default"
assert event.tags.oban_state == "available"
assert event.tags.oban_worker == "Sentry.Integrations.Oban.ErrorReporterTest.MyWorker"
assert %{job_meta: %Oban.Job{}} = event.integration_meta.oban
end
end
end

0 comments on commit c1c5e97

Please sign in to comment.