Skip to content

Commit 0923ae3

Browse files
committed
remove UUID dependency
1 parent 7d8e1d5 commit 0923ae3

File tree

5 files changed

+17
-6
lines changed

5 files changed

+17
-6
lines changed

lib/sentry/event.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ defmodule Sentry.Event do
176176

177177
@spec add_metadata(Event.t()) :: Event.t()
178178
def add_metadata(%Event{} = state) do
179-
%{state | event_id: UUID.uuid4(:hex), timestamp: Util.iso8601_timestamp()}
179+
%{state | event_id: Util.uuid4_hex(), timestamp: Util.iso8601_timestamp()}
180180
|> Map.update(:server_name, nil, fn server_name ->
181181
server_name || to_string(:net_adm.localhost())
182182
end)

lib/sentry/util.ex

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ defmodule Sentry.Util do
33
Provides basic utility functions.
44
"""
55

6+
@rfc_4122_variant10 2
7+
@uuid_v4_identifier 4
8+
69
@doc """
710
Generates a unix timestamp
811
"""
@@ -33,4 +36,15 @@ defmodule Sentry.Util do
3336
end
3437

3538
def mix_deps_to_map(modules), do: modules
39+
40+
@doc """
41+
Per http://www.ietf.org/rfc/rfc4122.txt
42+
"""
43+
@spec uuid4_hex() :: String.t()
44+
def uuid4_hex() do
45+
<<u0::48, _::4, u1::12, _::2, u2::62>> = :crypto.strong_rand_bytes(16)
46+
47+
<<u0::48, @uuid_v4_identifier::4, u1::12, @rfc_4122_variant10::2, u2::62>>
48+
|> Base.encode16(case: :lower)
49+
end
3650
end

mix.exs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,13 @@ defmodule Sentry.Mixfile do
1818
def application do
1919
[
2020
mod: {Sentry, []},
21-
applications: [:hackney, :elixir_uuid, :poison, :logger]
21+
applications: [:hackney, :poison, :logger]
2222
]
2323
end
2424

2525
defp deps do
2626
[
2727
{:hackney, "~> 1.8 or 1.6.5"},
28-
{:elixir_uuid, "~> 1.2"},
2928
{:poison, "~> 1.5 or ~> 2.0 or ~> 3.0"},
3029
{:plug, "~> 1.6", optional: true},
3130
{:phoenix, "~> 1.3", optional: true},

mix.lock

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
"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"},
88
"dialyxir": {:hex, :dialyxir, "0.5.1", "b331b091720fd93e878137add264bac4f644e1ddae07a70bf7062c7862c4b952", [:mix], [], "hexpm"},
99
"earmark": {:hex, :earmark, "1.2.4", "99b637c62a4d65a20a9fb674b8cffb8baa771c04605a80c911c4418c69b75439", [:mix], [], "hexpm"},
10-
"elixir_uuid": {:hex, :elixir_uuid, "1.2.0", "ff26e938f95830b1db152cb6e594d711c10c02c6391236900ddd070a6b01271d", [:mix], [], "hexpm"},
1110
"ex_doc": {:hex, :ex_doc, "0.18.3", "f4b0e4a2ec6f333dccf761838a4b253d75e11f714b85ae271c9ae361367897b7", [:mix], [{:earmark, "~> 1.1", [hex: :earmark, repo: "hexpm", optional: false]}], "hexpm"},
1211
"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"},
1312
"idna": {:hex, :idna, "5.1.1", "cbc3b2fa1645113267cc59c760bafa64b2ea0334635ef06dbac8801e42f7279c", [:rebar3], [{:unicode_util_compat, "0.3.1", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm"},

test/event_test.exs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -466,8 +466,7 @@ defmodule Sentry.EventTest do
466466
poison: "3.1.0",
467467
ranch: "1.3.2",
468468
ssl_verify_fun: "1.1.1",
469-
unicode_util_compat: "0.3.1",
470-
elixir_uuid: "1.2.0"
469+
unicode_util_compat: "0.3.1"
471470
}
472471
end
473472
end

0 commit comments

Comments
 (0)