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
2 changes: 1 addition & 1 deletion lib/sentry/event.ex
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ defmodule Sentry.Event do

@spec add_metadata(Event.t()) :: Event.t()
def add_metadata(%Event{} = state) do
%{state | event_id: UUID.uuid4(:hex), timestamp: Util.iso8601_timestamp()}
%{state | event_id: Util.uuid4_hex(), timestamp: Util.iso8601_timestamp()}
|> Map.update(:server_name, nil, fn server_name ->
server_name || to_string(:net_adm.localhost())
end)
Expand Down
15 changes: 15 additions & 0 deletions lib/sentry/util.ex
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ defmodule Sentry.Util do
Provides basic utility functions.
"""

@rfc_4122_variant10 2
@uuid_v4_identifier 4

@doc """
Generates a unix timestamp
"""
Expand Down Expand Up @@ -33,4 +36,16 @@ defmodule Sentry.Util do
end

def mix_deps_to_map(modules), do: modules

@doc """
Per http://www.ietf.org/rfc/rfc4122.txt
"""
@spec uuid4_hex() :: String.t()
def uuid4_hex() do
<<time_low_mid::48, _version::4, time_high::12, _reserved::2, rest::62>> =
:crypto.strong_rand_bytes(16)

<<time_low_mid::48, @uuid_v4_identifier::4, time_high::12, @rfc_4122_variant10::2, rest::62>>
|> Base.encode16(case: :lower)
end
end
3 changes: 1 addition & 2 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,13 @@ defmodule Sentry.Mixfile do
def application do
[
mod: {Sentry, []},
applications: [:hackney, :elixir_uuid, :poison, :logger]
applications: [:hackney, :poison, :logger]
]
end

defp deps do
[
{:hackney, "~> 1.8 or 1.6.5"},
{:elixir_uuid, "~> 1.2"},
{:poison, "~> 1.5 or ~> 2.0 or ~> 3.0"},
{:plug, "~> 1.6", optional: true},
{:phoenix, "~> 1.3", optional: true},
Expand Down
1 change: 0 additions & 1 deletion mix.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"credo": {:hex, :credo, "0.9.3", "76fa3e9e497ab282e0cf64b98a624aa11da702854c52c82db1bf24e54ab7c97a", [:mix], [{:bunt, "~> 0.2.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:poison, ">= 0.0.0", [hex: :poison, repo: "hexpm", optional: false]}], "hexpm"},
"dialyxir": {:hex, :dialyxir, "0.5.1", "b331b091720fd93e878137add264bac4f644e1ddae07a70bf7062c7862c4b952", [:mix], [], "hexpm"},
"earmark": {:hex, :earmark, "1.2.4", "99b637c62a4d65a20a9fb674b8cffb8baa771c04605a80c911c4418c69b75439", [:mix], [], "hexpm"},
"elixir_uuid": {:hex, :elixir_uuid, "1.2.0", "ff26e938f95830b1db152cb6e594d711c10c02c6391236900ddd070a6b01271d", [:mix], [], "hexpm"},
"ex_doc": {:hex, :ex_doc, "0.18.3", "f4b0e4a2ec6f333dccf761838a4b253d75e11f714b85ae271c9ae361367897b7", [:mix], [{:earmark, "~> 1.1", [hex: :earmark, repo: "hexpm", optional: false]}], "hexpm"},
"hackney": {:hex, :hackney, "1.12.1", "8bf2d0e11e722e533903fe126e14d6e7e94d9b7983ced595b75f532e04b7fdc7", [:rebar3], [{:certifi, "2.3.1", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "5.1.1", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "1.0.1", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "1.0.2", [hex: :mimerl, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "1.1.1", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}], "hexpm"},
"idna": {:hex, :idna, "5.1.1", "cbc3b2fa1645113267cc59c760bafa64b2ea0334635ef06dbac8801e42f7279c", [:rebar3], [{:unicode_util_compat, "0.3.1", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm"},
Expand Down
3 changes: 1 addition & 2 deletions test/event_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -466,8 +466,7 @@ defmodule Sentry.EventTest do
poison: "3.1.0",
ranch: "1.3.2",
ssl_verify_fun: "1.1.1",
unicode_util_compat: "0.3.1",
elixir_uuid: "1.2.0"
unicode_util_compat: "0.3.1"
}
end
end