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

Add logic to translate metric descriptors and initial flow #247

Merged
merged 13 commits into from
Dec 22, 2021
2 changes: 2 additions & 0 deletions exporter/collector/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ type Config struct {
type MetricConfig struct {
Prefix string `mapstructure:"prefix"`
SkipCreateMetricDescriptor bool `mapstructure:"skip_create_descriptor"`
// If a metric belongs to one of these domains it does not get a prefix.
KnownDomains []string `mapstructure:"known_domains"`
}

// ResourceMapping defines mapping of resources from source (OpenCensus) to target (Google Cloud).
Expand Down
3 changes: 3 additions & 0 deletions exporter/collector/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ func TestLoadConfig(t *testing.T) {
MetricConfig: MetricConfig{
Prefix: "prefix",
SkipCreateMetricDescriptor: true,
KnownDomains: []string{
"googleapis.com", "kubernetes.io", "istio.io", "knative.dev",
},
},
})
}
8 changes: 6 additions & 2 deletions exporter/collector/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,24 @@ func NewFactory() component.ExporterFactory {

return exporterhelper.NewFactory(
typeStr,
createDefaultConfig,
func() config.Exporter { return createDefaultConfig() },
exporterhelper.WithTraces(createTracesExporter),
exporterhelper.WithMetrics(createMetricsExporter),
)
}

// createDefaultConfig creates the default configuration for exporter.
func createDefaultConfig() config.Exporter {
func createDefaultConfig() *Config {
return &Config{
ExporterSettings: config.NewExporterSettings(config.NewComponentID(typeStr)),
TimeoutSettings: exporterhelper.TimeoutSettings{Timeout: defaultTimeout},
RetrySettings: exporterhelper.DefaultRetrySettings(),
QueueSettings: exporterhelper.DefaultQueueSettings(),
UserAgent: "opentelemetry-collector-contrib {{version}}",
MetricConfig: MetricConfig{
KnownDomains: domains,
Prefix: "workload.googleapis.com",
},
}
}

Expand Down
Loading