From 32f47b12f75283bd5e9dddc2a22088cd79d89a99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juraci=20Paix=C3=A3o=20Kr=C3=B6hling?= Date: Thu, 3 Dec 2020 17:06:57 +0100 Subject: [PATCH] Bumped OpenTelemetry Collector to v0.16.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Juraci Paixão Kröhling --- CHANGELOG.md | 5 ++ pkg/collector/parser/receiver_generic_test.go | 1 - pkg/collector/parser/receiver_otlp.go | 57 ++++++++++++++--- pkg/collector/parser/receiver_otlp_test.go | 64 ++++++++++++++++++- versions.txt | 4 +- 5 files changed, 119 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 141213cd70..7895322ab7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,11 @@ Changes by Version ================== +0.16.0 (2020-12-03) +------------------- +* Fix image prefix for release image ([#133](https://github.com/open-telemetry/opentelemetry-operator/pull/133), [@jpkrohling](https://github.com/jpkrohling)) +* Explicitly set Service Port Protocol for Jaeger Receivers ([#117](https://github.com/open-telemetry/opentelemetry-operator/pull/117), [@KingJ](https://github.com/KingJ)) + 0.15.0 (2020-11-27) ------------------- * Bumped OpenTelemetry Collector to v0.15.0 ([#131](https://github.com/open-telemetry/opentelemetry-operator/pull/131), [@jpkrohling](https://github.com/jpkrohling)) diff --git a/pkg/collector/parser/receiver_generic_test.go b/pkg/collector/parser/receiver_generic_test.go index dba6b7961a..bf05cc342f 100644 --- a/pkg/collector/parser/receiver_generic_test.go +++ b/pkg/collector/parser/receiver_generic_test.go @@ -52,7 +52,6 @@ func TestDownstreamParsers(t *testing.T) { }{ {"zipkin", "zipkin", "__zipkin", 9411, parser.NewZipkinReceiverParser}, {"opencensus", "opencensus", "__opencensus", 55678, parser.NewOpenCensusReceiverParser}, - {"otlp", "otlp", "__otlp", 55680, parser.NewOTLPReceiverParser}, // contrib receivers {"carbon", "carbon", "__carbon", 2003, parser.NewCarbonReceiverParser}, diff --git a/pkg/collector/parser/receiver_otlp.go b/pkg/collector/parser/receiver_otlp.go index acf19b6fa1..dc097f0372 100644 --- a/pkg/collector/parser/receiver_otlp.go +++ b/pkg/collector/parser/receiver_otlp.go @@ -1,20 +1,61 @@ package parser -import "github.com/go-logr/logr" +import ( + "fmt" -const parserNameOTLP = "__otlp" + "github.com/go-logr/logr" + corev1 "k8s.io/api/core/v1" +) + +var _ ReceiverParser = &OTLPReceiverParser{} + +const ( + parserNameOTLP = "__otlp" + + defaultOTLPLegacyPort int32 = 55680 + defaultOTLPGRPCPort int32 = 4317 +) + +// OTLPReceiverParser parses the configuration for OTLP receivers +type OTLPReceiverParser struct { + logger logr.Logger + name string + config map[interface{}]interface{} +} // NewOTLPReceiverParser builds a new parser for OTLP receivers func NewOTLPReceiverParser(logger logr.Logger, name string, config map[interface{}]interface{}) ReceiverParser { - return &GenericReceiver{ - logger: logger, - name: name, - config: config, - defaultPort: 55680, - parserName: parserNameOTLP, + return &OTLPReceiverParser{ + logger: logger, + name: name, + config: config, } } +// Ports returns all the service ports for all protocols in this parser +func (o *OTLPReceiverParser) Ports() ([]corev1.ServicePort, error) { + port := singlePortFromConfigEndpoint(o.logger, o.name, o.config) + if port != nil { + return []corev1.ServicePort{*port}, nil + } + + return []corev1.ServicePort{ + { + Port: defaultOTLPGRPCPort, + Name: portName(o.name, defaultGRPCPort), + }, + { + Port: defaultOTLPLegacyPort, + Name: portName(fmt.Sprintf("%s-legacy", o.name), defaultOTLPLegacyPort), + }, + }, nil +} + +// ParserName returns the name of this parser +func (o *OTLPReceiverParser) ParserName() string { + return parserNameOTLP +} + func init() { Register("otlp", NewOTLPReceiverParser) } diff --git a/pkg/collector/parser/receiver_otlp_test.go b/pkg/collector/parser/receiver_otlp_test.go index 5f45a86403..7c8d1d5710 100644 --- a/pkg/collector/parser/receiver_otlp_test.go +++ b/pkg/collector/parser/receiver_otlp_test.go @@ -1,3 +1,65 @@ package parser -// all tests for the OTLP parser are currently part of the test TestDownstreamParsers +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestOTLPSelfRegisters(t *testing.T) { + // verify + assert.True(t, IsRegistered("otlp")) +} + +func TestOTLPIsFoundByName(t *testing.T) { + // test + p := For(logger, "otlp", map[interface{}]interface{}{}) + + // verify + assert.Equal(t, "__otlp", p.ParserName()) +} + +func TestOTLPPortsOverridden(t *testing.T) { + // prepare + builder := NewOTLPReceiverParser(logger, "otlp", map[interface{}]interface{}{ + "endpoint": "0.0.0.0:1234", + }) + + // test + ports, err := builder.Ports() + + // verify + assert.NoError(t, err) + assert.Len(t, ports, 1) + assert.EqualValues(t, 1234, ports[0].Port) +} + +func TestOTLPExposeDefaultPorts(t *testing.T) { + // prepare + builder := NewOTLPReceiverParser(logger, "otlp", map[interface{}]interface{}{}) + + expectedResults := map[string]struct { + portNumber int32 + seen bool + }{ + "otlp": {portNumber: 4317}, + "otlp-legacy": {portNumber: 55680}, + } + + // test + ports, err := builder.Ports() + + // verify + assert.NoError(t, err) + assert.Len(t, ports, 2) + + for _, port := range ports { + r := expectedResults[port.Name] + r.seen = true + expectedResults[port.Name] = r + assert.EqualValues(t, r.portNumber, port.Port) + } + for k, v := range expectedResults { + assert.True(t, v.seen, "the port %s wasn't included in the service ports", k) + } +} diff --git a/versions.txt b/versions.txt index eb4d9a3956..345e870537 100644 --- a/versions.txt +++ b/versions.txt @@ -2,7 +2,7 @@ # by default with the OpenTelemetry Operator. This would usually be the latest # stable OpenTelemetry version. When you update this file, make sure to update the # the docs as well. -opentelemetry-collector=0.15.0 +opentelemetry-collector=0.16.0 # Represents the next release of the OpenTelemetry Operator. -operator=0.15.0 +operator=0.16.0