Skip to content

Commit

Permalink
[cmd/mdatagen] Provide scope_name explicitly in metadata.yaml
Browse files Browse the repository at this point in the history
Require scope_name to be provided explicitly for exporter, connectors, processors and receivers so the mdatagen can be used in separate repos
  • Loading branch information
dmitryax committed Mar 5, 2024
1 parent af7664a commit 5d7f323
Show file tree
Hide file tree
Showing 17 changed files with 32 additions and 18 deletions.
13 changes: 13 additions & 0 deletions .chloggen/mdatagen-scope-name.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# 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. otlpreceiver)
component: cmd/mdatagen

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Require scope_name to be provided explicitly for exporter, connectors, processors, receivers, and extensions.

# One or more tracking issues or pull requests related to the change
issues: [9693]

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.

1 change: 1 addition & 0 deletions cmd/mdatagen/internal/samplereceiver/metadata.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Sample metadata file with all available configurations for a receiver.

type: sample
scope_name: go.opentelemetry.io/collector/cmd/mdatagen/internal/samplereceiver

sem_conv_version: 1.9.0

Expand Down
18 changes: 2 additions & 16 deletions cmd/mdatagen/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"context"
"errors"
"fmt"
"os"
"path/filepath"
"strings"

Expand Down Expand Up @@ -222,7 +221,7 @@ type metadata struct {
// Metrics that can be emitted by the component.
Metrics map[metricName]metric `mapstructure:"metrics"`
// ScopeName of the metrics emitted by the component.
ScopeName string `mapstructure:"-"`
ScopeName string `mapstructure:"scope_name"`
// ShortFolderName is the shortened folder name of the component, removing class if present
ShortFolderName string `mapstructure:"-"`

Expand Down Expand Up @@ -253,7 +252,7 @@ func loadMetadata(filePath string) (metadata, error) {
return metadata{}, err
}

md := metadata{ScopeName: scopeName(filePath), ShortFolderName: shortFolderName(filePath)}
md := metadata{ShortFolderName: shortFolderName(filePath)}
if err := conf.Unmarshal(&md); err != nil {
return md, err
}
Expand Down Expand Up @@ -286,16 +285,3 @@ func shortFolderName(filePath string) string {
}
return parentFolder
}

func scopeName(filePath string) string {
sn := "go.opentelemetry.io/collector"
dirs := strings.Split(filepath.Dir(filePath), string(os.PathSeparator))
for _, dir := range dirs {
for _, cType := range componentTypes {
if strings.HasSuffix(dir, cType) {
sn += "/" + dir
}
}
}
return sn
}
3 changes: 3 additions & 0 deletions cmd/mdatagen/metadata-schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ type:
# Required for subcomponents: The type of the parent component.
parent: string

# Scope name of the telemetry emitted by the component. Recommended to be set to FQDN of the component.
scope_name:

# Required for components (Optional for subcomponents): A high-level view of the development status and use of this component
status:
# Required: The class of the component (For example receiver)
Expand Down
1 change: 1 addition & 0 deletions connector/forwardconnector/metadata.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
type: forward
scope_name: go.opentelemetry.io/collector/connector/forwardconnector

status:
class: connector
Expand Down
1 change: 1 addition & 0 deletions exporter/debugexporter/metadata.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
type: debug
scope_name: go.opentelemetry.io/collector/exporter/debugexporter

status:
class: exporter
Expand Down
1 change: 1 addition & 0 deletions exporter/loggingexporter/metadata.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
type: logging
scope_name: go.opentelemetry.io/collector/exporter/loggingexporter

status:
class: exporter
Expand Down
1 change: 1 addition & 0 deletions exporter/otlpexporter/metadata.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
type: otlp
scope_name: go.opentelemetry.io/collector/exporter/otlpexporter

status:
class: exporter
Expand Down
1 change: 1 addition & 0 deletions exporter/otlphttpexporter/metadata.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
type: otlphttp
scope_name: go.opentelemetry.io/collector/exporter/otlphttpexporter

status:
class: exporter
Expand Down
1 change: 1 addition & 0 deletions extension/ballastextension/metadata.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
type: memory_ballast
scope_name: go.opentelemetry.io/collector/extension/ballastextension

status:
class: extension
Expand Down
1 change: 1 addition & 0 deletions extension/memorylimiterextension/metadata.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
type: memory_limiter
scope_name: go.opentelemetry.io/collector/extension/memorylimiterextension

status:
class: extension
Expand Down
1 change: 1 addition & 0 deletions extension/zpagesextension/metadata.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
type: zpages
scope_name: go.opentelemetry.io/collector/extension/zpagesextension

status:
class: extension
Expand Down
1 change: 1 addition & 0 deletions processor/batchprocessor/metadata.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
type: batch
scope_name: go.opentelemetry.io/collector/processor/batchprocessor

status:
class: processor
Expand Down
1 change: 1 addition & 0 deletions processor/memorylimiterprocessor/metadata.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
type: memory_limiter
scope_name: go.opentelemetry.io/collector/processor/memorylimiterprocessor

status:
class: processor
Expand Down
1 change: 1 addition & 0 deletions receiver/otlpreceiver/metadata.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
type: otlp
scope_name: go.opentelemetry.io/collector/receiver/otlpreceiver

status:
class: receiver
Expand Down

0 comments on commit 5d7f323

Please sign in to comment.