Skip to content

Commit

Permalink
[receiver/prometheusremotewrite] Add component skeleton (#35295)
Browse files Browse the repository at this point in the history
**Description:** 

Add skeleton for Prometheus Remote-Write Receiver. With the release of
PrometheusRemoteWritev2, there's commitment from the Prometheus team to
implement and maintain this component :)


prometheus/prometheus#12633 (comment)

**Link to tracking Issue:**
#33782

Signed-off-by: Arthur Silva Sens <[email protected]>
  • Loading branch information
ArthurSens authored Oct 1, 2024
1 parent 795694c commit 6d1d0a3
Show file tree
Hide file tree
Showing 16 changed files with 292 additions and 0 deletions.
28 changes: 28 additions & 0 deletions .chloggen/prw-receiver.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Use this changelog template to create an entry for release notes.

# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: new_component

# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
component: receiver/prometheusremotewrite

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: |
Add a new receiver for Prometheus Remote Write.
# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
issues: [33782]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext:

# If your change doesn't affect end users or the exported elements of any package,
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
# Optional: The change log or logs in which this entry should be included.
# e.g. '[user]' or '[user, api]'
# Include 'user' if the change is relevant to end users.
# Include 'api' if there is a change to a library API.
# Default: '[user]'
change_logs: [user]
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ receiver/otlpjsonfilereceiver/ @open-teleme
receiver/podmanreceiver/ @open-telemetry/collector-contrib-approvers @rogercoll
receiver/postgresqlreceiver/ @open-telemetry/collector-contrib-approvers @djaglowski
receiver/prometheusreceiver/ @open-telemetry/collector-contrib-approvers @Aneurysm9 @dashpole
receiver/prometheusremotewritereceiver/ @open-telemetry/collector-contrib-approvers @dashpole @ArthurSens
receiver/pulsarreceiver/ @open-telemetry/collector-contrib-approvers @dmitryax @dao-jun
receiver/purefareceiver/ @open-telemetry/collector-contrib-approvers @jpkrohling @dgoscn @chrroberts-pure
receiver/purefbreceiver/ @open-telemetry/collector-contrib-approvers @jpkrohling @dgoscn @chrroberts-pure
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 @@ -266,6 +266,7 @@ body:
- receiver/podman
- receiver/postgresql
- receiver/prometheus
- receiver/prometheusremotewrite
- receiver/pulsar
- receiver/purefa
- receiver/purefb
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 @@ -260,6 +260,7 @@ body:
- receiver/podman
- receiver/postgresql
- receiver/prometheus
- receiver/prometheusremotewrite
- receiver/pulsar
- receiver/purefa
- receiver/purefb
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 @@ -260,6 +260,7 @@ body:
- receiver/podman
- receiver/postgresql
- receiver/prometheus
- receiver/prometheusremotewrite
- receiver/pulsar
- receiver/purefa
- receiver/purefb
Expand Down
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/unmaintained.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ body:
- receiver/podman
- receiver/postgresql
- receiver/prometheus
- receiver/prometheusremotewrite
- receiver/pulsar
- receiver/purefa
- receiver/purefb
Expand Down
1 change: 1 addition & 0 deletions receiver/prometheusremotewritereceiver/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include ../../Makefile.Common
10 changes: 10 additions & 0 deletions receiver/prometheusremotewritereceiver/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!-- status autogenerated section -->
| Status | |
| ------------- |-----------|
| Stability | [development]: metrics |
| Distributions | |
| Issues | [![Open issues](https://img.shields.io/github/issues-search/open-telemetry/opentelemetry-collector-contrib?query=is%3Aissue%20is%3Aopen%20label%3Areceiver%2Fprometheusremotewrite%20&label=open&color=orange&logo=opentelemetry)](https://github.com/open-telemetry/opentelemetry-collector-contrib/issues?q=is%3Aopen+is%3Aissue+label%3Areceiver%2Fprometheusremotewrite) [![Closed issues](https://img.shields.io/github/issues-search/open-telemetry/opentelemetry-collector-contrib?query=is%3Aissue%20is%3Aclosed%20label%3Areceiver%2Fprometheusremotewrite%20&label=closed&color=blue&logo=opentelemetry)](https://github.com/open-telemetry/opentelemetry-collector-contrib/issues?q=is%3Aclosed+is%3Aissue+label%3Areceiver%2Fprometheusremotewrite) |
| [Code Owners](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/CONTRIBUTING.md#becoming-a-code-owner) | [@dashpole](https://www.github.com/dashpole), [@ArthurSens](https://www.github.com/ArthurSens) |

[development]: https://github.com/open-telemetry/opentelemetry-collector#development
<!-- end autogenerated section -->
18 changes: 18 additions & 0 deletions receiver/prometheusremotewritereceiver/config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

package prometheusremotewritereceiver // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/prometheusremotewritereceiver"

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

// Config holds common fields and embedded protocol-specific configurations
type Config struct{}

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

// Validate checks the receiver configuration is valid
func (cfg *Config) Validate() error {
return nil
}
37 changes: 37 additions & 0 deletions receiver/prometheusremotewritereceiver/factory.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

package prometheusremotewritereceiver // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/prometheusremotewritereceiver"

import (
"context"

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

"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/prometheusremotewritereceiver/internal/metadata"
)

// NewFactory creates a new Prometheus receiver factory.
func NewFactory() receiver.Factory {
return receiver.NewFactory(
metadata.Type,
createDefaultConfig,
receiver.WithMetrics(createMetricsReceiver, metadata.MetricsStability))
}

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

// createMetrics creates a metrics receiver based on provided config.
func createMetricsReceiver(
_ context.Context,
set receiver.Settings,
cfg component.Config,
nextConsumer consumer.Metrics,
) (receiver.Metrics, error) {
rCfg := cfg.(*Config)
return newRemoteWriteReceiver(set, rCfg, nextConsumer)
}
33 changes: 33 additions & 0 deletions receiver/prometheusremotewritereceiver/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
module github.com/open-telemetry/opentelemetry-collector-contrib/receiver/prometheusremotewritereceiver

go 1.22.0

require (
go.opentelemetry.io/collector/component v0.110.0
go.opentelemetry.io/collector/consumer v0.110.0
go.opentelemetry.io/collector/receiver v0.110.0
go.uber.org/zap v1.27.0
)

require (
github.com/gogo/protobuf v1.3.2 // indirect
github.com/json-iterator/go v1.1.12 // 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.110.0 // indirect
go.opentelemetry.io/collector/consumer/consumerprofiles v0.110.0 // indirect
go.opentelemetry.io/collector/internal/globalsignal v0.110.0 // indirect
go.opentelemetry.io/collector/pdata v1.16.0 // indirect
go.opentelemetry.io/collector/pdata/pprofile v0.110.0 // indirect
go.opentelemetry.io/collector/pipeline v0.110.0 // indirect
go.opentelemetry.io/otel v1.30.0 // indirect
go.opentelemetry.io/otel/metric v1.30.0 // indirect
go.opentelemetry.io/otel/trace v1.30.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/net v0.28.0 // indirect
golang.org/x/sys v0.25.0 // indirect
golang.org/x/text v0.17.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240822170219-fc7c04adadcd // indirect
google.golang.org/grpc v1.66.2 // indirect
google.golang.org/protobuf v1.34.2 // indirect
)
100 changes: 100 additions & 0 deletions receiver/prometheusremotewritereceiver/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.

11 changes: 11 additions & 0 deletions receiver/prometheusremotewritereceiver/metadata.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
type: prometheusremotewrite

status:
class: receiver
stability:
development: [metrics]
distributions: []
codeowners:
active: [dashpole, ArthurSens]
tests:
config:
32 changes: 32 additions & 0 deletions receiver/prometheusremotewritereceiver/receiver.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

package prometheusremotewritereceiver // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/prometheusremotewritereceiver"

import (
"context"

"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/consumer"
"go.opentelemetry.io/collector/receiver"
"go.uber.org/zap"
)

func newRemoteWriteReceiver(_ receiver.Settings, _ *Config, _ consumer.Metrics) (receiver.Metrics, error) {
panic("need implement")
}

// nolint
type prometheusRemoteWriteReceiver struct {
settings receiver.Settings //nolint:unused
host component.Host //nolint:unused
nextConsumer consumer.Metrics //nolint:unused

config *Config //nolint:unused
logger *zap.Logger //nolint:unused
}

// nolint
func (prwc *prometheusRemoteWriteReceiver) Start(_ context.Context, _ component.Host) error {
panic("need implement")
}
1 change: 1 addition & 0 deletions versions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ module-sets:
- github.com/open-telemetry/opentelemetry-collector-contrib/receiver/podmanreceiver
- github.com/open-telemetry/opentelemetry-collector-contrib/receiver/postgresqlreceiver
- github.com/open-telemetry/opentelemetry-collector-contrib/receiver/prometheusreceiver
- github.com/open-telemetry/opentelemetry-collector-contrib/receiver/prometheusremotewritereceiver
- github.com/open-telemetry/opentelemetry-collector-contrib/receiver/pulsarreceiver
- github.com/open-telemetry/opentelemetry-collector-contrib/receiver/purefareceiver
- github.com/open-telemetry/opentelemetry-collector-contrib/receiver/purefbreceiver
Expand Down

0 comments on commit 6d1d0a3

Please sign in to comment.