Skip to content

Commit ca0f22a

Browse files
committed
[chore][test] Prove that unmarshal method gets called for a map wrapper
1 parent 42eaa5e commit ca0f22a

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

config/configgrpc/configgrpc.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import (
3636
"go.opentelemetry.io/collector/config/configopaque"
3737
"go.opentelemetry.io/collector/config/configoptional"
3838
"go.opentelemetry.io/collector/config/configtls"
39+
"go.opentelemetry.io/collector/confmap"
3940
"go.opentelemetry.io/collector/extension/extensionauth"
4041
)
4142

@@ -65,6 +66,15 @@ func BalancerName() string {
6566
return "round_robin"
6667
}
6768

69+
var _ confmap.Unmarshaler = (*Headers)(nil)
70+
71+
type Headers map[string]configopaque.String
72+
73+
// Unmarshal implements confmap.Unmarshaler.
74+
func (h *Headers) Unmarshal(conf *confmap.Conf) error {
75+
panic("I got called")
76+
}
77+
6878
// ClientConfig defines common settings for a gRPC client configuration.
6979
type ClientConfig struct {
7080
// The target to which the exporter is going to send traces or metrics,
@@ -95,7 +105,7 @@ type ClientConfig struct {
95105
WaitForReady bool `mapstructure:"wait_for_ready,omitempty"`
96106

97107
// The headers associated with gRPC requests.
98-
Headers map[string]configopaque.String `mapstructure:"headers,omitempty"`
108+
Headers Headers `mapstructure:"headers,omitempty"`
99109

100110
// Sets the balancer in grpclb_policy to discover the servers. Default is pick_first.
101111
// https://github.com/grpc/grpc-go/blob/master/examples/features/load_balancing/README.md

0 commit comments

Comments
 (0)