Skip to content

Commit

Permalink
[cmd/configschema]: include connectors (#29001)
Browse files Browse the repository at this point in the history
**Description:** include connectors

**Link to tracking Issue:** resolve #26990

---------

Co-authored-by: Pablo Baeyens <[email protected]>
  • Loading branch information
haoqixu and mx-psi authored Nov 21, 2023
1 parent 1c13014 commit fbd61ae
Show file tree
Hide file tree
Showing 8 changed files with 97 additions and 2 deletions.
27 changes: 27 additions & 0 deletions .chloggen/feat-26990-cfgmetadatagen.yaml
Original file line number Diff line number Diff line change
@@ -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: []
2 changes: 1 addition & 1 deletion cmd/configschema/cfgmetadatagen/cfgmetadatagen/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
10 changes: 10 additions & 0 deletions cmd/configschema/configs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
16 changes: 16 additions & 0 deletions cmd/configschema/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,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.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
Expand Down Expand Up @@ -626,6 +632,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
Expand Down Expand Up @@ -1132,3 +1139,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
)
2 changes: 2 additions & 0 deletions cmd/configschema/go.sum

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

18 changes: 17 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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.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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -630,7 +638,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
Expand Down Expand Up @@ -1136,3 +1143,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
)
2 changes: 2 additions & 0 deletions go.sum

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

22 changes: 22 additions & 0 deletions internal/components/components.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down Expand Up @@ -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
}

0 comments on commit fbd61ae

Please sign in to comment.