-
Notifications
You must be signed in to change notification settings - Fork 125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ecto adapter attribute #65
base: main
Are you sure you want to change the base?
Add ecto adapter attribute #65
Conversation
Could submit the ecto specific adapter attribute to https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/semantic_conventions/database.md#connection-level-attributes-for-specific-technologies -- as far as I can tell it is the same as like a JDBC driver class name. |
I agree you can create a function to map the adapter name to the |
Can you open an issue on ecto to request it be added as an attribute in the meta? |
I think this is supposed to be at the driver level which would be postgrex for the postgres adapter. |
Driver is a required option to sql adapter. https://github.com/elixir-ecto/ecto_sql/blob/6935c289f68e1404ef0a6ec652d8fb1f89a82b96/lib/ecto/adapters/sql.ex#L88 What do you think to ask them in the issue I will open to include |
@jhonndabi sorry I missed this, that sounds like a good plan to me. |
Also,j can you change the attribute to |
@jhonndabi would you be ok adding |
@tsloughter Ok, Sorry for the delay, I didn't see before. I'll work on that, and do the mapping. |
@jhonndabi can you resolve the conflicts? I think this is good to merge now once the conflicts are resolved. |
e3b7d11
to
d4f3a89
Compare
@tsloughter yes, of course! Sorry the delay. : ) |
instrumentation/opentelemetry_ecto/test/opentelemetry_ecto_test.exs
Outdated
Show resolved
Hide resolved
instrumentation/opentelemetry_ecto/test/opentelemetry_ecto_test.exs
Outdated
Show resolved
Hide resolved
"db.name": database, | ||
"db.url": url, | ||
"db.sql.table": source, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't actually know that an Ecto source is a sql table, do we here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://hexdocs.pm/ecto/Ecto.Schema.Metadata.html#module-source
The doc says it will be a table or a collection, I don't know if we have a way to determine if it's a table, but it could be a table. I'm not sure if for SQL adapters it will be always a table.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I figure for a sql adapter it will alway be a table. So thats all we need to know to know to include it (I think).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It could be a view, for example, not sure if it would break your semantics.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it's breaks the semantics here, view is like a virtual table.
6444296
to
f6e4e5c
Compare
f6e4e5c
to
043e438
Compare
@tsloughter Is there something else I can do here to get this merged? |
@jhonndabi hey, sorry, can you rebase? And @yordis does this overlap with your PR that is still a draft? |
@tsloughter yeah ... that is why I kept it that way, we can merge this one and I can continue the work there (either close it or change it) |
|
||
defp db_system(db_system) when db_system in @db_systems, do: db_system | ||
defp db_system(_), do: "other_sql" | ||
|
||
defp db_system(nil, Ecto.Adapters.Postgres), do: "postgresql" | ||
defp db_system(nil, Ecto.Adapters.MyXQL), do: "mysql" | ||
defp db_system(nil, Ecto.Adapters.Tds), do: "mssql" | ||
defp db_system(db_system, _), do: db_system(db_system) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tsloughter leaving a note here, as I said before, it will be prudent to ask Ecto
folks to include a function under the adapter module that allow us to fetch the engine
name ...
I am not sure how open they will be, but I think it is a fair thing to ask and see what happens.
"Ideally," this package wouldn't maintain the mapping
* `:db_system` - The identifier for the database management system (DBMS). | ||
defaults to the mapped value of the ecto adapter used. | ||
Must follow the list of well-known db systems from semantic conventions. | ||
See `https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/semantic_conventions/database.md` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would this be globally or per Adapter bases?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Per adapter bases. I think OpentelemetryEcto.setup/2
is meant to use just for one repo, right? And each repo can have only one Adapter (AFAIK).
@jhonndabi can you rebase this? |
@tsloughter done : ) |
527511c
to
f8ff0bb
Compare
Sorry this never got in. This needs another rebase at least. |
@tsloughter the whole lib needs a semconv rewrite. Probably best to leave it for that PR |
I couldn't find any discussion about how to include the required attribute
db.system
.I think currently there isn't a good way to infer that information, maybe ecto adapters can send to telemetry that information through metadata. For now, if we simple pass the ecto adapter as attribute, will be possible to infer and map that info.
Elixir.Ecto.Adapters.Postgres -> postgresql
Elixir.Ecto.Adapters.MyXQL -> mysql
Elixir.Ecto.Adapters.Tds -> mssql
This PR do the following:
Change some attributes key to follow semantic conventions.
Add the attribute
ecto.db.adapter
Add the attribute
db.system