https://github.com/amammay/propagationgcp
propagationgcp is a small package for setting up propagation in open telemetry using gcp/s X-Cloud-Trace-Context
https://github.com/amammay/propagationgcp
go golang grpc opentelemetry
Last synced: 2 months ago
JSON representation
propagationgcp is a small package for setting up propagation in open telemetry using gcp/s X-Cloud-Trace-Context
- Host: GitHub
- URL: https://github.com/amammay/propagationgcp
- Owner: amammay
- License: mit
- Created: 2021-06-13T00:54:31.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2021-06-19T13:34:39.000Z (about 5 years ago)
- Last Synced: 2025-05-07T01:43:03.623Z (about 1 year ago)
- Topics: go, golang, grpc, opentelemetry
- Language: Go
- Homepage:
- Size: 9.77 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-golang-repositories - propagationgcp - Cloud-Trace-Context (Repositories)
README
## Installation
```
$ go get -u github.com/amammay/propagationgcp
```
## Usage
```go
package main
import (
"context"
"github.com/amammay/propagationgcp"
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/propagation"
)
func initTracing() {
propagator := propagation.NewCompositeTextMapPropagator(
propagation.TraceContext{},
propagation.Baggage{},
propagationgcp.HTTPFormat{},
)
otel.SetTextMapPropagator(propagator)
}
func someMethod(ctx context.Context) {
sc := trace.SpanContextFromContext(ctx)
traceID := sc.TraceID().String()
spanID := sc.SpanID().String()
isSampled := sc.IsSampled()
_ = traceID
_ = spanID
_ = isSampled
}
```