-
Notifications
You must be signed in to change notification settings - Fork 581
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
Implement http.Hijacker for otelmux #6562
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,17 +35,14 @@ func TestPassthroughSpanFromGlobalTracer(t *testing.T) { | |
// span context in the incoming request context. | ||
router.HandleFunc("/user/{id}", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { | ||
called = true | ||
got := trace.SpanFromContext(r.Context()).SpanContext() | ||
assert.Equal(t, sc, got) | ||
w.WriteHeader(http.StatusOK) | ||
})) | ||
|
||
r := httptest.NewRequest("GET", "/user/123", nil) | ||
r = r.WithContext(trace.ContextWithRemoteSpanContext(context.Background(), sc)) | ||
req := httptest.NewRequest("GET", "/user/123", nil) | ||
req = req.WithContext(trace.ContextWithSpanContext(context.Background(), sc)) | ||
w := httptest.NewRecorder() | ||
router.ServeHTTP(w, req) | ||
|
||
router.ServeHTTP(w, r) | ||
assert.True(t, called, "failed to run test") | ||
assert.True(t, called) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why does this test need changing? |
||
} | ||
|
||
func TestPropagationWithGlobalPropagators(t *testing.T) { | ||
|
@@ -190,3 +187,18 @@ func TestFilter(t *testing.T) { | |
assert.Equal(t, 1, calledHealth, "failed to run test") | ||
assert.Equal(t, 1, calledTest, "failed to run test") | ||
} | ||
|
||
func TestRecordingResponseWriterHijack(t *testing.T) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Those two tests need to be fixed (so does the linter). |
||
handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { | ||
rrw := getRRW(w) | ||
conn, rw, err := rrw.Hijack() | ||
assert.Nil(t, conn) | ||
assert.Nil(t, rw) | ||
assert.NotNil(t, err) | ||
assert.Equal(t, "underlying ResponseWriter does not support hijacking", err.Error()) | ||
}) | ||
|
||
req := httptest.NewRequest("GET", "/", nil) | ||
w := httptest.NewRecorder() | ||
handler.ServeHTTP(w, req) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.