mirror of
https://github.com/hanzoai/telemetry.git
synced 2026-10-30 20:01:49 +00:00
#### Description This PR exposes the `endpoint` value of the `otlp` and `otlphttp` exporter components to the metrics generated by these exporters. This is useful for operators of the collector to observe data flow to different endpoints across large numbers of collector instances without having to cross-reference the specific configuration per instance. The implementation extends the `exporterhelper` with a new option `WithAttrs` that allows developers of exporters to add extra labels to metrics produced. This allows for more flexibility for implementers of exporters to add attributes that might be relevant in the specific use case. <!--Describe what testing was performed and which tests were added.--> #### Testing * Added tests to ensure attributes passed with the new option are recorded correctly * Tested a build of this branch by configuring the collector to receive OTLP and export it to another collector. The new `endpoint` shows up correctly. <!--Describe the documentation added.--> #### Documentation Assuming this change is accepted, I'll create a PR to update the [internal telemetry](https://opentelemetry.io/docs/collector/internal-telemetry/) page in the OpenTelemetry documentation
54 lines
1.9 KiB
Go
54 lines
1.9 KiB
Go
// Copyright The OpenTelemetry Authors
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
package exporterhelper // import "go.opentelemetry.io/collector/exporter/exporterhelper"
|
|
|
|
import (
|
|
"go.opentelemetry.io/otel/attribute"
|
|
|
|
"go.opentelemetry.io/collector/component"
|
|
"go.opentelemetry.io/collector/config/configretry"
|
|
"go.opentelemetry.io/collector/consumer"
|
|
"go.opentelemetry.io/collector/exporter/exporterhelper/internal"
|
|
)
|
|
|
|
// Option apply changes to BaseExporter.
|
|
type Option = internal.Option
|
|
|
|
// WithStart overrides the default Start function for an exporter.
|
|
// The default start function does nothing and always returns nil.
|
|
func WithStart(start component.StartFunc) Option {
|
|
return internal.WithStart(start)
|
|
}
|
|
|
|
// WithShutdown overrides the default Shutdown function for an exporter.
|
|
// The default shutdown function does nothing and always returns nil.
|
|
func WithShutdown(shutdown component.ShutdownFunc) Option {
|
|
return internal.WithShutdown(shutdown)
|
|
}
|
|
|
|
// WithTimeout overrides the default TimeoutConfig for an exporter.
|
|
// The default TimeoutConfig is 5 seconds.
|
|
func WithTimeout(timeoutConfig TimeoutConfig) Option {
|
|
return internal.WithTimeout(timeoutConfig)
|
|
}
|
|
|
|
// WithRetry overrides the default configretry.BackOffConfig for an exporter.
|
|
// The default configretry.BackOffConfig is to disable retries.
|
|
func WithRetry(config configretry.BackOffConfig) Option {
|
|
return internal.WithRetry(config)
|
|
}
|
|
|
|
// WithCapabilities overrides the default Capabilities() function for a Consumer.
|
|
// The default is non-mutable data.
|
|
// TODO: Verify if we can change the default to be mutable as we do for processors.
|
|
func WithCapabilities(capabilities consumer.Capabilities) Option {
|
|
return internal.WithCapabilities(capabilities)
|
|
}
|
|
|
|
// WithAttrs adds extra attributes to the metrics produced by the exporter
|
|
// The default set of extra attribute is empty
|
|
func WithAttrs(attrs ...attribute.KeyValue) Option {
|
|
return internal.WithAttributes(attrs...)
|
|
}
|