Skip to content

Commit

Permalink
feat(sumologicexporter)!: remove support for graphite metrics format
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikołaj Świątek committed May 23, 2022
1 parent 1c8e587 commit faa299f
Show file tree
Hide file tree
Showing 13 changed files with 37 additions and 471 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Breaking changes

- feat(sumologicexporter)!: remove support for Carbon2 metrics format [#590][#590]
- feat(sumologicexporter)!: remove support for Graphite metrics format [#592][#592]

[Unreleased]: https://github.com/SumoLogic/sumologic-otel-collector/compare/v0.51.0-sumo-0...main
[#590]: https://github.com/SumoLogic/sumologic-otel-collector/pull/590
[#592]: https://github.com/SumoLogic/sumologic-otel-collector/pull/592

## [v0.51.0-sumo-0]

Expand Down
13 changes: 13 additions & 0 deletions docs/Upgrading.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,19 @@
- [Removing unnecessary metadata using the resourceprocessor](#removing-unnecessary-metadata-using-the-resourceprocessor)
- [Moving record-level attributes used for metadata to the resource level](#moving-record-level-attributes-used-for-metadata-to-the-resource-level)

## Upgrading to Unreleased

### Carbon2 and Graphite metric format support removed from `sumologic` exporter

These metric formats don't offer any advantages over Prometheus or OTLP formats. To migrate, simply switch
the format to `prometheus`.

```yaml
exporters:
sumologic:
metric_format: prometheus
```
## Upgrading to v0.51.0-sumo-0
### `k8s_tagger` processor: removed `clusterName` metadata extraction option
Expand Down
13 changes: 3 additions & 10 deletions pkg/exporter/sumologicexporter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ exporters:

# format to use when sending metrics to Sumo, default = otlp,
# NOTE: only `otlp` is supported when used with sumologicextension
metric_format: {graphite, otlp, prometheus}
metric_format: {otlp, prometheus}

# format to use when sending traces to Sumo,
# currently only otlp is supported
Expand All @@ -42,7 +42,7 @@ exporters:
# default = true
clear_logs_timestamp: {true, false}

# For below described source and graphite template related configuration,
# For below described source related configuration,
# please refer to "Source templates" documentation chapter from this document.

# desired source category, useful if you want to override the source category
Expand All @@ -54,10 +54,6 @@ exporters:
# desired host name, useful if you want to override the source host
# configured for the source.
source_host: <source_host>
# template for Graphite format, applied only if metric_format is set to graphite;
# source templating is going to be applied,
# default = `%{_metric_}`
graphite_template: <graphite_template>
# name of resource attribute which should be dropped for records
# this is for attribute used by routing processor
# other attributes should be removed by processors in pipelines before
Expand Down Expand Up @@ -185,7 +181,7 @@ Below is a list of all attribute keys that are being translated.
## Source Templates

You can specify a template with an attribute for `source_category`, `source_name`,
`source_host` or `graphite_template` using `%{attr_name}`. Only *resource* attributes
`source_host` using `%{attr_name}`. Only *resource* attributes
can be used this way.

For example, when there is an attribute `my_attr`: `my_value`, `metrics/%{my_attr}`
Expand All @@ -194,9 +190,6 @@ Use OpenTelemetry attribute names like `k8s.pod.name` instead of `pod`,
even when [attribute translation](#attribute-translation)
is turned on.

For `graphite_template`, in addition to above, `%{_metric_}` is going to be replaced
with metric name.

If an attribute is not found, it is replaced with `undefined`.
For example, `%{existing_attr}/%{nonexistent_attr}` becomes `value-of-existing-attr/undefined`.

Expand Down
14 changes: 5 additions & 9 deletions pkg/exporter/sumologicexporter/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,8 @@ type Config struct {
LogFormat LogFormatType `mapstructure:"log_format"`

// Metrics related configuration
// The format of metrics you will be sending, either graphite, otlp or prometheus (Default is otlp)
// The format of metrics you will be sending, either otlp or prometheus (Default is otlp)
MetricFormat MetricFormatType `mapstructure:"metric_format"`
// Graphite template.
// Placeholders `%{attr_name}` will be replaced with attribute value for attr_name.
GraphiteTemplate string `mapstructure:"graphite_template"`

// Traces related configuration
// The format of traces you will be sending, currently only otlp format is supported
Expand Down Expand Up @@ -149,8 +146,9 @@ Please consult the changelog at https://github.com/SumoLogic/sumologic-otel-coll

switch cfg.MetricFormat {
case OTLPMetricFormat:
case GraphiteFormat:
case PrometheusFormat:
case RemovedGraphiteFormat:
return fmt.Errorf("support for the graphite metric format was removed, please use prometheus or otlp instead")
case RemovedCarbon2Format:
return fmt.Errorf("support for the carbon2 metric format was removed, please use prometheus or otlp instead")
default:
Expand Down Expand Up @@ -219,8 +217,8 @@ const (
JSONFormat LogFormatType = "json"
// OTLPLogFormat represents log_format: otlp
OTLPLogFormat LogFormatType = "otlp"
// GraphiteFormat represents metric_format: graphite
GraphiteFormat MetricFormatType = "graphite"
// RemovedGraphiteFormat represents the no longer supported graphite metric format
RemovedGraphiteFormat MetricFormatType = "graphite"
// RemovedCarbon2Format represents the no longer supported carbon2 metric format
RemovedCarbon2Format MetricFormatType = "carbon2"
// PrometheusFormat represents metric_format: prometheus
Expand Down Expand Up @@ -261,8 +259,6 @@ const (
DefaultSourceHost string = ""
// DefaultClient defines default Client
DefaultClient string = "otelcol"
// DefaultGraphiteTemplate defines default template for Graphite
DefaultGraphiteTemplate string = "%{_metric_}"
// DefaultTranslateAttributes defines default TranslateAttributes
DefaultTranslateAttributes bool = true
// DefaultTranslateTelegrafMetrics defines default TranslateTelegrafMetrics
Expand Down
13 changes: 13 additions & 0 deletions pkg/exporter/sumologicexporter/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,19 @@ func TestInitExporterInvalidConfiguration(t *testing.T) {
CompressEncoding: "gzip",
},
},
{
name: "unsupported Graphite metrics format",
expectedError: errors.New("support for the graphite metric format was removed, please use prometheus or otlp instead"),
cfg: &Config{
LogFormat: "json",
MetricFormat: "graphite",
HTTPClientSettings: confighttp.HTTPClientSettings{
Timeout: defaultTimeout,
Endpoint: "test_endpoint",
},
CompressEncoding: "gzip",
},
},
{
name: "unexpected trace format",
expectedError: errors.New("unexpected trace format: text"),
Expand Down
10 changes: 0 additions & 10 deletions pkg/exporter/sumologicexporter/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ type sumologicexporter struct {
compressorPool sync.Pool

prometheusFormatter prometheusFormatter
graphiteFormatter graphiteFormatter

// Lock around data URLs is needed because the reconfiguration of the exporter
// can happen asynchronously whenever the exporter is re registering.
Expand All @@ -79,11 +78,6 @@ func initExporter(cfg *Config, createSettings component.ExporterCreateSettings)
return nil, err
}

gf, err := newGraphiteFormatter(cfg.GraphiteTemplate)
if err != nil {
return nil, err
}

se := &sumologicexporter{
config: cfg,
logger: createSettings.Logger,
Expand All @@ -99,7 +93,6 @@ func initExporter(cfg *Config, createSettings component.ExporterCreateSettings)
},
// NOTE: client is now set in start()
prometheusFormatter: pf,
graphiteFormatter: gf,
}

se.logger.Info(
Expand Down Expand Up @@ -199,7 +192,6 @@ func (se *sumologicexporter) pushLogsData(ctx context.Context, ld plog.Logs) err
se.sources,
compr,
se.prometheusFormatter,
se.graphiteFormatter,
metricsUrl,
logsUrl,
tracesUrl,
Expand Down Expand Up @@ -286,7 +278,6 @@ func (se *sumologicexporter) pushMetricsData(ctx context.Context, md pmetric.Met
se.sources,
compr,
se.prometheusFormatter,
se.graphiteFormatter,
metricsUrl,
logsUrl,
tracesUrl,
Expand Down Expand Up @@ -373,7 +364,6 @@ func (se *sumologicexporter) pushTracesData(ctx context.Context, td ptrace.Trace
se.sources,
compr,
se.prometheusFormatter,
se.graphiteFormatter,
metricsUrl,
logsUrl,
tracesUrl,
Expand Down
24 changes: 0 additions & 24 deletions pkg/exporter/sumologicexporter/exporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1057,30 +1057,6 @@ func TestLogsTextFormatMetadataFilterWithDroppedAttribute(t *testing.T) {
assert.NoError(t, err)
}

func TestMetricsGraphiteFormatMetadataFilter(t *testing.T) {
test := prepareExporterTest(t, createTestConfig(), []func(w http.ResponseWriter, req *http.Request){
func(w http.ResponseWriter, req *http.Request) {
body := extractBody(t, req)
expected := `test_metric_data.test_value.second_value.value1.value2 14500 1605534165`
assert.Equal(t, expected, body)
assert.Equal(t, "application/vnd.sumologic.graphite", req.Header.Get("Content-Type"))
},
})
test.exp.config.MetricFormat = GraphiteFormat
graphiteFormatter, err := newGraphiteFormatter("%{_metric_}.%{test}.%{test2}.%{key1}.%{key2}")
assert.NoError(t, err)
test.exp.graphiteFormatter = graphiteFormatter

metrics := metricAndAttributesToPdataMetrics(exampleIntMetric())

attrs := metrics.ResourceMetrics().At(0).Resource().Attributes()
attrs.InsertString("key1", "value1")
attrs.InsertString("key2", "value2")

err = test.exp.pushMetricsData(context.Background(), metrics)
assert.NoError(t, err)
}

func TestMetricsPrometheusFormatMetadataFilter(t *testing.T) {
test := prepareExporterTest(t, createTestConfig(), []func(w http.ResponseWriter, req *http.Request){
func(w http.ResponseWriter, req *http.Request) {
Expand Down
3 changes: 1 addition & 2 deletions pkg/exporter/sumologicexporter/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@ func createDefaultConfig() config.Exporter {
TimestampKey: DefaultTimestampKey,
FlattenBody: DefaultFlattenBody,
},
GraphiteTemplate: DefaultGraphiteTemplate,
TraceFormat: OTLPTraceFormat,
TraceFormat: OTLPTraceFormat,

HTTPClientSettings: CreateDefaultHTTPClientSettings(),
RetrySettings: exporterhelper.NewDefaultRetrySettings(),
Expand Down
1 change: 0 additions & 1 deletion pkg/exporter/sumologicexporter/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ func TestCreateDefaultConfig(t *testing.T) {
AddTimestamp: true,
TimestampKey: "timestamp",
},
GraphiteTemplate: "%{_metric_}",
TranslateAttributes: true,
TranslateTelegrafMetrics: true,
TraceFormat: "otlp",
Expand Down
129 changes: 0 additions & 129 deletions pkg/exporter/sumologicexporter/graphite_formatter.go

This file was deleted.

Loading

0 comments on commit faa299f

Please sign in to comment.