|
|
@ -6,9 +6,9 @@ import (
|
|
|
|
"net/http/httptest"
|
|
|
|
"net/http/httptest"
|
|
|
|
"testing"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
|
|
|
|
"github.com/justinas/alice"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
ztrace "github.com/zeromicro/go-zero/core/trace"
|
|
|
|
ztrace "github.com/zeromicro/go-zero/core/trace"
|
|
|
|
|
|
|
|
"github.com/zeromicro/go-zero/rest/chain"
|
|
|
|
"go.opentelemetry.io/otel"
|
|
|
|
"go.opentelemetry.io/otel"
|
|
|
|
"go.opentelemetry.io/otel/propagation"
|
|
|
|
"go.opentelemetry.io/otel/propagation"
|
|
|
|
"go.opentelemetry.io/otel/trace"
|
|
|
|
"go.opentelemetry.io/otel/trace"
|
|
|
@ -24,7 +24,7 @@ func TestOtelHandler(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
|
|
for _, test := range []string{"", "bar"} {
|
|
|
|
for _, test := range []string{"", "bar"} {
|
|
|
|
t.Run(test, func(t *testing.T) {
|
|
|
|
t.Run(test, func(t *testing.T) {
|
|
|
|
h := alice.New(TracingHandler("foo", test)).Then(
|
|
|
|
h := chain.New(TracingHandler("foo", test)).Then(
|
|
|
|
http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
|
|
http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
|
|
ctx := otel.GetTextMapPropagator().Extract(r.Context(), propagation.HeaderCarrier(r.Header))
|
|
|
|
ctx := otel.GetTextMapPropagator().Extract(r.Context(), propagation.HeaderCarrier(r.Header))
|
|
|
|
spanCtx := trace.SpanContextFromContext(ctx)
|
|
|
|
spanCtx := trace.SpanContextFromContext(ctx)
|
|
|
|