add otel module based on uptrace-go

Signed-off-by: Adphi <philippe.adrien.nousse@gmail.com>
This commit is contained in:
2025-06-05 16:31:03 +02:00
parent 533a0ea43a
commit 549384ea57
17 changed files with 1309 additions and 214 deletions

28
otel/internal_test.go Normal file
View File

@ -0,0 +1,28 @@
package otel
import (
"context"
"math"
"testing"
"time"
"github.com/stretchr/testify/require"
)
func TestIDGenerator(t *testing.T) {
ctx := context.Background()
gen := newIDGenerator()
traceID1, spanID1 := gen.NewIDs(ctx)
traceID2, spanID2 := gen.NewIDs(ctx)
require.NotEqual(t, traceID1, traceID2)
require.NotEqual(t, spanID1, spanID2)
spanID3 := gen.NewSpanID(ctx, traceID1)
require.NotEqual(t, spanID1, spanID3)
}
func TestSpanPrecision(t *testing.T) {
dur := time.Duration(math.MaxUint32) * time.Duration(spanIDPrec)
require.Equal(t, "1193h2m47.295s", dur.String())
}