Skip to content

Commit 7fb7209

Browse files
committed
Revert "feat(go): test http-client integration (#362)"
This reverts commit b6005c8.
1 parent 7abeb72 commit 7fb7209

File tree

3 files changed

+45
-19
lines changed

3 files changed

+45
-19
lines changed

potal/go.sum

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
1-
github.com/aldy505/sentry-go v0.0.0-20251120002518-9de99efea3a2 h1:JQ+3yeRe9T53bH29i2bqVRj2dbJsOrAaQMaQP59dnhc=
2-
github.com/aldy505/sentry-go v0.0.0-20251120002518-9de99efea3a2/go.mod h1:eRXCoh3uvmjQLY6qu63BjUZnaBu5L5WhMV1RwYO8W5s=
31
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
42
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
3+
github.com/getsentry/sentry-go v0.36.0 h1:UkCk0zV28PiGf+2YIONSSYiYhxwlERE5Li3JPpZqEns=
4+
github.com/getsentry/sentry-go v0.36.0/go.mod h1:p5Im24mJBeruET8Q4bbcMfCQ+F+Iadc4L48tB1apo2c=
5+
github.com/getsentry/sentry-go v0.36.2-0.20251024113619-cda84dbb8532 h1:j71Y2rcZmVoi3TQqO79Xn4JPwNLVw9PKhCLZDQSKFOI=
6+
github.com/getsentry/sentry-go v0.36.2-0.20251024113619-cda84dbb8532/go.mod h1:p5Im24mJBeruET8Q4bbcMfCQ+F+Iadc4L48tB1apo2c=
7+
github.com/getsentry/sentry-go v0.36.2 h1:uhuxRPTrUy0dnSzTd0LrYXlBYygLkKY0hhlG5LXarzM=
8+
github.com/getsentry/sentry-go v0.36.2/go.mod h1:p5Im24mJBeruET8Q4bbcMfCQ+F+Iadc4L48tB1apo2c=
9+
github.com/getsentry/sentry-go v0.36.3-0.20251028153640-e2badbb7694c h1:lEVNr8EyF7wu8URA7vlhVUPkg8ea57q3ZIrCS8zvwvI=
10+
github.com/getsentry/sentry-go v0.36.3-0.20251028153640-e2badbb7694c/go.mod h1:p5Im24mJBeruET8Q4bbcMfCQ+F+Iadc4L48tB1apo2c=
511
github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA=
612
github.com/go-errors/errors v1.4.2/go.mod h1:sIVyrIiJhuEF+Pj9Ebtd6P/rEYROXFi3BopGUQ5a5Og=
713
github.com/go-test/deep v1.1.1 h1:0r/53hagsehfO4bzD2Pgr/+RgHqhmf+k1Bpse2cTu1U=

potal/internal/potalhttp/client.go

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ import (
99
"net/http"
1010
"os"
1111

12-
sentryhttpclient "github.com/getsentry/sentry-go/httpclient"
13-
1412
"github.com/getsentry/gib-potato/internal/event"
1513
"github.com/getsentry/sentry-go"
1614
)
@@ -19,6 +17,10 @@ func SendRequest(ctx context.Context, e event.PotalEvent) error {
1917
url := os.Getenv("POTAL_URL")
2018

2119
hub := sentry.GetHubFromContext(ctx)
20+
txn := sentry.TransactionFromContext(ctx)
21+
22+
span := txn.StartChild("http.client", sentry.WithDescription(fmt.Sprintf("POST %s", url)))
23+
defer span.Finish()
2224

2325
body, jsonErr := json.Marshal(e)
2426
if jsonErr != nil {
@@ -27,32 +29,49 @@ func SendRequest(ctx context.Context, e event.PotalEvent) error {
2729
return jsonErr
2830
}
2931

30-
r, newReqErr := http.NewRequestWithContext(ctx, "POST", url, bytes.NewBuffer(body))
32+
r, newReqErr := http.NewRequest("POST", url, bytes.NewBuffer(body))
3133
if newReqErr != nil {
3234
hub.CaptureException(newReqErr)
3335
log.Printf("An Error Occured %v", newReqErr)
3436
return newReqErr
3537
}
3638

3739
r.Header.Add("Content-Type", "application/json")
40+
r.Header.Add("Sentry-Trace", span.ToSentryTrace())
41+
r.Header.Add("Baggage", span.ToBaggage())
3842
r.Header.Add("Authorization", os.Getenv("POTAL_TOKEN"))
3943

40-
client := &http.Client{
41-
Transport: sentryhttpclient.NewSentryRoundTripper(nil),
42-
}
43-
44+
client := &http.Client{}
4445
res, reqErr := client.Do(r)
4546
if reqErr != nil {
4647
hub.CaptureException(reqErr)
48+
span.Status = sentry.SpanStatusInternalError
49+
4750
log.Printf("An Error Occured %v", reqErr)
4851
return reqErr
4952
}
5053
defer func() {
51-
_ = res.Body.Close()
54+
if err := res.Body.Close(); err != nil {
55+
log.Printf("Failed to close response body: %v", err)
56+
}
5257
}()
5358

54-
if res.StatusCode == http.StatusOK {
59+
span.Data = map[string]interface{}{
60+
"http.response.status_code": res.StatusCode,
61+
}
62+
63+
switch res.StatusCode {
64+
case http.StatusOK:
65+
span.Status = sentry.SpanStatusOK
5566
return nil
67+
case http.StatusUnauthorized:
68+
fallthrough
69+
case http.StatusForbidden:
70+
span.Status = sentry.SpanStatusPermissionDenied
71+
case http.StatusNotFound:
72+
span.Status = sentry.SpanStatusNotFound
73+
case http.StatusInternalServerError:
74+
span.Status = sentry.SpanStatusInternalError
5675
}
5776

5877
msg := fmt.Sprintf("GibPotato API: Got %s response", res.Status)

potal/main.go

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,15 @@ var slackClient *slack.Client
1616

1717
func main() {
1818
sentryErr := sentry.Init(sentry.ClientOptions{
19-
Dsn: os.Getenv("SENTRY_POTAL_DSN"),
20-
Release: os.Getenv("RELEASE"),
21-
Environment: os.Getenv("ENVIRONMENT"),
22-
AttachStacktrace: true,
23-
SendDefaultPII: true,
24-
EnableTracing: true,
25-
TracesSampleRate: 1.0,
26-
EnableLogs: true,
19+
Dsn: os.Getenv("SENTRY_POTAL_DSN"),
20+
Release: os.Getenv("RELEASE"),
21+
Environment: os.Getenv("ENVIRONMENT"),
22+
AttachStacktrace: true,
23+
SendDefaultPII: true,
24+
EnableTracing: true,
25+
TracesSampleRate: 1.0,
26+
EnableLogs: true,
27+
EnableTelemetryBuffer: true,
2728
})
2829
if sentryErr != nil {
2930
log.Fatalf("An Error Occured: %v", sentryErr)

0 commit comments

Comments
 (0)