@@ -18,6 +18,7 @@ import (
18
18
"context"
19
19
"fmt"
20
20
"log"
21
+ "net"
21
22
22
23
"go.uber.org/zap"
23
24
@@ -45,8 +46,8 @@ type DataSender interface {
45
46
// Send any accumulated data.
46
47
Flush ()
47
48
48
- // Return the port to which this sender will send data.
49
- GetEndpoint () string
49
+ // Return the address to which this sender will send data.
50
+ GetEndpoint () net. Addr
50
51
51
52
// Generate a config string to place in receiver part of collector config
52
53
// so that it can receive data from this sender.
@@ -82,8 +83,9 @@ type DataSenderBase struct {
82
83
Host string
83
84
}
84
85
85
- func (dsb * DataSenderBase ) GetEndpoint () string {
86
- return fmt .Sprintf ("%s:%d" , dsb .Host , dsb .Port )
86
+ func (dsb * DataSenderBase ) GetEndpoint () net.Addr {
87
+ addr , _ := net .ResolveTCPAddr ("tcp" , fmt .Sprintf ("%s:%d" , dsb .Host , dsb .Port ))
88
+ return addr
87
89
}
88
90
89
91
func (dsb * DataSenderBase ) ReportFatalError (err error ) {
@@ -132,7 +134,7 @@ func (je *JaegerGRPCDataSender) Start() error {
132
134
cfg .RetrySettings .Enabled = false
133
135
// Disable sending queue, we should push data from the caller goroutine.
134
136
cfg .QueueSettings .Enabled = false
135
- cfg .Endpoint = je .GetEndpoint ()
137
+ cfg .Endpoint = je .GetEndpoint (). String ()
136
138
cfg .TLSSetting = configtls.TLSClientSetting {
137
139
Insecure : true ,
138
140
}
@@ -163,7 +165,7 @@ type ocDataSender struct {
163
165
}
164
166
165
167
func (ods * ocDataSender ) fillConfig (cfg * opencensusexporter.Config ) * opencensusexporter.Config {
166
- cfg .Endpoint = ods .GetEndpoint ()
168
+ cfg .Endpoint = ods .GetEndpoint (). String ()
167
169
cfg .TLSSetting = configtls.TLSClientSetting {
168
170
Insecure : true ,
169
171
}
@@ -384,7 +386,7 @@ type otlpDataSender struct {
384
386
}
385
387
386
388
func (ods * otlpDataSender ) fillConfig (cfg * otlpexporter.Config ) * otlpexporter.Config {
387
- cfg .Endpoint = ods .GetEndpoint ()
389
+ cfg .Endpoint = ods .GetEndpoint (). String ()
388
390
// Disable retries, we should push data and if error just log it.
389
391
cfg .RetrySettings .Enabled = false
390
392
// Disable sending queue, we should push data from the caller goroutine.
@@ -579,7 +581,7 @@ func NewPrometheusDataSender(host string, port int) *PrometheusDataSender {
579
581
func (pds * PrometheusDataSender ) Start () error {
580
582
factory := prometheusexporter .NewFactory ()
581
583
cfg := factory .CreateDefaultConfig ().(* prometheusexporter.Config )
582
- cfg .Endpoint = pds .GetEndpoint ()
584
+ cfg .Endpoint = pds .GetEndpoint (). String ()
583
585
cfg .Namespace = pds .namespace
584
586
585
587
exp , err := factory .CreateMetricsExporter (context .Background (), defaultExporterParams (), cfg )
0 commit comments