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
23 changes: 23 additions & 0 deletions exporter/collector/breaking-changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,22 @@
The new pdata based exporter has some breaking changes from the original OpenCensus stackdriver
based `googlecloud` exporter:

## Metric Names and Descriptors

The previous collector exporter would default to sending metrics with the type:
`custom.googleapis.com/OpenCensus/{metric_name}`. This has been changed to
`workload.googleapis.com/{metric_name}`.

Additionally, the previous exporter had a hardcoded list of known metric domains
where this "prefix" would not be used. The new exporter allows full configuration
of this list via the `metric.known_domains` property.

Additionally, the DisplayName for a metric used to be exactly the
`{metric_name}`. Now, the metric name is chosen as the full-path after the
domain name of the metric type. E.g. if a metric called
`workload.googleapis.com/nginx/latency` is created, the display name will
be `nginx/latency` instead of `workload.googleapis.com/nginx/latency`.

## Labels

Original label key mapping code is
Expand All @@ -18,3 +34,10 @@ In the old exporter, delta sums were converted into GAUGE points ([see test
fixture](https://github.com/GoogleCloudPlatform/opentelemetry-operations-go/blob/9bc1f49ebe000b0b3b1aa5b7f201e7996effdcd8/exporter/collector/testdata/fixtures/delta_counter_metrics_expect.json#L15)).
The new pdata exporter sends these as CUMULATIVE points with the same delta time window
(reseting at each point) aka pseudo-cumulatives.

## OTLP Summary

The old exporter relied on upstream conversion of OTLP Summary into Gauge and
Cumulative points. The new exporter performas this conversion itself, which
means summary metric descriptors will include label description for `percentile`
labels.
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