Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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: 29 days ago
JSON representation

propagationgcp is a small package for setting up propagation in open telemetry using gcp/s X-Cloud-Trace-Context

Awesome Lists containing this project

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
}

```