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

Add Zerolog integration #857

Merged
merged 40 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
6f5a075
initial implementation of zerolog intergration
ribice Jul 10, 2024
833e318
initial implementation of zerolog intergration
ribice Jul 10, 2024
6aab5cc
skip goversion and maxproxs
ribice Jul 10, 2024
a088e3f
linter fix
ribice Jul 10, 2024
6fa0f48
add tests
ribice Jul 10, 2024
1493be2
add tests
ribice Jul 10, 2024
95972fe
remove comment
ribice Jul 10, 2024
564854e
add example
ribice Jul 20, 2024
a7527a9
update changelog
ribice Jul 20, 2024
550a5fc
Merge branch 'master' into zerolog
ribice Jul 20, 2024
7f0ffde
fix linter
ribice Jul 20, 2024
4136b1b
Merge branch 'zerolog' of https://github.com/getsentry/sentry-go into…
ribice Jul 20, 2024
ccfba2f
restructure
ribice Jul 20, 2024
d7b9af1
fix tests
ribice Jul 20, 2024
b15f057
merge
ribice Jul 21, 2024
0a79ba0
improve test coverage
ribice Jul 21, 2024
d1c0861
more tests
ribice Jul 21, 2024
95a256e
Merge branch 'master' into zerolog
ribice Jul 31, 2024
198dac6
more tests
ribice Jul 31, 2024
9022dcf
linter fix
ribice Jul 31, 2024
1c45a32
add comment for options
ribice Aug 4, 2024
4762153
update options comments
ribice Aug 4, 2024
fb10763
update options comments
ribice Aug 4, 2024
9d192ff
Merge branch 'master' into zerolog
ribice Aug 15, 2024
12e0a9e
merge master
ribice Oct 15, 2024
6a657a1
fix tests
ribice Oct 15, 2024
3963514
fix tests
ribice Oct 15, 2024
3706e45
linter fix
ribice Oct 15, 2024
fdcf0e6
Merge branch 'master' into zerolog
ribice Oct 25, 2024
8f6af7e
add more tests
ribice Oct 25, 2024
5c2946f
add fatal
ribice Oct 25, 2024
38f9fb3
remove duplicate code
ribice Oct 25, 2024
0e80084
merge master
ribice Nov 5, 2024
fa33c3d
make zerolog integration a module
ribice Nov 5, 2024
115792f
make zerolog integration a module
ribice Nov 5, 2024
e1db73e
update go vet script
ribice Nov 5, 2024
556bfbf
update go.sum
ribice Nov 5, 2024
4de77fe
merge master
ribice Nov 13, 2024
3cce39f
bump go version to 1.21 in zerolog:
ribice Nov 13, 2024
bd559f4
Update Makefile
cleptric Nov 14, 2024
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
3 changes: 3 additions & 0 deletions .craft.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ targets:
- name: github
tagPrefix: slog/v
tagOnly: true
- name: github
tagPrefix: zerolog/v
tagOnly: true
- name: registry
sdks:
github:getsentry/sentry-go:
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

### Features

- Add `sentryzerolog` integration ([#857](https://github.com/getsentry/sentry-go/pull/857))
- Add `sentryslog` integration ([#865](https://github.com/getsentry/sentry-go/pull/865))

- Always set Mechanism Type to generic ([#896](https://github.com/getsentry/sentry-go/pull/897))

### Misc
Expand Down
49 changes: 49 additions & 0 deletions _examples/zerolog/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package main

import (
"github.com/getsentry/sentry-go"
sentryzerolog "github.com/getsentry/sentry-go/zerolog"
"github.com/rs/zerolog"
"os"
"time"
)

func main() {
w, err := sentryzerolog.New(sentryzerolog.Config{
Options: sentryzerolog.Options{
Levels: []zerolog.Level{
zerolog.DebugLevel,
zerolog.ErrorLevel,
zerolog.FatalLevel,
zerolog.PanicLevel,
},
WithBreadcrumbs: true,
FlushTimeout: 5 * time.Second,
},
ClientOptions: sentry.ClientOptions{
Dsn: "",
Environment: "development",
Release: "1.0",
Debug: true,
AttachStacktrace: true,
},
})

if err != nil {
panic(err)
}

defer func() {
err = w.Close()
if err != nil {
panic(err)
}
}()

m := zerolog.MultiLevelWriter(os.Stdout, w)
logger := zerolog.New(m).With().Timestamp().Logger()

logger.Debug().Msg("Application has started")
logger.Error().Msg("Oh no!")
logger.Fatal().Msg("Can't continue...")
}
20 changes: 20 additions & 0 deletions zerolog/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
module github.com/getsentry/sentry-go/zerolog

go 1.21

require (
github.com/buger/jsonparser v1.1.1
github.com/getsentry/sentry-go v0.29.1
github.com/rs/zerolog v1.33.0
github.com/stretchr/testify v1.9.0
)

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
golang.org/x/sys v0.18.0 // indirect
golang.org/x/text v0.14.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
40 changes: 40 additions & 0 deletions zerolog/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
github.com/buger/jsonparser v1.1.1 h1:2PnMjfWD7wBILjqQbt530v576A/cAbQvEW9gGIpYMUs=
github.com/buger/jsonparser v1.1.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0=
github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/getsentry/sentry-go v0.29.1 h1:DyZuChN8Hz3ARxGVV8ePaNXh1dQ7d76AiB117xcREwA=
github.com/getsentry/sentry-go v0.29.1/go.mod h1:x3AtIzN01d6SiWkderzaH28Tm0lgkafpJ5Bm3li39O0=
github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA=
github.com/go-errors/errors v1.4.2/go.mod h1:sIVyrIiJhuEF+Pj9Ebtd6P/rEYROXFi3BopGUQ5a5Og=
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4=
github.com/pingcap/errors v0.11.4/go.mod h1:Oi8TUi2kEtXXLMJk9l1cGmz20kV3TaQ0usTwv5KuLY8=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
github.com/rs/zerolog v1.33.0 h1:1cU2KZkvPxNyfgEmhHAz/1A9Bz+llsdYzklWFzgp0r8=
github.com/rs/zerolog v1.33.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4=
golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
Loading
Loading