Documentation
¶
Index ¶
- func FilterChain(filters ...otelgrpc.Filter) otelgrpc.Filter
- func FilterMethods(methods ...string) otelgrpc.Filter
- func SpanRecordError(span trace.Span, err error, description string, ...)
- type CleanupFunc
- type ConnectFilterFunc
- type OtelProvider
- type OtelProviderOption
- func WithGCPTraceLogger() OtelProviderOption
- func WithGcpExporter(projectId string) OtelProviderOption
- func WithGcpExporterAndOptions(clientOpts []option.ClientOption, opts ...gcpexporter.Option) OtelProviderOption
- func WithGlobalAttributes(attribs ...attribute.KeyValue) OtelProviderOption
- func WithResourceOptions(opts ...resource.Option) OtelProviderOption
- func WithServiceNamespace(namespace string) OtelProviderOption
- func WithServiceVersion(version string) OtelProviderOption
- func WithTracerName(name string) OtelProviderOption
- func WithTracerProviderOptions(opts ...sdktrace.TracerProviderOption) OtelProviderOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FilterChain ¶
Creates a filter that simply calls every given filter, in the same order as they're passed, until either one returns false (to filter out the request) or until there are no filters left to check, thus allowing the request to be traced.
func FilterMethods ¶
Creates a filter that prevents any methods listed from having a trace automatically be created.
Note that methods should start with a slash and are in full form, e.g. `/grpc.health.v1.Health/Check`
Note that method names must be an exact match to be filtered.
func SpanRecordError ¶
func SpanRecordError(span trace.Span, err error, description string, eventOptions ...trace.EventOption)
SpanRecordError decorates a span with attributes and records the error SetStatus only works with new Cloud Trace, for the legacy version we're using the '/http/status_code' attribute to colour a span red It also adds the error flag to make filtering traces with errors easier and a description of the error
Types ¶
type ConnectFilterFunc ¶
func FilterMethodsConnect ¶
func FilterMethodsConnect(methods ...string) ConnectFilterFunc
FilterMethodsConnect Creates a filter for otelconnect that prevents any methods listed from having a trace automatically be created.
Note that methods should start with a slash and are in full form, e.g. `/grpc.health.v1.Health/Check`
Note that method names must be an exact match to be filtered.
func FilterMethodsConnectWithHealthCheck ¶
func FilterMethodsConnectWithHealthCheck(additionalMethods ...string) ConnectFilterFunc
FilterMethodsConnectWithHealthCheck filters the given methods including the grpc healthcheck
type OtelProvider ¶
Provides an opinionated wrapper around the Open Telemtry SDK.
func NewOtelProvider ¶
func NewOtelProvider(serviceName string, opts ...OtelProviderOption) (*OtelProvider, error)
Constructs a new OtelProvider using the given options to configure the instance.
If an option function returns an error, an error is returned alongside a null provider.
func (*OtelProvider) SetupGlobalState ¶
func (o *OtelProvider) SetupGlobalState(ctx context.Context) (CleanupFunc, error)
Sets up the global OTEL SDK state to use the specified configuration, with sane-ish defaults.
A new Resource is created using certain defaults as well as anything passed in from `WithResourceOptions`.
A new TracerProvider is created using certain defaults as well as anything passed in from `WithTracerProviderOptions`.
The TracerProvider uses the aforementioned Resource as its default.
The TracerProvider is registered as the global provider within the OTEL SDK.
A TextMapPropagator for the W3C Trace Context and B3 formats is installed by default as the global propagator.
You should defer-call the returned `CleanupFunc` as this will force the span batcher to flush the spans into the underlying exporter.
func (*OtelProvider) Start ¶
func (o *OtelProvider) Start(ctx context.Context, spanName string, opts ...trace.SpanStartOption) (context.Context, trace.Span)
A simple helper function that retrieves the current tracer from the context (or fetches a global Tracer) and then uses it to start a new span.
If you're interested in further details, please see the `Tracer.Start` function from the OTEL SDK.
type OtelProviderOption ¶
type OtelProviderOption func(*OtelProvider) error
Typical option function pattern
func WithGCPTraceLogger ¶
func WithGCPTraceLogger() OtelProviderOption
Sets the trace logger to use GCP
func WithGcpExporter ¶
func WithGcpExporter(projectId string) OtelProviderOption
A simple wrapper around `WithGcpExporterAndOptions` for the common use case where only a GCP project ID needs to be provided.
func WithGcpExporterAndOptions ¶
func WithGcpExporterAndOptions(clientOpts []option.ClientOption, opts ...gcpexporter.Option) OtelProviderOption
Export spans into GCP's tracing service. This function is useful when you need to set any additional options when creating the exporter.
Generally you can use `WithGcpExporter` instead as it has a simpler interface.
A small side effect of this function is that it will add additional resource options (as if it called `WithResourceOptions`), which shouldn't really cause any issues.
func WithGlobalAttributes ¶
func WithGlobalAttributes(attribs ...attribute.KeyValue) OtelProviderOption
Appends the global set of attributes that are attached onto every span.
func WithResourceOptions ¶
func WithResourceOptions(opts ...resource.Option) OtelProviderOption
Appends any additional options to use when creating the default OTEL resource. Note that the options set by this library take priority.
func WithServiceNamespace ¶
func WithServiceNamespace(namespace string) OtelProviderOption
Specifies the namespace of the service. We usually use the name of the overarching project here.
func WithServiceVersion ¶
func WithServiceVersion(version string) OtelProviderOption
Specifies the version of the service. Useful if there's more than one version of the service running at any given time.
func WithTracerName ¶
func WithTracerName(name string) OtelProviderOption
Sets the name of the underlying tracer that is used to create spans.
This isn't the most important thing in the world, and if not specified then the service name is used as a fallback.
func WithTracerProviderOptions ¶
func WithTracerProviderOptions(opts ...sdktrace.TracerProviderOption) OtelProviderOption
Appends any additional options to use when creating the underlying trace provider. Note that the options set by this library take priority.