Skip to content

Commit 8229b7a

Browse files
committed
export struct
1 parent b9389d4 commit 8229b7a

2 files changed

Lines changed: 28 additions & 28 deletions

File tree

translator/translate/otel/receiver/otlp/translator.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,19 +35,19 @@ type translator struct {
3535
common.NameProvider
3636
common.IndexProvider
3737
factory receiver.Factory
38-
endpointConfig endpointConfig
38+
endpointConfig EndpointConfig
3939
pipelineName string
4040
}
4141

42-
type endpointConfig struct {
42+
type EndpointConfig struct {
4343
protocol protocol
4444
endpoint string
4545
certFile string
4646
keyFile string
4747
}
4848

4949
var (
50-
configCache = make(map[endpointConfig]component.Config)
50+
configCache = make(map[EndpointConfig]component.Config)
5151
cacheMutex sync.RWMutex
5252
)
5353

@@ -56,12 +56,12 @@ var (
5656
func ClearConfigCache() {
5757
cacheMutex.Lock()
5858
defer cacheMutex.Unlock()
59-
configCache = make(map[endpointConfig]component.Config)
59+
configCache = make(map[EndpointConfig]component.Config)
6060
}
6161

6262
var _ common.ComponentTranslator = (*translator)(nil)
6363

64-
func NewTranslator(otlpConfig endpointConfig, opts ...common.TranslatorOption) common.ComponentTranslator {
64+
func NewTranslator(otlpConfig EndpointConfig, opts ...common.TranslatorOption) common.ComponentTranslator {
6565
t := &translator{
6666
factory: otlpreceiver.NewFactory(),
6767
endpointConfig: otlpConfig,
@@ -127,10 +127,10 @@ func (t *translator) Translate(_ *confmap.Conf) (component.Config, error) {
127127
return cfg, nil
128128
}
129129

130-
func ParseOtlpConfig(conf *confmap.Conf, pipelineName string, configKey string, signal pipeline.Signal, index int) ([]endpointConfig, error) {
130+
func ParseOtlpConfig(conf *confmap.Conf, pipelineName string, configKey string, signal pipeline.Signal, index int) ([]EndpointConfig, error) {
131131
// JMX only supports HTTP
132132
if pipelineName == common.PipelineNameJmx {
133-
return []endpointConfig{{protocol: HTTP, endpoint: defaultJMXHttpEndpoint}}, nil
133+
return []EndpointConfig{{protocol: HTTP, endpoint: defaultJMXHttpEndpoint}}, nil
134134
}
135135

136136
grpcDefault := defaultGrpcEndpoint
@@ -164,23 +164,23 @@ func ParseOtlpConfig(conf *confmap.Conf, pipelineName string, configKey string,
164164
}
165165

166166
// creates 2 separate config entry by protocol
167-
var configs []endpointConfig
167+
var configs []EndpointConfig
168168
if grpcEndpoint, ok := otlpMap["grpc_endpoint"].(string); ok && grpcEndpoint != "" {
169-
configs = append(configs, endpointConfig{
169+
configs = append(configs, EndpointConfig{
170170
protocol: GRPC, endpoint: grpcEndpoint, certFile: certFile, keyFile: keyFile,
171171
})
172172
}
173173
if httpEndpoint, ok := otlpMap["http_endpoint"].(string); ok && httpEndpoint != "" {
174-
configs = append(configs, endpointConfig{
174+
configs = append(configs, EndpointConfig{
175175
protocol: HTTP, endpoint: httpEndpoint, certFile: certFile, keyFile: keyFile,
176176
})
177177
}
178178

179179
// If no specific endpoints configured, return defaults
180180
if len(configs) == 0 {
181181
configs = append(configs,
182-
endpointConfig{protocol: GRPC, endpoint: grpcDefault, certFile: certFile, keyFile: keyFile},
183-
endpointConfig{protocol: HTTP, endpoint: httpDefault, certFile: certFile, keyFile: keyFile})
182+
EndpointConfig{protocol: GRPC, endpoint: grpcDefault, certFile: certFile, keyFile: keyFile},
183+
EndpointConfig{protocol: HTTP, endpoint: httpDefault, certFile: certFile, keyFile: keyFile})
184184
}
185185

186186
return configs, nil

translator/translate/otel/receiver/otlp/translator_test.go

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import (
1717
)
1818

1919
func TestTranslatorWithoutDataType(t *testing.T) {
20-
config := endpointConfig{
20+
config := EndpointConfig{
2121
protocol: HTTP,
2222
endpoint: "127.0.0.1:4318",
2323
}
@@ -30,15 +30,15 @@ func TestTranslatorWithoutDataType(t *testing.T) {
3030

3131
func TestTracesTranslator(t *testing.T) {
3232
// Clear cache before test
33-
configCache = make(map[endpointConfig]component.Config)
33+
configCache = make(map[EndpointConfig]component.Config)
3434

3535
testCases := map[string]struct {
36-
config endpointConfig
36+
config EndpointConfig
3737
want func(*otlpreceiver.Config) bool
3838
wantErr error
3939
}{
4040
"WithGRPCDefault": {
41-
config: endpointConfig{
41+
config: EndpointConfig{
4242
protocol: GRPC,
4343
endpoint: "127.0.0.1:4317",
4444
},
@@ -47,7 +47,7 @@ func TestTracesTranslator(t *testing.T) {
4747
},
4848
},
4949
"WithHTTPDefault": {
50-
config: endpointConfig{
50+
config: EndpointConfig{
5151
protocol: HTTP,
5252
endpoint: "127.0.0.1:4318",
5353
},
@@ -56,7 +56,7 @@ func TestTracesTranslator(t *testing.T) {
5656
},
5757
},
5858
"WithTLS": {
59-
config: endpointConfig{
59+
config: EndpointConfig{
6060
protocol: GRPC,
6161
endpoint: "127.0.0.1:4317",
6262
certFile: "path/to/cert.crt",
@@ -74,7 +74,7 @@ func TestTracesTranslator(t *testing.T) {
7474
for name, testCase := range testCases {
7575
t.Run(name, func(t *testing.T) {
7676
// Clear cache before each test case
77-
configCache = make(map[endpointConfig]component.Config)
77+
configCache = make(map[EndpointConfig]component.Config)
7878
tt := NewTranslator(testCase.config)
7979
got, err := tt.Translate(confmap.New())
8080
assert.Equal(t, testCase.wantErr, err)
@@ -90,15 +90,15 @@ func TestTracesTranslator(t *testing.T) {
9090

9191
func TestMetricsTranslator(t *testing.T) {
9292
// Clear cache before test
93-
configCache = make(map[endpointConfig]component.Config)
93+
configCache = make(map[EndpointConfig]component.Config)
9494

9595
testCases := map[string]struct {
96-
config endpointConfig
96+
config EndpointConfig
9797
want func(*otlpreceiver.Config) bool
9898
wantErr error
9999
}{
100100
"WithGRPCEndpoint": {
101-
config: endpointConfig{
101+
config: EndpointConfig{
102102
protocol: GRPC,
103103
endpoint: "127.0.0.1:1234",
104104
},
@@ -107,7 +107,7 @@ func TestMetricsTranslator(t *testing.T) {
107107
},
108108
},
109109
"WithHTTPEndpoint": {
110-
config: endpointConfig{
110+
config: EndpointConfig{
111111
protocol: HTTP,
112112
endpoint: "127.0.0.1:2345",
113113
},
@@ -120,7 +120,7 @@ func TestMetricsTranslator(t *testing.T) {
120120
for name, testCase := range testCases {
121121
t.Run(name, func(t *testing.T) {
122122
// Clear cache before each test case
123-
configCache = make(map[endpointConfig]component.Config)
123+
configCache = make(map[EndpointConfig]component.Config)
124124
tt := NewTranslator(testCase.config)
125125
got, err := tt.Translate(confmap.New())
126126
assert.Equal(t, testCase.wantErr, err)
@@ -136,9 +136,9 @@ func TestMetricsTranslator(t *testing.T) {
136136

137137
func TestCaching(t *testing.T) {
138138
// Clear cache before test
139-
configCache = make(map[endpointConfig]component.Config)
139+
configCache = make(map[EndpointConfig]component.Config)
140140

141-
config := endpointConfig{
141+
config := EndpointConfig{
142142
protocol: HTTP,
143143
endpoint: "127.0.0.1:4318",
144144
}
@@ -158,7 +158,7 @@ func TestTLSConflictDetection(t *testing.T) {
158158
ClearConfigCache() // Clear cache before test
159159

160160
// First translator with TLS
161-
config1 := endpointConfig{
161+
config1 := EndpointConfig{
162162
protocol: HTTP,
163163
endpoint: "127.0.0.1:4318",
164164
certFile: "cert1.pem",
@@ -169,7 +169,7 @@ func TestTLSConflictDetection(t *testing.T) {
169169
assert.NoError(t, err1)
170170

171171
// Second translator with different TLS for same endpoint
172-
config2 := endpointConfig{
172+
config2 := EndpointConfig{
173173
protocol: HTTP,
174174
endpoint: "127.0.0.1:4318",
175175
certFile: "cert2.pem",

0 commit comments

Comments
 (0)