From 932633e0925f81744d28c50f2569469ddc9b11b5 Mon Sep 17 00:00:00 2001 From: Ashvitha Sridharan Date: Thu, 27 Jul 2023 17:05:59 -0400 Subject: [PATCH] Add missing godoc --- agent/hcp/telemetry/otel_sink.go | 10 +++++++--- agent/hcp/telemetry_provider.go | 3 ++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/agent/hcp/telemetry/otel_sink.go b/agent/hcp/telemetry/otel_sink.go index 8fb55702aefd..49a6d595076c 100644 --- a/agent/hcp/telemetry/otel_sink.go +++ b/agent/hcp/telemetry/otel_sink.go @@ -3,7 +3,7 @@ package telemetry import ( "bytes" "context" - "fmt" + "errors" "regexp" "strings" "sync" @@ -20,8 +20,12 @@ import ( // DefaultExportInterval is a default time interval between export of aggregated metrics. const DefaultExportInterval = 10 * time.Second +// ConfigProvider is required to provide custom metrics processing. type ConfigProvider interface { + // GetLabels should return a set of OTEL attributes added by default all metrics. GetLabels() map[string]string + // GetFilters should return filtesr that are required to enable metric processing. + // Filters act as an allowlist to collect only the required metrics. GetFilters() *regexp.Regexp } @@ -78,11 +82,11 @@ func NewOTELReader(client MetricsClient, endpointProvider EndpointProvider, expo // enable us to create OTEL Instruments to record measurements. func NewOTELSink(ctx context.Context, opts *OTELSinkOpts) (*OTELSink, error) { if opts.Reader == nil { - return nil, fmt.Errorf("ferror: provide valid reader") + return nil, errors.New("ferror: provide valid reader") } if opts.ConfigProvider == nil { - return nil, fmt.Errorf("ferror: provide valid config provider") + return nil, errors.New("ferror: provide valid config provider") } logger := hclog.FromContext(ctx).Named("otel_sink") diff --git a/agent/hcp/telemetry_provider.go b/agent/hcp/telemetry_provider.go index 3109ce5d9187..cc9ef92eb192 100644 --- a/agent/hcp/telemetry_provider.go +++ b/agent/hcp/telemetry_provider.go @@ -20,7 +20,7 @@ import ( var ( // internalMetricRefreshFailure is a metric to monitor refresh failures. internalMetricRefreshFailure []string = []string{"hcp", "telemetry_config_provider", "refresh", "failure"} - // internalMetricRefreshFailure is a metric to monitor refresh successes. + // internalMetricRefreshSuccess is a metric to monitor refresh successes. internalMetricRefreshSuccess []string = []string{"hcp", "telemetry_config_provider", "refresh", "success"} ) @@ -54,6 +54,7 @@ type dynamicConfig struct { RefreshInterval time.Duration } +// equals returns true if two dynamicConfig objects are equal. func (d *dynamicConfig) equals(newCfg *dynamicConfig) (bool, error) { currHash, err := hashstructure.Hash(*d, hashstructure.FormatV2, nil) if err != nil {