OpenTelemetry to OpenCensus Span Converter (otel2oc/span_context.go)

opentelemetry-go · bridge/opencensus/internal/otel2oc/span_context.go · go · Apache-2.0
dev-tools, infra, tag:opencensus, tag:span-context

Converts OpenTelemetry span contexts to OpenCensus format for observability interoperability.

// Source: https://github.com/open-telemetry/opentelemetry-go | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
// Provided via justclaw.it.com; keep this notice with the code.
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

// Package otel2oc provides conversions from OpenTelemetry to OpenCensus.
package otel2oc

import (
	octrace "go.opencensus.io/trace"
	"go.opencensus.io/trace/tracestate"

	"go.opentelemetry.io/otel/trace"
)

// SpanContext converts an OpenTelemetry SpanContext into an OpenCensus
// SpanContext.
func SpanContext(sc trace.SpanContext) octrace.SpanContext {
	var to octrace.TraceOptions
	if sc.IsSampled() {
		// OpenCensus doesn't expose functions to directly set sampled
		to = 0x1
	}

	entries := 

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key