Skip to content

Commit

Permalink
[chore] Migrate the "generate" make target to mdatagen from core repo
Browse files Browse the repository at this point in the history
This change migrates `generate` make target from using deprecated cmd/mdatagen defined in this repo to mdategen defined in core repository.

In order to avoid breaking changes for end users, we keep the scope names used in this repo the same as before. This required defining them explicitly in metadata.yaml files. We can update them after open-telemetry/opentelemetry-collector#9494 and #21469 are resolver.

Taking the opportunity that that the scope names can be explicitly defined, this PR also updates missing scope names for extensions with inconsistent package names e.g.: awsproxy and jaegerremotesampling. It's not a breaking change because the generated meter and tracer are not being used yet.
  • Loading branch information
dmitryax committed Mar 6, 2024
1 parent 5b4e92a commit 4abe78d
Show file tree
Hide file tree
Showing 224 changed files with 312 additions and 104 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ docker-telemetrygen:

.PHONY: generate
generate: install-tools
cd cmd/mdatagen && $(GOCMD) install .
cd ./internal/tools && go install go.opentelemetry.io/collector/cmd/mdatagen
$(MAKE) for-all CMD="$(GOCMD) generate ./..."

.PHONY: mdatagen-test
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

50 changes: 0 additions & 50 deletions cmd/mdatagen/validate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,8 @@
package main

import (
"fmt"
"io/fs"
"path/filepath"
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

Expand Down Expand Up @@ -105,49 +101,3 @@ func TestValidate(t *testing.T) {
})
}
}

func TestValidateMetricDuplicates(t *testing.T) {
allowedMetrics := map[string][]string{
"container.cpu.utilization": {"docker_stats", "kubeletstats"},
"container.memory.rss": {"docker_stats", "kubeletstats"},
"container.uptime": {"docker_stats", "kubeletstats"},
}
allMetrics := map[string][]string{}
err := filepath.Walk("../../receiver", func(path string, info fs.FileInfo, err error) error {
if info.Name() == "metadata.yaml" {
md, err := loadMetadata(path)
require.NoError(t, err)
if len(md.Metrics) > 0 {
for metricName := range md.Metrics {
allMetrics[md.Type] = append(allMetrics[md.Type], string(metricName))
}
}
}
return nil
})
require.NoError(t, err)

seen := make(map[string]string)
for receiver, metrics := range allMetrics {
for _, metricName := range metrics {
if val, exists := seen[metricName]; exists {
receivers, allowed := allowedMetrics[metricName]
assert.True(
t,
allowed && contains(receiver, receivers) && contains(val, receivers),
fmt.Sprintf("Duplicate metric %v in receivers %v and %v. Please validate that this is intentional by adding the metric name and receiver types in the allowedMetrics map in this test\n", metricName, receiver, val),
)
}
seen[metricName] = receiver
}
}
}

