Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lib/sentry/transaction.ex
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ defmodule Sentry.Transaction do
},

# Optional
release: String.t(),
environment: String.t(),
transaction: String.t(),
transaction_info: transaction_info(),
Expand All @@ -83,6 +84,7 @@ defmodule Sentry.Transaction do
:measurements,
:sdk,
:platform,
:release,
:environment,
:tags,
:data
Expand All @@ -94,6 +96,7 @@ defmodule Sentry.Transaction do
__MODULE__,
attrs
|> Map.put(:event_id, UUID.uuid4_hex())
|> Map.put(:release, Config.release())
|> Map.put(:environment, Config.environment_name())
|> Map.put(:sdk, @sdk)
|> Map.put(:platform, "elixir")
Expand Down
27 changes: 27 additions & 0 deletions test/sentry_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,33 @@ defmodule SentryTest do

assert_receive {:after_send, "test-transaction", "340"}
end

test "includes release in transaction payload when configured", %{bypass: bypass} do
put_test_config(release: "1.9.123")

transaction =
create_transaction(%{
transaction: "transaction-with-release",
contexts: %{
trace: %{
trace_id: "trace-id",
span_id: "root-span"
}
}
})

Bypass.expect_once(bypass, "POST", "/api/1/envelope/", fn conn ->
{:ok, body, conn} = Plug.Conn.read_body(conn)
assert [{_headers, transaction_body}] = decode_envelope!(body)

assert transaction_body["transaction"] == "transaction-with-release"
assert transaction_body["release"] == "1.9.123"

Plug.Conn.send_resp(conn, 200, ~s<{"id": "340"}>)
end)

assert {:ok, "340"} = Sentry.send_transaction(transaction)
end
end

describe "flush/1" do
Expand Down