fix(tracing): merge Langfuse finish metadata and export auto root spans

Finish-time metadata was discarded and implicit root traces opened by
StartSpan/StartGeneration were never ended, leaving orphaned parents in
Langfuse. Also stop mutating the global OTel text-map propagator.
This commit is contained in:
wizardchen
2026-07-17 16:56:48 +08:00
committed by lyingbug
parent 5ee96019e0
commit 1649603af4
4 changed files with 196 additions and 28 deletions
+4 -5
View File
@@ -6,7 +6,6 @@ import (
"sync/atomic"
"github.com/Tencent/WeKnora/internal/logger"
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/propagation"
"go.opentelemetry.io/otel/sdk/resource"
@@ -92,10 +91,10 @@ func Init(cfg Config) (*Manager, error) {
trace.WithInstrumentationVersion(langfuseScopeVersion),
trace.WithInstrumentationAttributes(attribute.String("public_key", cfg.PublicKey)),
)
// Make the W3C propagator available to any OTel-aware HTTP client
// in the process. Harmless to set globally; extraction/injection in
// this package use the package-level `propagator` directly.
otel.SetTextMapPropagator(propagator)
// Extraction/injection in this package use the package-level
// `propagator` directly, so we deliberately do NOT call
// otel.SetTextMapPropagator here — mutating global OTel state could
// interfere with any other OTel instrumentation in the process.
}
globalMu.Lock()