Documentation ¶
Index ¶
- Constants
- func EndSpan(ctx context.Context, err error)
- func IsOpenCensusTracingEnabled() bool
- func IsOpenTelemetryTracingEnabled() bool
- func SetOpenTelemetryTracingEnabledField(enabled bool)
- func StartSpan(ctx context.Context, name string) context.Context
- func TracePrintf(ctx context.Context, attrMap map[string]interface{}, format string, ...)
Constants ¶
const ( // TelemetryPlatformTracingOpenCensus is the value to which the environment // variable GOOGLE_API_GO_EXPERIMENTAL_TELEMETRY_PLATFORM_TRACING should be // set to enable OpenCensus tracing. TelemetryPlatformTracingOpenCensus = "opencensus" // TelemetryPlatformTracingOpenCensus is the value to which the environment // variable GOOGLE_API_GO_EXPERIMENTAL_TELEMETRY_PLATFORM_TRACING should be // set to enable OpenTelemetry tracing. TelemetryPlatformTracingOpenTelemetry = "opentelemetry" // TelemetryPlatformTracingOpenCensus is the name of the environment // variable that can be set to change the default tracing from OpenCensus // to OpenTelemetry. TelemetryPlatformTracingVar = "GOOGLE_API_GO_EXPERIMENTAL_TELEMETRY_PLATFORM_TRACING" // OpenTelemetryTracerName is the name given to the OpenTelemetry Tracer // when it is obtained from the OpenTelemetry TracerProvider. OpenTelemetryTracerName = "cloud.google.com/go" )
Variables ¶
This section is empty.
Functions ¶
func EndSpan ¶
EndSpan ends a span with the given error. If IsOpenCensusTracingEnabled returns true, the span will be an OpenCensus span. If IsOpenTelemetryTracingEnabled returns true, the span will be an OpenTelemetry span. Set the environment variable GOOGLE_API_GO_EXPERIMENTAL_TELEMETRY_PLATFORM_TRACING to the case-insensitive value "opentelemetry" before loading the package to use OpenTelemetry tracing. The default will remain OpenCensus until May 29, 2024, at which time the default will switch to "opentelemetry" and explicitly setting the environment variable to "opencensus" will be required to continue using OpenCensus tracing.
func IsOpenCensusTracingEnabled ¶
func IsOpenCensusTracingEnabled() bool
IsOpenCensusTracingEnabled returns true if the environment variable GOOGLE_API_GO_EXPERIMENTAL_TELEMETRY_PLATFORM_TRACING is NOT set to the case-insensitive value "opentelemetry".
func IsOpenTelemetryTracingEnabled ¶
func IsOpenTelemetryTracingEnabled() bool
IsOpenTelemetryTracingEnabled returns true if the environment variable GOOGLE_API_GO_EXPERIMENTAL_TELEMETRY_PLATFORM_TRACING is set to the case-insensitive value "opentelemetry".
func SetOpenTelemetryTracingEnabledField ¶
func SetOpenTelemetryTracingEnabledField(enabled bool)
SetOpenTelemetryTracingEnabledField programmatically sets the value provided by GOOGLE_API_GO_EXPERIMENTAL_TELEMETRY_PLATFORM_TRACING for the purpose of unit testing. Do not invoke it directly. Intended for use only in unit tests. Restore original value after each test.
func StartSpan ¶
StartSpan adds a span to the trace with the given name. If IsOpenCensusTracingEnabled returns true, the span will be an OpenCensus span. If IsOpenTelemetryTracingEnabled returns true, the span will be an OpenTelemetry span. Set the environment variable GOOGLE_API_GO_EXPERIMENTAL_TELEMETRY_PLATFORM_TRACING to the case-insensitive value "opentelemetry" before loading the package to use OpenTelemetry tracing. The default will remain OpenCensus until May 29, 2024, at which time the default will switch to "opentelemetry" and explicitly setting the environment variable to "opencensus" will be required to continue using OpenCensus tracing.
func TracePrintf ¶
func TracePrintf(ctx context.Context, attrMap map[string]interface{}, format string, args ...interface{})
TracePrintf retrieves the current OpenCensus or OpenTelemetry span from context, then: * calls Span.Annotatef if OpenCensus is enabled; or * calls Span.AddEvent if OpenTelemetry is enabled.
If IsOpenCensusTracingEnabled returns true, the expected span must be an OpenCensus span. If IsOpenTelemetryTracingEnabled returns true, the expected span must be an OpenTelemetry span. Set the environment variable GOOGLE_API_GO_EXPERIMENTAL_TELEMETRY_PLATFORM_TRACING to the case-insensitive value "opentelemetry" before loading the package to use OpenTelemetry tracing. The default will remain OpenCensus until May 29, 2024, at which time the default will switch to "opentelemetry" and explicitly setting the environment variable to "opencensus" will be required to continue using OpenCensus tracing.
Types ¶
This section is empty.