Skip to content

Conversation

jstangroome
Copy link

My primary goal is for http client requests to trace time-to-first-response-byte, and there is very likely a much more efficient method to capture just this detail. The time to the first response byte is important for large streaming responses where it is far less helpful to record only the moment after the entire response body has been completely read.

However, using the existing pattern established by otelhttp.NewHandler(..., otelhttp.WithMessageEvents(otelhttp.ReadEvents)) for http server requests and extending it to also work with otelhttp.NewTransport the same information (and more) becomes available for a very small code change and no API change.

I looked for existing tests for Handler and WithMessageEvents to replicate to Transport but did not find any so I'm not sure what the preferred pattern would be for adding unit tests for this functionality.

@jstangroome jstangroome requested review from a team and dmathieu as code owners June 26, 2025 00:13
Copy link
Member

@dmathieu dmathieu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will need a changelog entry.

Copy link

codecov bot commented Jun 30, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 81.6%. Comparing base (ff63d70) to head (3395be0).

Additional details and impacted files

Impacted file tree graph

@@          Coverage Diff          @@
##            main   #7513   +/-   ##
=====================================
  Coverage   81.5%   81.6%           
=====================================
  Files        200     200           
  Lines      18129   18133    +4     
=====================================
+ Hits       14793   14803   +10     
+ Misses      2938    2932    -6     
  Partials     398     398           
Files with missing lines Coverage Δ
instrumentation/net/http/otelhttp/config.go 91.8% <ø> (+8.1%) ⬆️
instrumentation/net/http/otelhttp/transport.go 95.2% <100.0%> (+0.1%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@dmathieu
Copy link
Member

The linter is now failing :)
Also, the changelog entry needs to be moved up to the unreleased section.

Copy link
Member

@dmathieu dmathieu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM overall.

Comment on lines +652 to +654
if len(spans) != 1 {
t.Fatalf("expected 1 span; got: %d", len(spans))
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use `require.Len`` instead?

Comment on lines +640 to +642
if err != nil {
t.Fatal(err)
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not require.NoError?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants