Skip to content

RUM resource size reports as 0b when responses are chunked/streamed (no Content-Length) #940

@vincevargadev

Description

@vincevargadev

Feature description

Some of the HTTP requests that we track with the Flutter Datadog SDK report Resource size 0b. This causes visibility issues in our dashboards: We would like to see all requests' size so that we can spot large responses, and we can take action and improve our app.

I checked the implementation and it looks like the tracking_http_client only reports Content-Length and if that is not available, the request size will show up as 0b.

We would like to see the response size in the Datadog web UI for all requests are app makes.

Proposed solution

Use Content-Length when available, manually count response bytes otherwise, and report that value as resource size.

Rough draft to clarify idea:

int _bytesReceived = 0;

return innerResponse.listen(
  (data) {
    _bytesReceived += data.length;
    if (onData != null) onData(data);
  },
  // ...
);

final size = innerResponse.contentLength > 0
    ? innerResponse.contentLength
    : (_bytesReceived > 0 ? _bytesReceived : null);

rum.stopResource(rumKey!, statusCode, resourceType, size, attributes);

Other relevant information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions