Skip to content

Make spans for fetch() more accurate #12640

Closed
@lforst

Description

@lforst

Problem

In JS fetch() basically runs through 3 stages:

  1. fetch() is called and started
  2. fetch() resolves - generally meaning status code and response headers are returned
  3. The response body streams in (either one chunk or multiple chunks over time)

As of today, the spans we record for fetch calls only entail 1 and 2. Since the web is moving more and more towards streaming (LLMs, React Server Components, Server-Sent Events, ...), it would be quite important to also entail the response streams (3).

Solution Brainstorm

There different approaches we can take:

  • Simply extend the spans to also wait for the response body.
  • Extend the span to wait for the response body, but attach a child span that tracks the duration until the first byte (entailing 1 and 2). (see comment)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions