From ac0d474e498b0e40cc523583e2eacd982e975a7a Mon Sep 17 00:00:00 2001 From: Mitchell Henke Date: Tue, 10 Jul 2018 14:21:19 -0500 Subject: [PATCH] remove UUID dependency --- lib/sentry/event.ex | 2 +- lib/sentry/util.ex | 15 +++++++++++++++ mix.exs | 3 +-- mix.lock | 1 - test/event_test.exs | 3 +-- 5 files changed, 18 insertions(+), 6 deletions(-) diff --git a/lib/sentry/event.ex b/lib/sentry/event.ex index 0bb6473e..de62a2ce 100644 --- a/lib/sentry/event.ex +++ b/lib/sentry/event.ex @@ -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) diff --git a/lib/sentry/util.ex b/lib/sentry/util.ex index 22bbed35..9b5ba3b0 100644 --- a/lib/sentry/util.ex +++ b/lib/sentry/util.ex @@ -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 """ @@ -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 + <> = + :crypto.strong_rand_bytes(16) + + <> + |> Base.encode16(case: :lower) + end end diff --git a/mix.exs b/mix.exs index 69c0ec95..b5b28810 100644 --- a/mix.exs +++ b/mix.exs @@ -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}, diff --git a/mix.lock b/mix.lock index 93f53f3f..5179475d 100644 --- a/mix.lock +++ b/mix.lock @@ -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"}, diff --git a/test/event_test.exs b/test/event_test.exs index ca55148f..476aad43 100644 --- a/test/event_test.exs +++ b/test/event_test.exs @@ -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