From 25f9626836f642bfb6bf35c556b003def4388e66 Mon Sep 17 00:00:00 2001 From: sh0rez Date: Fri, 22 Nov 2024 11:34:26 +0100 Subject: [PATCH] deltatocumulative: Linear -> Processor --- processor/deltatocumulativeprocessor/config.go | 2 +- .../deltatocumulativeprocessor/factory.go | 6 +++--- .../{lineartelemetry => telemetry}/attr.go | 2 +- .../{lineartelemetry => telemetry}/metrics.go | 2 +- .../{linear.go => processor.go} | 18 +++++++++--------- 5 files changed, 15 insertions(+), 15 deletions(-) rename processor/deltatocumulativeprocessor/internal/{lineartelemetry => telemetry}/attr.go (94%) rename processor/deltatocumulativeprocessor/internal/{lineartelemetry => telemetry}/metrics.go (98%) rename processor/deltatocumulativeprocessor/{linear.go => processor.go} (90%) diff --git a/processor/deltatocumulativeprocessor/config.go b/processor/deltatocumulativeprocessor/config.go index 4cb97c91f59b..f5b5c1c59dfa 100644 --- a/processor/deltatocumulativeprocessor/config.go +++ b/processor/deltatocumulativeprocessor/config.go @@ -11,7 +11,7 @@ import ( "go.opentelemetry.io/collector/component" - telemetry "github.com/open-telemetry/opentelemetry-collector-contrib/processor/deltatocumulativeprocessor/internal/lineartelemetry" + telemetry "github.com/open-telemetry/opentelemetry-collector-contrib/processor/deltatocumulativeprocessor/internal/telemetry" ) var _ component.ConfigValidator = (*Config)(nil) diff --git a/processor/deltatocumulativeprocessor/factory.go b/processor/deltatocumulativeprocessor/factory.go index c3014019afd3..904ae1ee6827 100644 --- a/processor/deltatocumulativeprocessor/factory.go +++ b/processor/deltatocumulativeprocessor/factory.go @@ -11,8 +11,8 @@ import ( "go.opentelemetry.io/collector/consumer" "go.opentelemetry.io/collector/processor" - ltel "github.com/open-telemetry/opentelemetry-collector-contrib/processor/deltatocumulativeprocessor/internal/lineartelemetry" "github.com/open-telemetry/opentelemetry-collector-contrib/processor/deltatocumulativeprocessor/internal/metadata" + "github.com/open-telemetry/opentelemetry-collector-contrib/processor/deltatocumulativeprocessor/internal/telemetry" ) func NewFactory() processor.Factory { @@ -29,10 +29,10 @@ func createMetricsProcessor(_ context.Context, set processor.Settings, cfg compo return nil, fmt.Errorf("configuration parsing error") } - ltel, err := ltel.New(set.TelemetrySettings) + tel, err := telemetry.New(set.TelemetrySettings) if err != nil { return nil, err } - return newLinear(pcfg, ltel, next), nil + return newProcessor(pcfg, tel, next), nil } diff --git a/processor/deltatocumulativeprocessor/internal/lineartelemetry/attr.go b/processor/deltatocumulativeprocessor/internal/telemetry/attr.go similarity index 94% rename from processor/deltatocumulativeprocessor/internal/lineartelemetry/attr.go rename to processor/deltatocumulativeprocessor/internal/telemetry/attr.go index cdd68a75b76c..ccfac6553fcb 100644 --- a/processor/deltatocumulativeprocessor/internal/lineartelemetry/attr.go +++ b/processor/deltatocumulativeprocessor/internal/telemetry/attr.go @@ -1,7 +1,7 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -package telemetry // import "github.com/open-telemetry/opentelemetry-collector-contrib/processor/deltatocumulativeprocessor/internal/lineartelemetry" +package telemetry // import "github.com/open-telemetry/opentelemetry-collector-contrib/processor/deltatocumulativeprocessor/internal/telemetry" import "go.opentelemetry.io/otel/attribute" diff --git a/processor/deltatocumulativeprocessor/internal/lineartelemetry/metrics.go b/processor/deltatocumulativeprocessor/internal/telemetry/metrics.go similarity index 98% rename from processor/deltatocumulativeprocessor/internal/lineartelemetry/metrics.go rename to processor/deltatocumulativeprocessor/internal/telemetry/metrics.go index 7576883075c5..ab6fde655005 100644 --- a/processor/deltatocumulativeprocessor/internal/lineartelemetry/metrics.go +++ b/processor/deltatocumulativeprocessor/internal/telemetry/metrics.go @@ -1,7 +1,7 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -package telemetry // import "github.com/open-telemetry/opentelemetry-collector-contrib/processor/deltatocumulativeprocessor/internal/lineartelemetry" +package telemetry // import "github.com/open-telemetry/opentelemetry-collector-contrib/processor/deltatocumulativeprocessor/internal/telemetry" import ( "context" diff --git a/processor/deltatocumulativeprocessor/linear.go b/processor/deltatocumulativeprocessor/processor.go similarity index 90% rename from processor/deltatocumulativeprocessor/linear.go rename to processor/deltatocumulativeprocessor/processor.go index 2b725b7dc78d..149431b8970c 100644 --- a/processor/deltatocumulativeprocessor/linear.go +++ b/processor/deltatocumulativeprocessor/processor.go @@ -16,13 +16,13 @@ import ( "github.com/open-telemetry/opentelemetry-collector-contrib/internal/exp/metrics/identity" "github.com/open-telemetry/opentelemetry-collector-contrib/internal/exp/metrics/staleness" "github.com/open-telemetry/opentelemetry-collector-contrib/processor/deltatocumulativeprocessor/internal/delta" - telemetry "github.com/open-telemetry/opentelemetry-collector-contrib/processor/deltatocumulativeprocessor/internal/lineartelemetry" "github.com/open-telemetry/opentelemetry-collector-contrib/processor/deltatocumulativeprocessor/internal/metrics" + "github.com/open-telemetry/opentelemetry-collector-contrib/processor/deltatocumulativeprocessor/internal/telemetry" ) -var _ processor.Metrics = (*Linear)(nil) +var _ processor.Metrics = (*Processor)(nil) -type Linear struct { +type Processor struct { next consumer.Metrics cfg Config @@ -36,10 +36,10 @@ type Linear struct { tel telemetry.Metrics } -func newLinear(cfg *Config, tel telemetry.Metrics, next consumer.Metrics) *Linear { +func newProcessor(cfg *Config, tel telemetry.Metrics, next consumer.Metrics) *Processor { ctx, cancel := context.WithCancel(context.Background()) - proc := Linear{ + proc := Processor{ next: next, cfg: *cfg, last: state{ @@ -60,7 +60,7 @@ func newLinear(cfg *Config, tel telemetry.Metrics, next consumer.Metrics) *Linea return &proc } -func (p *Linear) ConsumeMetrics(ctx context.Context, md pmetric.Metrics) error { +func (p *Processor) ConsumeMetrics(ctx context.Context, md pmetric.Metrics) error { p.mtx.Lock() defer p.mtx.Unlock() @@ -141,7 +141,7 @@ func (p *Linear) ConsumeMetrics(ctx context.Context, md pmetric.Metrics) error { return p.next.ConsumeMetrics(ctx, md) } -func (p *Linear) Start(_ context.Context, _ component.Host) error { +func (p *Processor) Start(_ context.Context, _ component.Host) error { if p.cfg.MaxStale != 0 { // delete stale streams once per minute go func() { @@ -166,12 +166,12 @@ func (p *Linear) Start(_ context.Context, _ component.Host) error { return nil } -func (p *Linear) Shutdown(_ context.Context) error { +func (p *Processor) Shutdown(_ context.Context) error { p.cancel() return nil } -func (p *Linear) Capabilities() consumer.Capabilities { +func (p *Processor) Capabilities() consumer.Capabilities { return consumer.Capabilities{MutatesData: true} }