getsentry / raven-go

Sentry client in Go
https://sentry.io
BSD 3-Clause "New" or "Revised" License
561 stars 147 forks source link

Add level/severity support #258

Closed stevenon1003 closed 5 years ago

stevenon1003 commented 5 years ago

Currently all sentry messages are ERROR level. To support "debug"/"info"/"warning"/"fatal", we can use tags parameter. Actually in Sentry UI panel, we can see "level" tag but the value is always "error" at this moment.

The change is backward compatible. If developer wants to use this new enhancement, here is an example:

raven.CaptureErrorAndWait(errors.New("Test1"),map[string]string{
    "level" : "warning",
})
kamilogorek commented 5 years ago

Can you extract it to a separate function? It's repeated 8 times 😅

func setPacketLevel (packet *Packet, level string) {
  if Severity(level) != "" {
    packet.Level = Severity(level)
  }
}

// ...

setPacketLevel(packet, tags["level"])
kamilogorek commented 5 years ago

@stevenon1003 upon the second reading, I just realized that all those packets are just sent through Capture call, which already has a place for modifications like this.

https://github.com/getsentry/raven-go/blob/c977f96e109525a5d8fa10a19165341f601f38b0/client.go#L628-L659

Therefore, your whole PR, can be summarized to just adding this 3 lines below line 645 😅:

if Severity(captureTags["level"]) != "" {
    packet.Level = Severity(captureTags["level"])
}
stevenon1003 commented 5 years ago

@stevenon1003 upon the second reading, I just realized that all those packets are just sent through Capture call, which already has a place for modifications like this.

https://github.com/getsentry/raven-go/blob/c977f96e109525a5d8fa10a19165341f601f38b0/client.go#L628-L659

Therefore, your whole PR, can be summarized to just adding this 3 lines below line 645 😅:

if Severity(captureTags["level"]) != "" {
    packet.Level = Severity(captureTags["level"])
}

Thanks @kamilogorek , it is the first time for me to contribute in github / sentry library. Thanks for sharing your idea.

kamilogorek commented 5 years ago

Awesome! Thanks for your contribution :)