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

doc(webconnectivitylte): clarify http_transaction_{start,end} semantics #1495

Merged
merged 1 commit into from
Feb 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions internal/experiment/webconnectivitylte/cleartextflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,15 +243,13 @@ func (t *CleartextFlow) httpTransaction(ctx context.Context, network, address, a
txp model.HTTPTransport, req *http.Request, trace *measurexlite.Trace) (*http.Response, []byte, error) {
const maxbody = 1 << 19
started := trace.TimeSince(trace.ZeroTime())
// TODO(bassosimone): I am wondering whether we should have the HTTP transaction
// start at the beginning of the flow rather than here. If we start it at the
// beginning this is nicer, but, at the same time, starting it at the beginning
// of the flow means we're not collecting information about DNS. So, I am a
// bit torn about what is the best approach to follow here. Maybe it does not
// even matter to emit transaction_start/end events given that we have transaction ID.

// Implementation note: we want to emit http_transaction_start when we actually start doing
// HTTP things such that it's possible to correctly classify network events
t.TestKeys.AppendNetworkEvents(measurexlite.NewAnnotationArchivalNetworkEvent(
trace.Index(), started, "http_transaction_start", trace.Tags()...,
))

resp, err := txp.RoundTrip(req)
var body []byte
if err == nil {
Expand All @@ -265,10 +263,12 @@ func (t *CleartextFlow) httpTransaction(ctx context.Context, network, address, a
if err == nil && httpRedirectIsRedirect(resp) {
err = httpValidateRedirect(resp)
}

finished := trace.TimeSince(trace.ZeroTime())
t.TestKeys.AppendNetworkEvents(measurexlite.NewAnnotationArchivalNetworkEvent(
trace.Index(), finished, "http_transaction_done", trace.Tags()...,
))

ev := measurexlite.NewArchivalHTTPRequestResult(
trace.Index(),
started,
Expand All @@ -284,6 +284,7 @@ func (t *CleartextFlow) httpTransaction(ctx context.Context, network, address, a
finished,
trace.Tags()...,
)

t.TestKeys.PrependRequests(ev)
return resp, body, err
}
Expand Down
13 changes: 7 additions & 6 deletions internal/experiment/webconnectivitylte/secureflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,15 +298,13 @@ func (t *SecureFlow) httpTransaction(ctx context.Context, network, address, alpn
txp model.HTTPTransport, req *http.Request, trace *measurexlite.Trace) (*http.Response, []byte, error) {
const maxbody = 1 << 19
started := trace.TimeSince(trace.ZeroTime())
// TODO(bassosimone): I am wondering whether we should have the HTTP transaction
// start at the beginning of the flow rather than here. If we start it at the
// beginning this is nicer, but, at the same time, starting it at the beginning
// of the flow means we're not collecting information about DNS. So, I am a
// bit torn about what is the best approach to follow here. Maybe it does not
// even matter to emit transaction_start/end events given that we have transaction ID.

// Implementation note: we want to emit http_transaction_start when we actually start doing
// HTTP things such that it's possible to correctly classify network events
t.TestKeys.AppendNetworkEvents(measurexlite.NewAnnotationArchivalNetworkEvent(
trace.Index(), started, "http_transaction_start", trace.Tags()...,
))

resp, err := txp.RoundTrip(req)
var body []byte
if err == nil {
Expand All @@ -320,10 +318,12 @@ func (t *SecureFlow) httpTransaction(ctx context.Context, network, address, alpn
if err == nil && httpRedirectIsRedirect(resp) {
err = httpValidateRedirect(resp)
}

finished := trace.TimeSince(trace.ZeroTime())
t.TestKeys.AppendNetworkEvents(measurexlite.NewAnnotationArchivalNetworkEvent(
trace.Index(), finished, "http_transaction_done", trace.Tags()...,
))

ev := measurexlite.NewArchivalHTTPRequestResult(
trace.Index(),
started,
Expand All @@ -339,6 +339,7 @@ func (t *SecureFlow) httpTransaction(ctx context.Context, network, address, alpn
finished,
trace.Tags()...,
)

t.TestKeys.PrependRequests(ev)
return resp, body, err
}
Expand Down
Loading