@@ -128,6 +128,12 @@ class StreamingSpanEvent {
128
128
129
129
let span = null
130
130
if ( StreamingHttpSpanEvent . isHttpSegment ( segment ) ) {
131
+ // Get external host from the segment name
132
+ const nameParams = segment . name . split ( '/' )
133
+ const external = nameParams . indexOf ( 'External' )
134
+ if ( external > - 1 ) {
135
+ agentAttributes . host = nameParams [ external + 1 ]
136
+ }
131
137
span = new StreamingHttpSpanEvent ( traceId , agentAttributes , customAttributes )
132
138
} else if ( StreamingDatastoreSpanEvent . isDatastoreSegment ( segment ) ) {
133
139
span = new StreamingDatastoreSpanEvent ( traceId , agentAttributes , customAttributes )
@@ -194,10 +200,14 @@ class StreamingHttpSpanEvent extends StreamingSpanEvent {
194
200
195
201
if ( agentAttributes . url ) {
196
202
this . addAgentAttribute ( 'http.url' , agentAttributes . url )
197
- this . addAgentAttribute ( 'server.address' , new URL ( agentAttributes . url ) . hostname )
198
203
agentAttributes . url = null
199
204
}
200
205
206
+ if ( agentAttributes . host ) {
207
+ this . addAgentAttribute ( 'server.address' , agentAttributes . host )
208
+ agentAttributes . host = null
209
+ }
210
+
201
211
if ( agentAttributes . procedure ) {
202
212
this . addAgentAttribute ( 'http.method' , agentAttributes . procedure )
203
213
this . addAgentAttribute ( 'http.request.method' , agentAttributes . procedure )
0 commit comments