Report Redix error messages through OTel status (#81)
Instead of custom attributes, leverage the status description as described in Semantic Conventions. This approach is taken from current `opentelemetry_ecto` implementation. Small non-related change is a fix the license description in `mix.exs`.
This commit is contained in:
parent
e856486e30
commit
8df66285bb
|
@ -1,5 +1,12 @@
|
|||
# Changelog
|
||||
|
||||
## 0.1.1
|
||||
|
||||
### Bug fixes
|
||||
|
||||
* Report errors via OpenTelemetry SetStatus API instead of custom
|
||||
attributes
|
||||
|
||||
## 0.1.0
|
||||
|
||||
* Initial release
|
||||
|
|
|
@ -60,7 +60,6 @@ defmodule OpentelemetryRedix do
|
|||
}
|
||||
|> Map.merge(net_attributes(connection))
|
||||
|> Map.merge(redix_attributes(meta))
|
||||
|> Map.merge(error_attributes(meta))
|
||||
|
||||
s =
|
||||
OpenTelemetry.Tracer.start_span(operation, %{
|
||||
|
@ -69,8 +68,8 @@ defmodule OpentelemetryRedix do
|
|||
attributes: attributes
|
||||
})
|
||||
|
||||
if meta[:reason] do
|
||||
OpenTelemetry.Span.set_status(s, OpenTelemetry.status(:error, ""))
|
||||
if meta[:kind] == :error do
|
||||
OpenTelemetry.Span.set_status(s, OpenTelemetry.status(:error, format_error(meta.reason)))
|
||||
end
|
||||
|
||||
OpenTelemetry.Span.end_span(s)
|
||||
|
@ -87,6 +86,6 @@ defmodule OpentelemetryRedix do
|
|||
defp redix_attributes(%{connection_name: name}), do: %{"db.redix.connection_name": name}
|
||||
defp redix_attributes(_), do: %{}
|
||||
|
||||
defp error_attributes(%{reason: reason}), do: %{"db.redix.error": inspect(reason)}
|
||||
defp error_attributes(_), do: %{}
|
||||
defp format_error(%{__exception__: true} = exception), do: Exception.message(exception)
|
||||
defp format_error(reason), do: inspect(reason)
|
||||
end
|
||||
|
|
|
@ -5,7 +5,7 @@ defmodule OpentelemetryRedix.MixProject do
|
|||
[
|
||||
app: :opentelemetry_redix,
|
||||
description: description(),
|
||||
version: "0.1.0",
|
||||
version: "0.1.1",
|
||||
elixir: "~> 1.10",
|
||||
start_permanent: Mix.env() == :prod,
|
||||
deps: deps(),
|
||||
|
@ -23,7 +23,7 @@ defmodule OpentelemetryRedix.MixProject do
|
|||
defp package do
|
||||
[
|
||||
files: ~w(lib .formatter.exs mix.exs README* LICENSE* CHANGELOG*),
|
||||
licenses: ["Apache-2"],
|
||||
licenses: ["Apache-2.0"],
|
||||
links: %{
|
||||
"GitHub" =>
|
||||
"https://github.com/open-telemetry/opentelemetry-erlang-contrib/tree/main/instrumentation/opentelemetry_redix",
|
||||
|
|
Loading…
Reference in New Issue