Skip to content

Commit

Permalink
Add db.name to ecto spans (#172)
Browse files Browse the repository at this point in the history
* Add db.name to ecto spans

As per the spec, the db.name attribute is required on database spans. This changes adds it.

Ref: https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/semantic_conventions/database.md#call-level-attributes

* Add db.name attribute to tests

* Changelog update

* Update instrumentation/opentelemetry_ecto/test/opentelemetry_ecto_test.exs

* Update instrumentation/opentelemetry_ecto/test/opentelemetry_ecto_test.exs
  • Loading branch information
cedricziel authored May 23, 2023
1 parent ddf0706 commit 8292870
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
6 changes: 6 additions & 0 deletions instrumentation/opentelemetry_ecto/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## 1.1.1

### Changed

* Add db.name to ecto spans

## 1.1.0

### Changed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ defmodule OpentelemetryEcto do
"db.statement": query,
source: source,
"db.instance": database,
"db.name": database,
"db.url": url,
"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 @@ -50,6 +50,7 @@ defmodule OpentelemetryEctoTest do

assert %{
"db.instance": "opentelemetry_ecto_test",
"db.name": "opentelemetry_ecto_test",
"db.statement": "SELECT u0.\"id\", u0.\"email\" FROM \"users\" AS u0",
"db.type": :sql,
"db.url": "ecto://localhost",
Expand Down Expand Up @@ -82,6 +83,7 @@ defmodule OpentelemetryEctoTest do

assert %{
"db.instance": "opentelemetry_ecto_test",
"db.name": "opentelemetry_ecto_test",
"db.statement": "SELECT p0.\"id\", p0.\"body\", p0.\"user_id\" FROM \"posts\" AS p0",
"db.type": :sql,
"db.url": "ecto://localhost",
Expand Down

0 comments on commit 8292870

Please sign in to comment.