Skip to content

Commit

Permalink
Revert "sumologicexporter: add carbon formatter (#2523)" (#2543)
Browse files Browse the repository at this point in the history
This reverts commit 0b87f70.
  • Loading branch information
bogdandrutu authored and pmatyjasek-sumo committed Apr 28, 2021
1 parent a04163e commit b7cd496
Show file tree
Hide file tree
Showing 6 changed files with 1 addition and 246 deletions.
2 changes: 1 addition & 1 deletion exporter/sumologicexporter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Empty string means no compression
- `max_request_body_size` (optional): Max HTTP request body size in bytes before compression (if applied). By default `1_048_576` (1MB) is used.
- `metadata_attributes` (optional): List of regexes for attributes which should be send as metadata
- `log_format` (optional) (logs only): Format to use when sending logs to Sumo. (default `json`) (possible values: `json`, `text`)
- `metric_format` (optional) (metrics only): Format of the metrics to be sent (default is `prometheus`) (possible values: `carbon2`, `prometheus`)
- `metric_format` (optional) (metrics only): Format of the metrics to be sent (default is `prometheus`).
`carbon2` and `graphite` are going to be supported soon.
- `source_category` (optional): Desired source category. Useful if you want to override the source category configured for the source.
- `source_name` (optional): Desired source name. Useful if you want to override the source name configured for the source.
Expand Down
113 changes: 0 additions & 113 deletions exporter/sumologicexporter/carbon_formatter.go

This file was deleted.

99 changes: 0 additions & 99 deletions exporter/sumologicexporter/carbon_formatter_test.go

This file was deleted.

1 change: 0 additions & 1 deletion exporter/sumologicexporter/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ type Config struct {

// Metrics related configuration
// The format of metrics you will be sending, either graphite or carbon2 or prometheus (Default is prometheus)
// Possible values are `carbon2` and `prometheus`
MetricFormat MetricFormatType `mapstructure:"metric_format"`

// List of regexes for attributes which should be send as metadata
Expand Down
5 changes: 0 additions & 5 deletions exporter/sumologicexporter/sender.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ const (

contentTypeLogs string = "application/x-www-form-urlencoded"
contentTypePrometheus string = "application/vnd.sumologic.prometheus"
contentTypeCarbon2 string = "application/vnd.sumologic.carbon2"

contentEncodingGzip string = "gzip"
contentEncodingDeflate string = "deflate"
Expand Down Expand Up @@ -142,8 +141,6 @@ func (s *sender) send(ctx context.Context, pipeline PipelineType, body io.Reader
switch s.config.MetricFormat {
case PrometheusFormat:
req.Header.Add(headerContentType, contentTypePrometheus)
case Carbon2Format:
req.Header.Add(headerContentType, contentTypeCarbon2)
default:
return fmt.Errorf("unsupported metrics format: %s", s.config.MetricFormat)
}
Expand Down Expand Up @@ -261,8 +258,6 @@ func (s *sender) sendMetrics(ctx context.Context, flds fields) ([]metricPair, er
switch s.config.MetricFormat {
case PrometheusFormat:
formattedLine = s.prometheusFormatter.metric2String(record)
case Carbon2Format:
formattedLine = carbon2Metric2String(record)
default:
err = fmt.Errorf("unexpected metric format: %s", s.config.MetricFormat)
}
Expand Down
27 changes: 0 additions & 27 deletions exporter/sumologicexporter/sender_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -777,30 +777,3 @@ func TestMetricsBufferOverflow(t *testing.T) {
assert.EqualError(t, err, `parse ":": missing protocol scheme`)
assert.Equal(t, 0, test.s.countMetrics())
}

func TestSendCarbon2Metrics(t *testing.T) {
test := prepareSenderTest(t, []func(w http.ResponseWriter, req *http.Request){
func(w http.ResponseWriter, req *http.Request) {
body := extractBody(t, req)
expected := `test=test_value test2=second_value _unit=m/s metric=true metric=test.metric.data unit=bytes 14500 1605534165
foo=bar metric=gauge_metric_name 124 1608124661
foo=bar metric=gauge_metric_name 245 1608124662`
assert.Equal(t, expected, body)
assert.Equal(t, "otelcol", req.Header.Get("X-Sumo-Client"))
assert.Equal(t, "application/vnd.sumologic.carbon2", req.Header.Get("Content-Type"))
},
})
defer func() { test.srv.Close() }()

test.s.config.MetricFormat = Carbon2Format
test.s.metricBuffer = []metricPair{
exampleIntMetric(),
exampleIntGaugeMetric(),
}

test.s.metricBuffer[0].attributes.InsertString("unit", "m/s")
test.s.metricBuffer[0].attributes.InsertBool("metric", true)

_, err := test.s.sendMetrics(context.Background(), fields{"key1": "value", "key2": "value2"})
assert.NoError(t, err)
}

0 comments on commit b7cd496

Please sign in to comment.