-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add OTEL trace for clusterpedia-apiserver
- Loading branch information
Showing
35 changed files
with
6,347 additions
and
5 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
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,5 @@ | ||
package constants | ||
|
||
const ( | ||
OtelAgentAddrENV = "OTEL_EXPORTER_OTLP_ENDPOINT" | ||
) |
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,38 @@ | ||
package trace | ||
|
||
import ( | ||
"context" | ||
|
||
"go.opentelemetry.io/otel" | ||
"go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc" | ||
"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.7.0" | ||
"google.golang.org/grpc" | ||
"k8s.io/klog/v2" | ||
) | ||
|
||
// InitTracer initializes the trace provider and the otel grpc exporter. | ||
func InitTracer(ctx context.Context) (func(ctx context.Context) error, error) { | ||
traceExporter, err := otlptracegrpc.New(ctx, otlptracegrpc.WithInsecure(), otlptracegrpc.WithDialOption(grpc.WithBlock())) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
tracerProvider := sdktrace.NewTracerProvider( | ||
sdktrace.WithBatcher(traceExporter), | ||
sdktrace.WithSampler(sdktrace.AlwaysSample()), | ||
sdktrace.WithResource(resource.NewWithAttributes(semconv.SchemaURL))) | ||
|
||
otel.SetTracerProvider(tracerProvider) | ||
otel.SetTextMapPropagator(propagation.NewCompositeTextMapPropagator(propagation.TraceContext{}, propagation.Baggage{})) | ||
|
||
return func(ctx context.Context) error { | ||
if err := traceExporter.Shutdown(ctx); err != nil { | ||
klog.V(2).ErrorS(err, "failed to stop exporter") | ||
return err | ||
} | ||
return nil | ||
}, nil | ||
} |
This file was deleted.
Oops, something went wrong.
6 changes: 6 additions & 0 deletions
6
vendor/github.com/clusterpedia-io/api/cluster/v1alpha2/doc.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
51 changes: 51 additions & 0 deletions
51
vendor/github.com/clusterpedia-io/api/cluster/v1alpha2/register.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.