Skip to content

Commit

Permalink
Revert the renaming from "endpoint" to "metrics_endpoint" for consist…
Browse files Browse the repository at this point in the history
…ency
  • Loading branch information
WayneWuAtl committed Jun 11, 2024
1 parent e6388ba commit 2df0fd8
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 20 deletions.
8 changes: 4 additions & 4 deletions pkg/backends/otlp/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ type Backend struct {
droppedMetrics uint64
droppedEvents uint64

metricsEndpoint string
endpoint string
logsEndpoint string
convertTimersToGauges bool
is data.InstrumentationScope
Expand Down Expand Up @@ -63,7 +63,7 @@ func NewClientFromViper(v *viper.Viper, logger logrus.FieldLogger, pool *transpo
}

return &Backend{
metricsEndpoint: cfg.MetricsEndpoint,
endpoint: cfg.Endpoint,
logsEndpoint: cfg.LogsEndpoint,
convertTimersToGauges: cfg.Conversion == ConversionAsGauge,
is: data.NewInstrumentationScope("gostatsd/aggregation", version),
Expand Down Expand Up @@ -254,7 +254,7 @@ func (bd *Backend) SendMetricsAsync(ctx context.Context, mm *gostatsd.MetricMap,
err := bd.postMetrics(ctx, group.Values())
if err != nil {
bd.logger.WithError(err).WithFields(logrus.Fields{
"metricsEndpoint": bd.metricsEndpoint,
"endpoint": bd.endpoint,
}).Error("Issues trying to submit data")
}
cb(multierr.Errors(err))
Expand All @@ -266,7 +266,7 @@ func (c *Backend) postMetrics(ctx context.Context, resourceMetrics []data.Resour
statser.Gauge("backend.dropped", float64(atomic.LoadUint64(&c.droppedMetrics)), nil)
}()

req, err := data.NewMetricsRequest(ctx, c.metricsEndpoint, resourceMetrics)
req, err := data.NewMetricsRequest(ctx, c.endpoint, resourceMetrics)
if err != nil {
atomic.AddUint64(&c.droppedMetrics, uint64(len(resourceMetrics)))
return err
Expand Down
4 changes: 2 additions & 2 deletions pkg/backends/otlp/backend_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ func TestBackendSendAsyncMetrics(t *testing.T) {
t.Cleanup(s.Close)

v := viper.New()
v.Set("otlp.metrics_endpoint", fmt.Sprintf("%s/%s", s.URL, "v1/metrics"))
v.Set("otlp.endpoint", fmt.Sprintf("%s/%s", s.URL, "v1/metrics"))
v.Set("otlp.logs_endpoint", fmt.Sprintf("%s/%s", s.URL, "v1/logs"))
if tc.enableHistograms {
v.Set("otlp.conversion", ConversionAsHistogram)
Expand Down Expand Up @@ -350,7 +350,7 @@ func TestSendEvent(t *testing.T) {
t.Cleanup(s.Close)

v := viper.New()
v.Set("otlp.metrics_endpoint", fmt.Sprintf("%s/%s", s.URL, "v1/metrics"))
v.Set("otlp.endpoint", fmt.Sprintf("%s/%s", s.URL, "v1/metrics"))
v.Set("otlp.logs_endpoint", fmt.Sprintf("%s/%s", s.URL, "v1/logs"))
for k, vv := range tc.configMap {
v.Set(k, vv)
Expand Down
8 changes: 4 additions & 4 deletions pkg/backends/otlp/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ const (

type Config struct {
gostatsd.TimerSubtypes `mapstructure:"disabled_timer_aggregations"`
// MetricsEndpoint (Required) is the FQDN with path for the metrics ingestion metricsEndpoint
MetricsEndpoint string `mapstructure:"metrics_endpoint"`
// LogsEndpoint (Required) is the FQDN with path for the logs ingestion metricsEndpoint
// Endpoint (Required) is the FQDN with path for the metrics ingestion endpoint
Endpoint string `mapstructure:"endpoint"`
// LogsEndpoint (Required) is the FQDN with path for the logs ingestion endpoint
LogsEndpoint string `mapstructure:"logs_endpoint"`
// MaxRequests (Optional, default: cpu.count * 2) is the upper limit on the number of inflight requests
MaxRequests int `mapstructure:"max_requests"`
Expand Down Expand Up @@ -74,7 +74,7 @@ func NewConfig(v *viper.Viper) (*Config, error) {
}

func (c *Config) Validate() (errs error) {
if c.MetricsEndpoint == "" {
if c.Endpoint == "" {
errs = multierr.Append(errs, errors.New("no metrics endpoint defined"))
}
if c.LogsEndpoint == "" {
Expand Down
14 changes: 7 additions & 7 deletions pkg/backends/otlp/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,18 @@ func TestNewConfig(t *testing.T) {
name: "min configuration defined",
v: func() *viper.Viper {
v := viper.New()
v.SetDefault("otlp.metrics_endpoint", "http://local/v1/metrics")
v.SetDefault("otlp.endpoint", "http://local/v1/metrics")
v.SetDefault("otlp.logs_endpoint", "http://local/v1/logs")
v.SetDefault("otlp.max_requests", 1)
return v
}(),
expect: &Config{
MetricsEndpoint: "http://local/v1/metrics",
LogsEndpoint: "http://local/v1/logs",
MaxRequests: 1,
Conversion: "AsGauge",
Transport: "default",
UserAgent: "gostatsd",
Endpoint: "http://local/v1/metrics",
LogsEndpoint: "http://local/v1/logs",
MaxRequests: 1,
Conversion: "AsGauge",
Transport: "default",
UserAgent: "gostatsd",
},
errVal: "",
},
Expand Down
2 changes: 1 addition & 1 deletion pkg/backends/otlp/testdata/all-options.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[ otlp ]
metrics_endpoint = 'an-example-of-an-awesome-hostname/with/path/to/otlp/metric/endpoint'
endpoint = 'an-example-of-an-awesome-hostname/with/path/to/otlp/metric/endpoint'
logs_endpoint = 'an-example-of-an-awesome-hostname/with/path/to/otlp/logs/endpoint'
max_requests = 7
resource_keys = [ 'service.name', 'service.version', 'deployment.environment']
Expand Down
2 changes: 1 addition & 1 deletion pkg/backends/otlp/testdata/metrics_endpoint_only.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[otlp]
metrics_endpoint='my-example-of-a-metrics-endpoint'
endpoint='my-example-of-a-metrics-endpoint'
2 changes: 1 addition & 1 deletion pkg/backends/otlp/testdata/minimal.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[otlp]
metrics_endpoint='my-example-of-a-metrics-endpoint'
endpoint='my-example-of-a-metrics-endpoint'
logs_endpoint='my-example-of-a-logs-endpoint'

0 comments on commit 2df0fd8

Please sign in to comment.