Skip to content

Commit 5d93619

Browse files
authored
Apply fieldalignment to collectdreceiver (#37321)
This change applies to structs in the hot path of the collectd receiver and therefore impacting performance.
1 parent 1f3adcc commit 5d93619

File tree

2 files changed

+32
-5
lines changed

2 files changed

+32
-5
lines changed
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: enhancement
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
7+
component: collectdreceiver
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: apply fieldalignment to collectd records to reduce memory allocation
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: [37321]
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: []

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 {

0 commit comments

Comments
 (0)