func contains(r string, rs []string) bool {
for _, s := range rs {
if s == r {
return true
}
}
return false
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions connector/countconnector/metadata.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
type: count
scope_name: otelcol/countconnector

status:
class: connector
Expand Down
1 change: 1 addition & 0 deletions connector/datadogconnector/metadata.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
type: datadog
scope_name: otelcol/datadog

status:
class: connector
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions connector/failoverconnector/metadata.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
type: failover
scope_name: otelcol/failover

status:
class: connector
Expand Down
1 change: 1 addition & 0 deletions connector/routingconnector/metadata.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
type: routing
scope_name: otelcol/routing

status:
class: connector
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions connector/spanmetricsconnector/metadata.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
type: spanmetrics
scope_name: otelcol/spanmetrics

status:
class: connector
Expand Down
1 change: 1 addition & 0 deletions exporter/alertmanagerexporter/metadata.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
type: alertmanager
scope_name: otelcol/alertmanager

status:
class: exporter
Expand Down
1 change: 1 addition & 0 deletions exporter/alibabacloudlogserviceexporter/metadata.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
type: alibabacloud_logservice
scope_name: otelcol/alibabacloudlogservice

status:
class: exporter
Expand Down
1 change: 1 addition & 0 deletions exporter/awscloudwatchlogsexporter/metadata.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
type: awscloudwatchlogs
scope_name: otelcol/awscloudwatchlogs

status:
class: exporter
Expand Down
1 change: 1 addition & 0 deletions exporter/awsemfexporter/metadata.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
type: awsemf
scope_name: otelcol/awsemf

status:
class: exporter
Expand Down
1 change: 1 addition & 0 deletions exporter/awskinesisexporter/metadata.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
type: awskinesis
scope_name: otelcol/awskinesis

status:
class: exporter
Expand Down
1 change: 1 addition & 0 deletions exporter/awss3exporter/metadata.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
type: awss3
scope_name: otelcol/awss3

status:
class: exporter
Expand Down
1 change: 1 addition & 0 deletions exporter/awsxrayexporter/metadata.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
type: awsxray
scope_name: otelcol/awsxray

status:
class: exporter
Expand Down
1 change: 1 addition & 0 deletions exporter/azuredataexplorerexporter/metadata.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
type: azuredataexplorer
scope_name: otelcol/azuredataexplorer

status:
class: exporter
Expand Down
1 change: 1 addition & 0 deletions exporter/azuremonitorexporter/metadata.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
type: azuremonitor
scope_name: otelcol/azuremonitor

status:
class: exporter
Expand Down
1 change: 1 addition & 0 deletions exporter/carbonexporter/metadata.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
type: carbon
scope_name: otelcol/carbon

status:
class: exporter
Expand Down
1 change: 1 addition & 0 deletions exporter/cassandraexporter/metadata.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
type: cassandra
scope_name: otelcol/cassandra

status:
class: exporter
Expand Down
1 change: 1 addition & 0 deletions exporter/clickhouseexporter/metadata.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
type: clickhouse
scope_name: otelcol/clickhouse

status:
class: exporter
Expand Down
1 change: 1 addition & 0 deletions exporter/coralogixexporter/metadata.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
type: coralogix
scope_name: otelcol/coralogix

status:
class: exporter
Expand Down
1 change: 1 addition & 0 deletions exporter/datadogexporter/metadata.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
type: datadog
scope_name: otelcol/datadog

status:
class: exporter
Expand Down
1 change: 1 addition & 0 deletions exporter/datasetexporter/metadata.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
type: dataset
scope_name: otelcol/dataset

status:
class: exporter
Expand Down
1 change: 1 addition & 0 deletions exporter/dynatraceexporter/metadata.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
type: dynatrace
scope_name: otelcol/dynatrace

status:
class: exporter
Expand Down
1 change: 1 addition & 0 deletions exporter/elasticsearchexporter/metadata.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
type: elasticsearch
scope_name: otelcol/elasticsearch

status:
class: exporter
Expand Down
1 change: 1 addition & 0 deletions exporter/fileexporter/metadata.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
type: file
scope_name: otelcol/file

status:
class: exporter
Expand Down
1 change: 1 addition & 0 deletions exporter/googlecloudexporter/metadata.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
type: googlecloud
scope_name: otelcol/googlecloud

status:
class: exporter
Expand Down
1 change: 1 addition & 0 deletions exporter/googlecloudpubsubexporter/metadata.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
type: googlecloudpubsub
scope_name: otelcol/googlecloudpubsub

status:
class: exporter
Expand Down
1 change: 1 addition & 0 deletions exporter/googlemanagedprometheusexporter/metadata.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
type: googlemanagedprometheus
scope_name: otelcol/googlemanagedprometheus

status:
class: exporter
Expand Down
1 change: 1 addition & 0 deletions exporter/honeycombmarkerexporter/metadata.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
type: honeycombmarker
scope_name: otelcol/honeycombmarker

status:
class: exporter
Expand Down
1 change: 1 addition & 0 deletions exporter/influxdbexporter/metadata.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
type: influxdb
scope_name: otelcol/influxdb

status:
class: exporter
Expand Down
1 change: 1 addition & 0 deletions exporter/instanaexporter/metadata.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
type: instana
scope_name: otelcol/instana

status:
class: exporter
Expand Down
1 change: 1 addition & 0 deletions exporter/kafkaexporter/metadata.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
type: kafka
scope_name: otelcol/kafka

status:
class: exporter
Expand Down
1 change: 1 addition & 0 deletions exporter/kineticaexporter/metadata.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
type: kinetica
scope_name: otelcol/kinetica

status:
class: exporter
Expand Down
1 change: 1 addition & 0 deletions exporter/loadbalancingexporter/metadata.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
type: loadbalancing
scope_name: otelcol/loadbalancing

status:
class: exporter
Expand Down
1 change: 1 addition & 0 deletions exporter/logicmonitorexporter/metadata.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
type: logicmonitor
scope_name: otelcol/logicmonitor

status:
class: exporter
Expand Down
1 change: 1 addition & 0 deletions exporter/logzioexporter/metadata.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
type: logzio
scope_name: otelcol/logzio

status:
class: exporter
Expand Down
1 change: 1 addition & 0 deletions exporter/lokiexporter/metadata.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
type: loki
scope_name: otelcol/loki

status:
class: exporter
Expand Down
1 change: 1 addition & 0 deletions exporter/mezmoexporter/metadata.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
type: mezmo
scope_name: otelcol/mezmo

status:
class: exporter
Expand Down
1 change: 1 addition & 0 deletions exporter/opencensusexporter/metadata.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
type: opencensus
scope_name: otelcol/opencensus

status:
class: exporter
Expand Down
1 change: 1 addition & 0 deletions exporter/opensearchexporter/metadata.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
type: opensearch
scope_name: otelcol/opensearch

status:
class: exporter
Expand Down
1 change: 1 addition & 0 deletions exporter/otelarrowexporter/metadata.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
type: otelarrow
scope_name: otelcol/otelarrow

status:
class: exporter
Expand Down
1 change: 1 addition & 0 deletions exporter/prometheusexporter/metadata.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
type: prometheus
scope_name: otelcol/prometheus

status:
class: exporter
Expand Down
1 change: 1 addition & 0 deletions exporter/prometheusremotewriteexporter/metadata.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
type: prometheusremotewrite
scope_name: otelcol/prometheusremotewrite

status:
class: exporter
Expand Down
1 change: 1 addition & 0 deletions exporter/pulsarexporter/metadata.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
type: pulsar
scope_name: otelcol/pulsar

status:
class: exporter
Expand Down
1 change: 1 addition & 0 deletions exporter/sapmexporter/metadata.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
type: sapm
scope_name: otelcol/sapm

status:
class: exporter
Expand Down
1 change: 1 addition & 0 deletions exporter/sentryexporter/metadata.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
type: sentry
scope_name: otelcol/sentry

status:
class: exporter
Expand Down
1 change: 1 addition & 0 deletions exporter/signalfxexporter/metadata.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
type: signalfx
scope_name: otelcol/signalfx

status:
class: exporter
Expand Down

0 comments on commit 4abe78d

Please sign in to comment.