mirror of
https://github.com/zeromicro/go-zero.git
synced 2026-05-07 06:59:59 +08:00
chore: remove jaeger exporter due to official deprecation (#5361)
Signed-off-by: kevin <wanjunfeng@gmail.com>
This commit is contained in:
@@ -3,13 +3,11 @@ package trace
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/url"
|
|
||||||
"os"
|
"os"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/zeromicro/go-zero/core/logx"
|
"github.com/zeromicro/go-zero/core/logx"
|
||||||
"go.opentelemetry.io/otel"
|
"go.opentelemetry.io/otel"
|
||||||
"go.opentelemetry.io/otel/exporters/jaeger"
|
|
||||||
"go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc"
|
"go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc"
|
||||||
"go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp"
|
"go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp"
|
||||||
"go.opentelemetry.io/otel/exporters/stdout/stdouttrace"
|
"go.opentelemetry.io/otel/exporters/stdout/stdouttrace"
|
||||||
@@ -20,12 +18,10 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
kindJaeger = "jaeger"
|
|
||||||
kindZipkin = "zipkin"
|
kindZipkin = "zipkin"
|
||||||
kindOtlpGrpc = "otlpgrpc"
|
kindOtlpGrpc = "otlpgrpc"
|
||||||
kindOtlpHttp = "otlphttp"
|
kindOtlpHttp = "otlphttp"
|
||||||
kindFile = "file"
|
kindFile = "file"
|
||||||
protocolUdp = "udp"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -62,15 +58,7 @@ func StopAgent() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func createExporter(c Config) (sdktrace.SpanExporter, error) {
|
func createExporter(c Config) (sdktrace.SpanExporter, error) {
|
||||||
// Just support jaeger and zipkin now, more for later
|
|
||||||
switch c.Batcher {
|
switch c.Batcher {
|
||||||
case kindJaeger:
|
|
||||||
u, err := url.Parse(c.Endpoint)
|
|
||||||
if err == nil && u.Scheme == protocolUdp {
|
|
||||||
return jaeger.New(jaeger.WithAgentEndpoint(jaeger.WithAgentHost(u.Hostname()),
|
|
||||||
jaeger.WithAgentPort(u.Port())))
|
|
||||||
}
|
|
||||||
return jaeger.New(jaeger.WithCollectorEndpoint(jaeger.WithEndpoint(c.Endpoint)))
|
|
||||||
case kindZipkin:
|
case kindZipkin:
|
||||||
return zipkin.New(c.Endpoint)
|
return zipkin.New(c.Endpoint)
|
||||||
case kindOtlpGrpc:
|
case kindOtlpGrpc:
|
||||||
|
|||||||
@@ -27,21 +27,16 @@ func TestStartAgent(t *testing.T) {
|
|||||||
Name: "foo",
|
Name: "foo",
|
||||||
}
|
}
|
||||||
c2 := Config{
|
c2 := Config{
|
||||||
Name: "bar",
|
|
||||||
Endpoint: endpoint1,
|
|
||||||
Batcher: kindJaeger,
|
|
||||||
}
|
|
||||||
c3 := Config{
|
|
||||||
Name: "any",
|
Name: "any",
|
||||||
Endpoint: endpoint2,
|
Endpoint: endpoint2,
|
||||||
Batcher: kindZipkin,
|
Batcher: kindZipkin,
|
||||||
}
|
}
|
||||||
c4 := Config{
|
c3 := Config{
|
||||||
Name: "bla",
|
Name: "bla",
|
||||||
Endpoint: endpoint3,
|
Endpoint: endpoint3,
|
||||||
Batcher: "otlp",
|
Batcher: "otlp",
|
||||||
}
|
}
|
||||||
c5 := Config{
|
c4 := Config{
|
||||||
Name: "otlpgrpc",
|
Name: "otlpgrpc",
|
||||||
Endpoint: endpoint3,
|
Endpoint: endpoint3,
|
||||||
Batcher: kindOtlpGrpc,
|
Batcher: kindOtlpGrpc,
|
||||||
@@ -49,7 +44,7 @@ func TestStartAgent(t *testing.T) {
|
|||||||
"uptrace-dsn": "http://project2_secret_token@localhost:14317/2",
|
"uptrace-dsn": "http://project2_secret_token@localhost:14317/2",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
c6 := Config{
|
c5 := Config{
|
||||||
Name: "otlphttp",
|
Name: "otlphttp",
|
||||||
Endpoint: endpoint4,
|
Endpoint: endpoint4,
|
||||||
Batcher: kindOtlpHttp,
|
Batcher: kindOtlpHttp,
|
||||||
@@ -58,22 +53,12 @@ func TestStartAgent(t *testing.T) {
|
|||||||
},
|
},
|
||||||
OtlpHttpPath: "/v1/traces",
|
OtlpHttpPath: "/v1/traces",
|
||||||
}
|
}
|
||||||
c7 := Config{
|
c6 := Config{
|
||||||
Name: "UDP",
|
|
||||||
Endpoint: endpoint5,
|
|
||||||
Batcher: kindJaeger,
|
|
||||||
}
|
|
||||||
c8 := Config{
|
|
||||||
Disabled: true,
|
|
||||||
Endpoint: endpoint6,
|
|
||||||
Batcher: kindJaeger,
|
|
||||||
}
|
|
||||||
c9 := Config{
|
|
||||||
Name: "file",
|
Name: "file",
|
||||||
Endpoint: endpoint71,
|
Endpoint: endpoint71,
|
||||||
Batcher: kindFile,
|
Batcher: kindFile,
|
||||||
}
|
}
|
||||||
c10 := Config{
|
c7 := Config{
|
||||||
Name: "file",
|
Name: "file",
|
||||||
Endpoint: endpoint72,
|
Endpoint: endpoint72,
|
||||||
Batcher: kindFile,
|
Batcher: kindFile,
|
||||||
@@ -87,9 +72,6 @@ func TestStartAgent(t *testing.T) {
|
|||||||
StartAgent(c5)
|
StartAgent(c5)
|
||||||
StartAgent(c6)
|
StartAgent(c6)
|
||||||
StartAgent(c7)
|
StartAgent(c7)
|
||||||
StartAgent(c8)
|
|
||||||
StartAgent(c9)
|
|
||||||
StartAgent(c10)
|
|
||||||
defer StopAgent()
|
defer StopAgent()
|
||||||
|
|
||||||
// With sync.Once, only the first non-disabled config (c1) takes effect.
|
// With sync.Once, only the first non-disabled config (c1) takes effect.
|
||||||
@@ -164,24 +146,6 @@ func TestCreateExporter_ValidExporters(t *testing.T) {
|
|||||||
wantErr: true,
|
wantErr: true,
|
||||||
errMsg: "unknown exporter",
|
errMsg: "unknown exporter",
|
||||||
},
|
},
|
||||||
{
|
|
||||||
name: "jaeger http",
|
|
||||||
config: Config{
|
|
||||||
Name: "jaeger-http",
|
|
||||||
Endpoint: "http://localhost:14268/api/traces",
|
|
||||||
Batcher: kindJaeger,
|
|
||||||
},
|
|
||||||
wantErr: false,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "jaeger udp",
|
|
||||||
config: Config{
|
|
||||||
Name: "jaeger-udp",
|
|
||||||
Endpoint: "udp://localhost:6831",
|
|
||||||
Batcher: kindJaeger,
|
|
||||||
},
|
|
||||||
wantErr: false,
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
name: "zipkin",
|
name: "zipkin",
|
||||||
config: Config{
|
config: Config{
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ type Config struct {
|
|||||||
Name string `json:",optional"`
|
Name string `json:",optional"`
|
||||||
Endpoint string `json:",optional"`
|
Endpoint string `json:",optional"`
|
||||||
Sampler float64 `json:",default=1.0"`
|
Sampler float64 `json:",default=1.0"`
|
||||||
Batcher string `json:",default=jaeger,options=jaeger|zipkin|otlpgrpc|otlphttp|file"`
|
Batcher string `json:",default=otlpgrpc,options=zipkin|otlpgrpc|otlphttp|file"`
|
||||||
// OtlpHeaders represents the headers for OTLP gRPC or HTTP transport.
|
// OtlpHeaders represents the headers for OTLP gRPC or HTTP transport.
|
||||||
// For example:
|
// For example:
|
||||||
// uptrace-dsn: 'http://project2_secret_token@localhost:14317/2'
|
// uptrace-dsn: 'http://project2_secret_token@localhost:14317/2'
|
||||||
|
|||||||
1
go.mod
1
go.mod
@@ -23,7 +23,6 @@ require (
|
|||||||
go.etcd.io/etcd/client/v3 v3.5.15
|
go.etcd.io/etcd/client/v3 v3.5.15
|
||||||
go.mongodb.org/mongo-driver/v2 v2.4.1
|
go.mongodb.org/mongo-driver/v2 v2.4.1
|
||||||
go.opentelemetry.io/otel v1.24.0
|
go.opentelemetry.io/otel v1.24.0
|
||||||
go.opentelemetry.io/otel/exporters/jaeger v1.17.0
|
|
||||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.24.0
|
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.24.0
|
||||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.24.0
|
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.24.0
|
||||||
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.24.0
|
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.24.0
|
||||||
|
|||||||
2
go.sum
2
go.sum
@@ -199,8 +199,6 @@ go.mongodb.org/mongo-driver/v2 v2.4.1 h1:hGDMngUao03OVQ6sgV5csk+RWOIkF+CuLsTPobN
|
|||||||
go.mongodb.org/mongo-driver/v2 v2.4.1/go.mod h1:jHeEDJHJq7tm6ZF45Issun9dbogjfnPySb1vXA7EeAI=
|
go.mongodb.org/mongo-driver/v2 v2.4.1/go.mod h1:jHeEDJHJq7tm6ZF45Issun9dbogjfnPySb1vXA7EeAI=
|
||||||
go.opentelemetry.io/otel v1.24.0 h1:0LAOdjNmQeSTzGBzduGe/rU4tZhMwL5rWgtp9Ku5Jfo=
|
go.opentelemetry.io/otel v1.24.0 h1:0LAOdjNmQeSTzGBzduGe/rU4tZhMwL5rWgtp9Ku5Jfo=
|
||||||
go.opentelemetry.io/otel v1.24.0/go.mod h1:W7b9Ozg4nkF5tWI5zsXkaKKDjdVjpD4oAt9Qi/MArHo=
|
go.opentelemetry.io/otel v1.24.0/go.mod h1:W7b9Ozg4nkF5tWI5zsXkaKKDjdVjpD4oAt9Qi/MArHo=
|
||||||
go.opentelemetry.io/otel/exporters/jaeger v1.17.0 h1:D7UpUy2Xc2wsi1Ras6V40q806WM07rqoCWzXu7Sqy+4=
|
|
||||||
go.opentelemetry.io/otel/exporters/jaeger v1.17.0/go.mod h1:nPCqOnEH9rNLKqH/+rrUjiMzHJdV1BlpKcTwRTyKkKI=
|
|
||||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.24.0 h1:t6wl9SPayj+c7lEIFgm4ooDBZVb01IhLB4InpomhRw8=
|
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.24.0 h1:t6wl9SPayj+c7lEIFgm4ooDBZVb01IhLB4InpomhRw8=
|
||||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.24.0/go.mod h1:iSDOcsnSA5INXzZtwaBPrKp/lWu/V14Dd+llD0oI2EA=
|
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.24.0/go.mod h1:iSDOcsnSA5INXzZtwaBPrKp/lWu/V14Dd+llD0oI2EA=
|
||||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.24.0 h1:Mw5xcxMwlqoJd97vwPxA8isEaIoxsta9/Q51+TTJLGE=
|
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.24.0 h1:Mw5xcxMwlqoJd97vwPxA8isEaIoxsta9/Q51+TTJLGE=
|
||||||
|
|||||||
@@ -21,10 +21,11 @@ import (
|
|||||||
|
|
||||||
func TestOtelHandler(t *testing.T) {
|
func TestOtelHandler(t *testing.T) {
|
||||||
ztrace.StartAgent(ztrace.Config{
|
ztrace.StartAgent(ztrace.Config{
|
||||||
Name: "go-zero-test",
|
Name: "go-zero-test",
|
||||||
Endpoint: "http://localhost:14268/api/traces",
|
Endpoint: "http://localhost:14268",
|
||||||
Batcher: "jaeger",
|
OtlpHttpPath: "/v1/traces",
|
||||||
Sampler: 1.0,
|
Batcher: "otlphttp",
|
||||||
|
Sampler: 1.0,
|
||||||
})
|
})
|
||||||
defer ztrace.StopAgent()
|
defer ztrace.StopAgent()
|
||||||
|
|
||||||
@@ -84,10 +85,11 @@ func TestTraceHandler(t *testing.T) {
|
|||||||
|
|
||||||
func TestDontTracingSpan(t *testing.T) {
|
func TestDontTracingSpan(t *testing.T) {
|
||||||
ztrace.StartAgent(ztrace.Config{
|
ztrace.StartAgent(ztrace.Config{
|
||||||
Name: "go-zero-test",
|
Name: "go-zero-test",
|
||||||
Endpoint: "http://localhost:14268/api/traces",
|
Endpoint: "http://localhost:14268",
|
||||||
Batcher: "jaeger",
|
OtlpHttpPath: "/v1/traces",
|
||||||
Sampler: 1.0,
|
Batcher: "otlphttp",
|
||||||
|
Sampler: 1.0,
|
||||||
})
|
})
|
||||||
defer ztrace.StopAgent()
|
defer ztrace.StopAgent()
|
||||||
|
|
||||||
@@ -129,10 +131,11 @@ func TestDontTracingSpan(t *testing.T) {
|
|||||||
|
|
||||||
func TestTraceResponseWriter(t *testing.T) {
|
func TestTraceResponseWriter(t *testing.T) {
|
||||||
ztrace.StartAgent(ztrace.Config{
|
ztrace.StartAgent(ztrace.Config{
|
||||||
Name: "go-zero-test",
|
Name: "go-zero-test",
|
||||||
Endpoint: "http://localhost:14268/api/traces",
|
Endpoint: "http://localhost:14268",
|
||||||
Batcher: "jaeger",
|
OtlpHttpPath: "/v1/traces",
|
||||||
Sampler: 1.0,
|
Batcher: "otlphttp",
|
||||||
|
Sampler: 1.0,
|
||||||
})
|
})
|
||||||
defer ztrace.StopAgent()
|
defer ztrace.StopAgent()
|
||||||
|
|
||||||
|
|||||||
@@ -21,10 +21,11 @@ import (
|
|||||||
|
|
||||||
func TestDoRequest(t *testing.T) {
|
func TestDoRequest(t *testing.T) {
|
||||||
ztrace.StartAgent(ztrace.Config{
|
ztrace.StartAgent(ztrace.Config{
|
||||||
Name: "go-zero-test",
|
Name: "go-zero-test",
|
||||||
Endpoint: "http://localhost:14268/api/traces",
|
Endpoint: "http://localhost:14268",
|
||||||
Batcher: "jaeger",
|
OtlpHttpPath: "/v1/traces",
|
||||||
Sampler: 1.0,
|
Batcher: "otlphttp",
|
||||||
|
Sampler: 1.0,
|
||||||
})
|
})
|
||||||
defer ztrace.StopAgent()
|
defer ztrace.StopAgent()
|
||||||
|
|
||||||
|
|||||||
@@ -23,10 +23,11 @@ import (
|
|||||||
|
|
||||||
func TestOpenTracingInterceptor(t *testing.T) {
|
func TestOpenTracingInterceptor(t *testing.T) {
|
||||||
ztrace.StartAgent(ztrace.Config{
|
ztrace.StartAgent(ztrace.Config{
|
||||||
Name: "go-zero-test",
|
Name: "go-zero-test",
|
||||||
Endpoint: "http://localhost:14268/api/traces",
|
Endpoint: "http://localhost:14268",
|
||||||
Batcher: "jaeger",
|
OtlpHttpPath: "/v1/traces",
|
||||||
Sampler: 1.0,
|
Batcher: "otlphttp",
|
||||||
|
Sampler: 1.0,
|
||||||
})
|
})
|
||||||
defer ztrace.StopAgent()
|
defer ztrace.StopAgent()
|
||||||
|
|
||||||
|
|||||||
@@ -32,10 +32,11 @@ func TestUnaryOpenTracingInterceptor_Disable(t *testing.T) {
|
|||||||
|
|
||||||
func TestUnaryOpenTracingInterceptor_Enabled(t *testing.T) {
|
func TestUnaryOpenTracingInterceptor_Enabled(t *testing.T) {
|
||||||
ztrace.StartAgent(ztrace.Config{
|
ztrace.StartAgent(ztrace.Config{
|
||||||
Name: "go-zero-test",
|
Name: "go-zero-test",
|
||||||
Endpoint: "http://localhost:14268/api/traces",
|
Endpoint: "http://localhost:14268",
|
||||||
Batcher: "jaeger",
|
OtlpHttpPath: "/v1/traces",
|
||||||
Sampler: 1.0,
|
Batcher: "otlphttp",
|
||||||
|
Sampler: 1.0,
|
||||||
})
|
})
|
||||||
defer ztrace.StopAgent()
|
defer ztrace.StopAgent()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user