Skip to content

Commit

Permalink
fix featuregate for googlecloud exporter by not checking it during Ne…
Browse files Browse the repository at this point in the history
…wFactory (#9116)
  • Loading branch information
dashpole authored Apr 9, 2022
1 parent 6e1dcf6 commit 44aca08
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 37 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

- `hostmetricsreceiver`: Use cpu times for time delta in cpu.utilization calculation (#8857)
- `dynatraceexporter`: Remove overly verbose stacktrace from certain logs (#8989)
- `googlecloudexporter`: fix the `exporter.googlecloud.OTLPDirect` fature-gate, which was not applied when the flag was provided (#9116)

### 🚩 Deprecations 🚩

Expand Down
56 changes: 19 additions & 37 deletions exporter/googlecloudexporter/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,6 @@ func init() {

// NewFactory creates a factory for the googlecloud exporter
func NewFactory() component.ExporterFactory {
if !featuregate.IsEnabled(pdataExporterFeatureGate) {
return component.NewExporterFactory(
typeStr,
createLegacyDefaultConfig,
component.WithTracesExporter(createLegacyTracesExporter),
component.WithMetricsExporter(createLegacyMetricsExporter),
)
}
return component.NewExporterFactory(
typeStr,
createDefaultConfig,
Expand All @@ -60,6 +52,15 @@ func NewFactory() component.ExporterFactory {

// createDefaultConfig creates the default configuration for exporter.
func createDefaultConfig() config.Exporter {
if !featuregate.IsEnabled(pdataExporterFeatureGate) {
return &LegacyConfig{
ExporterSettings: config.NewExporterSettings(config.NewComponentID(typeStr)),
TimeoutSettings: exporterhelper.TimeoutSettings{Timeout: defaultTimeout},
RetrySettings: exporterhelper.NewDefaultRetrySettings(),
QueueSettings: exporterhelper.NewDefaultQueueSettings(),
UserAgent: "opentelemetry-collector-contrib {{version}}",
}
}
return &Config{
ExporterSettings: config.NewExporterSettings(config.NewComponentID(typeStr)),
TimeoutSettings: exporterhelper.TimeoutSettings{Timeout: defaultTimeout},
Expand All @@ -69,22 +70,17 @@ func createDefaultConfig() config.Exporter {
}
}

func createLegacyDefaultConfig() config.Exporter {
return &LegacyConfig{
ExporterSettings: config.NewExporterSettings(config.NewComponentID(typeStr)),
TimeoutSettings: exporterhelper.TimeoutSettings{Timeout: defaultTimeout},
RetrySettings: exporterhelper.NewDefaultRetrySettings(),
QueueSettings: exporterhelper.NewDefaultQueueSettings(),
UserAgent: "opentelemetry-collector-contrib {{version}}",
}
}

// createTracesExporter creates a trace exporter based on this config.
func createTracesExporter(
ctx context.Context,
params component.ExporterCreateSettings,
cfg config.Exporter) (component.TracesExporter, error) {
eCfg := cfg.(*Config)
var eCfg *Config
if !featuregate.IsEnabled(pdataExporterFeatureGate) {
eCfg = toNewConfig(cfg.(*LegacyConfig))
} else {
eCfg = cfg.(*Config)
}
tExp, err := collector.NewGoogleCloudTracesExporter(ctx, eCfg.Config, params.BuildInfo.Version, eCfg.Timeout)
if err != nil {
return nil, err
Expand All @@ -101,20 +97,15 @@ func createTracesExporter(
exporterhelper.WithRetry(eCfg.RetrySettings))
}

// createLegacyTracesExporter creates a trace exporter based on this config.
func createLegacyTracesExporter(
ctx context.Context,
params component.ExporterCreateSettings,
cfg config.Exporter) (component.TracesExporter, error) {
eCfg := cfg.(*LegacyConfig)
return createTracesExporter(ctx, params, toNewConfig(eCfg))
}

// createMetricsExporter creates a metrics exporter based on this config.
func createMetricsExporter(
ctx context.Context,
params component.ExporterCreateSettings,
cfg config.Exporter) (component.MetricsExporter, error) {
if !featuregate.IsEnabled(pdataExporterFeatureGate) {
eCfg := cfg.(*LegacyConfig)
return newLegacyGoogleCloudMetricsExporter(eCfg, params)
}
eCfg := cfg.(*Config)
mExp, err := collector.NewGoogleCloudMetricsExporter(ctx, eCfg.Config, params.TelemetrySettings.Logger, params.BuildInfo.Version, eCfg.Timeout)
if err != nil {
Expand All @@ -131,12 +122,3 @@ func createMetricsExporter(
exporterhelper.WithQueue(eCfg.QueueSettings),
exporterhelper.WithRetry(eCfg.RetrySettings))
}

// createLegacyMetricsExporter creates a metrics exporter based on this config.
func createLegacyMetricsExporter(
ctx context.Context,
params component.ExporterCreateSettings,
cfg config.Exporter) (component.MetricsExporter, error) {
eCfg := cfg.(*LegacyConfig)
return newLegacyGoogleCloudMetricsExporter(eCfg, params)
}

0 comments on commit 44aca08

Please sign in to comment.