tracing

package
v1.0.17 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 28, 2026 License: Apache-2.0, BSD-3-Clause Imports: 21 Imported by: 1

Documentation

Overview

* * Copyright 2021 Comcast Cable Communications Management, LLC * * Licensed 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. * * SPDX-License-Identifier: Apache-2.0

* * Copyright 2021 Comcast Cable Communications Management, LLC * * Licensed 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. * * SPDX-License-Identifier: Apache-2.0

* * Copyright 2021 Comcast Cable Communications Management, LLC * * Licensed 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. * * SPDX-License-Identifier: Apache-2.0

* * Copyright 2021 Comcast Cable Communications Management, LLC * * Licensed 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. * * SPDX-License-Identifier: Apache-2.0

Index

Constants

View Source
const (
	AuditIDHeader            = "X-Auditid"
	UserAgentHeader          = "User-Agent"
	DefaultMoracideTagPrefix = "X-Cl-Experiment"
)

Variables

This section is empty.

Functions

func EndOtelSpan

func EndOtelSpan(xpcTracer *XpcTracer, span oteltrace.Span)

func GetContext

func GetContext(ctx context.Context, key string) interface{}

GetContext - getting context value from context

func NewOtelSpan

func NewOtelSpan(xpcTracer *XpcTracer, r *http.Request) (context.Context, oteltrace.Span)

func NoopSetSpan

func NoopSetSpan(fields log.Fields, tag string)

func OtelSetSpan

func OtelSetSpan(fields log.Fields, tag string)

func SetContext

func SetContext(ctx context.Context, ctxName string, ctxValue interface{}) context.Context

SetContext - setting context for logging

func SetSpanMoracideTags

func SetSpanMoracideTags(fields log.Fields, moracideTagPrefix string)

func SetSpanStatusCode

func SetSpanStatusCode(fields log.Fields)

Types

type SpanSetterFunc

type SpanSetterFunc func(log.Fields, string)

type XpcTrace

type XpcTrace struct {
	ReqMoracideTag string

	ReqTraceparent string
	ReqTracestate  string
	OutTraceparent string
	OutTracestate  string

	// These are not useful as of now, just set them for the sake of completion and future
	AuditID      string
	MoneyTrace   string
	ReqUserAgent string
	OutUserAgent string

	TraceID string // use the value in outTraceparent, otherwise MoneyTrace
	// contains filtered or unexported fields
}

XpcTrace is a carrier/baggage struct to extract data from spans, request headers for usage later Store the trace in ctx for easy retrieval. Ideal place to store it is ofc, xw But because of legacy reasons, xw is not always available in the API flow

func NewXpcTrace

func NewXpcTrace(xpcTracer *XpcTracer, r *http.Request) *XpcTrace

NewXpcTrace extracts traceparent, tracestate, moracideTags from otel spans or reqs

type XpcTracer

type XpcTracer struct {
	OtelEnabled bool

	SetSpan SpanSetterFunc
	// contains filtered or unexported fields
}

XpcTracer is a wrapper around tracer setup

func NewXpcTracer

func NewXpcTracer(conf *configuration.Config) *XpcTracer

func (*XpcTracer) AppEnv

func (t *XpcTracer) AppEnv() string

func (*XpcTracer) AppName

func (t *XpcTracer) AppName() string

func (*XpcTracer) AppVersion

func (t *XpcTracer) AppVersion() string

func (*XpcTracer) MoracideTagPrefix

func (t *XpcTracer) MoracideTagPrefix() string

func (*XpcTracer) OtelOpName

func (t *XpcTracer) OtelOpName() string

otelOpName should return "http.request" by default

func (*XpcTracer) OtelTracerProvider

func (t *XpcTracer) OtelTracerProvider() oteltrace.TracerProvider

func (*XpcTracer) Region

func (t *XpcTracer) Region() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL