Skip to content

Commit 061b8ea

Browse files
sumologicexporter!: change metrics behavior (#32737)
**Description:** <Describe what has changed.> <!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> * remove suppport for carbon2 and graphite * add support for otlp format * do not support metadata attributes * do not support source headers * set otlp as default format This PR reduces size of #32315 **Link to tracking Issue:** #31479 **Testing:** - unit tests - manual tests **Documentation:** - Readme --------- Signed-off-by: Dominik Rosiek <[email protected]> Co-authored-by: Adam Boguszewski <[email protected]>
1 parent 1139675 commit 061b8ea

19 files changed

+936
-1242
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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: change metrics behavior
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: [31479]
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+
* remove suppport for carbon2 and graphite
20+
* add support for otlp format
21+
* do not support metadata attributes
22+
* do not support source headers
23+
* set otlp as default metrics format
24+
25+
# If your change doesn't affect end users or the exported elements of any package,
26+
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
27+
# Optional: The change log or logs in which this entry should be included.
28+
# e.g. '[user]' or '[user, api]'
29+
# Include 'user' if the change is relevant to end users.
30+
# Include 'api' if there is a change to a library API.
31+
# Default: '[user]'
32+
change_logs: [user]

exporter/sumologicexporter/README.md

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
For some time we have been developing the [new Sumo Logic exporter](https://github.com/SumoLogic/sumologic-otel-collector/tree/main/pkg/exporter/sumologicexporter#sumo-logic-exporter) and now we are in the process of moving it into this repository.
2020

21-
The following options are deprecated and they will not exist in the new version:
21+
The following options are deprecated for logs and already do not work for metrics:
2222

2323
- `metric_format: {carbon2, graphite}`
2424
- `metadata_attributes: [<regex>]`
@@ -29,8 +29,8 @@ The following options are deprecated and they will not exist in the new version:
2929

3030
After the new exporter will be moved to this repository:
3131

32-
- `carbon2` and `graphite` are going to be no longer supported and `prometheus` or `otlp` format should be used
33-
- all resource level attributes are going to be treated as `metadata_attributes`. You can use [Group by Attributes processor](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/processor/groupbyattrsprocessor) to move attributes from record level to resource level. For example:
32+
- `carbon2` and `graphite` are no longer supported and `prometheus` or `otlp` format should be used
33+
- all resource level attributes are going to be treated (are treated for metrics) as `metadata_attributes`. You can use [Group by Attributes processor](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/processor/groupbyattrsprocessor) to move attributes from record level to resource level. For example:
3434

3535
```yaml
3636
# before switch to new collector
@@ -45,7 +45,7 @@ After the new exporter will be moved to this repository:
4545
- my_attribute
4646
```
4747
48-
- Source templates (`source_category`, `source_name` and `source_host`) are going to be removed from the exporter and sources may be set using `_sourceCategory`, `sourceName` or `_sourceHost` resource attributes. We recommend to use [Transform Processor](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/processor/transformprocessor/). For example:
48+
- Source templates (`source_category`, `source_name` and `source_host`) are going to be removed from the exporter and sources may be set using `_sourceCategory`, `sourceName` or `_sourceHost` resource attributes. This feature has been already disabled for metrics. We recommend to use [Transform Processor](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/processor/transformprocessor/). For example:
4949

5050
```yaml
5151
# before switch to new collector
@@ -95,11 +95,15 @@ exporters:
9595
# format to use when sending logs to Sumo Logic, default = json,
9696
log_format: {json, text}
9797
98-
# format to use when sending metrics to Sumo Logic, default = prometheus,
99-
#
100-
# carbon2 and graphite are deprecated:
101-
# https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/exporter/sumologicexporter#migration-to-new-architecture
102-
metric_format: {carbon2, graphite, prometheus}
98+
# format to use when sending metrics to Sumo Logic, default = otlp,
99+
# NOTE: only `otlp` is supported when used with sumologicextension
100+
metric_format: {otlp, prometheus}
101+
102+
# Decompose OTLP Histograms into individual metrics, similar to how they're represented in Prometheus format.
103+
# The Sumo OTLP source currently doesn't support Histograms, and they are quietly dropped. This option produces
104+
# metrics similar to when metric_format is set to prometheus.
105+
# default = false
106+
decompose_otlp_histograms: {true, false}
103107

104108
# Template for Graphite format.
105109
# this option affects graphite format only

exporter/sumologicexporter/carbon_formatter.go

Lines changed: 0 additions & 103 deletions
This file was deleted.

exporter/sumologicexporter/carbon_formatter_test.go

Lines changed: 0 additions & 88 deletions
This file was deleted.

exporter/sumologicexporter/config.go

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,11 @@ type Config struct {
3838
LogFormat LogFormatType `mapstructure:"log_format"`
3939

4040
// Metrics related configuration
41-
// The format of metrics you will be sending, either graphite or carbon2 or prometheus (Default is prometheus)
42-
// Possible values are `carbon2` and `prometheus`
41+
// The format of metrics you will be sending, either otlp or prometheus (Default is otlp)
4342
MetricFormat MetricFormatType `mapstructure:"metric_format"`
44-
// Graphite template.
45-
// Placeholders `%{attr_name}` will be replaced with attribute value for attr_name.
46-
GraphiteTemplate string `mapstructure:"graphite_template"`
43+
44+
// Decompose OTLP Histograms into individual metrics, similar to how they're represented in Prometheus format
45+
DecomposeOtlpHistograms bool `mapstructure:"decompose_otlp_histograms"`
4746

4847
// List of regexes for attributes which should be send as metadata
4948
MetadataAttributes []string `mapstructure:"metadata_attributes"`
@@ -92,12 +91,14 @@ const (
9291
TextFormat LogFormatType = "text"
9392
// JSONFormat represents log_format: json
9493
JSONFormat LogFormatType = "json"
94+
// RemovedGraphiteFormat represents the no longer supported graphite metric format
95+
RemovedGraphiteFormat MetricFormatType = "graphite"
96+
// RemovedCarbon2Format represents the no longer supported carbon2 metric format
97+
RemovedCarbon2Format MetricFormatType = "carbon2"
9598
// GraphiteFormat represents metric_format: text
96-
GraphiteFormat MetricFormatType = "graphite"
97-
// Carbon2Format represents metric_format: json
98-
Carbon2Format MetricFormatType = "carbon2"
99-
// PrometheusFormat represents metric_format: json
10099
PrometheusFormat MetricFormatType = "prometheus"
100+
// OTLPMetricFormat represents metric_format: otlp
101+
OTLPMetricFormat MetricFormatType = "otlp"
101102
// GZIPCompression represents compress_encoding: gzip
102103
GZIPCompression CompressEncodingType = "gzip"
103104
// DeflateCompression represents compress_encoding: deflate
@@ -119,7 +120,7 @@ const (
119120
// DefaultLogFormat defines default LogFormat
120121
DefaultLogFormat LogFormatType = JSONFormat
121122
// DefaultMetricFormat defines default MetricFormat
122-
DefaultMetricFormat MetricFormatType = PrometheusFormat
123+
DefaultMetricFormat MetricFormatType = OTLPMetricFormat
123124
// DefaultSourceCategory defines default SourceCategory
124125
DefaultSourceCategory string = ""
125126
// DefaultSourceName defines default SourceName
@@ -141,9 +142,12 @@ func (cfg *Config) Validate() error {
141142
}
142143

143144
switch cfg.MetricFormat {
144-
case GraphiteFormat:
145-
case Carbon2Format:
145+
case RemovedGraphiteFormat:
146+
fallthrough
147+
case RemovedCarbon2Format:
148+
return fmt.Errorf("%s metric format is no longer supported", cfg.MetricFormat)
146149
case PrometheusFormat:
150+
case OTLPMetricFormat:
147151
default:
148152
return fmt.Errorf("unexpected metric format: %s", cfg.MetricFormat)
149153
}

exporter/sumologicexporter/config_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ func TestConfigValidation(t *testing.T) {
2222
name: "invalid log format",
2323
cfg: &Config{
2424
LogFormat: "test_format",
25-
MetricFormat: "carbon2",
25+
MetricFormat: "otlp",
2626
CompressEncoding: "gzip",
2727
ClientConfig: confighttp.ClientConfig{
2828
Timeout: defaultTimeout,
@@ -48,7 +48,7 @@ func TestConfigValidation(t *testing.T) {
4848
name: "invalid compress encoding",
4949
cfg: &Config{
5050
LogFormat: "json",
51-
MetricFormat: "carbon2",
51+
MetricFormat: "otlp",
5252
CompressEncoding: "test_format",
5353
ClientConfig: confighttp.ClientConfig{
5454
Timeout: defaultTimeout,
@@ -62,7 +62,7 @@ func TestConfigValidation(t *testing.T) {
6262
expectedErr: "no endpoint and no auth extension specified",
6363
cfg: &Config{
6464
LogFormat: "json",
65-
MetricFormat: "carbon2",
65+
MetricFormat: "otlp",
6666
CompressEncoding: "gzip",
6767
ClientConfig: confighttp.ClientConfig{
6868
Timeout: defaultTimeout,
@@ -73,7 +73,7 @@ func TestConfigValidation(t *testing.T) {
7373
name: "invalid log format",
7474
cfg: &Config{
7575
LogFormat: "json",
76-
MetricFormat: "carbon2",
76+
MetricFormat: "otlp",
7777
CompressEncoding: "gzip",
7878
ClientConfig: confighttp.ClientConfig{
7979
Timeout: defaultTimeout,
@@ -90,7 +90,7 @@ func TestConfigValidation(t *testing.T) {
9090
name: "valid config",
9191
cfg: &Config{
9292
LogFormat: "json",
93-
MetricFormat: "carbon2",
93+
MetricFormat: "otlp",
9494
CompressEncoding: "gzip",
9595
ClientConfig: confighttp.ClientConfig{
9696
Timeout: defaultTimeout,

0 commit comments

Comments
 (0)