Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add statsd receiver #364

Merged
merged 2 commits into from
Aug 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ For a general overview of the directories from this operator and what to expect

Your contribution is welcome! For it to be accepted, we have a few standards that must be followed.

If you are contributing to sync the receivers from [otel-collector-contrib](https://github.com/open-telemetry/opentelemetry-collector-contrib), note that the operator only synchronizes receivers that aren't scrapers, as there's no need to open ports in services for this case. In general, receivers would open a UDP/TCP port and the operator should be adding an entry in the Kubernetes Service resource accordingly.

### New features

Before starting the development of a new feature, please create an issue and discuss it with the project maintainers. Features should come with documentation and enough tests (unit and/or end-to-end).
Expand Down
3 changes: 3 additions & 0 deletions pkg/collector/parser/receiver_generic.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ type GenericReceiver struct {
parserName string
}

// NOTE: Operator will sync with only receivers that aren't scrapers. Operator sync up receivers
// so that it can expose the required port based on the receiver's config. Receiver scrapers are ignored.

// NewGenericReceiverParser builds a new parser for generic receivers.
func NewGenericReceiverParser(logger logr.Logger, name string, config map[interface{}]interface{}) ReceiverParser {
return &GenericReceiver{
Expand Down
1 change: 1 addition & 0 deletions pkg/collector/parser/receiver_generic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ func TestDownstreamParsers(t *testing.T) {
{"wavefront", "wavefront", "__wavefront", 2003, parser.NewWavefrontReceiverParser},
{"zipkin-scribe", "zipkin-scribe", "__zipkinscribe", 9410, parser.NewZipkinScribeReceiverParser},
{"fluentforward", "fluentforward", "__fluentforward", 8006, parser.NewFluentForwardReceiverParser},
{"statsd", "statsd", "__statsd", 8125, parser.NewStatsdReceiverParser},
} {
t.Run(tt.receiverName, func(t *testing.T) {
t.Run("builds successfully", func(t *testing.T) {
Expand Down
34 changes: 34 additions & 0 deletions pkg/collector/parser/receiver_statsd.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Copyright The OpenTelemetry Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package parser

import "github.com/go-logr/logr"

const parserNameStatsd = "__statsd"

// NewStatsdReceiverParser builds a new parser for Statsd receivers, from the contrib repository.
func NewStatsdReceiverParser(logger logr.Logger, name string, config map[interface{}]interface{}) ReceiverParser {
return &GenericReceiver{
logger: logger,
name: name,
config: config,
defaultPort: 8125,
parserName: parserNameStatsd,
}
}

func init() {
Register("statsd", NewStatsdReceiverParser)
}
17 changes: 17 additions & 0 deletions pkg/collector/parser/receiver_statsd_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright The OpenTelemetry Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package parser

// all tests for the Statsd parser are currently part of the test TestDownstreamParsers