Skip to content

Commit

Permalink
Improve README
Browse files Browse the repository at this point in the history
  • Loading branch information
VojtechVitek committed Mar 6, 2024
1 parent 42ec54f commit f15203d
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
# TraceId

Go package that helps create and pass `TraceId` header among microservices for simple tracing capabilities and log grouping.
Go pkg to propagate `TraceId` header across multiple services.

The generated `TraceId` value is [UUIDv7](https://datatracker.ietf.org/doc/html/draft-peabody-dispatch-new-uuid-format-03#name-uuid-version-7), which lets you infer the time of the trace creation from its value.
- Enables simple tracing capabilities and log grouping.
- The value can be exposed to end-users in case of an error.
- The value is [UUIDv7](https://datatracker.ietf.org/doc/html/draft-peabody-dispatch-new-uuid-format-03#name-uuid-version-7), which lets you [infer the timestamp](https://github.com/go-chi/traceid?tab=readme-ov-file#get-time-from-uuidv7-value).
- Unlike [OTEL](https://pkg.go.dev/go.opentelemetry.io/otel), this package doesn't trace spans or metrics, doesn't require any backend and doesn't have large dependencies (GRPC).

## traceid.Middleware example
## Example - HTTP middleware

```go
package main
Expand Down Expand Up @@ -38,11 +41,11 @@ func main() {
See [example/main.go](./example/main.go)
## traceid.SetHeader()
## Example - making HTTP requests
```go
func main() {
// Set TraceId in context, if not set yet.
// Set TraceId in context, if not set from parent ctx yet.
ctx := traceid.NewContext(context.Background())

// Make a request with TraceId header.
Expand All @@ -53,7 +56,6 @@ func main() {
resp, err := resp.Do(req)
//...
}
}
```
## Get time from UUIDv7 value
Expand Down

0 comments on commit f15203d

Please sign in to comment.