Skip to content

Commit

Permalink
Drop db.type attribute from opentelemetry_ecto
Browse files Browse the repository at this point in the history
  • Loading branch information
jhonndabi committed Nov 24, 2023
1 parent b638a1d commit 725a891
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 9 deletions.
9 changes: 1 addition & 8 deletions instrumentation/opentelemetry_ecto/lib/opentelemetry_ecto.ex
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ defmodule OpentelemetryEcto do
def handle_event(
event,
measurements,
%{query: query, source: source, result: query_result, repo: repo, type: type},
%{query: query, source: source, result: query_result, repo: repo},
config
) do
# Doing all this even if the span isn't sampled so the sampler
Expand All @@ -78,20 +78,13 @@ defmodule OpentelemetryEcto do
time_unit = Keyword.get(config, :time_unit, :microsecond)
additional_attributes = Keyword.get(config, :additional_attributes, %{})

db_type =
case type do
:ecto_sql_query -> :sql
_ -> type
end

# TODO: need connection information to complete the required attributes
# net.peer.name or net.peer.ip and net.peer.port
base_attributes = %{
"db.ecto.adapter": to_string(adapter),
"db.name": database,
"db.sql.table": source,
"db.statement": query,
"db.type": db_type,
"total_time_#{time_unit}s": System.convert_time_unit(total_time, :native, time_unit)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ defmodule OpentelemetryEctoTest do
"db.name": "opentelemetry_ecto_test",
"db.sql.table": "users",
"db.system": :postgresql,
"db.statement": "SELECT u0.\"id\", u0.\"email\" FROM \"users\" AS u0",
decode_time_microseconds: _,
query_time_microseconds: _,
queue_time_microseconds: _,
Expand Down Expand Up @@ -116,7 +117,6 @@ defmodule OpentelemetryEctoTest do
"db.sql.table": "posts",
"db.system": :postgresql,
"db.statement": "SELECT p0.\"id\", p0.\"body\", p0.\"user_id\" FROM \"posts\" AS p0",
"db.type": :sql,
decode_time_milliseconds: _,
query_time_milliseconds: _,
queue_time_milliseconds: _,
Expand Down

0 comments on commit 725a891

Please sign in to comment.