Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Collector e2e] Fix recordfixtures script to use featuregate #270

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions exporter/collector/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ const (
// The value of "type" key in configuration.
typeStr = "googlecloud"
defaultTimeout = 12 * time.Second // Consistent with Cloud Monitoring's timeout
pdataExporterFeatureGate = "exporter.googlecloud.OTLPDirect"
PdataExporterFeatureGate = "exporter.googlecloud.OTLPDirect"
)

func init() {
featuregate.Register(featuregate.Gate{
ID: pdataExporterFeatureGate,
ID: PdataExporterFeatureGate,
Description: "When enabled, the googlecloud exporter translates pdata directly to google cloud monitoring's types, rather than first translating to opencensus.",
Enabled: false,
})
Expand Down Expand Up @@ -67,7 +67,7 @@ func createDefaultConfig() *Config {
QueueSettings: exporterhelper.DefaultQueueSettings(),
UserAgent: "opentelemetry-collector-contrib {{version}}",
}
if featuregate.IsEnabled(pdataExporterFeatureGate) {
if featuregate.IsEnabled(PdataExporterFeatureGate) {
cfg.MetricConfig = MetricConfig{
KnownDomains: domains,
Prefix: "workload.googleapis.com",
Expand All @@ -92,7 +92,7 @@ func createMetricsExporter(
params component.ExporterCreateSettings,
cfg config.Exporter) (component.MetricsExporter, error) {
eCfg := cfg.(*Config)
if !featuregate.IsEnabled(pdataExporterFeatureGate) {
if !featuregate.IsEnabled(PdataExporterFeatureGate) {
return newLegacyGoogleCloudMetricsExporter(ctx, eCfg, params)
}
return newGoogleCloudMetricsExporter(ctx, eCfg, params)
Expand Down
6 changes: 3 additions & 3 deletions exporter/collector/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ import (
// SetPdataFeatureGateForTest changes the pdata feature gate during a test.
// usage: defer SetPdataFeatureGateForTest(true)()
func SetPdataFeatureGateForTest(enabled bool) func() {
originalValue := featuregate.IsEnabled(pdataExporterFeatureGate)
featuregate.Apply(map[string]bool{pdataExporterFeatureGate: enabled})
originalValue := featuregate.IsEnabled(PdataExporterFeatureGate)
featuregate.Apply(map[string]bool{PdataExporterFeatureGate: enabled})
return func() {
featuregate.Apply(map[string]bool{pdataExporterFeatureGate: originalValue})
featuregate.Apply(map[string]bool{PdataExporterFeatureGate: originalValue})
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ import (
"time"

"github.com/stretchr/testify/require"
"go.opentelemetry.io/collector/service/featuregate"

"github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/collector"
"github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/collector/internal/integrationtest"
)

Expand All @@ -46,6 +48,7 @@ func (t *FakeTesting) Name() string { return "record fixtures" }

func main() {
t := &FakeTesting{}
featuregate.Apply(map[string]bool{collector.PdataExporterFeatureGate: true})
ctx := context.Background()
endTime := time.Now()
startTime := endTime.Add(-time.Second)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
}
},
"metricKind": "CUMULATIVE",
"unit": "1",
"valueType": "INT64",
"points": [
{
Expand All @@ -30,7 +29,8 @@
"int64Value": "253"
}
}
]
],
"unit": "1"
}
]
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
{
"createServiceTimeSeriesRequests": [
{
"timeSeries": [
{
"metric": {
"type": "kubernetes.io/internal/nodes/clustermetrics/node_network_availability_transition_time",
"labels": {
"network_unavailable": "False"
}
},
"resource": {
"type": "k8s_node",
"labels": {
"cluster_name": "rabbitmq-test-dev",
"location": "us-central1-c",
"node_name": "gke-rabbitmq-test-dev-default-pool-4ffbde79-k6w0"
"createServiceTimeSeriesRequests": [
{
"timeSeries": [
{
"metric": {
"type": "kubernetes.io/internal/nodes/clustermetrics/node_network_availability_transition_time",
"labels": {
"network_unavailable": "False"
}
},
"resource": {
"type": "k8s_node",
"labels": {
"cluster_name": "rabbitmq-test-dev",
"location": "us-central1-c",
"node_name": "gke-rabbitmq-test-dev-default-pool-4ffbde79-k6w0"
}
},
"metricKind": "GAUGE",
"valueType": "INT64",
"points": [
{
"interval": {
"endTime": "1970-01-01T00:00:00Z"
},
"value": {
"int64Value": "1639069893"
}
},
"metricKind": "GAUGE",
"valueType": "INT64",
"points": [
{
"interval": {
"endTime": "1970-01-01T00:00:00Z"
},
"value": {
"int64Value": "1639069893"
}
}
]
}
]
}
]
}
}
]
}
]
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,19 @@
}
},
"metricKind": "CUMULATIVE",
"unit": "1",
"valueType": "INT64",
"points": [
{
"interval": {
"start_time": "1970-01-01T00:00:01Z",
"endTime": "1970-01-01T00:00:00Z"
"endTime": "1970-01-01T00:00:00Z",
"startTime": "1970-01-01T00:00:00Z"
aabmass marked this conversation as resolved.
Show resolved Hide resolved
},
"value": {
"int64Value": "253"
}
}
]
],
"unit": "1"
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
}
},
"metricKind": "GAUGE",
"unit": "By",
"valueType": "INT64",
"points": [
{
Expand All @@ -29,7 +28,8 @@
"int64Value": "6641752448"
}
}
]
],
"unit": "By"
}
]
}
Expand Down
Loading