Skip to content

Commit

Permalink
[chore] use mdatagen for memorylimiter processor (#9182)
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Boten <[email protected]>
  • Loading branch information
Alex Boten authored Dec 22, 2023
1 parent ad12b54 commit dbaec76
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 18 deletions.
19 changes: 11 additions & 8 deletions processor/memorylimiterprocessor/README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
# Memory Limiter Processor

| Status | |
| ------------------------ | --------------------- |
| Stability | [beta] |
| Supported pipeline types | traces, metrics, logs |
| Distributions | [core], [contrib] |
<!-- status autogenerated section -->
| Status | |
| ------------- |-----------|
| Stability | [beta]: traces, metrics, logs |
| Distributions | [core], [contrib] |
| Issues | [![Open issues](https://img.shields.io/github/issues-search/open-telemetry/opentelemetry-collector-contrib?query=is%3Aissue%20is%3Aopen%20label%3Aprocessor%2Fmemorylimiter%20&label=open&color=orange&logo=opentelemetry)](https://github.com/open-telemetry/opentelemetry-collector-contrib/issues?q=is%3Aopen+is%3Aissue+label%3Aprocessor%2Fmemorylimiter) [![Closed issues](https://img.shields.io/github/issues-search/open-telemetry/opentelemetry-collector-contrib?query=is%3Aissue%20is%3Aclosed%20label%3Aprocessor%2Fmemorylimiter%20&label=closed&color=blue&logo=opentelemetry)](https://github.com/open-telemetry/opentelemetry-collector-contrib/issues?q=is%3Aclosed+is%3Aissue+label%3Aprocessor%2Fmemorylimiter) |

[beta]: https://github.com/open-telemetry/opentelemetry-collector#beta
[core]: https://github.com/open-telemetry/opentelemetry-collector-releases/tree/main/distributions/otelcol
[contrib]: https://github.com/open-telemetry/opentelemetry-collector-releases/tree/main/distributions/otelcol-contrib
<!-- end autogenerated section -->

The memory limiter processor is used to prevent out of memory situations on
the collector. Given that the amount and type of data the collector processes is
Expand Down Expand Up @@ -110,6 +116,3 @@ processors:
Refer to [config.yaml](./testdata/config.yaml) for detailed
examples on using the processor.
[beta]: https://github.com/open-telemetry/opentelemetry-collector#beta
[contrib]: https://github.com/open-telemetry/opentelemetry-collector-releases/tree/main/distributions/otelcol-contrib
[core]: https://github.com/open-telemetry/opentelemetry-collector-releases/tree/main/distributions/otelcol
16 changes: 7 additions & 9 deletions processor/memorylimiterprocessor/factory.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

//go:generate mdatagen metadata.yaml

package memorylimiterprocessor // import "go.opentelemetry.io/collector/processor/memorylimiterprocessor"

import (
Expand All @@ -10,14 +12,10 @@ import (
"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/consumer"
"go.opentelemetry.io/collector/processor"
"go.opentelemetry.io/collector/processor/memorylimiterprocessor/internal/metadata"
"go.opentelemetry.io/collector/processor/processorhelper"
)

const (
// The value of "type" Attribute Key in configuration.
typeStr = "memory_limiter"
)

var processorCapabilities = consumer.Capabilities{MutatesData: false}

type factory struct {
Expand All @@ -33,11 +31,11 @@ func NewFactory() processor.Factory {
memoryLimiters: map[component.Config]*memoryLimiter{},
}
return processor.NewFactory(
typeStr,
metadata.Type,
createDefaultConfig,
processor.WithTraces(f.createTracesProcessor, component.StabilityLevelBeta),
processor.WithMetrics(f.createMetricsProcessor, component.StabilityLevelBeta),
processor.WithLogs(f.createLogsProcessor, component.StabilityLevelBeta))
processor.WithTraces(f.createTracesProcessor, metadata.TracesStability),
processor.WithMetrics(f.createMetricsProcessor, metadata.MetricsStability),
processor.WithLogs(f.createLogsProcessor, metadata.LogsStability))
}

// CreateDefaultConfig creates the default configuration for processor. Notice
Expand Down

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

2 changes: 1 addition & 1 deletion processor/memorylimiterprocessor/memorylimiter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ func (be *ballastExtension) GetBallastSize() uint64 {

func newObsReport(t *testing.T) *processorhelper.ObsReport {
set := processorhelper.ObsReportSettings{
ProcessorID: component.NewID(typeStr),
ProcessorID: component.NewID("memory_limiter"),
ProcessorCreateSettings: processortest.NewNopCreateSettings(),
}
set.ProcessorCreateSettings.MetricsLevel = configtelemetry.LevelNone
Expand Down
7 changes: 7 additions & 0 deletions processor/memorylimiterprocessor/metadata.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
type: memory_limiter

status:
class: processor
stability:
beta: [traces, metrics, logs]
distributions: [core, contrib]

0 comments on commit dbaec76

Please sign in to comment.