-
Notifications
You must be signed in to change notification settings - Fork 6
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
7 changed files
with
250 additions
and
22 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
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,58 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"log" | ||
"os" | ||
|
||
"go.opentelemetry.io/otel" | ||
"go.opentelemetry.io/otel/exporters/otlp/otlptrace" | ||
"go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp" | ||
"go.opentelemetry.io/otel/propagation" | ||
"go.opentelemetry.io/otel/sdk/resource" | ||
sdktrace "go.opentelemetry.io/otel/sdk/trace" | ||
semconv "go.opentelemetry.io/otel/semconv/v1.21.0" | ||
"go.opentelemetry.io/otel/trace" | ||
) | ||
|
||
func setupOTEL(ctx context.Context) func(context.Context) error { | ||
client := otlptracehttp.NewClient() | ||
exporter, err := otlptrace.New(ctx, client) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
res, err := resource.Merge( | ||
resource.Default(), | ||
resource.NewWithAttributes( | ||
semconv.SchemaURL, | ||
semconv.ServiceName("grafana-build"), | ||
), | ||
) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
otel.SetTextMapPropagator(propagation.TraceContext{}) | ||
tp := sdktrace.NewTracerProvider( | ||
sdktrace.WithBatcher(exporter), | ||
sdktrace.WithResource(res), | ||
) | ||
otel.SetTracerProvider(tp) | ||
return tp.Shutdown | ||
} | ||
|
||
func findParentTrace(ctx context.Context) context.Context { | ||
traceParent := os.Getenv("TRACEPARENT") | ||
if traceParent == "" { | ||
return ctx | ||
} | ||
log.Printf("Parent trace found: %s", traceParent) | ||
carrier := make(propagation.MapCarrier) | ||
carrier.Set("traceparent", traceParent) | ||
prop := otel.GetTextMapPropagator() | ||
ctx = prop.Extract(ctx, carrier) | ||
span := trace.SpanFromContext(ctx) | ||
if span == nil { | ||
return ctx | ||
} | ||
return trace.ContextWithRemoteSpanContext(ctx, span.SpanContext()) | ||
} |
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
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,28 +1,46 @@ | ||
module github.com/grafana/grafana-build | ||
|
||
go 1.21 | ||
go 1.21.0 | ||
|
||
require ( | ||
dagger.io/dagger v0.8.4 | ||
github.com/Masterminds/semver v1.5.0 | ||
github.com/quasilyte/go-ruleguard/dsl v0.3.22 | ||
github.com/stretchr/testify v1.8.2 | ||
github.com/stretchr/testify v1.8.4 | ||
github.com/urfave/cli/v2 v2.24.4 | ||
go.opentelemetry.io/otel v1.17.0 | ||
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.17.0 | ||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.17.0 | ||
go.opentelemetry.io/otel/sdk v1.17.0 | ||
golang.org/x/sync v0.3.0 | ||
) | ||
|
||
require ( | ||
github.com/99designs/gqlgen v0.17.31 // indirect | ||
github.com/Khan/genqlient v0.6.0 // indirect | ||
github.com/adrg/xdg v0.4.0 // indirect | ||
github.com/cenkalti/backoff/v4 v4.2.1 // indirect | ||
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect | ||
github.com/davecgh/go-spew v1.1.1 // indirect | ||
github.com/go-logr/logr v1.2.4 // indirect | ||
github.com/go-logr/stdr v1.2.2 // indirect | ||
github.com/golang/protobuf v1.5.3 // indirect | ||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.0 // indirect | ||
github.com/iancoleman/strcase v0.3.0 // indirect | ||
github.com/mitchellh/go-homedir v1.1.0 // indirect | ||
github.com/pmezard/go-difflib v1.0.0 // indirect | ||
github.com/russross/blackfriday/v2 v2.1.0 // indirect | ||
github.com/vektah/gqlparser/v2 v2.5.6 // indirect | ||
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect | ||
golang.org/x/sys v0.10.0 // indirect | ||
go.opentelemetry.io/otel/metric v1.17.0 // indirect | ||
go.opentelemetry.io/otel/trace v1.17.0 // indirect | ||
go.opentelemetry.io/proto/otlp v1.0.0 // indirect | ||
golang.org/x/net v0.10.0 // indirect | ||
golang.org/x/sys v0.11.0 // indirect | ||
golang.org/x/text v0.9.0 // indirect | ||
google.golang.org/genproto/googleapis/api v0.0.0-20230530153820-e85fd2cbaebc // indirect | ||
google.golang.org/genproto/googleapis/rpc v0.0.0-20230530153820-e85fd2cbaebc // indirect | ||
google.golang.org/grpc v1.57.0 // indirect | ||
google.golang.org/protobuf v1.31.0 // indirect | ||
gopkg.in/yaml.v3 v3.0.1 // indirect | ||
) |
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
Oops, something went wrong.