Skip to content

Commit cbc6ce9

Browse files
author
Dominik Rosiek
committed
sumologicexporter!: remove deprecated configuration options and remove unused code
Signed-off-by: Dominik Rosiek <[email protected]>
1 parent 5e41c6b commit cbc6ce9

12 files changed

Lines changed: 113 additions & 573 deletions

File tree

.chloggen/drosiek-refactor.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Use this changelog template to create an entry for release notes.
2+
3+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
4+
change_type: breaking
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
7+
component: sumologicexporter
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: remove deprecated configuration options
11+
12+
# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
13+
issues: [32315]
14+
15+
# (Optional) One or more lines of additional information to render under the primary note.
16+
# These lines will be padded with 2 spaces and then inserted directly into the document.
17+
# Use pipe (|) for multiline entries.
18+
subtext:
19+
20+
# If your change doesn't affect end users or the exported elements of any package,
21+
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
22+
# Optional: The change log or logs in which this entry should be included.
23+
# e.g. '[user]' or '[user, api]'
24+
# Include 'user' if the change is relevant to end users.
25+
# Include 'api' if there is a change to a library API.
26+
# Default: '[user]'
27+
change_logs: [user]

exporter/sumologicexporter/README.md

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,6 @@ exporters:
8585
# default = 1_048_576 (1MB)
8686
max_request_body_size: <max_request_body_size>
8787
88-
# List of regexes for attributes which should be send as metadata
89-
# default = []
90-
#
91-
# This option is unsupported:
92-
# https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/exporter/sumologicexporter#migration-to-new-architecture
93-
metadata_attributes: [<regex>]
94-
9588
# format to use when sending logs to Sumo Logic, default = otlp,
9689
log_format: {otlp, json, text}
9790
@@ -105,44 +98,6 @@ exporters:
10598
# default = false
10699
decompose_otlp_histograms: {true, false}
107100

108-
# Template for Graphite format.
109-
# this option affects graphite format only
110-
# By default this is "%{_metric_}".
111-
#
112-
# Please regfer to Source temmplates for formatting explanation:
113-
# https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/exporter/sumologicexporter#source-templates
114-
#
115-
# This option is unsupported:
116-
# https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/exporter/sumologicexporter#migration-to-new-architecture
117-
graphite_template: <template>
118-
119-
# Desired source category. Useful if you want to override the source category configured for the source.
120-
#
121-
# Please regfer to Source temmplates for formatting explanation:
122-
# https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/exporter/sumologicexporter#source-templates
123-
#
124-
# This option is unsupported:
125-
# https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/exporter/sumologicexporter#migration-to-new-architecture
126-
source_category: <template>
127-
128-
# Desired source name. Useful if you want to override the source name configured for the source.
129-
#
130-
# Please regfer to Source temmplates for formatting explanation:
131-
# https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/exporter/sumologicexporter#source-templates
132-
#
133-
# This option is unsupported:
134-
# https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/exporter/sumologicexporter#migration-to-new-architecture
135-
source_name: <template>
136-
137-
# Desired source host. Useful if you want to override the source hosy configured for the source.
138-
#
139-
# Please regfer to Source temmplates for formatting explanation:
140-
# https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/exporter/sumologicexporter#source-templates
141-
#
142-
# This option is unsupported:
143-
# https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/exporter/sumologicexporter#migration-to-new-architecture
144-
source_host: <template>
145-
146101
# timeout is the timeout for every attempt to send data to the backend,
147102
# maximum connection timeout is 55s, default = 5s
148103
timeout: <timeout>

exporter/sumologicexporter/config.go

Lines changed: 47 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -46,22 +46,6 @@ type Config struct {
4646
// Decompose OTLP Histograms into individual metrics, similar to how they're represented in Prometheus format
4747
DecomposeOtlpHistograms bool `mapstructure:"decompose_otlp_histograms"`
4848

49-
// List of regexes for attributes which should be send as metadata
50-
MetadataAttributes []string `mapstructure:"metadata_attributes"`
51-
52-
// Sumo specific options
53-
// Desired source category.
54-
// Useful if you want to override the source category configured for the source.
55-
// Placeholders `%{attr_name}` will be replaced with attribute value for attr_name.
56-
SourceCategory string `mapstructure:"source_category"`
57-
// Desired source name.
58-
// Useful if you want to override the source name configured for the source.
59-
// Placeholders `%{attr_name}` will be replaced with attribute value for attr_name.
60-
SourceName string `mapstructure:"source_name"`
61-
// Desired host name.
62-
// Useful if you want to override the source host configured for the source.
63-
// Placeholders `%{attr_name}` will be replaced with attribute value for attr_name.
64-
SourceHost string `mapstructure:"source_host"`
6549
// Name of the client
6650
Client string `mapstructure:"client"`
6751

@@ -81,6 +65,53 @@ func createDefaultClientConfig() confighttp.ClientConfig {
8165
}
8266
}
8367

