Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apps with socket.io have 3x duplicate telemetry for incoming HTTP requests #446

Closed
OsvaldoRosado opened this issue Nov 5, 2018 · 0 comments

Comments

@OsvaldoRosado
Copy link
Member

OsvaldoRosado commented Nov 5, 2018

Socket.io creates its own listeners on the HTTP server passed in, which later call the users’s own listeners. The SDK patches each listener, causing the unintentional duplication at each level.

We perform a simple check for avoiding duplication on outgoing HTTP dependencies (https://github.com/Microsoft/ApplicationInsights-node.js/blob/develop/AutoCollection/HttpDependencies.ts#L61) but no such check is done for incoming HTTP requests. Adding this simple check for ensuring the request object was not acted upon yet would fix this bug. In the meantime, it can also be implemented within a telemetry processor for anyone hitting this bug.

The bug can be reproduced with:

const appInsights = require('applicationinsights');
appInsights.setup('ikey').start();

const express = require('express');
const app = express();
const server = require('http').createServer(app);
const io = require('socket.io')(server);

const router = express.Router();

router.get('/test', (req, res, next) => {
        res.status(200).send('Hello!');
});

app.use('/', router);


io.on('connection', function(){ 

});
server.listen(3000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant