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
|
# Changelog
|
||||||
|
|
||||||
|
## 0.1.1
|
||||||
|
|
||||||
|
### Bug fixes
|
||||||
|
|
||||||
|
* Report errors via OpenTelemetry SetStatus API instead of custom
|
||||||
|
attributes
|
||||||
|
|
||||||
## 0.1.0
|
## 0.1.0
|
||||||
|
|
||||||
* Initial release
|
* Initial release
|
||||||
|
|
|
@ -60,7 +60,6 @@ defmodule OpentelemetryRedix do
|
||||||
}
|
}
|
||||||
|> Map.merge(net_attributes(connection))
|
|> Map.merge(net_attributes(connection))
|
||||||
|> Map.merge(redix_attributes(meta))
|
|> Map.merge(redix_attributes(meta))
|
||||||
|> Map.merge(error_attributes(meta))
|
|
||||||
|
|
||||||
s =
|
s =
|
||||||
OpenTelemetry.Tracer.start_span(operation, %{
|
OpenTelemetry.Tracer.start_span(operation, %{
|
||||||
|
@ -69,8 +68,8 @@ defmodule OpentelemetryRedix do
|
||||||
attributes: attributes
|
attributes: attributes
|
||||||
})
|
})
|
||||||
|
|
||||||
if meta[:reason] do
|
if meta[:kind] == :error do
|
||||||
OpenTelemetry.Span.set_status(s, OpenTelemetry.status(:error, ""))
|
OpenTelemetry.Span.set_status(s, OpenTelemetry.status(:error, format_error(meta.reason)))
|
||||||
end
|
end
|
||||||
|
|
||||||
OpenTelemetry.Span.end_span(s)
|
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(%{connection_name: name}), do: %{"db.redix.connection_name": name}
|
||||||
defp redix_attributes(_), do: %{}
|
defp redix_attributes(_), do: %{}
|
||||||
|
|
||||||
defp error_attributes(%{reason: reason}), do: %{"db.redix.error": inspect(reason)}
|
defp format_error(%{__exception__: true} = exception), do: Exception.message(exception)
|
||||||
defp error_attributes(_), do: %{}
|
defp format_error(reason), do: inspect(reason)
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,7 +5,7 @@ defmodule OpentelemetryRedix.MixProject do
|
||||||
[
|
[
|
||||||
app: :opentelemetry_redix,
|
app: :opentelemetry_redix,
|
||||||
description: description(),
|
description: description(),
|
||||||
version: "0.1.0",
|
version: "0.1.1",
|
||||||
elixir: "~> 1.10",
|
elixir: "~> 1.10",
|
||||||
start_permanent: Mix.env() == :prod,
|
start_permanent: Mix.env() == :prod,
|
||||||
deps: deps(),
|
deps: deps(),
|
||||||
|
@ -23,7 +23,7 @@ defmodule OpentelemetryRedix.MixProject do
|
||||||
defp package do
|
defp package do
|
||||||
[
|
[
|
||||||
files: ~w(lib .formatter.exs mix.exs README* LICENSE* CHANGELOG*),
|
files: ~w(lib .formatter.exs mix.exs README* LICENSE* CHANGELOG*),
|
||||||
licenses: ["Apache-2"],
|
licenses: ["Apache-2.0"],
|
||||||
links: %{
|
links: %{
|
||||||
"GitHub" =>
|
"GitHub" =>
|
||||||
"https://github.com/open-telemetry/opentelemetry-erlang-contrib/tree/main/instrumentation/opentelemetry_redix",
|
"https://github.com/open-telemetry/opentelemetry-erlang-contrib/tree/main/instrumentation/opentelemetry_redix",
|
||||||
|
|
Loading…
Reference in New Issue