68+
func (cfg *Config) Validate() error {
69+
switch cfg.LogFormat {
70+
case OTLPLogFormat:
71+
case JSONFormat:
72+
case TextFormat:
73+
default:
74+
return fmt.Errorf("unexpected log format: %s", cfg.LogFormat)
75+
}
76+
77+
switch cfg.MetricFormat {
78+
case RemovedGraphiteFormat:
79+
return fmt.Errorf("support for the graphite metric format was removed, please use prometheus or otlp instead")
80+
case RemovedCarbon2Format:
81+
return fmt.Errorf("support for the carbon2 metric format was removed, please use prometheus or otlp instead")
82+
case PrometheusFormat:
83+
case OTLPMetricFormat:
84+
default:
85+
return fmt.Errorf("unexpected metric format: %s", cfg.MetricFormat)
86+
}
87+
88+
switch cfg.ClientConfig.Compression {
89+
case configcompression.TypeGzip:
90+
case configcompression.TypeDeflate:
91+
case configcompression.TypeZstd:
92+
case NoCompression:
93+
94+
default:
95+
return fmt.Errorf("invalid compression encoding type: %v", cfg.ClientConfig.Compression)
96+
}
97+
98+
if len(cfg.ClientConfig.Endpoint) == 0 && cfg.ClientConfig.Auth == nil {
99+
return errors.New("no endpoint and no auth extension specified")
100+
}
101+
102+
if _, err := url.Parse(cfg.ClientConfig.Endpoint); err != nil {
103+
return fmt.Errorf("failed parsing endpoint URL: %s; err: %w",
104+
cfg.ClientConfig.Endpoint, err,
105+
)
106+
}
107+
108+
if err := cfg.QueueSettings.Validate(); err != nil {
109+
return fmt.Errorf("queue settings has invalid configuration: %w", err)
110+
}
111+
112+
return nil
113+
}
114+
84115
// LogFormatType represents log_format
85116
type LogFormatType string
86117

@@ -141,50 +172,3 @@ const (
141172
// DefaultStickySessionEnabled defines default StickySessionEnabled value
142173
DefaultStickySessionEnabled bool = false
143174
)
144-
145-
func (cfg *Config) Validate() error {
146-
switch cfg.LogFormat {
147-
case OTLPLogFormat:
148-
case JSONFormat:
149-
case TextFormat:
150-
default:
151-
return fmt.Errorf("unexpected log format: %s", cfg.LogFormat)
152-
}
153-
154-
switch cfg.MetricFormat {
155-
case RemovedGraphiteFormat:
156-
return fmt.Errorf("support for the graphite metric format was removed, please use prometheus or otlp instead")
157-
case RemovedCarbon2Format:
158-
return fmt.Errorf("support for the carbon2 metric format was removed, please use prometheus or otlp instead")
159-
case PrometheusFormat:
160-
case OTLPMetricFormat:
161-
default:
162-
return fmt.Errorf("unexpected metric format: %s", cfg.MetricFormat)
163-
}
164-
165-
switch cfg.ClientConfig.Compression {
166-
case configcompression.TypeGzip:
167-
case configcompression.TypeDeflate:
168-
case configcompression.TypeZstd:
169-
case NoCompression:
170-
171-
default:
172-
return fmt.Errorf("invalid compression encoding type: %v", cfg.ClientConfig.Compression)
173-
}
174-
175-
if len(cfg.ClientConfig.Endpoint) == 0 && cfg.ClientConfig.Auth == nil {
176-
return errors.New("no endpoint and no auth extension specified")
177-
}
178-
179-
if _, err := url.Parse(cfg.ClientConfig.Endpoint); err != nil {
180-
return fmt.Errorf("failed parsing endpoint URL: %s; err: %w",
181-
cfg.ClientConfig.Endpoint, err,
182-
)
183-
}
184-
185-
if err := cfg.QueueSettings.Validate(); err != nil {
186-
return fmt.Errorf("queue settings has invalid configuration: %w", err)
187-
}
188-
189-
return nil
190-
}

exporter/sumologicexporter/exporter.go

