https://github.com/yext/glog-contrib
Contributed code for use with the glog package. For example, logging backends that integrate with other services.
https://github.com/yext/glog-contrib
Last synced: 11 months ago
JSON representation
Contributed code for use with the glog package. For example, logging backends that integrate with other services.
- Host: GitHub
- URL: https://github.com/yext/glog-contrib
- Owner: yext
- License: mit
- Created: 2014-03-07T20:09:37.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2023-07-12T21:13:53.000Z (about 3 years ago)
- Last Synced: 2024-07-30T14:34:06.693Z (about 2 years ago)
- Language: Go
- Size: 56.6 KB
- Stars: 2
- Watchers: 21
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
glog-contrib
============
Contributed code for use with the glog package. For example, logging backends that integrate with other services.
## Sentry
The Sentry package contains an implementation of a bridge between
the sentry-go package and glog which allows for glog errors of
level ERROR to be tracked as errors in Sentry. This includes
custom code that interfaces with the xerrors package (as well
as the Yext fork named yerrors) in order to send stack trace
data for the glog invocation, error object construction,
and any masked error calls to Sentry.
`sentry.CaptureErrors` is the entrypoint for tracking Sentry exceptions via glog.
Given Sentry DSNs and client options (DSN should not be specified in opts),
constructs individual Sentry Client's for each DSN. The glog.Event channel
should be provided by running `glog.RegisterBackend()`. For example:
```go
sentry.CaptureErrors(
"projectName",
[]string{"https://primaryDsn", "https://optionalSecondaryDsn", ...},
sentrygo.ClientOptions{
Release: "release",
Environment: "prod",
},
glog.RegisterBackend())
```
When an event is received via glog at the ERROR severity,
the first provided DSN will be used, unless a `sentry.AltDsn`
is tagged on the glog event, in which case the specified client
for that DSN will be used:
```go
glog.Error("error for secondary DSN", sentry.AltDsn("https://optionalSecondaryDsn"))
```
## Installation
glog-contrib is released as a Go module. To download the latest version, run
```
go get github.com/yext/glog-contrib
```