Skip to content

Commit f3bace0

Browse files
[pkg/config/configmiddleware] Migrate middleware config to schema based (#15440)
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> #### Description Use `metadata.yaml` schema to generate go code and json schema for middleware config.
1 parent acb8813 commit f3bace0

8 files changed

Lines changed: 86 additions & 8 deletions

File tree

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Use this changelog template to create an entry for release notes.
2+
3+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
4+
change_type: enhancement
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. receiver/otlp)
7+
component: pkg/config/configmiddleware
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: Migrated middleware config to schema based
11+
12+
# One or more tracking issues or pull requests related to the change
13+
issues: [15440]
14+
15+
# (Optional) One or more lines of additional information to render under the primary note.
16+
# These lines will be padded with 2 spaces and then inserted directly into the document.
17+
# Use pipe (|) for multiline entries.
18+
subtext:
19+
20+
# Optional: The change log or logs in which this entry should be included.
21+
# e.g. '[user]' or '[user, api]'
22+
# Include 'user' if the change is relevant to end users.
23+
# Include 'api' if there is a change to a library API.
24+
# Default: '[user]'
25+
change_logs: [api]
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2020-12/schema",
3+
"$id": "go.opentelemetry.io/collector/config/configmiddleware",
4+
"title": "pkg/config/configmiddleware",
5+
"$defs": {
6+
"config": {
7+
"description": "Defines the extension ID for a middleware component.",
8+
"type": "object",
9+
"properties": {
10+
"id": {
11+
"description": "Specifies the name of the extension to use.",
12+
"type": "string"
13+
}
14+
}
15+
}
16+
}
17+
}

config/configmiddleware/configmiddleware.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,6 @@ var (
2424
errNotGRPCClient = errors.New("requested extension is not a gRPC client middleware")
2525
)
2626

27-
// Middleware defines the extension ID for a middleware component.
28-
type Config struct {
29-
// ID specifies the name of the extension to use.
30-
ID component.ID `mapstructure:"id,omitempty"`
31-
// prevent unkeyed literal initialization
32-
_ struct{}
33-
}
34-
3527
// GetHTTPClientRoundTripper attempts to select the appropriate
3628
// extensionmiddleware.HTTPClient from the map of extensions, and
3729
// returns the HTTP client wrapper function. If a middleware is not

config/configmiddleware/generated_config.go

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/configmiddleware/generated_config_test.go

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/configmiddleware/generated_package_test.go

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/configmiddleware/go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ require (
88
go.opentelemetry.io/collector/extension v1.60.0
99
go.opentelemetry.io/collector/extension/extensionmiddleware v0.154.0
1010
go.opentelemetry.io/collector/extension/extensionmiddleware/extensionmiddlewaretest v0.154.0
11+
go.uber.org/goleak v1.3.0
1112
google.golang.org/grpc v1.81.1
1213
)
1314

config/configmiddleware/metadata.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,13 @@ github_project: open-telemetry/opentelemetry-collector
55
status:
66
disable_codecov_badge: true
77
class: pkg
8+
9+
exported_configs:
10+
config:
11+
description: Defines the extension ID for a middleware component.
12+
type: object
13+
properties:
14+
id:
15+
description: Specifies the name of the extension to use.
16+
type: string
17+
x-customType: go.opentelemetry.io/collector/component.ID

0 commit comments

Comments
 (0)