mirror of https://github.com/milvus-io/milvus.git
enhance: Add `ParseCTraceContext` util function for tracing (#30883)
See also #29803 Signed-off-by: Congqi Xia <congqi.xia@zilliz.com>pull/30372/head
parent
81a2d9ced6
commit
4082315bd0
|
@ -29,7 +29,6 @@ import (
|
||||||
"unsafe"
|
"unsafe"
|
||||||
|
|
||||||
"github.com/pingcap/log"
|
"github.com/pingcap/log"
|
||||||
"go.opentelemetry.io/otel/trace"
|
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
|
|
||||||
"github.com/milvus-io/milvus-proto/go-api/v2/schemapb"
|
"github.com/milvus-io/milvus-proto/go-api/v2/schemapb"
|
||||||
|
@ -209,16 +208,7 @@ func (li *LoadIndexInfo) appendIndexData(ctx context.Context, indexKeys []string
|
||||||
if paramtable.Get().CommonCfg.EnableStorageV2.GetAsBool() {
|
if paramtable.Get().CommonCfg.EnableStorageV2.GetAsBool() {
|
||||||
status = C.AppendIndexV3(li.cLoadIndexInfo)
|
status = C.AppendIndexV3(li.cLoadIndexInfo)
|
||||||
} else {
|
} else {
|
||||||
span := trace.SpanFromContext(ctx)
|
traceCtx := ParseCTraceContext(ctx)
|
||||||
|
|
||||||
traceID := span.SpanContext().TraceID()
|
|
||||||
spanID := span.SpanContext().SpanID()
|
|
||||||
traceCtx := C.CTraceContext{
|
|
||||||
traceID: (*C.uint8_t)(unsafe.Pointer(&traceID[0])),
|
|
||||||
spanID: (*C.uint8_t)(unsafe.Pointer(&spanID[0])),
|
|
||||||
traceFlags: (C.uint8_t)(span.SpanContext().TraceFlags()),
|
|
||||||
}
|
|
||||||
|
|
||||||
status = C.AppendIndexV2(traceCtx, li.cLoadIndexInfo)
|
status = C.AppendIndexV2(traceCtx, li.cLoadIndexInfo)
|
||||||
}
|
}
|
||||||
return nil, nil
|
return nil, nil
|
||||||
|
|
|
@ -38,7 +38,6 @@ import (
|
||||||
"github.com/cockroachdb/errors"
|
"github.com/cockroachdb/errors"
|
||||||
"github.com/golang/protobuf/proto"
|
"github.com/golang/protobuf/proto"
|
||||||
"go.opentelemetry.io/otel"
|
"go.opentelemetry.io/otel"
|
||||||
"go.opentelemetry.io/otel/trace"
|
|
||||||
"go.uber.org/atomic"
|
"go.uber.org/atomic"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
|
|
||||||
|
@ -471,15 +470,7 @@ func (s *LocalSegment) Search(ctx context.Context, searchReq *SearchRequest) (*S
|
||||||
return nil, merr.WrapErrSegmentNotLoaded(s.segmentID, "segment released")
|
return nil, merr.WrapErrSegmentNotLoaded(s.segmentID, "segment released")
|
||||||
}
|
}
|
||||||
|
|
||||||
span := trace.SpanFromContext(ctx)
|
traceCtx := ParseCTraceContext(ctx)
|
||||||
|
|
||||||
traceID := span.SpanContext().TraceID()
|
|
||||||
spanID := span.SpanContext().SpanID()
|
|
||||||
traceCtx := C.CTraceContext{
|
|
||||||
traceID: (*C.uint8_t)(unsafe.Pointer(&traceID[0])),
|
|
||||||
spanID: (*C.uint8_t)(unsafe.Pointer(&spanID[0])),
|
|
||||||
traceFlags: (C.uint8_t)(span.SpanContext().TraceFlags()),
|
|
||||||
}
|
|
||||||
|
|
||||||
hasIndex := s.ExistIndex(searchReq.searchFieldID)
|
hasIndex := s.ExistIndex(searchReq.searchFieldID)
|
||||||
log = log.With(zap.Bool("withIndex", hasIndex))
|
log = log.With(zap.Bool("withIndex", hasIndex))
|
||||||
|
@ -525,15 +516,7 @@ func (s *LocalSegment) Retrieve(ctx context.Context, plan *RetrievePlan) (*segco
|
||||||
zap.String("segmentType", s.typ.String()),
|
zap.String("segmentType", s.typ.String()),
|
||||||
)
|
)
|
||||||
|
|
||||||
span := trace.SpanFromContext(ctx)
|
traceCtx := ParseCTraceContext(ctx)
|
||||||
|
|
||||||
traceID := span.SpanContext().TraceID()
|
|
||||||
spanID := span.SpanContext().SpanID()
|
|
||||||
traceCtx := C.CTraceContext{
|
|
||||||
traceID: (*C.uint8_t)(unsafe.Pointer(&traceID[0])),
|
|
||||||
spanID: (*C.uint8_t)(unsafe.Pointer(&spanID[0])),
|
|
||||||
traceFlags: (C.uint8_t)(span.SpanContext().TraceFlags()),
|
|
||||||
}
|
|
||||||
|
|
||||||
maxLimitSize := paramtable.Get().QuotaConfig.MaxOutputSize.GetAsInt64()
|
maxLimitSize := paramtable.Get().QuotaConfig.MaxOutputSize.GetAsInt64()
|
||||||
var retrieveResult RetrieveResult
|
var retrieveResult RetrieveResult
|
||||||
|
|
|
@ -0,0 +1,44 @@
|
||||||
|
// Licensed to the LF AI & Data foundation under one
|
||||||
|
// or more contributor license agreements. See the NOTICE file
|
||||||
|
// distributed with this work for additional information
|
||||||
|
// regarding copyright ownership. The ASF licenses this file
|
||||||
|
// to you under the Apache License, Version 2.0 (the
|
||||||
|
// "License"); you may not use this file except in compliance
|
||||||
|
// with the License. You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
package segments
|
||||||
|
|
||||||
|
/*
|
||||||
|
#cgo pkg-config: milvus_segcore
|
||||||
|
|
||||||
|
#include "segcore/segment_c.h"
|
||||||
|
*/
|
||||||
|
import "C"
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"unsafe"
|
||||||
|
|
||||||
|
"go.opentelemetry.io/otel/trace"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ParseCTraceContext parses tracing span and convert it into `C.CTraceContext`.
|
||||||
|
func ParseCTraceContext(ctx context.Context) C.CTraceContext {
|
||||||
|
span := trace.SpanFromContext(ctx)
|
||||||
|
|
||||||
|
traceID := span.SpanContext().TraceID()
|
||||||
|
spanID := span.SpanContext().SpanID()
|
||||||
|
return C.CTraceContext{
|
||||||
|
traceID: (*C.uint8_t)(unsafe.Pointer(&traceID[0])),
|
||||||
|
spanID: (*C.uint8_t)(unsafe.Pointer(&spanID[0])),
|
||||||
|
traceFlags: (C.uint8_t)(span.SpanContext().TraceFlags()),
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue