Skip to content

Commit 1e01d69

Browse files
committed
expose grpc(default) when using otelarrow as exporter
Signed-off-by: Praful Khanduri <holiodin@gmail.com>
1 parent 97d1355 commit 1e01d69

6 files changed

Lines changed: 90 additions & 5 deletions

File tree

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
2+
change_type: enhancement
3+
4+
# The name of the component, or a single word describing the area of concern, (e.g. collector, target allocator, auto-instrumentation, opamp, github action)
5+
component: collector
6+
7+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
8+
note: "Expose the default gRPC receiver port (4317) for otelarrow and automatically apply grpc protocol defaults when protocols are omitted or otelarrow is enabled."
9+
10+
11+
# One or more tracking issues related to the change
12+
issues: [4713]
13+
14+
# (Optional) One or more lines of additional information to render under the primary note.
15+
# These lines will be padded with 2 spaces and then inserted directly into the document.
16+
# Use pipe (|) for multiline entries.
17+
subtext:

apis/v1beta1/config_test.go

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -732,10 +732,11 @@ func TestConfig_getEnvironmentVariablesForComponentKinds(t *testing.T) {
732732

733733
func TestConfig_GetReceiverPorts(t *testing.T) {
734734
tests := []struct {
735-
name string
736-
file string
737-
want []v1.ServicePort
738-
wantErr bool
735+
name string
736+
file string
737+
want []v1.ServicePort
738+
wantErr bool
739+
applyDefaults bool
739740
}{
740741
{
741742
name: "k8sevents",
@@ -788,6 +789,33 @@ func TestConfig_GetReceiverPorts(t *testing.T) {
788789
},
789790
},
790791
},
792+
{
793+
name: "otelarrow",
794+
file: "testdata/otelcol-otelarrow.yaml",
795+
want: []v1.ServicePort{
796+
{
797+
Name: "otelarrow-grpc",
798+
Protocol: "",
799+
AppProtocol: ptr.To("grpc"),
800+
Port: 4317,
801+
TargetPort: intstr.FromInt32(4317),
802+
},
803+
},
804+
},
805+
{
806+
name: "otelarrow missing protocols",
807+
file: "testdata/otelcol-otelarrow-no-protocols.yaml",
808+
applyDefaults: true,
809+
want: []v1.ServicePort{
810+
{
811+
Name: "otelarrow-grpc",
812+
Protocol: "",
813+
AppProtocol: ptr.To("grpc"),
814+
Port: 4317,
815+
TargetPort: intstr.FromInt32(4317),
816+
},
817+
},
818+
},
791819
{
792820
name: "filelog",
793821
file: "testdata/otelcol-filelog.yaml",
@@ -807,6 +835,10 @@ func TestConfig_GetReceiverPorts(t *testing.T) {
807835
c := &Config{}
808836
err = go_yaml.Unmarshal(collectorYaml, c)
809837
require.NoError(t, err)
838+
if tt.applyDefaults {
839+
_, err = c.ApplyDefaults(logr.Discard())
840+
require.NoError(t, err)
841+
}
810842
ports, err := c.GetReceiverPorts(logr.Discard())
811843
if tt.wantErr {
812844
require.Error(t, err)
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
receivers:
2+
otelarrow: {}
3+
4+
exporters:
5+
debug:
6+
7+
service:
8+
pipelines:
9+
traces:
10+
receivers: [otelarrow]
11+
exporters: [debug]
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
receivers:
2+
otelarrow:
3+
protocols:
4+
grpc:
5+
6+
exporters:
7+
debug:
8+
9+
service:
10+
pipelines:
11+
traces:
12+
receivers: [otelarrow]
13+
exporters: [debug]

internal/components/multi_endpoint.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,15 @@ func (m *MultiPortReceiver) GetDefaultConfig(logger logr.Logger, config any, opt
7777
if err := mapstructure.Decode(config, multiProtoEndpointCfg); err != nil {
7878
return nil, err
7979
}
80+
protocols := multiProtoEndpointCfg.Protocols
81+
if len(protocols) == 0 {
82+
protocols = map[string]*SingleEndpointConfig{}
83+
for protocol := range m.portMappings {
84+
protocols[protocol] = nil
85+
}
86+
}
8087
defaultedConfig := map[string]any{}
81-
for protocol, ec := range multiProtoEndpointCfg.Protocols {
88+
for protocol, ec := range protocols {
8289
defaultSvc, ok := m.portMappings[protocol]
8390
if !ok {
8491
return nil, fmt.Errorf("unknown protocol set: %s", protocol)

internal/components/receivers/helpers.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,11 @@ var componentParsers = []components.Parser{
7272
WithTargetPort(3100).
7373
WithAppProtocol(&components.HttpProtocol)).
7474
MustBuild(),
75+
components.NewMultiPortReceiverBuilder("otelarrow").
76+
AddPortMapping(components.NewProtocolBuilder("grpc", 4317).
77+
WithAppProtocol(&components.GrpcProtocol).
78+
WithTargetPort(4317)).
79+
MustBuild(),
7580
components.NewSinglePortParserBuilder("awsxray", 2000).
7681
WithTargetPort(2000).
7782
WithProtocol(corev1.ProtocolUDP).

0 commit comments

Comments
 (0)