Skip to content

Commit 2a66234

Browse files
committed
(for Q5) update OTel Bridge compatibility mapping pseudo-code to set span service.target rather than destination.service.resource
1 parent 80f3782 commit 2a66234

1 file changed

Lines changed: 15 additions & 20 deletions

File tree

specs/agents/tracing-api-otel.md

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -169,13 +169,14 @@ if (span_kind == 'SERVER' && (isRpc || isHttp)) {
169169
}
170170
```
171171

172-
#### Span type, sub-type and destination service resource
172+
#### Span type, sub-type and service target
173173

174174
```javascript
175175
a = span.otel.attributes;
176176
type = undefined;
177177
subtype = undefined;
178-
resource = undefined;
178+
serviceTargetType = null;
179+
serviceTargetName = null;
179180

180181
httpPortFromScheme = function (scheme) {
181182
if ('http' == scheme) {
@@ -207,11 +208,8 @@ if (netName && netPort > 0) {
207208
if (a['db.system']) {
208209
type = 'db'
209210
subtype = a['db.system'];
210-
resource = netName || subtype;
211-
if (a['db.name']) {
212-
resource += '/'
213-
resource += a['db.name'];
214-
}
211+
serviceTargetType = subtype;
212+
serviceTargetName = a['db.name'] || null;
215213

216214
} else if (a['messaging.system']) {
217215
type = 'messaging';
@@ -220,33 +218,28 @@ if (a['db.system']) {
220218
if (!netName && a['messaging.url']) {
221219
netName = parseNetName(a['messaging.url']);
222220
}
223-
resource = netName || subtype;
224-
if (a['messaging.destination']) {
225-
resource += '/';
226-
resource += a['messaging.destination'];
227-
}
221+
serviceTargetType = subtype;
222+
serviceTargetName = a['messaging.destination'] || null;
228223

229224
} else if (a['rpc.system']) {
230225
type = 'external';
231226
subtype = a['rpc.system'];
232-
resource = netName || subtype;
233-
if (a['rpc.service']) {
234-
resource += '/';
235-
resource += a['rpc.service'];
236-
}
227+
serviceTargetType = subtype;
228+
serviceTargetName = netName || a['rpc.service'] || null;
237229

238230
} else if (a['http.url'] || a['http.scheme']) {
239231
type = 'external';
240232
subtype = 'http';
233+
serviceTargetType = subtype;
241234

242235
httpHost = a['http.host'] || netPeer;
243236
if (httpHost) {
244237
if (netPort < 0) {
245238
netPort = httpPortFromScheme(a['http.scheme']);
246239
}
247-
resource = netPort < 0 ? httpHost : httpHost + ':' + netPort;
240+
serviceTargetName = netPort < 0 ? httpHost : httpHost + ':' + netPort;
248241
} else if (a['http.url']) {
249-
resource = parseNetName(a['http.url']);
242+
serviceTargetName = parseNetName(a['http.url']);
250243
}
251244
}
252245

@@ -260,7 +253,9 @@ if (type === undefined) {
260253
}
261254
span.type = type;
262255
span.subtype = subtype;
263-
span.destination.service.resource = resource;
256+
if (serviceTargetType || serviceTargetName) {
257+
span.setServiceTarget(serviceTargetType, serviceTargetName);
258+
}
264259
```
265260

266261
### Active Spans and Context

0 commit comments

Comments
 (0)