https://github.com/piotrkowalczuk/zapstackdriver
Helper package that allows logging using zap in stackdriver compatible format.
https://github.com/piotrkowalczuk/zapstackdriver
logging stackdriver zap
Last synced: 9 months ago
JSON representation
Helper package that allows logging using zap in stackdriver compatible format.
- Host: GitHub
- URL: https://github.com/piotrkowalczuk/zapstackdriver
- Owner: piotrkowalczuk
- Created: 2018-02-05T10:21:00.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2023-05-15T11:10:11.000Z (over 2 years ago)
- Last Synced: 2025-02-10T06:29:09.304Z (11 months ago)
- Topics: logging, stackdriver, zap
- Language: Go
- Size: 15.6 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# zapstackdriver [](https://godoc.org/github.com/piotrkowalczuk/zapstackdriver)
## Compatibility
* [LogSeverity](https://cloud.google.com/logging/docs/reference/v2/rest/v2/LogEntry#LogSeverity) - is mapped from zap log level.
* [HttpRequest](https://cloud.google.com/logging/docs/reference/v2/rest/v2/LogEntry#HttpRequest) - using [HTTPRequest](https://godoc.org/github.com/piotrkowalczuk/zapstackdriver#HTTPRequest)
* [LogEntryOperation](https://cloud.google.com/logging/docs/reference/v2/rest/v2/LogEntry#LogEntryOperation) - through [operation](https://godoc.org/github.com/piotrkowalczuk/zapstackdriver/operation) package interface
* [LogEntrySourceLocation](https://cloud.google.com/logging/docs/reference/v2/rest/v2/LogEntry#LogEntrySourceLocation) - it's filled automatically, due to Go limitations function name is missing
* [serviceContext](https://cloud.google.com/error-reporting/docs/formatting-error-messages) - using [ServiceContext](https://godoc.org/github.com/piotrkowalczuk/zapstackdriver#ServiceContext)
## Benchmarks
Custom [EncodeEntry](https://godoc.org/github.com/piotrkowalczuk/zapstackdriver#Encoder.EncodeEntry) does not slows down zap significantly.
```
goos: darwin
goarch: amd64
pkg: github.com/piotrkowalczuk/zapstackdriver
BenchmarkEncoder/production-2 1000000 1321 ns/op 321 B/op 3 allocs/op
BenchmarkEncoder/development-2 200000 7150 ns/op 536 B/op 12 allocs/op
BenchmarkEncoder/stackdriver-2 1000000 1332 ns/op 325 B/op 3 allocs/op
PASS
ok github.com/piotrkowalczuk/zapstackdriver 4.225s
```