@@ -47,10 +47,7 @@ defmodule Sentry.Opentelemetry.SpanProcessor do
4747 } )
4848 end
4949
50- defp build_transaction (
51- % SpanRecord { attributes: attributes , origin: "opentelemetry_ecto" } = root_span ,
52- child_spans
53- ) do
50+ defp build_transaction ( % SpanRecord { origin: "opentelemetry_ecto" } = root_span , child_spans ) do
5451 Transaction . new ( % {
5552 transaction: root_span . name ,
5653 start_timestamp: root_span . start_time ,
@@ -61,18 +58,7 @@ defmodule Sentry.Opentelemetry.SpanProcessor do
6158 contexts: % {
6259 trace: build_trace_context ( root_span )
6360 } ,
64- data: % {
65- "db.system" => attributes [ :"db.system" ] ,
66- "db.name" => attributes [ :"db.name" ] ,
67- "db.instance" => attributes [ :"db.instance" ] ,
68- "db.type" => attributes [ :"db.type" ] ,
69- "db.url" => attributes [ :"db.url" ] ,
70- "total_time_microseconds" => attributes [ :total_time_microseconds ] ,
71- "idle_time_microseconds" => attributes [ :idle_time_microseconds ] ,
72- "decode_time_microseconds" => attributes [ :decode_time_microseconds ] ,
73- "queue_time_microseconds" => attributes [ :queue_time_microseconds ] ,
74- "query_time_microseconds" => attributes [ :query_time_microseconds ]
75- } ,
61+ data: root_span . attributes ,
7662 measurements: % { } ,
7763 spans: Enum . map ( child_spans , & build_span ( & 1 ) )
7864 } )
@@ -83,7 +69,7 @@ defmodule Sentry.Opentelemetry.SpanProcessor do
8369 child_spans
8470 ) do
8571 Transaction . new ( % {
86- transaction: "#{ attributes [ : "phoenix.plug"] } ##{ attributes [ : "phoenix.action"] } " ,
72+ transaction: "#{ attributes [ "phoenix.plug" ] } ##{ attributes [ "phoenix.action" ] } " ,
8773 start_timestamp: root_span . start_time ,
8874 timestamp: root_span . end_time ,
8975 transaction_info: % {
@@ -93,23 +79,23 @@ defmodule Sentry.Opentelemetry.SpanProcessor do
9379 trace: build_trace_context ( root_span )
9480 } ,
9581 request: % {
96- url: attributes [ : "http.target"] ,
97- method: attributes [ : "http.method"] ,
82+ url: attributes [ "http.target" ] ,
83+ method: attributes [ "http.method" ] ,
9884 headers: % {
99- "User-Agent" => attributes [ : "http.user_agent"]
85+ "User-Agent" => attributes [ "http.user_agent" ]
10086 } ,
10187 env: % {
102- "SERVER_NAME" => attributes [ : "net.host.name"] ,
103- "SERVER_PORT" => attributes [ : "net.host.port"]
88+ "SERVER_NAME" => attributes [ "net.host.name" ] ,
89+ "SERVER_PORT" => attributes [ "net.host.port" ]
10490 }
10591 } ,
10692 data: % {
107- "http.response.status_code" => attributes [ : "http.status_code"] ,
108- "method" => attributes [ : "http.method"] ,
109- "path" => attributes [ : "http.target"] ,
93+ "http.response.status_code" => attributes [ "http.status_code" ] ,
94+ "method" => attributes [ "http.method" ] ,
95+ "path" => attributes [ "http.target" ] ,
11096 "params" => % {
111- "controller" => attributes [ : "phoenix.plug"] ,
112- "action" => attributes [ : "phoenix.action"]
97+ "controller" => attributes [ "phoenix.plug" ] ,
98+ "action" => attributes [ "phoenix.action" ]
11399 }
114100 } ,
115101 measurements: % { } ,
@@ -121,30 +107,30 @@ defmodule Sentry.Opentelemetry.SpanProcessor do
121107 % SpanRecord { attributes: attributes , origin: "opentelemetry_bandit" } = root_span ,
122108 child_spans
123109 ) do
124- % Sentry. Transaction{
110+ Transaction . new ( % {
125111 start_timestamp: root_span . start_time ,
126112 timestamp: root_span . end_time ,
127- transaction: attributes [ : "http.target"] ,
113+ transaction: attributes [ "http.target" ] ,
128114 transaction_info: % {
129115 source: "url"
130116 } ,
131117 contexts: % {
132118 trace: build_trace_context ( root_span )
133119 } ,
134120 request: % {
135- url: attributes [ : "http.url"] ,
136- method: attributes [ : "http.method"] ,
121+ url: attributes [ "http.url" ] ,
122+ method: attributes [ "http.method" ] ,
137123 headers: % {
138- "User-Agent" => attributes [ : "http.user_agent"]
124+ "User-Agent" => attributes [ "http.user_agent" ]
139125 } ,
140126 env: % {
141- "SERVER_NAME" => attributes [ : "net.peer.name"] ,
142- "SERVER_PORT" => attributes [ : "net.peer.port"]
127+ "SERVER_NAME" => attributes [ "net.peer.name" ] ,
128+ "SERVER_PORT" => attributes [ "net.peer.port" ]
143129 }
144130 } ,
145131 measurements: % { } ,
146132 spans: Enum . map ( child_spans , & build_span ( & 1 ) )
147- }
133+ } )
148134 end
149135
150136 defp build_trace_context (
@@ -157,19 +143,21 @@ defmodule Sentry.Opentelemetry.SpanProcessor do
157143 op: "http.server" ,
158144 origin: root_span . origin ,
159145 data: % {
160- "http.response.status_code" => attributes [ : "http.status_code"]
146+ "http.response.status_code" => attributes [ "http.status_code" ]
161147 }
162148 }
163149 end
164150
165- defp build_trace_context ( % SpanRecord { origin: "opentelemetry_ecto" } = root_span ) do
151+ defp build_trace_context (
152+ % SpanRecord { origin: "opentelemetry_ecto" , attributes: attributes } = root_span
153+ ) do
166154 % {
167155 trace_id: root_span . trace_id ,
168156 span_id: root_span . span_id ,
169157 parent_span_id: root_span . parent_span_id ,
170- op: "db" ,
158+ op: "db. #{ attributes [ "db.type" ] } .ecto " ,
171159 origin: root_span . origin ,
172- data: root_span . attributes
160+ data: attributes
173161 }
174162 end
175163
@@ -187,7 +175,7 @@ defmodule Sentry.Opentelemetry.SpanProcessor do
187175 defp build_span (
188176 % SpanRecord { origin: "opentelemetry_phoenix" , attributes: attributes } = span_record
189177 ) do
190- op = "#{ attributes [ : "phoenix.plug"] } ##{ attributes [ : "phoenix.action"] } "
178+ op = "#{ attributes [ "phoenix.plug" ] } ##{ attributes [ "phoenix.action" ] } "
191179
192180 % Span {
193181 op: op ,
@@ -196,7 +184,7 @@ defmodule Sentry.Opentelemetry.SpanProcessor do
196184 trace_id: span_record . trace_id ,
197185 span_id: span_record . span_id ,
198186 parent_span_id: span_record . parent_span_id ,
199- description: attributes [ : "http.route"] ,
187+ description: attributes [ "http.route" ] ,
200188 origin: span_record . origin
201189 }
202190 end
@@ -228,16 +216,14 @@ defmodule Sentry.Opentelemetry.SpanProcessor do
228216 defp build_span ( % SpanRecord { origin: "opentelemetry_ecto" , attributes: attributes } = span_record ) do
229217 % Span {
230218 trace_id: span_record . trace_id ,
231- op: span_record . name ,
232- start_timestamp: span_record . start_time ,
233- timestamp: span_record . end_time ,
234219 span_id: span_record . span_id ,
235220 parent_span_id: span_record . parent_span_id ,
221+ op: "db.#{ attributes [ "db.type" ] } .ecto" ,
222+ description: attributes [ "db.statement" ] || span_record . name ,
236223 origin: span_record . origin ,
237- data: % {
238- "db.system" => attributes [ :"db.system" ] ,
239- "db.name" => attributes [ :"db.name" ]
240- }
224+ start_timestamp: span_record . start_time ,
225+ timestamp: span_record . end_time ,
226+ data: attributes
241227 }
242228 end
243229
0 commit comments