From 9c238ef891a2546bcb0d1994f880bf8717848bcc Mon Sep 17 00:00:00 2001 From: haoqixu Date: Tue, 7 Nov 2023 11:34:05 +0800 Subject: [PATCH 1/3] [cmd/configschema]: include connectors --- .../cfgmetadatagen/cfgmetadatagen/cli.go | 2 +- cmd/configschema/configs.go | 10 +++++++++ cmd/configschema/go.mod | 16 ++++++++++++++ cmd/configschema/go.sum | 2 ++ go.mod | 18 ++++++++++++++- go.sum | 2 ++ internal/components/components.go | 22 +++++++++++++++++++ 7 files changed, 70 insertions(+), 2 deletions(-) diff --git a/cmd/configschema/cfgmetadatagen/cfgmetadatagen/cli.go b/cmd/configschema/cfgmetadatagen/cfgmetadatagen/cli.go index 6fc9a20a09b1..426c3f7394a5 100644 --- a/cmd/configschema/cfgmetadatagen/cfgmetadatagen/cli.go +++ b/cmd/configschema/cfgmetadatagen/cfgmetadatagen/cli.go @@ -31,7 +31,7 @@ func GenerateFiles(factories otelcol.Factories, sourceDir string, outputDir stri func writeComponentYAML(yw metadataWriter, cfg configschema.CfgInfo, dr configschema.DirResolver) error { fields, err := configschema.ReadFields(reflect.ValueOf(cfg.CfgInstance), dr) if err != nil { - return fmt.Errorf("error reading fields for component: %w", err) + return fmt.Errorf("error reading fields for component %v/%v: %w", cfg.Group, cfg.Type, err) } yamlBytes, err := yaml.Marshal(fields) if err != nil { diff --git a/cmd/configschema/configs.go b/cmd/configschema/configs.go index 62bd9f00a87a..e59b904b2779 100644 --- a/cmd/configschema/configs.go +++ b/cmd/configschema/configs.go @@ -113,6 +113,16 @@ func GetCfgInfo(components otelcol.Factories, componentType, componentName strin Group: componentType, CfgInstance: f.CreateDefaultConfig(), }, nil + case connector: + f := components.Connectors[t] + if f == nil { + return CfgInfo{}, fmt.Errorf("unknown %s name %q", componentType, componentName) + } + return CfgInfo{ + Type: f.Type(), + Group: componentType, + CfgInstance: f.CreateDefaultConfig(), + }, nil case extension: f := components.Extensions[t] if f == nil { diff --git a/cmd/configschema/go.mod b/cmd/configschema/go.mod index e20abf793f85..7c30322ae127 100644 --- a/cmd/configschema/go.mod +++ b/cmd/configschema/go.mod @@ -468,6 +468,12 @@ require ( github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f // indirect github.com/nginxinc/nginx-prometheus-exporter v0.8.1-0.20201110005315-f5a5f8086c19 // indirect + github.com/open-telemetry/opentelemetry-collector-contrib/connector/countconnector v0.0.0-00010101000000-000000000000 // indirect + github.com/open-telemetry/opentelemetry-collector-contrib/connector/datadogconnector v0.0.0-00010101000000-000000000000 // indirect + github.com/open-telemetry/opentelemetry-collector-contrib/connector/exceptionsconnector v0.0.0-00010101000000-000000000000 // indirect + github.com/open-telemetry/opentelemetry-collector-contrib/connector/routingconnector v0.0.0-00010101000000-000000000000 // indirect + github.com/open-telemetry/opentelemetry-collector-contrib/connector/servicegraphconnector v0.0.0-00010101000000-000000000000 // indirect + github.com/open-telemetry/opentelemetry-collector-contrib/connector/spanmetricsconnector v0.0.0-00010101000000-000000000000 // indirect github.com/open-telemetry/opentelemetry-collector-contrib/exporter/awskinesisexporter v0.89.0 // indirect github.com/open-telemetry/opentelemetry-collector-contrib/exporter/datadogexporter v0.89.0 // indirect github.com/open-telemetry/opentelemetry-collector-contrib/exporter/f5cloudexporter v0.89.0 // indirect @@ -623,6 +629,7 @@ require ( go.opentelemetry.io/collector/config/internal v0.89.0 // indirect go.opentelemetry.io/collector/confmap v0.89.0 // indirect go.opentelemetry.io/collector/connector v0.89.0 // indirect + go.opentelemetry.io/collector/connector/forwardconnector v0.89.0 // indirect go.opentelemetry.io/collector/consumer v0.89.0 // indirect go.opentelemetry.io/collector/exporter/debugexporter v0.89.0 // indirect go.opentelemetry.io/collector/exporter/loggingexporter v0.89.0 // indirect @@ -1129,3 +1136,12 @@ replace github.com/open-telemetry/opentelemetry-collector-contrib/receiver/azure replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/golden => ../../pkg/golden replace github.com/open-telemetry/opentelemetry-collector-contrib/internal/collectd => ../../internal/collectd + +replace ( + github.com/open-telemetry/opentelemetry-collector-contrib/connector/countconnector => ../../connector/countconnector + github.com/open-telemetry/opentelemetry-collector-contrib/connector/datadogconnector => ../../connector/datadogconnector + github.com/open-telemetry/opentelemetry-collector-contrib/connector/exceptionsconnector => ../../connector/exceptionsconnector + github.com/open-telemetry/opentelemetry-collector-contrib/connector/routingconnector => ../../connector/routingconnector + github.com/open-telemetry/opentelemetry-collector-contrib/connector/servicegraphconnector => ../../connector/servicegraphconnector + github.com/open-telemetry/opentelemetry-collector-contrib/connector/spanmetricsconnector => ../../connector/spanmetricsconnector +) diff --git a/cmd/configschema/go.sum b/cmd/configschema/go.sum index da36d0e28410..1a15f163137e 100644 --- a/cmd/configschema/go.sum +++ b/cmd/configschema/go.sum @@ -1600,6 +1600,8 @@ go.opentelemetry.io/collector/confmap v0.89.0 h1:N5Vg1+FXEFBHHlGIPg4OSlM9uTHjCI7 go.opentelemetry.io/collector/confmap v0.89.0/go.mod h1:D8FMPvuihtVxwXaz/qp5q9X2lq9l97QyjfsdZD1spmc= go.opentelemetry.io/collector/connector v0.89.0 h1:2v7RgaLrlGmvHV1BjG133MswZ2BhH77vTHOLa4/Tqm0= go.opentelemetry.io/collector/connector v0.89.0/go.mod h1:z82Yw0wZarpva9byeqByb3+eZSZ35DMdNRkjFgMm0S0= +go.opentelemetry.io/collector/connector/forwardconnector v0.89.0 h1:L2SjHTu2PtGJG9pHIBTlzWR5YnkApcR/5u3jgxa+XIM= +go.opentelemetry.io/collector/connector/forwardconnector v0.89.0/go.mod h1:s0hVBjug/iwc9Fw6QlcKFZ5ezeqFfp3uK9IgS5cZNhc= go.opentelemetry.io/collector/consumer v0.89.0 h1:MteKhkudX2L1ylbtdpSazO8SwyHSxl6fUEElc0rRLDQ= go.opentelemetry.io/collector/consumer v0.89.0/go.mod h1:aOaoi6R0qVvfHu0pEPCzSE74gIPNJoCQM8Ml4Bc9NHE= go.opentelemetry.io/collector/exporter v0.89.0 h1:8sYpJdKDQ2RuYOPKDsMz/lMJqp4WEWZgfJzyn9IgOag= diff --git a/go.mod b/go.mod index be7233730fab..293f0b2adc17 100644 --- a/go.mod +++ b/go.mod @@ -3,6 +3,12 @@ module github.com/open-telemetry/opentelemetry-collector-contrib go 1.20 require ( + github.com/open-telemetry/opentelemetry-collector-contrib/connector/countconnector v0.0.0-00010101000000-000000000000 + github.com/open-telemetry/opentelemetry-collector-contrib/connector/datadogconnector v0.0.0-00010101000000-000000000000 + github.com/open-telemetry/opentelemetry-collector-contrib/connector/exceptionsconnector v0.0.0-00010101000000-000000000000 + github.com/open-telemetry/opentelemetry-collector-contrib/connector/routingconnector v0.0.0-00010101000000-000000000000 + github.com/open-telemetry/opentelemetry-collector-contrib/connector/servicegraphconnector v0.0.0-00010101000000-000000000000 + github.com/open-telemetry/opentelemetry-collector-contrib/connector/spanmetricsconnector v0.0.0-00010101000000-000000000000 github.com/open-telemetry/opentelemetry-collector-contrib/exporter/alibabacloudlogserviceexporter v0.89.0 github.com/open-telemetry/opentelemetry-collector-contrib/exporter/awscloudwatchlogsexporter v0.89.0 github.com/open-telemetry/opentelemetry-collector-contrib/exporter/awsemfexporter v0.89.0 @@ -164,6 +170,8 @@ require ( github.com/open-telemetry/opentelemetry-collector-contrib/receiver/windowsperfcountersreceiver v0.89.0 github.com/open-telemetry/opentelemetry-collector-contrib/receiver/zipkinreceiver v0.89.0 github.com/open-telemetry/opentelemetry-collector-contrib/receiver/zookeeperreceiver v0.89.0 + go.opentelemetry.io/collector/connector v0.89.0 + go.opentelemetry.io/collector/connector/forwardconnector v0.89.0 go.opentelemetry.io/collector/exporter v0.89.0 go.opentelemetry.io/collector/exporter/debugexporter v0.89.0 go.opentelemetry.io/collector/exporter/loggingexporter v0.89.0 @@ -627,7 +635,6 @@ require ( go.opentelemetry.io/collector/config/configtls v0.89.0 // indirect go.opentelemetry.io/collector/config/internal v0.89.0 // indirect go.opentelemetry.io/collector/confmap v0.89.0 // indirect - go.opentelemetry.io/collector/connector v0.89.0 // indirect go.opentelemetry.io/collector/consumer v0.89.0 // indirect go.opentelemetry.io/collector/extension/auth v0.89.0 // indirect go.opentelemetry.io/collector/featuregate v1.0.0-rcv0018 // indirect @@ -1133,3 +1140,12 @@ replace github.com/open-telemetry/opentelemetry-collector-contrib/receiver/azure replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/golden => ./pkg/golden replace github.com/open-telemetry/opentelemetry-collector-contrib/internal/collectd => ./internal/collectd + +replace ( + github.com/open-telemetry/opentelemetry-collector-contrib/connector/countconnector => ./connector/countconnector + github.com/open-telemetry/opentelemetry-collector-contrib/connector/datadogconnector => ./connector/datadogconnector + github.com/open-telemetry/opentelemetry-collector-contrib/connector/exceptionsconnector => ./connector/exceptionsconnector + github.com/open-telemetry/opentelemetry-collector-contrib/connector/routingconnector => ./connector/routingconnector + github.com/open-telemetry/opentelemetry-collector-contrib/connector/servicegraphconnector => ./connector/servicegraphconnector + github.com/open-telemetry/opentelemetry-collector-contrib/connector/spanmetricsconnector => ./connector/spanmetricsconnector +) diff --git a/go.sum b/go.sum index 5c89f5c7570a..634acc8ee648 100644 --- a/go.sum +++ b/go.sum @@ -1604,6 +1604,8 @@ go.opentelemetry.io/collector/confmap v0.89.0 h1:N5Vg1+FXEFBHHlGIPg4OSlM9uTHjCI7 go.opentelemetry.io/collector/confmap v0.89.0/go.mod h1:D8FMPvuihtVxwXaz/qp5q9X2lq9l97QyjfsdZD1spmc= go.opentelemetry.io/collector/connector v0.89.0 h1:2v7RgaLrlGmvHV1BjG133MswZ2BhH77vTHOLa4/Tqm0= go.opentelemetry.io/collector/connector v0.89.0/go.mod h1:z82Yw0wZarpva9byeqByb3+eZSZ35DMdNRkjFgMm0S0= +go.opentelemetry.io/collector/connector/forwardconnector v0.89.0 h1:L2SjHTu2PtGJG9pHIBTlzWR5YnkApcR/5u3jgxa+XIM= +go.opentelemetry.io/collector/connector/forwardconnector v0.89.0/go.mod h1:s0hVBjug/iwc9Fw6QlcKFZ5ezeqFfp3uK9IgS5cZNhc= go.opentelemetry.io/collector/consumer v0.89.0 h1:MteKhkudX2L1ylbtdpSazO8SwyHSxl6fUEElc0rRLDQ= go.opentelemetry.io/collector/consumer v0.89.0/go.mod h1:aOaoi6R0qVvfHu0pEPCzSE74gIPNJoCQM8Ml4Bc9NHE= go.opentelemetry.io/collector/exporter v0.89.0 h1:8sYpJdKDQ2RuYOPKDsMz/lMJqp4WEWZgfJzyn9IgOag= diff --git a/internal/components/components.go b/internal/components/components.go index 2555806fd655..42fa66662f2e 100644 --- a/internal/components/components.go +++ b/internal/components/components.go @@ -4,6 +4,8 @@ package components // import "github.com/open-telemetry/opentelemetry-collector-contrib/internal/components" import ( + "go.opentelemetry.io/collector/connector" + "go.opentelemetry.io/collector/connector/forwardconnector" "go.opentelemetry.io/collector/exporter" "go.opentelemetry.io/collector/exporter/debugexporter" "go.opentelemetry.io/collector/exporter/loggingexporter" @@ -19,6 +21,12 @@ import ( "go.opentelemetry.io/collector/receiver" "go.opentelemetry.io/collector/receiver/otlpreceiver" + "github.com/open-telemetry/opentelemetry-collector-contrib/connector/countconnector" + "github.com/open-telemetry/opentelemetry-collector-contrib/connector/datadogconnector" + "github.com/open-telemetry/opentelemetry-collector-contrib/connector/exceptionsconnector" + "github.com/open-telemetry/opentelemetry-collector-contrib/connector/routingconnector" + "github.com/open-telemetry/opentelemetry-collector-contrib/connector/servicegraphconnector" + "github.com/open-telemetry/opentelemetry-collector-contrib/connector/spanmetricsconnector" "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/alibabacloudlogserviceexporter" "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/awscloudwatchlogsexporter" "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/awsemfexporter" @@ -385,5 +393,19 @@ func Components() (otelcol.Factories, error) { return otelcol.Factories{}, err } + connectors := []connector.Factory{ + forwardconnector.NewFactory(), + countconnector.NewFactory(), + datadogconnector.NewFactory(), + exceptionsconnector.NewFactory(), + routingconnector.NewFactory(), + servicegraphconnector.NewFactory(), + spanmetricsconnector.NewFactory(), + } + factories.Connectors, err = connector.MakeFactoryMap(connectors...) + if err != nil { + return otelcol.Factories{}, err + } + return factories, nil } From d1b1ac9926044c47ba6e3efcd3d2cd5c5337077a Mon Sep 17 00:00:00 2001 From: haoqixu Date: Sat, 18 Nov 2023 00:08:55 +0800 Subject: [PATCH 2/3] chore: update go.mod --- cmd/configschema/go.mod | 12 ++++++------ go.mod | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/cmd/configschema/go.mod b/cmd/configschema/go.mod index 7c30322ae127..2bf6c2ae53b0 100644 --- a/cmd/configschema/go.mod +++ b/cmd/configschema/go.mod @@ -468,12 +468,12 @@ require ( github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f // indirect github.com/nginxinc/nginx-prometheus-exporter v0.8.1-0.20201110005315-f5a5f8086c19 // indirect - github.com/open-telemetry/opentelemetry-collector-contrib/connector/countconnector v0.0.0-00010101000000-000000000000 // indirect - github.com/open-telemetry/opentelemetry-collector-contrib/connector/datadogconnector v0.0.0-00010101000000-000000000000 // indirect - github.com/open-telemetry/opentelemetry-collector-contrib/connector/exceptionsconnector v0.0.0-00010101000000-000000000000 // indirect - github.com/open-telemetry/opentelemetry-collector-contrib/connector/routingconnector v0.0.0-00010101000000-000000000000 // indirect - github.com/open-telemetry/opentelemetry-collector-contrib/connector/servicegraphconnector v0.0.0-00010101000000-000000000000 // indirect - github.com/open-telemetry/opentelemetry-collector-contrib/connector/spanmetricsconnector v0.0.0-00010101000000-000000000000 // indirect + github.com/open-telemetry/opentelemetry-collector-contrib/connector/countconnector v0.89.0 // indirect + github.com/open-telemetry/opentelemetry-collector-contrib/connector/datadogconnector v0.89.0 // indirect + github.com/open-telemetry/opentelemetry-collector-contrib/connector/exceptionsconnector v0.89.0 // indirect + github.com/open-telemetry/opentelemetry-collector-contrib/connector/routingconnector v0.89.0 // indirect + github.com/open-telemetry/opentelemetry-collector-contrib/connector/servicegraphconnector v0.89.0 // indirect + github.com/open-telemetry/opentelemetry-collector-contrib/connector/spanmetricsconnector v0.89.0 // indirect github.com/open-telemetry/opentelemetry-collector-contrib/exporter/awskinesisexporter v0.89.0 // indirect github.com/open-telemetry/opentelemetry-collector-contrib/exporter/datadogexporter v0.89.0 // indirect github.com/open-telemetry/opentelemetry-collector-contrib/exporter/f5cloudexporter v0.89.0 // indirect diff --git a/go.mod b/go.mod index 293f0b2adc17..f489fad9360b 100644 --- a/go.mod +++ b/go.mod @@ -3,12 +3,12 @@ module github.com/open-telemetry/opentelemetry-collector-contrib go 1.20 require ( - github.com/open-telemetry/opentelemetry-collector-contrib/connector/countconnector v0.0.0-00010101000000-000000000000 - github.com/open-telemetry/opentelemetry-collector-contrib/connector/datadogconnector v0.0.0-00010101000000-000000000000 - github.com/open-telemetry/opentelemetry-collector-contrib/connector/exceptionsconnector v0.0.0-00010101000000-000000000000 - github.com/open-telemetry/opentelemetry-collector-contrib/connector/routingconnector v0.0.0-00010101000000-000000000000 - github.com/open-telemetry/opentelemetry-collector-contrib/connector/servicegraphconnector v0.0.0-00010101000000-000000000000 - github.com/open-telemetry/opentelemetry-collector-contrib/connector/spanmetricsconnector v0.0.0-00010101000000-000000000000 + github.com/open-telemetry/opentelemetry-collector-contrib/connector/countconnector v0.89.0 + github.com/open-telemetry/opentelemetry-collector-contrib/connector/datadogconnector v0.89.0 + github.com/open-telemetry/opentelemetry-collector-contrib/connector/exceptionsconnector v0.89.0 + github.com/open-telemetry/opentelemetry-collector-contrib/connector/routingconnector v0.89.0 + github.com/open-telemetry/opentelemetry-collector-contrib/connector/servicegraphconnector v0.89.0 + github.com/open-telemetry/opentelemetry-collector-contrib/connector/spanmetricsconnector v0.89.0 github.com/open-telemetry/opentelemetry-collector-contrib/exporter/alibabacloudlogserviceexporter v0.89.0 github.com/open-telemetry/opentelemetry-collector-contrib/exporter/awscloudwatchlogsexporter v0.89.0 github.com/open-telemetry/opentelemetry-collector-contrib/exporter/awsemfexporter v0.89.0 From 174334081384b9de61a0d51d5ad5d9b56e12b423 Mon Sep 17 00:00:00 2001 From: haoqixu Date: Sat, 18 Nov 2023 00:23:48 +0800 Subject: [PATCH 3/3] chore: add changelog --- .chloggen/feat-26990-cfgmetadatagen.yaml | 27 ++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100755 .chloggen/feat-26990-cfgmetadatagen.yaml diff --git a/.chloggen/feat-26990-cfgmetadatagen.yaml b/.chloggen/feat-26990-cfgmetadatagen.yaml new file mode 100755 index 000000000000..384d19d9d908 --- /dev/null +++ b/.chloggen/feat-26990-cfgmetadatagen.yaml @@ -0,0 +1,27 @@ +# Use this changelog template to create an entry for release notes. + +# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' +change_type: enhancement + +# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver) +component: configschema + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: Generate metadata for connectors. + +# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists. +issues: [26990] + +# (Optional) One or more lines of additional information to render under the primary note. +# These lines will be padded with 2 spaces and then inserted directly into the document. +# Use pipe (|) for multiline entries. +subtext: + +# If your change doesn't affect end users or the exported elements of any package, +# you should instead start your pull request title with [chore] or use the "Skip Changelog" label. +# Optional: The change log or logs in which this entry should be included. +# e.g. '[user]' or '[user, api]' +# Include 'user' if the change is relevant to end users. +# Include 'api' if there is a change to a library API. +# Default: '[user]' +change_logs: []