-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Description
I just noticed that in our mapping of otel spans -> sentry spans, we have the logic:
const httpTarget = attributes[SemanticAttributes.HTTP_TARGET];
const httpRoute = attributes[SemanticAttributes.HTTP_ROUTE];
// Ex. /api/users
const httpPath = httpRoute || httpTarget;However, I just ran some experiments, and noticed that the target is always just the path of the request, even if it goes to an external URL:
http.request('http://example.com?what=true#hahaha', (httpRes) => {
httpRes.on('data', () => {});
httpRes.on('end', (d) => {
res.send({ version: "v2" });
});
}).end();Results in a span:
{
'http.url': 'http://example.com/?what=true',
'http.method': 'GET',
'http.target': '/?what=true',
'net.peer.name': 'example.com',
'http.host': 'example.com:80',
'net.peer.ip': '93.184.216.34',
'net.peer.port': 80,
'http.response_content_length_uncompressed': 1413,
'http.status_code': 200,
'http.status_text': 'OK',
'http.flavor': '1.1',
'net.transport': 'ip_tcp'
}
and:
app.get("/test-2", function (req, res) {
http.request('/test-3', (httpRes) => {
httpRes.on('data', () => {});
httpRes.on('end', (d) => {
res.send({ other: 123 });
});
}).end();
});results in:
{
'http.url': 'http://localhost/test-3',
'http.method': 'GET',
'http.target': '/test-3',
'net.peer.name': 'localhost',
'http.host': 'localhost:80',
'http.error_name': 'Error',
'http.error_message': 'connect ECONNREFUSED 127.0.0.1:80'
}
So I think we have to use the http.url instead of http.target? I don't see a good way to know programmatically that you are making a request to your own host, sadly, but maybe somebody has a good idea?
Metadata
Metadata
Assignees
Labels
No labels