Skip to content

Commit 962a113

Browse files
author
Alex Boten
authored
[receiver/chrony] remove duplicate Timeout setting (#26113)
Use the Timeout setting from ScraperHelper instead --------- Signed-off-by: Alex Boten <[email protected]>
1 parent b78c41f commit 962a113

File tree

4 files changed

+67
-24
lines changed

4 files changed

+67
-24
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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: breaking
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
7+
component: chronyreceiver
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: "Removes duplicate `Timeout` field. This change has no impact on end users of the component."
11+
12+
# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
13+
issues: [26113]
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+
# If your change doesn't affect end users or the exported elements of any package,
21+
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
22+
# Optional: The change log or logs in which this entry should be included.
23+
# e.g. '[user]' or '[user, api]'
24+
# Include 'user' if the change is relevant to end users.
25+
# Include 'api' if there is a change to a library API.
26+
# Default: '[user]'
27+
change_logs: [api]

receiver/chronyreceiver/config.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ type Config struct {
2626
//
2727
// The default value is unix:///var/run/chrony/chronyd.sock
2828
Endpoint string `mapstructure:"endpoint"`
29-
// Timeout controls the max time allowed to read data from chronyd
30-
Timeout time.Duration `mapstructure:"timeout"`
3129
}
3230

3331
var (
@@ -37,12 +35,13 @@ var (
3735
)
3836

3937
func newDefaultCongfig() component.Config {
38+
cfg := scraperhelper.NewDefaultScraperControllerSettings(metadata.Type)
39+
cfg.Timeout = 10 * time.Second
4040
return &Config{
41-
ScraperControllerSettings: scraperhelper.NewDefaultScraperControllerSettings(metadata.Type),
41+
ScraperControllerSettings: cfg,
4242
MetricsBuilderConfig: metadata.DefaultMetricsBuilderConfig(),
4343

4444
Endpoint: "unix:///var/run/chrony/chronyd.sock",
45-
Timeout: 10 * time.Second,
4645
}
4746
}
4847

receiver/chronyreceiver/config_test.go

Lines changed: 36 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ func TestLoadConfig(t *testing.T) {
4040
ScraperControllerSettings: scs,
4141
MetricsBuilderConfig: metadata.DefaultMetricsBuilderConfig(),
4242
Endpoint: "udp://localhost:3030",
43-
Timeout: 10 * time.Second,
4443
}, cfg)
4544
}
4645

@@ -55,54 +54,72 @@ func TestValidate(t *testing.T) {
5554
{
5655
scenario: "Valid udp configuration",
5756
conf: Config{
58-
Endpoint: "udp://localhost:323",
59-
Timeout: 10 * time.Second,
60-
ScraperControllerSettings: scraperhelper.NewDefaultScraperControllerSettings(metadata.Type),
57+
Endpoint: "udp://localhost:323",
58+
ScraperControllerSettings: scraperhelper.ScraperControllerSettings{
59+
CollectionInterval: time.Minute,
60+
InitialDelay: time.Second,
61+
Timeout: 10 * time.Second,
62+
},
6163
},
6264
err: nil,
6365
},
6466
{
6567
scenario: "Invalid udp hostname",
6668
conf: Config{
67-
Endpoint: "udp://:323",
68-
Timeout: 10 * time.Second,
69-
ScraperControllerSettings: scraperhelper.NewDefaultScraperControllerSettings(metadata.Type),
69+
Endpoint: "udp://:323",
70+
ScraperControllerSettings: scraperhelper.ScraperControllerSettings{
71+
CollectionInterval: time.Minute,
72+
InitialDelay: time.Second,
73+
Timeout: 10 * time.Second,
74+
},
7075
},
7176
err: chrony.ErrInvalidNetwork,
7277
},
7378
{
7479
scenario: "Invalid udp port",
7580
conf: Config{
76-
Endpoint: "udp://localhost",
77-
Timeout: 10 * time.Second,
78-
ScraperControllerSettings: scraperhelper.NewDefaultScraperControllerSettings(metadata.Type),
81+
Endpoint: "udp://localhost",
82+
ScraperControllerSettings: scraperhelper.ScraperControllerSettings{
83+
CollectionInterval: time.Minute,
84+
InitialDelay: time.Second,
85+
Timeout: 10 * time.Second,
86+
},
7987
},
8088
err: chrony.ErrInvalidNetwork,
8189
},
8290
{
8391
scenario: "Valid unix path",
8492
conf: Config{
85-
Endpoint: fmt.Sprintf("unix://%s", t.TempDir()),
86-
Timeout: 10 * time.Second,
87-
ScraperControllerSettings: scraperhelper.NewDefaultScraperControllerSettings(metadata.Type),
93+
Endpoint: fmt.Sprintf("unix://%s", t.TempDir()),
94+
ScraperControllerSettings: scraperhelper.ScraperControllerSettings{
95+
CollectionInterval: time.Minute,
96+
InitialDelay: time.Second,
97+
Timeout: 10 * time.Second,
98+
},
8899
},
89100
err: nil,
90101
},
91102
{
92103
scenario: "Invalid unix path",
93104
conf: Config{
94-
Endpoint: "unix:///no/dir/to/socket",
95-
Timeout: 10 * time.Second,
96-
ScraperControllerSettings: scraperhelper.NewDefaultScraperControllerSettings(metadata.Type),
105+
Endpoint: "unix:///no/dir/to/socket",
106+
ScraperControllerSettings: scraperhelper.ScraperControllerSettings{
107+
CollectionInterval: time.Minute,
108+
InitialDelay: time.Second,
109+
Timeout: 10 * time.Second,
110+
},
97111
},
98112
err: os.ErrNotExist,
99113
},
100114
{
101115
scenario: "Invalid timeout set",
102116
conf: Config{
103-
Endpoint: "unix://no/dir/to/socket",
104-
Timeout: 0,
105-
ScraperControllerSettings: scraperhelper.NewDefaultScraperControllerSettings(metadata.Type),
117+
Endpoint: "unix://no/dir/to/socket",
118+
ScraperControllerSettings: scraperhelper.ScraperControllerSettings{
119+
CollectionInterval: time.Minute,
120+
InitialDelay: time.Second,
121+
Timeout: 0,
122+
},
106123
},
107124
err: errInvalidValue,
108125
},

receiver/chronyreceiver/factory_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,10 @@ func TestCreatingMetricsReceiver(t *testing.T) {
5151
&Config{
5252
ScraperControllerSettings: scraperhelper.ScraperControllerSettings{
5353
CollectionInterval: 30 * time.Second,
54+
Timeout: 10 * time.Second,
5455
},
5556
MetricsBuilderConfig: mbc,
5657
Endpoint: "udp://localhost:323",
57-
Timeout: 10 * time.Second,
5858
},
5959
consumertest.NewNop(),
6060
)

0 commit comments

Comments
 (0)