Skip to content

Commit

Permalink
[processor/deltatocumulative]: initial structure (#30706)
Browse files Browse the repository at this point in the history
_tracking issue:
https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/30705_

Adds basic component structure without any actual functionality as
advised by `CONTRIBUTING.md`.
  • Loading branch information
sh0rez authored Jan 29, 2024
1 parent b60f30f commit facd369
Show file tree
Hide file tree
Showing 16 changed files with 339 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ pkg/winperfcounters/ @open-telemetry/collect
processor/attributesprocessor/ @open-telemetry/collector-contrib-approvers @boostchicken
processor/cumulativetodeltaprocessor/ @open-telemetry/collector-contrib-approvers @TylerHelmuth
processor/datadogprocessor/ @open-telemetry/collector-contrib-approvers @mx-psi @dineshg13
processor/deltatocumulativeprocessor/ @open-telemetry/collector-contrib-approvers @sh0rez
processor/deltatorateprocessor/ @open-telemetry/collector-contrib-approvers @Aneurysm9
processor/filterprocessor/ @open-telemetry/collector-contrib-approvers @TylerHelmuth @boostchicken
processor/groupbyattrsprocessor/ @open-telemetry/collector-contrib-approvers @rnishtala-sumo
Expand Down
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/bug_report.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ body:
- processor/attributes
- processor/cumulativetodelta
- processor/datadog
- processor/deltatocumulative
- processor/deltatorate
- processor/filter
- processor/groupbyattrs
Expand Down
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/feature_request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ body:
- processor/attributes
- processor/cumulativetodelta
- processor/datadog
- processor/deltatocumulative
- processor/deltatorate
- processor/filter
- processor/groupbyattrs
Expand Down
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/other.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ body:
- processor/attributes
- processor/cumulativetodelta
- processor/datadog
- processor/deltatocumulative
- processor/deltatorate
- processor/filter
- processor/groupbyattrs
Expand Down
1 change: 1 addition & 0 deletions processor/deltatocumulativeprocessor/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include ../../Makefile.Common
29 changes: 29 additions & 0 deletions processor/deltatocumulativeprocessor/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Delta to cumulative processor

<!-- status autogenerated section -->
| Status | |
| ------------- |-----------|
| Stability | [development]: metrics |
| Distributions | [contrib] |
| Warnings | [Statefulness](#warnings) |
| Issues | [![Open issues](https://img.shields.io/github/issues-search/open-telemetry/opentelemetry-collector-contrib?query=is%3Aissue%20is%3Aopen%20label%3Aprocessor%2Fdeltatocumulative%20&label=open&color=orange&logo=opentelemetry)](https://github.com/open-telemetry/opentelemetry-collector-contrib/issues?q=is%3Aopen+is%3Aissue+label%3Aprocessor%2Fdeltatocumulative) [![Closed issues](https://img.shields.io/github/issues-search/open-telemetry/opentelemetry-collector-contrib?query=is%3Aissue%20is%3Aclosed%20label%3Aprocessor%2Fdeltatocumulative%20&label=closed&color=blue&logo=opentelemetry)](https://github.com/open-telemetry/opentelemetry-collector-contrib/issues?q=is%3Aclosed+is%3Aissue+label%3Aprocessor%2Fdeltatocumulative) |
| [Code Owners](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/CONTRIBUTING.md#becoming-a-code-owner) | [@sh0rez](https://www.github.com/sh0rez) |

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


## Description

The delta to cumulative processor (`deltatocumulativeprocessor`) converts
metrics from delta temporality to cumulative, by accumulating samples in memory.

## Configuration

``` yaml
processors:
deltatocumulative:
```
There is no further configuration required. All delta samples are converted to cumulative.
16 changes: 16 additions & 0 deletions processor/deltatocumulativeprocessor/config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

package deltatocumulativeprocessor // import "github.com/open-telemetry/opentelemetry-collector-contrib/processor/deltatocumulativeprocessor"

import (
"go.opentelemetry.io/collector/component"
)

var _ component.ConfigValidator = (*Config)(nil)

type Config struct{}

func (c *Config) Validate() error {
return nil
}
8 changes: 8 additions & 0 deletions processor/deltatocumulativeprocessor/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

//go:generate mdatagen metadata.yaml

// package deltatocumulativeprocessor implements a processor which
// converts metrics from delta temporality to cumulative.
package deltatocumulativeprocessor // import "github.com/open-telemetry/opentelemetry-collector-contrib/processor/deltatocumulativeprocessor"
36 changes: 36 additions & 0 deletions processor/deltatocumulativeprocessor/factory.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

package deltatocumulativeprocessor // import "github.com/open-telemetry/opentelemetry-collector-contrib/processor/deltatocumulativeprocessor"

import (
"context"
"fmt"

"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/consumer"
"go.opentelemetry.io/collector/processor"

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

func NewFactory() processor.Factory {
return processor.NewFactory(
metadata.Type,
createDefaultConfig,
processor.WithMetrics(createMetricsProcessor, metadata.MetricsStability),
)
}

func createDefaultConfig() component.Config {
return &Config{}
}

func createMetricsProcessor(_ context.Context, set processor.CreateSettings, cfg component.Config, next consumer.Metrics) (processor.Metrics, error) {
pcfg, ok := cfg.(*Config)
if !ok {
return nil, fmt.Errorf("configuration parsing error")
}

return newProcessor(pcfg, set.Logger, next), nil
}
37 changes: 37 additions & 0 deletions processor/deltatocumulativeprocessor/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
module github.com/open-telemetry/opentelemetry-collector-contrib/processor/deltatocumulativeprocessor

go 1.20

require (
go.opentelemetry.io/collector/component v0.93.1-0.20240125183026-3cacd40b27e8
go.opentelemetry.io/collector/consumer v0.93.1-0.20240125183026-3cacd40b27e8
go.opentelemetry.io/collector/pdata v1.0.2-0.20240125183026-3cacd40b27e8
go.opentelemetry.io/collector/processor v0.93.1-0.20240125183026-3cacd40b27e8
go.opentelemetry.io/otel/metric v1.22.0
go.opentelemetry.io/otel/trace v1.22.0
go.uber.org/zap v1.26.0
)

require (
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/knadh/koanf/maps v0.1.1 // indirect
github.com/knadh/koanf/providers/confmap v0.1.0 // indirect
github.com/knadh/koanf/v2 v2.0.1 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/mapstructure v1.5.1-0.20231216201459-8508981c8b6c // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
go.opentelemetry.io/collector/config/configtelemetry v0.93.1-0.20240125183026-3cacd40b27e8 // indirect
go.opentelemetry.io/collector/confmap v0.93.1-0.20240125183026-3cacd40b27e8 // indirect
go.opentelemetry.io/otel v1.22.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/net v0.20.0 // indirect
golang.org/x/sys v0.16.0 // indirect
golang.org/x/text v0.14.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20231002182017-d307bd883b97 // indirect
google.golang.org/grpc v1.60.1 // indirect
google.golang.org/protobuf v1.32.0 // indirect
)
120 changes: 120 additions & 0 deletions processor/deltatocumulativeprocessor/go.sum

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

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

10 changes: 10 additions & 0 deletions processor/deltatocumulativeprocessor/metadata.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
type: deltatocumulative

status:
class: processor
stability:
development: [metrics]
distributions: [contrib]
warnings: [Statefulness]
codeowners:
active: [sh0rez]
Loading

0 comments on commit facd369

Please sign in to comment.