|
|
@@ -4,7 +4,7 @@ import (
|
|
|
"context"
|
|
|
"crypto/tls"
|
|
|
"fmt"
|
|
|
-
|
|
|
+ "strings"
|
|
|
"sync"
|
|
|
"time"
|
|
|
|
|
|
@@ -52,6 +52,25 @@ func Init(machineId, hostname, version string) {
|
|
|
if endpointUrl.Scheme != "https" {
|
|
|
opts = append(opts, otlptracehttp.WithInsecure())
|
|
|
}
|
|
|
+ // 设置压缩算法
|
|
|
+ compressionType := "none"
|
|
|
+ if *flags.TracesCompression != "" {
|
|
|
+ switch strings.ToLower(*flags.TracesCompression) {
|
|
|
+ case "gzip":
|
|
|
+ opts = append(opts, otlptracehttp.WithCompression(otlptracehttp.GzipCompression))
|
|
|
+ compressionType = "gzip"
|
|
|
+ case "zstd":
|
|
|
+ opts = append(opts, otlptracehttp.WithCompression(otlptracehttp.ZstdCompression))
|
|
|
+ compressionType = "zstd"
|
|
|
+ case "none", "":
|
|
|
+ // 默认无压缩,不需要设置
|
|
|
+ compressionType = "none"
|
|
|
+ default:
|
|
|
+ klog.Warnf("Unknown compression algorithm: %s, using default (no compression)", *flags.TracesCompression)
|
|
|
+ compressionType = "none"
|
|
|
+ }
|
|
|
+ }
|
|
|
+ klog.Infof("Traces compression: %s", compressionType)
|
|
|
client := otlptracehttp.NewClient(opts...)
|
|
|
exporter, err := otlptrace.New(context.Background(), client)
|
|
|
if err != nil {
|