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

Bumped OpenTelemetry Collector to v0.16.0 #135

Merged
merged 1 commit into from
Dec 4, 2020
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
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
Changes by Version
==================

0.16.0 (2020-12-03)
-------------------
* Bumped OpenTelemetry Collector to v0.16.0 ([#135](https://github.com/open-telemetry/opentelemetry-operator/pull/135), [@jpkrohling](https://github.com/jpkrohling))
* 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))

_Note: The default port for the OTLP receiver has been changed from 55680 to 4317. To keep compatibility with your existing workload, the operator is now generating a service with the two port numbers by default. Both have 4317 as the target port._

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))
Expand Down
1 change: 0 additions & 1 deletion pkg/collector/parser/receiver_generic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down
104 changes: 96 additions & 8 deletions pkg/collector/parser/receiver_otlp.go
Original file line number Diff line number Diff line change
@@ -1,18 +1,106 @@
package parser

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

const parserNameOTLP = "__otlp"
"github.com/go-logr/logr"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/util/intstr"
)

var _ ReceiverParser = &OTLPReceiverParser{}

const (
parserNameOTLP = "__otlp"

defaultOTLPGRPCPort int32 = 4317
defaultOTLPGRPCLegacyPort int32 = 55680
defaultOTLPHTTPPort int32 = 55681
)

// 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,
if protocols, ok := config["protocols"].(map[interface{}]interface{}); ok {
return &OTLPReceiverParser{
logger: logger,
name: name,
config: protocols,
}
}

return &OTLPReceiverParser{
name: name,
config: map[interface{}]interface{}{},
}
}

// Ports returns all the service ports for all protocols in this parser
func (o *OTLPReceiverParser) Ports() ([]corev1.ServicePort, error) {
ports := []corev1.ServicePort{}

for _, protocol := range []struct {
name string
defaultPorts []corev1.ServicePort
}{
{
name: "grpc",
defaultPorts: []corev1.ServicePort{
{
Name: portName(fmt.Sprintf("%s-grpc", o.name), defaultOTLPGRPCPort),
Port: defaultOTLPGRPCPort,
TargetPort: intstr.FromInt(int(defaultOTLPGRPCPort)),
},
{
Name: portName(fmt.Sprintf("%s-grpc-legacy", o.name), defaultOTLPGRPCLegacyPort),
Port: defaultOTLPGRPCLegacyPort,
TargetPort: intstr.FromInt(int(defaultOTLPGRPCPort)), // we target the official port, not the legacy
},
},
},
{
name: "http",
defaultPorts: []corev1.ServicePort{{
Name: portName(fmt.Sprintf("%s-http", o.name), defaultOTLPHTTPPort),
Port: defaultOTLPHTTPPort,
TargetPort: intstr.FromInt(int(defaultOTLPHTTPPort)),
}},
},
} {
// do we have the protocol specified at all?
if receiverProtocol, ok := o.config[protocol.name]; ok {
// we have the specified protocol, we definitely need a service port
nameWithProtocol := fmt.Sprintf("%s-%s", o.name, protocol.name)
var protocolPort *corev1.ServicePort

// do we have a configuration block for the protocol?
settings, ok := receiverProtocol.(map[interface{}]interface{})
if ok {
protocolPort = singlePortFromConfigEndpoint(o.logger, nameWithProtocol, settings)
}

// have we parsed a port based on the configuration block?
// if not, we use the default port
if protocolPort == nil {
ports = append(ports, protocol.defaultPorts...)
} else {
ports = append(ports, *protocolPort)
}
}
}

return ports, nil
}

// ParserName returns the name of this parser
func (o *OTLPReceiverParser) ParserName() string {
return parserNameOTLP
}

func init() {
Expand Down
72 changes: 71 additions & 1 deletion pkg/collector/parser/receiver_otlp_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,73 @@
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{}{
"protocols": map[interface{}]interface{}{
"grpc": 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{}{
"protocols": map[interface{}]interface{}{
"grpc": map[interface{}]interface{}{},
},
})

expectedResults := map[string]struct {
portNumber int32
seen bool
}{
"otlp-grpc": {portNumber: 4317},
"otlp-grpc-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)
}
}
4 changes: 2 additions & 2 deletions versions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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