Skip to content

Commit

Permalink
collector: upgrade collector to v0.93
Browse files Browse the repository at this point in the history
This change does the following:
 - Update the OTel collector
 - Use updated Prometheus library with patch: GoogleCloudPlatform/prometheus#132
 - Update unit tests

Change-Id: I1f0a293f496d265c8ef1de7b01a287d5c5c7be71
  • Loading branch information
ridwanmsharif committed Jan 30, 2024
1 parent ea5fb13 commit e92c6db
Show file tree
Hide file tree
Showing 13 changed files with 443 additions and 474 deletions.
2 changes: 0 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ OTEL_VER ?= latest
update-components:
go list -m -f '{{if not (or .Indirect .Main)}}{{.Path}}{{end}}' all | \
grep "^go.opentelemetry.io" | \
grep -v "go.opentelemetry.io/collector/featuregate" | \
grep -v "go.opentelemetry.io/collector/pdata" | \
xargs -t -I '{}' go get {}@$(OTEL_VER)
go get -u github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/collector/googlemanagedprometheus@latest
go list -m -f '{{if not (or .Indirect .Main)}}{{.Path}}{{end}}' all | \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ type Config struct {
// Timeout for all API calls. If not set, defaults to 12 seconds.
exporterhelper.TimeoutSettings `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct.
exporterhelper.QueueSettings `mapstructure:"sending_queue"`
exporterhelper.RetrySettings `mapstructure:"retry_on_failure"`
}

// GMPConfig is a subset of the collector config applicable to the GMP exporter.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"testing"
"time"

"github.com/cenkalti/backoff/v4"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.opentelemetry.io/collector/component"
Expand Down Expand Up @@ -55,14 +54,6 @@ func TestLoadConfig(t *testing.T) {
Prefix: "my-metric-domain.com",
},
},
RetrySettings: exporterhelper.RetrySettings{
Enabled: true,
InitialInterval: 10 * time.Second,
MaxInterval: 1 * time.Minute,
MaxElapsedTime: 10 * time.Minute,
RandomizationFactor: backoff.DefaultRandomizationFactor,
Multiplier: backoff.DefaultMultiplier,
},
QueueSettings: exporterhelper.QueueSettings{
Enabled: true,
NumConsumers: 2,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,8 @@ func NewFactory() exporter.Factory {

// createDefaultConfig creates the default configuration for exporter.
func createDefaultConfig() component.Config {
retrySettings := exporterhelper.NewDefaultRetrySettings()
retrySettings.Enabled = false
return &Config{
TimeoutSettings: exporterhelper.TimeoutSettings{Timeout: defaultTimeout},
RetrySettings: retrySettings,
QueueSettings: exporterhelper.NewDefaultQueueSettings(),
GMPConfig: GMPConfig{
MetricConfig: MetricConfig{
Expand Down Expand Up @@ -73,6 +70,5 @@ func createMetricsExporter(
// Disable exporterhelper Timeout, since we are using a custom mechanism
// within exporter itself
exporterhelper.WithTimeout(exporterhelper.TimeoutSettings{Timeout: 0}),
exporterhelper.WithQueue(eCfg.QueueSettings),
exporterhelper.WithRetry(eCfg.RetrySettings))
exporterhelper.WithQueue(eCfg.QueueSettings))
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@ exporters:
enabled: true
num_consumers: 2
queue_size: 10
retry_on_failure:
enabled: true
initial_interval: 10s
max_interval: 60s
max_elapsed_time: 10m
metric:
prefix: my-metric-domain.com
add_metric_suffixes: false
Expand Down
2 changes: 1 addition & 1 deletion collector/internal/env/env_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ import (
func Test_Create(t *testing.T) {
require.NoError(t, Create())

expectedUserAgentRegex := fmt.Sprintf(`^Google Cloud Metrics Agent/latest \(TargetPlatform=(?i:%v); Framework=OpenTelemetry Collector\) .* \(Cores=\d+; Memory=(?:[0-9]*[.])?[0-9]+GB; Disk=(?:[0-9]*[.])?[0-9]+GB\)$`, runtime.GOOS)
expectedUserAgentRegex := fmt.Sprintf(`^Google Cloud Run GMP Sidecar/latest \(TargetPlatform=(?i:%v); Framework=OpenTelemetry Collector\) .* \(Cores=\d+; Memory=(?:[0-9]*[.])?[0-9]+GB; Disk=(?:[0-9]*[.])?[0-9]+GB\)$`, runtime.GOOS)
assert.Regexp(t, expectedUserAgentRegex, os.Getenv("USERAGENT"))
}
6 changes: 0 additions & 6 deletions confgenerator/confgenerator.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,6 @@ func googleManagedPrometheusExporter(userAgent string) otel.Component {
return otel.Component{
Type: "googlemanagedprometheus",
Config: map[string]interface{}{
// (b/233372619) Due to a constraint in the Monarch API for retrying successful data points,
// leaving this enabled is causing adverse effects for some customers. Google OpenTelemetry team
// recommends disabling this.
"retry_on_failure": map[string]interface{}{
"enabled": false,
},
"user_agent": userAgent,
"untyped_double_export": true,
// The exporter has the config option addMetricSuffixes with default value true. It will add Prometheus
Expand Down
2 changes: 0 additions & 2 deletions confgenerator/testdata/add-metadata-labels/golden/otel.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ exporters:
googlemanagedprometheus:
metric:
add_metric_suffixes: false
retry_on_failure:
enabled: false
untyped_double_export: true
user_agent: Google-Cloud-Run-GMP-Sidecar/latest; ShortName=run-gmp;ShortVersion=latest
processors:
Expand Down
2 changes: 0 additions & 2 deletions confgenerator/testdata/builtin/golden/otel.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ exporters:
googlemanagedprometheus:
metric:
add_metric_suffixes: false
retry_on_failure:
enabled: false
untyped_double_export: true
user_agent: Google-Cloud-Run-GMP-Sidecar/latest; ShortName=run-gmp;ShortVersion=latest
processors:
Expand Down
2 changes: 0 additions & 2 deletions confgenerator/testdata/relabel-labels/golden/otel.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ exporters:
googlemanagedprometheus:
metric:
add_metric_suffixes: false
retry_on_failure:
enabled: false
untyped_double_export: true
user_agent: Google-Cloud-Run-GMP-Sidecar/latest; ShortName=run-gmp;ShortVersion=latest
processors:
Expand Down
2 changes: 0 additions & 2 deletions confgenerator/testdata/simple-app-scrape/golden/otel.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ exporters:
googlemanagedprometheus:
metric:
add_metric_suffixes: false
retry_on_failure:
enabled: false
untyped_double_export: true
user_agent: Google-Cloud-Run-GMP-Sidecar/latest; ShortName=run-gmp;ShortVersion=latest
processors:
Expand Down
Loading

0 comments on commit e92c6db

Please sign in to comment.