Lines changed: 26 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,11 @@ type sumologicexporter struct {
3636
host component.Host
3737
logger *zap.Logger
3838

39-
sources sourceFormats
40-
filter filter
41-
prometheusFormatter prometheusFormatter
42-
settings component.TelemetrySettings
43-
4439
clientLock sync.RWMutex
4540
client *http.Client
4641

42+
prometheusFormatter prometheusFormatter
43+
4744
// Lock around data URLs is needed because the reconfiguration of the exporter
4845
// can happen asynchronously whenever the exporter is re registering.
4946
dataURLsLock sync.RWMutex
@@ -60,65 +57,35 @@ type sumologicexporter struct {
6057
id component.ID
6158
}
6259

63-
func initExporter(cfg *Config, settings component.TelemetrySettings) (*sumologicexporter, error) {
64-
65-
if cfg.MetricFormat == RemovedGraphiteFormat {
66-
settings.Logger.Error("`metric_format: graphite` nad `graphite_template` are no longer supported. See https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/exporter/sumologicexporter#migration-to-new-architecture for more information")
67-
}
68-
69-
if cfg.MetricFormat == RemovedCarbon2Format {
70-
settings.Logger.Error("`metric_format: carbon` is no longer supported. See https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/exporter/sumologicexporter#migration-to-new-architecture for more information")
71-
}
72-
73-
if len(cfg.MetadataAttributes) > 0 {
74-
settings.Logger.Warn("`metadata_attributes: []` is deprecated and is going to be removed in the future. See https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/exporter/sumologicexporter#migration-to-new-architecture for more information")
75-
}
76-
77-
if cfg.SourceCategory != "" {
78-
settings.Logger.Warn("`source_category: <template>` is deprecated and is going to be removed in the future. See https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/exporter/sumologicexporter#migration-to-new-architecture for more information")
79-
}
80-
81-
if cfg.SourceHost != "" {
82-
settings.Logger.Warn("`source_host: <template>` is deprecated and is going to be removed in the future. See https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/exporter/sumologicexporter#migration-to-new-architecture for more information")
83-
}
84-
85-
if cfg.SourceName != "" {
86-
settings.Logger.Warn("`source_name: <template>` is deprecated and is going to be removed in the future. See https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/exporter/sumologicexporter#migration-to-new-architecture for more information")
87-
}
88-
89-
sfs := newSourceFormats(cfg)
90-
91-
f, err := newFilter(cfg.MetadataAttributes)
92-
if err != nil {
93-
return nil, err
94-
}
95-
96-
pf := newPrometheusFormatter()
97-
60+
func initExporter(cfg *Config, createSettings exporter.CreateSettings) *sumologicexporter {
9861
se := &sumologicexporter{
99-
logger: settings.Logger,
100-
config: cfg,
101-
sources: sfs,
102-
filter: f,
103-
prometheusFormatter: pf,
104-
settings: settings,
62+
config: cfg,
63+
logger: createSettings.Logger,
64+
// NOTE: client is now set in start()
65+
prometheusFormatter: newPrometheusFormatter(),
66+
id: createSettings.ID,
67+
foundSumologicExtension: false,
10568
}
10669

107-
return se, nil
70+
se.logger.Info(
71+
"Sumo Logic Exporter configured",
72+
zap.String("log_format", string(cfg.LogFormat)),
73+
zap.String("metric_format", string(cfg.MetricFormat)),
74+
)
75+
76+
return se
10877
}
10978

11079
func newLogsExporter(
80+
ctx context.Context,
81+
params exporter.CreateSettings,
11182
cfg *Config,
112-
set exporter.CreateSettings,
11383
) (exporter.Logs, error) {
114-
se, err := initExporter(cfg, set.TelemetrySettings)
115-
if err != nil {
116-
return nil, fmt.Errorf("failed to initialize the logs exporter: %w", err)
117-
}
84+
se := initExporter(cfg, params)
11885

11986
return exporterhelper.NewLogsExporter(
120-
context.TODO(),
121-
set,
87+
ctx,
88+
params,
12289
cfg,
12390
se.pushLogsData,
12491
// Disable exporterhelper Timeout, since we are using a custom mechanism
@@ -132,17 +99,15 @@ func newLogsExporter(
13299
}
133100

134101
func newMetricsExporter(
102+
ctx context.Context,
103+
params exporter.CreateSettings,
135104
cfg *Config,
136-
set exporter.CreateSettings,
137105
) (exporter.Metrics, error) {
138-
se, err := initExporter(cfg, set.TelemetrySettings)
139-
if err != nil {
140-
return nil, err
141-
}
106+
se := initExporter(cfg, params)
142107

143108
return exporterhelper.NewMetricsExporter(
144-
context.TODO(),
145-
set,
109+
ctx,
110+
params,
146111
cfg,
147112
se.pushMetricsData,
148113
// Disable exporterhelper Timeout, since we are using a custom mechanism
@@ -286,8 +251,6 @@ func (se *sumologicexporter) pushLogsData(ctx context.Context, ld plog.Logs) err
286251
se.logger,
287252
se.config,
288253
se.getHTTPClient(),
289-
se.filter,
290-
se.sources,
291254
se.prometheusFormatter,
292255
metricsURL,
293256
logsURL,
@@ -365,8 +328,6 @@ func (se *sumologicexporter) pushMetricsData(ctx context.Context, md pmetric.Met
365328
se.logger,
366329
se.config,
367330
se.getHTTPClient(),
368-
se.filter,
369-
se.sources,
370331
se.prometheusFormatter,
371332
metricsURL,
372333
logsURL,

0 commit comments

Comments
 (0)