Skip to content

Commit c62353b

Browse files
[exporter/exporterhelper] Migrate TimeoutConfig to schema-based configuration generated by mdatagen. (#15505)
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> #### Description Migrate `TimeoutConfig` (part of exporterhelper) to mdatagen schema-based configuration. Removes the hand-written TimeoutConfig struct and NewTimeoutConfig constructor in favor of generated code driven by metadata.yaml and config.schema.json. <!--Authorship attestation. See AGENTS.md for details. AI agents must not check this box on behalf of the user; the human author must check it themselves before the PR is ready for review.--> #### Authorship - [x] I, a human, wrote this pull request description myself. <!--Please delete paragraphs that you did not use before submitting.-->
1 parent a183c9c commit c62353b

14 files changed

Lines changed: 183 additions & 42 deletions
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/exporterhelper
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: Migrate `TimeoutConfig` to schema-based configuration generated by mdatagen.
11+
12+
# One or more tracking issues or pull requests related to the change
13+
issues: [15505]
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: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"$id": "go.opentelemetry.io/collector/exporter/exporterhelper",
3+
"$schema": "https://json-schema.org/draft/2020-12/schema",
4+
"$defs": {
5+
"timeout_config": {
6+
"type": "object",
7+
"properties": {
8+
"timeout": {
9+
"type": "string",
10+
"description": "Defines the timeout for every attempt to send data to the backend. A zero timeout means no timeout.",
11+
"default": "5s",
12+
"minimum": 0,
13+
"pattern": "^([0-9]+(\\.[0-9]+)?(ns|us|µs|ms|s|m|h))+$"
14+
}
15+
},
16+
"description": "A timeout configuration. The timeout applies to individual attempts to send data to the backend."
17+
}
18+
},
19+
"title": "pkg/exporterhelper"
20+
}

exporter/exporterhelper/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.

exporter/exporterhelper/generated_config_test.go

Lines changed: 22 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"$id": "go.opentelemetry.io/collector/exporter/exporterhelper/internal",
3+
"$schema": "https://json-schema.org/draft/2020-12/schema",
4+
"$defs": {
5+
"timeout_config": {
6+
"type": "object",
7+
"properties": {
8+
"timeout": {
9+
"type": "string",
10+
"description": "Defines the timeout for every attempt to send data to the backend. A zero timeout means no timeout.",
11+
"default": "5s",
12+
"minimum": 0,
13+
"pattern": "^([0-9]+(\\.[0-9]+)?(ns|us|µs|ms|s|m|h))+$"
14+
}
15+
},
16+
"description": "A timeout configuration. The timeout applies to individual attempts to send data to the backend."
17+
}
18+
},
19+
"title": "exporterhelper/timeout"
20+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// Copyright The OpenTelemetry Authors
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
//go:generate mdatagen metadata.yaml
5+
6+
package internal // import "go.opentelemetry.io/collector/exporter/exporterhelper/internal"

exporter/exporterhelper/internal/generated_config.go

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

exporter/exporterhelper/internal/generated_config_test.go

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

exporter/exporterhelper/internal/package_test.go renamed to exporter/exporterhelper/internal/generated_package_test.go

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
type: exporterhelper/timeout
2+
parent: pkg/exporterhelper
3+
4+
exported_configs:
5+
timeout_config:
6+
description: A timeout configuration. The timeout applies to individual attempts to send data to the backend.
7+
type: object
8+
properties:
9+
timeout:
10+
description: Defines the timeout for every attempt to send data to the backend. A zero timeout means no timeout.
11+
type: duration
12+
default: 5s
13+
minimum: 0

0 commit comments

Comments
 (0)