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

Update sentry call #65

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
coverage.out
logrussentry
23 changes: 13 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
sudo: false
language: go
go:
- 1.4
- 1.5
- 1.6
- 1.7
- tip
matrix:
allow_failures:
- go: tip
- 1.9

env:
global:
secure: swil3Y+gIZkN/Ch6NF13dM1QPF+rABiW5kTSP149arwwu1tcDGIv/64zifGzrOxkrez9ZUQzJs5fqsBtRX5p4Q8hC7s8D+3On5TqLovPUr4Pu5Fjy4VJdGz6NaD1Zp1hcwBPJo30efI16utACfjDSuvGhc2s3W98LmZJajaNqVbDFYOkCgZQgIToWeMQ25ZcObvsM+RrJUsZMndSaCZ0N4JTA3fb4uygOmd60qo/kcoiYbp7daP0cshq9IggcQPlPgVraodmY4MLy5bCRHtN6xzqa0DfzvGHqPp815pIYCYi2AxfdkrnUz1ZZxGIv7lrC4MHe+kC7YSe1YhJYfxEFInXhbOd5bcdQeJ0By1V0woku5wzXU7MrE4ZqzABYUhbEFdyWFrBqkvMWkLE70uFhpRxQgE8x9C0qbjY7/yNK0RRPXyiGn98kk6eio+H1fPdxUI/PlrmblUiObvjnWZo+rSWajSlzdYzFvY+OOrP3H7dSQTbotsqqqQYyIILxOX+zbQR+SNlRURqhra7xOreYSSaCyZBzCi0O3B4iz2AdwRdb6OVz7YRIJZuOr02Ht+H0csnzMs3IWHxjLxB6SmpQvZ1cMUy04vgQWsghcTip1jVsU5oTYLtW0V501p0DjcLdzKo6lj+fddjMLeV0Ok6S1v717Cu03DaMYzbp2VnXjI=

before_install:
- go get github.com/axw/gocov/gocov
- go get github.com/mattn/goveralls
- if ! go get github.com/golang/tools/cmd/cover; then go get golang.org/x/tools/cmd/cover; fi
- if ! go get github.com/golang/tools/cmd/cover; then go get golang.org/x/tools/cmd/cover;
fi

before_script:
- go vet ./...
- gofmt -s -l .

script:
- $HOME/gopath/bin/goveralls -service=travis-ci
- go test -v -covermode=count -coverprofile=coverage.out
- "$HOME/gopath/bin/goveralls -coverprofile=coverage.out -service=travis-ci -repotoken
$COVERALLS_TOKEN"
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Sentry Hook for Logrus <img src="http://i.imgur.com/hTeVwmJ.png" width="40" height="40" alt=":walrus:" class="emoji" title=":walrus:" />


