chore: add semantic conventions pgk to redix (#119)

This commit is contained in:
Yordis Prieto 2022-11-14 17:33:48 -05:00 committed by GitHub
parent a72305f574
commit 01fc804ab2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 4 deletions

View File

@ -15,9 +15,11 @@ defmodule OpentelemetryRedix do
""" """
alias OpenTelemetry.SemanticConventions.Trace
alias OpentelemetryRedix.Command alias OpentelemetryRedix.Command
alias OpentelemetryRedix.ConnectionTracker alias OpentelemetryRedix.ConnectionTracker
require Trace
require OpenTelemetry.Tracer require OpenTelemetry.Tracer
@typedoc "Setup options" @typedoc "Setup options"
@ -54,9 +56,9 @@ defmodule OpentelemetryRedix do
attributes = attributes =
%{ %{
"db.system": "redis", Trace.db_system() => "redis",
"db.operation": operation, Trace.db_operation() => operation,
"db.statement": statement Trace.db_statement() => statement
} }
|> Map.merge(net_attributes(connection)) |> Map.merge(net_attributes(connection))
|> Map.merge(redix_attributes(meta)) |> Map.merge(redix_attributes(meta))
@ -77,7 +79,7 @@ defmodule OpentelemetryRedix do
defp net_attributes(%{address: address}) when is_binary(address) do defp net_attributes(%{address: address}) when is_binary(address) do
[host, port] = address |> String.split(":") [host, port] = address |> String.split(":")
%{"net.peer.name": host, "net.peer.port": port} %{Trace.net_peer_name() => host, Trace.net_peer_port() => port}
end end
defp net_attributes(_), do: %{} defp net_attributes(_), do: %{}