Skip to content

Expose socket-level stats in response #427

Description

@daniil-poletaev

We're migrating from got-scraping to impit in proxy. One thing we're currently unable to replace is the socket-level data transfer stats that got-scraping exposed via response.request.socket:

response = await gotScraping.get(...);
const { body, statusCode } = response;

// Compute data transfer stats
// We store the previous bytes due to the fact that sockets can be reused
const { socket } = response.request as {
   socket: Socket & {
      prevBytesRead?: number;
      prevBytesWritten?: number;
   };
};
const socketBytesRead = socket.bytesRead;
const socketBytesWritten = socket.bytesWritten;
this._incrementStats(connectionId, {
   [providerId]: {
      recvBytes: socketBytesRead - (socket.prevBytesRead || 0),
      sentBytes: socketBytesWritten - (socket.prevBytesWritten || 0),
   },
});

Can we expose socket stats in Impit as well?

Metadata

Metadata

Assignees

No one assigned

    Labels

    t-toolingIssues with this label are in the ownership of the tooling team.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions