-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[exporter/loadbalancing] Add top level sending_queue, retry_on_failure and timeout settings #36094
base: main
Are you sure you want to change the base?
Changes from all commits
5787b39
e7acefa
089532b
8560979
de6a9c6
65b6d73
3a856cb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Use this changelog template to create an entry for release notes. | ||
|
||
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' | ||
change_type: enhancement | ||
|
||
# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver) | ||
component: loadbalancingexporter | ||
|
||
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). | ||
note: Adding sending_queue, retry_on_failure and timeout settings to loadbalancing exporter configuration | ||
|
||
# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists. | ||
issues: [35378,16826] | ||
|
||
# (Optional) One or more lines of additional information to render under the primary note. | ||
# These lines will be padded with 2 spaces and then inserted directly into the document. | ||
# Use pipe (|) for multiline entries. | ||
subtext: | | ||
When switching to top-level sending_queue configuration - users should carefully review queue size | ||
In some rare cases setting top-level queue size to n*queueSize might be not enough to prevent data loss | ||
|
||
# If your change doesn't affect end users or the exported elements of any package, | ||
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label. | ||
# Optional: The change log or logs in which this entry should be included. | ||
# e.g. '[user]' or '[user, api]' | ||
# Include 'user' if the change is relevant to end users. | ||
# Include 'api' if there is a change to a library API. | ||
# Default: '[user]' | ||
change_logs: [user] |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,14 +7,22 @@ package loadbalancingexporter // import "github.com/open-telemetry/opentelemetry | |
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
"go.opentelemetry.io/collector/component" | ||
"go.opentelemetry.io/collector/config/configretry" | ||
"go.opentelemetry.io/collector/exporter" | ||
"go.opentelemetry.io/collector/exporter/exporterhelper" | ||
"go.opentelemetry.io/collector/exporter/otlpexporter" | ||
"go.uber.org/zap" | ||
|
||
"github.com/open-telemetry/opentelemetry-collector-contrib/exporter/loadbalancingexporter/internal/metadata" | ||
) | ||
|
||
const ( | ||
zapEndpointKey = "endpoint" | ||
) | ||
|
||
// NewFactory creates a factory for the exporter. | ||
func NewFactory() exporter.Factory { | ||
return exporter.NewFactory( | ||
|
@@ -32,20 +40,94 @@ func createDefaultConfig() component.Config { | |
otlpDefaultCfg.Endpoint = "placeholder:4317" | ||
|
||
return &Config{ | ||
TimeoutSettings: exporterhelper.NewDefaultTimeoutConfig(), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This behavior should be clearly documented. I think it would even make sense to log a warning in case users tried to use that option. That said, there ARE users relying on this feature at the moment. What should we do about them? I think we should copy their current values to the load-balancer level, which would give them roughly the same desired behavior they have today. So, here's how it could work:
I don't think we need a feature flag or deprecation plan for this. |
||
QueueSettings: exporterhelper.NewDefaultQueueConfig(), | ||
BackOffConfig: configretry.NewDefaultBackOffConfig(), | ||
Protocol: Protocol{ | ||
OTLP: *otlpDefaultCfg, | ||
}, | ||
} | ||
} | ||
|
||
func createTracesExporter(_ context.Context, params exporter.Settings, cfg component.Config) (exporter.Traces, error) { | ||
return newTracesExporter(params, cfg) | ||
func buildExporterConfig(cfg *Config, endpoint string) otlpexporter.Config { | ||
oCfg := cfg.Protocol.OTLP | ||
oCfg.Endpoint = endpoint | ||
|
||
return oCfg | ||
} | ||
|
||
func buildExporterSettings(params exporter.Settings, endpoint string) exporter.Settings { | ||
// Override child exporter ID to segregate metrics from loadbalancing top level | ||
childName := endpoint | ||
if params.ID.Name() != "" { | ||
childName = fmt.Sprintf("%s_%s", params.ID.Name(), childName) | ||
} | ||
params.ID = component.NewIDWithName(params.ID.Type(), childName) | ||
// Add "endpoint" attribute to child exporter logger to segregate logs from loadbalancing top level | ||
params.Logger = params.Logger.With(zap.String(zapEndpointKey, endpoint)) | ||
|
||
return params | ||
} | ||
|
||
func createTracesExporter(ctx context.Context, params exporter.Settings, cfg component.Config) (exporter.Traces, error) { | ||
c := cfg.(*Config) | ||
exporter, err := newTracesExporter(params, cfg) | ||
if err != nil { | ||
return nil, fmt.Errorf("cannot configure loadbalancing traces exporter: %w", err) | ||
} | ||
|
||
return exporterhelper.NewTraces( | ||
ctx, | ||
params, | ||
cfg, | ||
exporter.ConsumeTraces, | ||
exporterhelper.WithStart(exporter.Start), | ||
exporterhelper.WithShutdown(exporter.Shutdown), | ||
exporterhelper.WithCapabilities(exporter.Capabilities()), | ||
exporterhelper.WithTimeout(c.TimeoutSettings), | ||
exporterhelper.WithQueue(c.QueueSettings), | ||
exporterhelper.WithRetry(c.BackOffConfig), | ||
) | ||
} | ||
|
||
func createLogsExporter(_ context.Context, params exporter.Settings, cfg component.Config) (exporter.Logs, error) { | ||
return newLogsExporter(params, cfg) | ||
func createLogsExporter(ctx context.Context, params exporter.Settings, cfg component.Config) (exporter.Logs, error) { | ||
c := cfg.(*Config) | ||
exporter, err := newLogsExporter(params, cfg) | ||
if err != nil { | ||
return nil, fmt.Errorf("cannot configure loadbalancing logs exporter: %w", err) | ||
} | ||
|
||
return exporterhelper.NewLogs( | ||
ctx, | ||
params, | ||
cfg, | ||
exporter.ConsumeLogs, | ||
exporterhelper.WithStart(exporter.Start), | ||
exporterhelper.WithShutdown(exporter.Shutdown), | ||
exporterhelper.WithCapabilities(exporter.Capabilities()), | ||
exporterhelper.WithTimeout(c.TimeoutSettings), | ||
exporterhelper.WithQueue(c.QueueSettings), | ||
exporterhelper.WithRetry(c.BackOffConfig), | ||
) | ||
} | ||
|
||
func createMetricsExporter(_ context.Context, params exporter.Settings, cfg component.Config) (exporter.Metrics, error) { | ||
return newMetricsExporter(params, cfg) | ||
func createMetricsExporter(ctx context.Context, params exporter.Settings, cfg component.Config) (exporter.Metrics, error) { | ||
c := cfg.(*Config) | ||
exporter, err := newMetricsExporter(params, cfg) | ||
if err != nil { | ||
return nil, fmt.Errorf("cannot configure loadbalancing metrics exporter: %w", err) | ||
} | ||
|
||
return exporterhelper.NewMetrics( | ||
ctx, | ||
params, | ||
cfg, | ||
exporter.ConsumeMetrics, | ||
exporterhelper.WithStart(exporter.Start), | ||
exporterhelper.WithShutdown(exporter.Shutdown), | ||
exporterhelper.WithCapabilities(exporter.Capabilities()), | ||
exporterhelper.WithTimeout(c.TimeoutSettings), | ||
exporterhelper.WithQueue(c.QueueSettings), | ||
exporterhelper.WithRetry(c.BackOffConfig), | ||
) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs more documentation: what happens when a failure occurs and then the ring is changed? Will it be directed to a new backend (yes!)? This expected behavior should be explicitly documented to our users.