mirror of
https://github.com/cloudflare/cloudflared.git
synced 2025-07-27 19:29:57 +00:00
TUN-6604: Trace icmp echo request on Linux and Darwin
This commit is contained in:
@@ -27,6 +27,8 @@ type InMemoryClient interface {
|
||||
// ProtoSpans returns a copy of the list of in-memory stored spans as otlp
|
||||
// protobuf byte array.
|
||||
ProtoSpans() ([]byte, error)
|
||||
// Clear spans removes all in-memory spans
|
||||
ClearSpans()
|
||||
}
|
||||
|
||||
// InMemoryOtlpClient is a client implementation for otlptrace.Client
|
||||
@@ -78,6 +80,12 @@ func (mc *InMemoryOtlpClient) ProtoSpans() ([]byte, error) {
|
||||
return proto.Marshal(pbRequest)
|
||||
}
|
||||
|
||||
func (mc *InMemoryOtlpClient) ClearSpans() {
|
||||
mc.mu.Lock()
|
||||
defer mc.mu.Unlock()
|
||||
mc.spans = make([]*tracepb.ResourceSpans, 0)
|
||||
}
|
||||
|
||||
// NoopOtlpClient is a client implementation for otlptrace.Client that does nothing
|
||||
type NoopOtlpClient struct{}
|
||||
|
||||
@@ -102,3 +110,5 @@ func (mc *NoopOtlpClient) Spans() (string, error) {
|
||||
func (mc *NoopOtlpClient) ProtoSpans() ([]byte, error) {
|
||||
return nil, errNoopTracer
|
||||
}
|
||||
|
||||
func (mc *NoopOtlpClient) ClearSpans() {}
|
||||
|
@@ -189,6 +189,10 @@ func (cft *cfdTracer) AddSpans(headers http.Header) {
|
||||
headers[CanonicalCloudflaredTracingHeader] = []string{enc}
|
||||
}
|
||||
|
||||
func (cft *cfdTracer) ClearSpans() {
|
||||
cft.exporter.ClearSpans()
|
||||
}
|
||||
|
||||
// End will set the OK status for the span and then end it.
|
||||
func End(span trace.Span) {
|
||||
endSpan(span, -1, codes.Ok, nil)
|
||||
@@ -246,7 +250,6 @@ func extractTraceFromString(ctx context.Context, trace string) (context.Context,
|
||||
parts[0] = strings.Repeat("0", left) + parts[0]
|
||||
trace = strings.Join(parts, separator)
|
||||
}
|
||||
|
||||
// Override the 'cf-trace-id' as 'uber-trace-id' so the jaeger propagator can extract it.
|
||||
traceHeader := map[string]string{TracerContextNameOverride: trace}
|
||||
remoteCtx := otel.GetTextMapPropagator().Extract(ctx, propagation.MapCarrier(traceHeader))
|
||||
@@ -277,6 +280,11 @@ func extractTrace(req *http.Request) (context.Context, bool) {
|
||||
if traceHeader[TracerContextNameOverride] == "" {
|
||||
return nil, false
|
||||
}
|
||||
|
||||
remoteCtx := otel.GetTextMapPropagator().Extract(req.Context(), propagation.MapCarrier(traceHeader))
|
||||
return remoteCtx, true
|
||||
}
|
||||
|
||||
func NewNoopSpan() trace.Span {
|
||||
return trace.SpanFromContext(nil)
|
||||
}
|
||||
|
Reference in New Issue
Block a user