@@ -36,6 +36,9 @@ defmodule OpentelemetryEcto do
3636 defaults to the concatenation of the event name with periods, e.g.
3737 `"blog.repo.query"`. This will always be followed with a colon and the
3838 source (the table name for SQL adapters).
39+ * `:additional_attributes` - additional attributes to include in the span. If there
40+ are conflits with default provided attributes, the ones provided with
41+ this config will have precedence.
3942 """
4043 def setup ( event_prefix , config \\ [ ] ) do
4144 event = event_prefix ++ [ :query ]
@@ -74,6 +77,7 @@ defmodule OpentelemetryEcto do
7477 end <> if source != nil , do: ":#{ source } " , else: ""
7578
7679 time_unit = Keyword . get ( config , :time_unit , :microsecond )
80+ additional_attributes = Keyword . get ( config , :additional_attributes , % { } )
7781
7882 db_type =
7983 case type do
@@ -101,6 +105,8 @@ defmodule OpentelemetryEcto do
101105 _ , acc ->
102106 acc
103107 end )
108+ |> Map . merge ( base_attributes )
109+ |> Map . merge ( additional_attributes )
104110
105111 parent_context = OpentelemetryProcessPropagator . fetch_parent_ctx ( 1 , :"$callers" )
106112
@@ -111,7 +117,7 @@ defmodule OpentelemetryEcto do
111117 s =
112118 OpenTelemetry.Tracer . start_span ( span_name , % {
113119 start_time: start_time ,
114- attributes: Map . merge ( attributes , base_attributes ) ,
120+ attributes: attributes ,
115121 kind: :client
116122 } )
117123
0 commit comments