Documentation ¶
Index ¶
- Constants
- Variables
- func ConfigureOpenTelemetry(opts ...Option) (func(), error)
- type Config
- type Logger
- type Option
- func WithErrorHandler(handler otel.ErrorHandler) Option
- func WithExporterEndpoint(url string) Option
- func WithExporterInsecure(insecure bool) Option
- func WithExporterProtocol(protocol Protocol) Option
- func WithHeaders(headers map[string]string) Option
- func WithLogLevel(loglevel string) Option
- func WithLogger(logger Logger) Option
- func WithMetricsEnabled(enabled bool) Option
- func WithMetricsExporterEndpoint(url string) Option
- func WithMetricsExporterInsecure(insecure bool) Option
- func WithMetricsExporterProtocol(protocol Protocol) Option
- func WithMetricsHeaders(headers map[string]string) Option
- func WithMetricsReportingPeriod(p time.Duration) Option
- func WithPropagators(propagators []string) Option
- func WithResourceAttributes(attributes map[string]string) Option
- func WithResourceOption(option resource.Option) Option
- func WithSampler(sampler trace.Sampler) Option
- func WithServiceName(name string) Option
- func WithServiceVersion(version string) Option
- func WithShutdown(f func(c *Config) error) Option
- func WithSpanProcessor(sp ...trace.SpanProcessor) Option
- func WithTracesEnabled(enabled bool) Option
- func WithTracesExporterEndpoint(url string) Option
- func WithTracesExporterInsecure(insecure bool) Option
- func WithTracesExporterProtocol(protocol Protocol) Option
- func WithTracesHeaders(headers map[string]string) Option
- type OtelConfig
- type Protocol
Constants ¶
const ( // GRPC default port. GRPCDefaultPort = "4317" // HTTP default port. HTTPDefaultPort = "4318" // SSL/TLS default port. SSLDefaultPort = "443" )
These are strings because they get appended to the host.
Variables ¶
var ( // SetVendorOptions provides a way for a vendor to add a set of Options that are automatically applied. SetVendorOptions func() []Option // ValidateConfig is a function that a vendor can implement to provide additional validation after // a configuration is built. ValidateConfig func(*Config) error // DefaultExporterEndpoint provides a way for vendors to update the default exporter endpoint address. // Defaults to 'localhost'. DefaultExporterEndpoint string = "localhost" )
Functions ¶
func ConfigureOpenTelemetry ¶
ConfigureOpenTelemetry is a function that be called with zero or more options. Options can be the basic ones above, or provided by individual vendors.
Types ¶
type Config ¶
type Config struct { ExporterEndpoint string `env:"OTEL_EXPORTER_OTLP_ENDPOINT,overwrite"` ExporterEndpointInsecure bool `env:"OTEL_EXPORTER_OTLP_INSECURE,default=false"` TracesExporterEndpoint string `env:"OTEL_EXPORTER_OTLP_TRACES_ENDPOINT,overwrite"` TracesExporterEndpointInsecure bool `env:"OTEL_EXPORTER_OTLP_TRACES_INSECURE"` TracesEnabled *bool `env:"OTEL_TRACES_ENABLED,default=true"` ServiceName string `env:"OTEL_SERVICE_NAME,overwrite"` ServiceVersion string `env:"OTEL_SERVICE_VERSION,overwrite,default=unknown"` MetricsExporterEndpoint string `env:"OTEL_EXPORTER_OTLP_METRICS_ENDPOINT,overwrite"` MetricsExporterEndpointInsecure bool `env:"OTEL_EXPORTER_OTLP_METRICS_INSECURE"` MetricsEnabled *bool `env:"OTEL_METRICS_ENABLED,default=true"` MetricsReportingPeriod string `env:"OTEL_EXPORTER_OTLP_METRICS_PERIOD,overwrite,default=30s"` LogLevel string `env:"OTEL_LOG_LEVEL,overwrite,default=info"` Propagators []string `env:"OTEL_PROPAGATORS,overwrite,default=tracecontext,baggage"` ExporterProtocol Protocol `env:"OTEL_EXPORTER_OTLP_PROTOCOL,overwrite,default=grpc"` TracesExporterProtocol Protocol `env:"OTEL_EXPORTER_OTLP_TRACES_PROTOCOL,overwrite"` MetricsExporterProtocol Protocol `env:"OTEL_EXPORTER_OTLP_METRICS_PROTOCOL,overwrite"` Headers map[string]string `env:"OTEL_EXPORTER_OTLP_HEADERS,overwrite,separator=="` TracesHeaders map[string]string `env:"OTEL_EXPORTER_OTLP_TRACES_HEADERS,overwrite,separator=="` MetricsHeaders map[string]string `env:"OTEL_EXPORTER_OTLP_METRICS_HEADERS,overwrite,separator=="` ResourceAttributes map[string]string `env:"OTEL_RESOURCE_ATTRIBUTES,overwrite,separator=="` SpanProcessors []trace.SpanProcessor Sampler trace.Sampler ResourceOptions []resource.Option Resource *resource.Resource Logger Logger `json:"-"` ShutdownFunctions []func(c *Config) error `json:"-"` // contains filtered or unexported fields }
Config is a configuration object; it is public so that it can be manipulated by vendors. Note that ExporterEndpoint specifies "DEFAULTPORT"; this is because the default port should vary depending on the protocol chosen. If not overridden by explicit configuration, it will be overridden with an appropriate default upon initialization.
type Logger ¶
type Logger interface { Fatalf(format string, v ...interface{}) Debugf(format string, v ...interface{}) }
Logger is an interface for a logger that can be passed to WithLogger.
type Option ¶
type Option func(*Config)
Option is the type of an Option to the ConfigureOpenTelemetry function; it's a function that accepts a config and modifies it.
func WithErrorHandler ¶
func WithErrorHandler(handler otel.ErrorHandler) Option
Configures a global error handler to be used throughout an OpenTelemetry instrumented project. See "go.opentelemetry.io/otel".
func WithExporterEndpoint ¶
WithExporterEndpoint configures the generic endpoint used for sending all telemtry signals via OTLP.
func WithExporterInsecure ¶
WithExporterInsecure permits connecting to the generic exporter endpoint without a certificate.
func WithExporterProtocol ¶
WithExporterProtocol defines the default protocol.
func WithHeaders ¶
WithHeaders configures OTLP exporter headers.
func WithLogLevel ¶
WithLogLevel configures the logging level for OpenTelemetry.
func WithMetricsEnabled ¶
WithMetricsEnabled configures whether metrics should be enabled.
func WithMetricsExporterEndpoint ¶
WithMetricsExporterEndpoint configures the endpoint for sending metrics via OTLP.
func WithMetricsExporterInsecure ¶
WithMetricsExporterInsecure permits connecting to the metric endpoint without a certificate.
func WithMetricsExporterProtocol ¶
WithMetricsExporterProtocol defines the protocol for Metrics.
func WithMetricsHeaders ¶
WithMetricsHeaders configures OTLP metrics exporter headers.
func WithMetricsReportingPeriod ¶
WithMetricsReportingPeriod configures the metric reporting period, how often the controller collects and exports metric data.
func WithPropagators ¶
WithPropagators configures propagators.
func WithResourceAttributes ¶
WithResourceAttributes configures attributes on the resource; if the resource already exists, it sets additional attributes or overwrites those already there.
func WithResourceOption ¶ added in v1.11.0
WithResourceOption configures options on the resource; These are appended after the default options and can override them.
func WithSampler ¶
WithSampler configures the Sampler to use when processing trace spans.
func WithServiceName ¶
WithServiceName configures a "service.name" resource label.
func WithServiceVersion ¶
WithServiceVersion configures a "service.version" resource label.
func WithShutdown ¶
WithShutdown adds functions that will be called first when the shutdown function is called. They are given a copy of the Config object (which has access to the Logger), and should return an error only in extreme circumstances, as an error return here is immediately fatal.
func WithSpanProcessor ¶
func WithSpanProcessor(sp ...trace.SpanProcessor) Option
WithSpanProcessor adds one or more SpanProcessors.
func WithTracesEnabled ¶
WithTracesEnabled configures whether traces should be enabled.
func WithTracesExporterEndpoint ¶
WithTracesExporterEndpoint configures the endpoint for sending traces via OTLP.
func WithTracesExporterInsecure ¶
WithTracesExporterInsecure permits connecting to the trace endpoint without a certificate.
func WithTracesExporterProtocol ¶
WithTracesExporterProtocol defines the protocol for Traces.
func WithTracesHeaders ¶
WithTracesHeaders configures OTLP traces exporter headers.
type OtelConfig ¶
type OtelConfig struct {
// contains filtered or unexported fields
}
OtelConfig is the object we're here for; it implements the initialization of Open Telemetry.
func (OtelConfig) Shutdown ¶
func (ls OtelConfig) Shutdown()
Shutdown is the function called to shut down OpenTelemetry. It invokes any registered shutdown functions.
type Protocol ¶
Protocol defines the possible values of the protocol field.
const ( ProtocolGRPC Protocol = Protocol(pipelines.ProtocolGRPC) ProtocolHTTPProto Protocol = Protocol(pipelines.ProtocolHTTPProtobuf) ProtocolHTTPJSON Protocol = Protocol(pipelines.ProtocolHTTPJSON) )
Import the values for Protocol from pipelines but make them available without importing pipelines.