-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
63 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
name: otelzap-go | ||
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
pull_request: | ||
branches: [ "main" ] | ||
|
||
jobs: | ||
|
||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v3 | ||
with: | ||
go-version: 1.18 | ||
|
||
- name: Build | ||
run: go build -v ./... | ||
|
||
- name: Test | ||
run: go test -v -race -coverprofile=coverage.txt -covermode=atomic ./... | ||
|
||
- name: Coverage | ||
uses: codecov/codecov-action@v3 | ||
with: | ||
files: coverage.txt | ||
fail_ci_if_error: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,33 @@ | ||
# otelzap | ||
# otelzap [![GoDoc][doc-img]][doc] [![Build Status][ci-img]][ci] [![Coverage Status][cov-img]][cov] [![Go Report Card][reportcard-img]][reportcard] | ||
|
||
OpenTelemetry integration with ZAP logger | ||
OpenTelemetry integration with ZAP logger. | ||
|
||
Released under the [MIT License](LICENSE). | ||
|
||
|
||
## Quick start | ||
|
||
This package can be used to add regular log messages as OpenTelemetry events. | ||
|
||
```{.go} | ||
func MyAction(ctx context.Context, foo int) { | ||
ctx, span := tracer.Start(ctx, "MyAction") | ||
defer span.End() | ||
LOG := otelzap.SpanLogger(span, logger) | ||
LOG.Debug("do my action", zap.Int("foo", foo)) | ||
} | ||
``` | ||
|
||
The code above will also add OpenTelemetry event with "foo" attribute attached. | ||
|
||
|
||
[doc-img]: https://godoc.org/github.com/Pilatuz/otelzap?status.svg | ||
[doc]: https://godoc.org/github.com/Pilatuz/otelzap | ||
[ci-img]: https://github.com/Pilatuz/otelzap/actions/workflows/go.yml/badge.svg | ||
[ci]: https://github.com/Pilatuz/otelzap/actions | ||
[cov-img]: https://codecov.io/gh/Pilatuz/otelzap/branch/main/graph/badge.svg | ||
[cov]: https://codecov.io/gh/Pilatuz/otelzap | ||
[reportcard-img]: https://goreportcard.com/badge/github.com/Pilatuz/otelzap | ||
[reportcard]: https://goreportcard.com/report/github.com/Pilatuz/otelzap |