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

Implement hijacker interface for Negroni integration #871

Merged
merged 4 commits into from
Sep 3, 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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
- Add ability to skip frames in stacktrace ([#852](https://github.com/getsentry/sentry-go/pull/852))
- Remove Martini integration ([#861](https://github.com/getsentry/sentry-go/pull/861))


### Breaking Changes

- WrapResponseWriter has been moved from sentryhttp to sentry. If you've imported it from sentryhttp, you'll need to update your imports.

## 0.28.1

The Sentry SDK team is happy to announce the immediate availability of Sentry Go SDK v0.28.1.
Expand Down
2 changes: 1 addition & 1 deletion http/sentryhttp.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func (h *Handler) handle(handler http.Handler) http.HandlerFunc {
)
transaction.SetData("http.request.method", r.Method)

rw := NewWrapResponseWriter(w, r.ProtoMajor)
rw := sentry.NewWrapResponseWriter(w, r.ProtoMajor)

defer func() {
status := rw.Status()
Expand Down
20 changes: 2 additions & 18 deletions negroni/sentrynegroni.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,22 +45,6 @@ func New(options Options) negroni.Handler {
}
}

// responseWriter is a wrapper around http.ResponseWriter that captures the status code.
type responseWriter struct {
http.ResponseWriter
statusCode int
}

// WriteHeader captures the status code and calls the original WriteHeader method.
func (rw *responseWriter) WriteHeader(code int) {
rw.statusCode = code
rw.ResponseWriter.WriteHeader(code)
}

func newResponseWriter(w http.ResponseWriter) *responseWriter {
return &responseWriter{ResponseWriter: w, statusCode: http.StatusOK}
}

func (h *handler) ServeHTTP(w http.ResponseWriter, r *http.Request, next http.HandlerFunc) {
ctx := r.Context()
hub := sentry.GetHubFromContext(ctx)
Expand Down Expand Up @@ -91,10 +75,10 @@ func (h *handler) ServeHTTP(w http.ResponseWriter, r *http.Request, next http.Ha
options...,
)
transaction.SetData("http.request.method", r.Method)
rw := newResponseWriter(w)
rw := sentry.NewWrapResponseWriter(w, r.ProtoMajor)

defer func() {
status := rw.statusCode
status := rw.Status()
transaction.Status = sentry.HTTPtoSpanStatus(status)
transaction.SetData("http.response.status_code", status)
transaction.Finish()
Expand Down
2 changes: 1 addition & 1 deletion http/wrap_writer.go → wrap_writer.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package sentryhttp
package sentry

import (
"bufio"
Expand Down
2 changes: 1 addition & 1 deletion http/wrap_writer_test.go → wrap_writer_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package sentryhttp
package sentry

import (
"bufio"
Expand Down
Loading