Skip to content

Commit

Permalink
Merge branch 'master' into fix/missing-stacktrack
Browse files Browse the repository at this point in the history
  • Loading branch information
ribice authored Apr 2, 2024
2 parents c03711a + c12c44b commit af7c573
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 49 deletions.
2 changes: 1 addition & 1 deletion .craft.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
minVersion: 0.35.0
changelogPolicy: auto
changelogPolicy: simple
artifactProvider:
name: none
targets:
Expand Down
9 changes: 0 additions & 9 deletions .github/workflows/danger.yml

This file was deleted.

3 changes: 2 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,10 @@ jobs:
- name: Test
run: make test-coverage
- name: Upload coverage to Codecov
uses: codecov/codecov-action@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d # pin@v3.1.4
uses: codecov/codecov-action@c16abc29c95fcf9174b58eb7e1abf4c866893bc8 # pin@v4.1.1
with:
directory: .coverage
token: ${{ secrets.CODECOV_TOKEN }}
- name: Test (with race detection)
run: make test-race
# The race detector adds considerable runtime overhead. To save time on
Expand Down
3 changes: 1 addition & 2 deletions dsn.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,10 @@ func NewDsn(rawURL string) (*Dsn, error) {
// Port
var port int
if parsedURL.Port() != "" {
parsedPort, err := strconv.Atoi(parsedURL.Port())
port, err = strconv.Atoi(parsedURL.Port())
if err != nil {
return nil, &DsnParseError{"invalid port"}
}
port = parsedPort
} else {
port = scheme.defaultPort()
}
Expand Down
20 changes: 8 additions & 12 deletions interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,6 @@ const (
LevelFatal Level = "fatal"
)

func getSensitiveHeaders() map[string]bool {
return map[string]bool{
"Authorization": true,
"Cookie": true,
"X-Forwarded-For": true,
"X-Real-Ip": true,
}
}

// SdkInfo contains all metadata about about the SDK being used.
type SdkInfo struct {
Name string `json:"name,omitempty"`
Expand Down Expand Up @@ -171,6 +162,13 @@ type Request struct {
Env map[string]string `json:"env,omitempty"`
}

var sensitiveHeaders = map[string]struct{}{
"Authorization": {},
"Cookie": {},
"X-Forwarded-For": {},
"X-Real-Ip": {},
}

// NewRequest returns a new Sentry Request from the given http.Request.
//
// NewRequest avoids operations that depend on network access. In particular, it
Expand Down Expand Up @@ -201,7 +199,6 @@ func NewRequest(r *http.Request) *Request {
env = map[string]string{"REMOTE_ADDR": addr, "REMOTE_PORT": port}
}
} else {
sensitiveHeaders := getSensitiveHeaders()
for k, v := range r.Header {
if _, ok := sensitiveHeaders[k]; !ok {
headers[k] = strings.Join(v, ",")
Expand Down Expand Up @@ -527,13 +524,12 @@ func (e *Event) checkInMarshalJSON() ([]byte, error) {

// NewEvent creates a new Event.
func NewEvent() *Event {
event := Event{
return &Event{
Contexts: make(map[string]Context),
Extra: make(map[string]interface{}),
Tags: make(map[string]string),
Modules: make(map[string]string),
}
return &event
}

// Thread specifies threads that were running at the time of an event.
Expand Down
17 changes: 8 additions & 9 deletions internal/ratelimit/category.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,14 @@ var knownCategories = map[Category]struct{}{

// String returns the category formatted for debugging.
func (c Category) String() string {
switch c {
case "":
if c == "" {
return "CategoryAll"
default:
caser := cases.Title(language.English)
rv := "Category"
for _, w := range strings.Fields(string(c)) {
rv += caser.String(w)
}
return rv
}

caser := cases.Title(language.English)
rv := "Category"
for _, w := range strings.Fields(string(c)) {
rv += caser.String(w)
}
return rv
}
19 changes: 9 additions & 10 deletions sentry.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,18 +72,17 @@ func Recover() *EventID {

// RecoverWithContext captures a panic and passes relevant context object.
func RecoverWithContext(ctx context.Context) *EventID {
if err := recover(); err != nil {
var hub *Hub

if HasHubOnContext(ctx) {
hub = GetHubFromContext(ctx)
} else {
hub = CurrentHub()
}
err := recover()
if err == nil {
return nil
}

return hub.RecoverWithContext(ctx, err)
hub := GetHubFromContext(ctx)
if hub == nil {
hub = CurrentHub()
}
return nil

return hub.RecoverWithContext(ctx, err)
}

// WithScope is a shorthand for CurrentHub().WithScope.
Expand Down
6 changes: 3 additions & 3 deletions traces_profiler.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (

// Checks whether the transaction should be profiled (according to ProfilesSampleRate)
// and starts a profiler if so.
func (span *Span) sampleTransactionProfile() {
var sampleRate = span.clientOptions().ProfilesSampleRate
func (s *Span) sampleTransactionProfile() {
var sampleRate = s.clientOptions().ProfilesSampleRate
switch {
case sampleRate < 0.0 || sampleRate > 1.0:
Logger.Printf("Skipping transaction profiling: ProfilesSampleRate out of range [0.0, 1.0]: %f\n", sampleRate)
Expand All @@ -19,7 +19,7 @@ func (span *Span) sampleTransactionProfile() {
if globalProfiler == nil {
Logger.Println("Skipping transaction profiling: the profiler couldn't be started")
} else {
span.collectProfile = collectTransactionProfile
s.collectProfile = collectTransactionProfile
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions tracing.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,11 +169,11 @@ func StartSpan(ctx context.Context, operation string, options ...SpanOption) *Sp

span.Sampled = span.sample()

span.recorder = &spanRecorder{}
if hasParent {
span.recorder = parent.spanRecorder()
} else {
span.recorder = &spanRecorder{}
}

span.recorder.record(&span)

hub := hubFromContext(ctx)
Expand Down

0 comments on commit af7c573

Please sign in to comment.