Skip to content

Commit a514ddd

Browse files
committed
[chore] apply fieldalignment to collectdreceiver
1 parent 01104dd commit a514ddd

File tree

5 files changed

+17
-17
lines changed

5 files changed

+17
-17
lines changed

receiver/collectdreceiver/collectd.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -17,25 +17,25 @@ import (
1717
)
1818

1919
type collectDRecord struct {
20-
Dsnames []*string `json:"dsnames"`
21-
Dstypes []*string `json:"dstypes"`
20+
Time *float64 `json:"time"`
2221
Host *string `json:"host"`
2322
Interval *float64 `json:"interval"`
2423
Plugin *string `json:"plugin"`
2524
PluginInstance *string `json:"plugin_instance"`
26-
Time *float64 `json:"time"`
2725
TypeS *string `json:"type"`
2826
TypeInstance *string `json:"type_instance"`
29-
Values []*json.Number `json:"values"`
3027
Message *string `json:"message"`
3128
Meta map[string]any `json:"meta"`
3229
Severity *string `json:"severity"`
30+
Dstypes []*string `json:"dstypes"`
31+
Dsnames []*string `json:"dsnames"`
32+
Values []*json.Number `json:"values"`
3333
}
3434

3535
type createMetricInfo struct {
36-
Name string
3736
DsType *string
3837
Val *json.Number
38+
Name string
3939
}
4040

4141
func (cdr *collectDRecord) isEvent() bool {

receiver/collectdreceiver/config.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ import (
1313

1414
// Config defines configuration for Collectd receiver.
1515
type Config struct {
16-
confighttp.ServerConfig `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct
17-
Timeout time.Duration `mapstructure:"timeout"`
18-
Encoding string `mapstructure:"encoding"`
19-
AttributesPrefix string `mapstructure:"attributes_prefix"`
16+
Encoding string `mapstructure:"encoding"`
17+
AttributesPrefix string `mapstructure:"attributes_prefix"`
18+
confighttp.ServerConfig `mapstructure:",squash"`
19+
Timeout time.Duration `mapstructure:"timeout"`
2020
}
2121

2222
func (c *Config) Validate() error {

receiver/collectdreceiver/config_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ func TestLoadConfig(t *testing.T) {
2222
t.Parallel()
2323

2424
tests := []struct {
25-
id component.ID
2625
expected component.Config
2726
wantErr error
27+
id component.ID
2828
}{
2929
{
3030
id: component.NewIDWithName(metadata.Type, ""),

receiver/collectdreceiver/receiver.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ var _ receiver.Metrics = (*collectdReceiver)(nil)
2626

2727
// collectdReceiver implements the receiver.Metrics for CollectD protocol.
2828
type collectdReceiver struct {
29+
nextConsumer consumer.Metrics
2930
logger *zap.Logger
3031
server *http.Server
31-
defaultAttrsPrefix string
32-
nextConsumer consumer.Metrics
3332
obsrecv *receiverhelper.ObsReport
34-
createSettings receiver.Settings
3533
config *Config
34+
createSettings receiver.Settings
35+
defaultAttrsPrefix string
3636
}
3737

3838
// newCollectdReceiver creates the CollectD receiver with the given parameters.

receiver/collectdreceiver/receiver_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -25,22 +25,22 @@ import (
2525
)
2626

2727
type wantedBody struct {
28+
Attributes map[string]string
2829
Name string
2930
Time float64
30-
Attributes map[string]string
3131
Value float64
3232
}
3333

3434
func TestNewReceiver(t *testing.T) {
3535
type args struct {
36+
nextConsumer consumer.Metrics
3637
config *Config
3738
attrsPrefix string
38-
nextConsumer consumer.Metrics
3939
}
4040
tests := []struct {
41-
name string
4241
args args
4342
wantErr error
43+
name string
4444
}{
4545
{
4646
name: "happy path",
@@ -71,8 +71,8 @@ func TestCollectDServer(t *testing.T) {
7171
HTTPMethod string
7272
QueryParams string
7373
RequestBody string
74-
ResponseCode int
7574
WantData []pmetric.Metrics
75+
ResponseCode int
7676
}
7777

7878
config := &Config{

0 commit comments

Comments
 (0)