Skip to content

Commit

Permalink
[processor/groupbyattrs] Update to use generated status (#21061)
Browse files Browse the repository at this point in the history
* Update to use generated status

* cleanup
  • Loading branch information
TylerHelmuth committed Apr 19, 2023
1 parent af0f695 commit a39dfaa
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 29 deletions.
17 changes: 9 additions & 8 deletions processor/groupbyattrsprocessor/README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
# Group by Attributes processor
<!-- status autogenerated section -->
| Status | |
| ------------------------ |-----------|
| Stability | [beta] |
| Supported pipeline types | traces, metrics, logs |
| Distributions | [contrib] |

| Status | |
| ------------------------ | --------------------- |
| Stability | [beta] |
| Supported pipeline types | traces, metrics, logs |
| Distributions | [contrib] |
[beta]: https://github.com/open-telemetry/opentelemetry-collector#beta
[contrib]: https://github.com/open-telemetry/opentelemetry-collector-releases/tree/main/distributions/otelcol-contrib
<!-- end autogenerated section -->

## Description

Expand Down Expand Up @@ -192,6 +196,3 @@ The following internal metrics are recorded by this processor:
| `num_grouped_metrics` | number of metrics that had attributes grouped |
| `num_non_grouped_metrics` | number of metrics that did not have attributes grouped |
| `metric_groups` | distribution of groups extracted for metrics |

[beta]:https://github.com/open-telemetry/opentelemetry-collector#beta
[contrib]:https://github.com/open-telemetry/opentelemetry-collector-releases/tree/main/distributions/otelcol-contrib
6 changes: 4 additions & 2 deletions processor/groupbyattrsprocessor/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import (
"github.com/stretchr/testify/require"
"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/confmap/confmaptest"

"github.com/open-telemetry/opentelemetry-collector-contrib/processor/groupbyattrsprocessor/internal/metadata"
)

func TestLoadingConfig(t *testing.T) {
Expand All @@ -32,13 +34,13 @@ func TestLoadingConfig(t *testing.T) {
expected component.Config
}{
{
id: component.NewIDWithName(typeStr, "grouping"),
id: component.NewIDWithName(metadata.Type, "grouping"),
expected: &Config{
GroupByKeys: []string{"key1", "key2"},
},
},
{
id: component.NewIDWithName(typeStr, "compaction"),
id: component.NewIDWithName(metadata.Type, "compaction"),
expected: &Config{
GroupByKeys: []string{},
},
Expand Down
2 changes: 2 additions & 0 deletions processor/groupbyattrsprocessor/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//go:generate mdatagen metadata.yaml

// Package groupbyattrsprocessor creates Resources based on specified
// attributes, and groups metrics, log records and spans with matching
// attributes under the corresponding Resource.
Expand Down
15 changes: 5 additions & 10 deletions processor/groupbyattrsprocessor/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,8 @@ import (
"go.opentelemetry.io/collector/processor"
"go.opentelemetry.io/collector/processor/processorhelper"
"go.uber.org/zap"
)

const (
// typeStr is the value of "type" for this processor in the configuration.
typeStr component.Type = "groupbyattrs"
// The stability level of the processor.
stability = component.StabilityLevelBeta
"github.com/open-telemetry/opentelemetry-collector-contrib/processor/groupbyattrsprocessor/internal/metadata"
)

var (
Expand All @@ -47,11 +42,11 @@ func NewFactory() processor.Factory {
})

return processor.NewFactory(
typeStr,
metadata.Type,
createDefaultConfig,
processor.WithTraces(createTracesProcessor, stability),
processor.WithLogs(createLogsProcessor, stability),
processor.WithMetrics(createMetricsProcessor, stability))
processor.WithTraces(createTracesProcessor, metadata.Stability),
processor.WithLogs(createLogsProcessor, metadata.Stability),
processor.WithMetrics(createMetricsProcessor, metadata.Stability))
}

// createDefaultConfig creates the default configuration for the processor.
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions processor/groupbyattrsprocessor/metadata.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
type: groupbyattrs

status:
class: processor
stability: beta
pipelines: [traces, metrics, logs]
distributions: [contrib]
warnings: []
20 changes: 11 additions & 9 deletions processor/groupbyattrsprocessor/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import (
"go.opencensus.io/stats"
"go.opencensus.io/stats/view"
"go.opentelemetry.io/collector/obsreport"

"github.com/open-telemetry/opentelemetry-collector-contrib/processor/groupbyattrsprocessor/internal/metadata"
)

var (
Expand All @@ -40,57 +42,57 @@ func MetricViews() []*view.View {

return []*view.View{
{
Name: obsreport.BuildProcessorCustomMetricName(string(typeStr), mNumGroupedSpans.Name()),
Name: obsreport.BuildProcessorCustomMetricName(string(metadata.Type), mNumGroupedSpans.Name()),
Measure: mNumGroupedSpans,
Description: mNumGroupedSpans.Description(),
Aggregation: view.Sum(),
},
{
Name: obsreport.BuildProcessorCustomMetricName(string(typeStr), mNumNonGroupedSpans.Name()),
Name: obsreport.BuildProcessorCustomMetricName(string(metadata.Type), mNumNonGroupedSpans.Name()),
Measure: mNumNonGroupedSpans,
Description: mNumNonGroupedSpans.Description(),
Aggregation: view.Sum(),
},
{
Name: obsreport.BuildProcessorCustomMetricName(string(typeStr), mDistSpanGroups.Name()),
Name: obsreport.BuildProcessorCustomMetricName(string(metadata.Type), mDistSpanGroups.Name()),
Measure: mDistSpanGroups,
Description: mDistSpanGroups.Description(),
Aggregation: distributionGroups,
},

{
Name: obsreport.BuildProcessorCustomMetricName(string(typeStr), mNumGroupedLogs.Name()),
Name: obsreport.BuildProcessorCustomMetricName(string(metadata.Type), mNumGroupedLogs.Name()),
Measure: mNumGroupedLogs,
Description: mNumGroupedLogs.Description(),
Aggregation: view.Sum(),
},
{
Name: obsreport.BuildProcessorCustomMetricName(string(typeStr), mNumNonGroupedLogs.Name()),
Name: obsreport.BuildProcessorCustomMetricName(string(metadata.Type), mNumNonGroupedLogs.Name()),
Measure: mNumNonGroupedLogs,
Description: mNumNonGroupedLogs.Description(),
Aggregation: view.Sum(),
},
{
Name: obsreport.BuildProcessorCustomMetricName(string(typeStr), mDistLogGroups.Name()),
Name: obsreport.BuildProcessorCustomMetricName(string(metadata.Type), mDistLogGroups.Name()),
Measure: mDistLogGroups,
Description: mDistLogGroups.Description(),
Aggregation: distributionGroups,
},

{
Name: obsreport.BuildProcessorCustomMetricName(string(typeStr), mNumGroupedMetrics.Name()),
Name: obsreport.BuildProcessorCustomMetricName(string(metadata.Type), mNumGroupedMetrics.Name()),
Measure: mNumGroupedMetrics,
Description: mNumGroupedMetrics.Description(),
Aggregation: view.Sum(),
},
{
Name: obsreport.BuildProcessorCustomMetricName(string(typeStr), mNumNonGroupedMetrics.Name()),
Name: obsreport.BuildProcessorCustomMetricName(string(metadata.Type), mNumNonGroupedMetrics.Name()),
Measure: mNumNonGroupedMetrics,
Description: mNumNonGroupedMetrics.Description(),
Aggregation: view.Sum(),
},
{
Name: obsreport.BuildProcessorCustomMetricName(string(typeStr), mDistMetricGroups.Name()),
Name: obsreport.BuildProcessorCustomMetricName(string(metadata.Type), mDistMetricGroups.Name()),
Measure: mDistMetricGroups,
Description: mDistMetricGroups.Description(),
Aggregation: distributionGroups,
Expand Down

0 comments on commit a39dfaa

Please sign in to comment.