[![Build Status](https://travis-ci.org/evalphobia/logrus_sentry.svg?branch=master)](https://travis-ci.org/evalphobia/logrus_sentry) [![Coverage Status](https://coveralls.io/repos/evalphobia/logrus_sentry/badge.svg?branch=master&service=github)](https://coveralls.io/github/evalphobia/logrus_sentry?branch=master) [![GoDoc](https://godoc.org/github.com/evalphobia/logrus_sentry?status.svg)](https://godoc.org/github.com/evalphobia/logrus_sentry)
[![Build Status](https://travis-ci.org/kiip/logrussentry.svg?branch=master)](https://travis-ci.org/kiip/logrussentry) [![Coverage Status](https://coveralls.io/repos/github/kiip/logrussentry/badge.svg?branch=master)](https://coveralls.io/github/kiip/logrussentry?branch=master) [![GoDoc](https://godoc.org/github.com/kiip/logrussentry?status.svg)](https://godoc.org/github.com/kiip/logrussentry)

[Sentry](https://getsentry.com) provides both self-hosted and hosted
solutions for exception tracking.
Expand All @@ -16,13 +16,13 @@ Every sentry application defined on the server gets a different

```go
import (
"github.com/sirupsen/logrus"
"github.com/evalphobia/logrus_sentry"
"github.com/kiip/logrus"
"github.com/kiip/logrussentry"
)

func main() {
log := logrus.New()
hook, err := logrus_sentry.NewSentryHook(YOUR_DSN, []logrus.Level{
hook, err := logrussentry.NewSentryHook(YOUR_DSN, []logrus.Level{
logrus.PanicLevel,
logrus.FatalLevel,
logrus.ErrorLevel,
Expand All @@ -45,7 +45,7 @@ levels := []logrus.Level{
logrus.FatalLevel,
logrus.ErrorLevel,
}
hook, err := logrus_sentry.NewWithTagsSentryHook(YOUR_DSN, tags, levels)
hook, err := logrussentry.NewWithTagsSentryHook(YOUR_DSN, tags, levels)

```

Expand All @@ -54,8 +54,8 @@ the `NewWithClientSentryHook` constructor:

```go
import (
"github.com/sirupsen/logrus"
"github.com/evalphobia/logrus_sentry"
"github.com/kiip/logrus"
"github.com/kiip/logrussentry"
"github.com/getsentry/raven-go"
)

Expand All @@ -67,7 +67,7 @@ func main() {
log.Fatal(err)
}

hook, err := logrus_sentry.NewWithClientSentryHook(client, []logrus.Level{
hook, err := logrussentry.NewWithClientSentryHook(client, []logrus.Level{
logrus.PanicLevel,
logrus.FatalLevel,
logrus.ErrorLevel,
Expand Down Expand Up @@ -116,7 +116,7 @@ The SentryHook has a default timeout of `100 milliseconds` when created
with a call to `NewSentryHook`. This can be changed by assigning a value to the `Timeout` field:

```go
hook, _ := logrus_sentry.NewSentryHook(...)
hook, _ := logrussentry.NewSentryHook(...)
hook.Timeout = 20*time.Second
```

Expand All @@ -126,7 +126,7 @@ By default the hook will not send any stacktraces. However, this can be enabled
with:

```go
hook, _ := logrus_sentry.NewSentryHook(...)
hook, _ := logrussentry.NewSentryHook(...)
hook.StacktraceConfiguration.Enable = true
```

Expand Down
4 changes: 2 additions & 2 deletions async_test.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package logrus_sentry
package logrussentry

import (
"net/http"
"sync"
"testing"
"time"

"github.com/sirupsen/logrus"
"github.com/kiip/logrus"
)

func TestParallelLogging(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions data_field.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package logrus_sentry
package logrussentry

import (
"net/http"

"github.com/getsentry/raven-go"
"github.com/sirupsen/logrus"
"github.com/kiip/logrus"
)

const (
Expand Down
4 changes: 2 additions & 2 deletions data_field_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package logrus_sentry
package logrussentry

import (
"errors"
Expand All @@ -8,7 +8,7 @@ import (
"testing"

"github.com/getsentry/raven-go"
"github.com/sirupsen/logrus"
"github.com/kiip/logrus"
"github.com/stretchr/testify/assert"
)

Expand Down
6 changes: 3 additions & 3 deletions sentry.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package logrus_sentry
package logrussentry

import (
"encoding/json"
Expand All @@ -8,8 +8,8 @@ import (
"time"

"github.com/getsentry/raven-go"
"github.com/kiip/logrus"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
)

var (
Expand Down Expand Up @@ -313,7 +313,7 @@ func (hook *SentryHook) convertStackTrace(st errors.StackTrace) *raven.Stacktrac
pc := uintptr(stFrames[i])
fn := runtime.FuncForPC(pc)
file, line := fn.FileLine(pc)
frame := raven.NewStacktraceFrame(pc, file, line, stConfig.Context, stConfig.InAppPrefixes)
frame := raven.NewStacktraceFrame(pc, fn.Name(), file, line, stConfig.Context, stConfig.InAppPrefixes)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this fn call need to fix quickly ...

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Owner

@evalphobia evalphobia Dec 15, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So only this line is needed to follow changed parameters on NewStacktraceFrame ?
Sorry, I thought this PR was accidentally created by mistake.
Should I create new PR or @shreyasj2006 would you fix this PR ?

@naiba Sorry, I forgot merging and already fixed by @Sef1995
#66

if frame != nil {
frames = append(frames, frame)
}
Expand Down
14 changes: 8 additions & 6 deletions sentry_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package logrus_sentry
package logrussentry

import (
"compress/zlib"
Expand All @@ -16,8 +16,8 @@ import (
"time"

"github.com/getsentry/raven-go"
"github.com/kiip/logrus"
pkgerrors "github.com/pkg/errors"
"github.com/sirupsen/logrus"
)

const (
Expand Down Expand Up @@ -278,8 +278,10 @@ func TestSentryStacktrace(t *testing.T) {
if stacktraceSize == 0 {
t.Error("Stacktrace should not be empty")
}
lastFrame := packet.Stacktrace.Frames[stacktraceSize-2]
expectedSuffix := "logrus_sentry/sentry_test.go"

lastFrame := packet.Stacktrace.Frames[stacktraceSize-1]
expectedSuffix := "logrussentry/sentry_test.go"

if !strings.HasSuffix(lastFrame.Filename, expectedSuffix) {
t.Errorf("File name should have ended with %s, was %s", expectedSuffix, lastFrame.Filename)
}
Expand All @@ -290,7 +292,7 @@ func TestSentryStacktrace(t *testing.T) {
t.Error("Frame should not be identified as in_app without prefixes")
}

hook.StacktraceConfiguration.InAppPrefixes = []string{"github.com/sirupsen/logrus"}
hook.StacktraceConfiguration.InAppPrefixes = []string{"github.com/kiip/logrus"}
hook.StacktraceConfiguration.Context = 2
hook.StacktraceConfiguration.Skip = 2

Expand All @@ -301,7 +303,7 @@ func TestSentryStacktrace(t *testing.T) {
t.Error("Stacktrace should not be empty")
}
lastFrame = packet.Stacktrace.Frames[stacktraceSize-1]
expectedFilename := "github.com/sirupsen/logrus/entry.go"
expectedFilename := "github.com/kiip/logrus/entry.go"
if lastFrame.Filename != expectedFilename {
t.Errorf("File name should have been %s, was %s", expectedFilename, lastFrame.Filename)
}
Expand Down
2 changes: 1 addition & 1 deletion utils.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package logrus_sentry
package logrussentry

import (
"fmt"
Expand Down