Skip to content

Commit be43a45

Browse files
JimChenWYUjimchen
and
jimchen
authored
fix info (#7)
Co-authored-by: jimchen <[email protected]>
1 parent 303c027 commit be43a45

File tree

8 files changed

+77
-160
lines changed

8 files changed

+77
-160
lines changed

receiver/hostmetricsreceiver/internal/scraper/infoscraper/documentation.md

+9-9
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ metrics:
1616
1717
unix timestamp.
1818
19-
| Unit | Metric Type | Value Type |
20-
| ---- | ----------- | ---------- |
21-
| 1 | Gauge | Double |
19+
| Unit | Metric Type | Value Type | Aggregation Temporality | Monotonic |
20+
| ---- | ----------- | ---------- | ----------------------- | --------- |
21+
| 1 | Sum | Int | Cumulative | false |
2222
23-
## Resource Attributes
23+
#### Attributes
2424
25-
| Name | Description | Values | Enabled |
26-
| ---- | ----------- | ------ | ------- |
27-
| info.cpu.num | cpu num. | Any Int | true |
28-
| info.hostname | hostname. | Any Str | true |
29-
| info.org | common org. | Any Str | true |
25+
| Name | Description | Values |
26+
| ---- | ----------- | ------ |
27+
| org | org | Any Str |
28+
| hostname | hostname. | Any Str |
29+
| cpu.num | cpu num. | Any Int |

receiver/hostmetricsreceiver/internal/scraper/infoscraper/info_scraper.go

+8-6
Original file line numberDiff line numberDiff line change
@@ -65,17 +65,19 @@ func (s *scraper) shutdown(ctx context.Context) error {
6565
// scrape
6666
func (s *scraper) scrape(_ context.Context) (pmetric.Metrics, error) {
6767
now := pcommon.NewTimestampFromTime(s.now())
68-
s.mb.RecordInfoNowDataPoint(now, float64(now.AsTime().Unix()))
6968

7069
hostname, err := s.hostname()
7170
if err != nil {
7271
return pmetric.NewMetrics(), scrapererror.NewPartialScrapeError(err, metricsLen)
7372
}
74-
return s.mb.Emit(
75-
metadata.WithInfoOrg(org()),
76-
metadata.WithInfoCPUNum(int64(s.cpuNum())),
77-
metadata.WithInfoHostname(hostname),
78-
), nil
73+
s.mb.RecordInfoNowDataPoint(
74+
now, now.AsTime().Unix(),
75+
org(),
76+
hostname,
77+
int64(s.cpuNum()),
78+
)
79+
80+
return s.mb.Emit(), nil
7981
}
8082

8183
func org() string {

receiver/hostmetricsreceiver/internal/scraper/infoscraper/internal/metadata/generated_config.go

+2-30
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

receiver/hostmetricsreceiver/internal/scraper/infoscraper/internal/metadata/generated_config_test.go

+1-11
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

receiver/hostmetricsreceiver/internal/scraper/infoscraper/internal/metadata/generated_metrics.go

+28-51
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

receiver/hostmetricsreceiver/internal/scraper/infoscraper/internal/metadata/generated_metrics_test.go

+19-29
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

receiver/hostmetricsreceiver/internal/scraper/infoscraper/internal/metadata/testdata/config.yaml

-14
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,7 @@ all_set:
33
metrics:
44
info.now:
55
enabled: true
6-
resource_attributes:
7-
info.cpu.num:
8-
enabled: true
9-
info.hostname:
10-
enabled: true
11-
info.org:
12-
enabled: true
136
none_set:
147
metrics:
158
info.now:
169
enabled: false
17-
resource_attributes:
18-
info.cpu.num:
19-
enabled: false
20-
info.hostname:
21-
enabled: false
22-
info.org:
23-
enabled: false

receiver/hostmetricsreceiver/internal/scraper/infoscraper/metadata.yaml

+10-10
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,24 @@ type: hostmetricsreceiver/info
22

33
sem_conv_version: 1.9.0
44

5-
resource_attributes:
6-
info.org:
7-
description: common org.
8-
enabled: true
5+
attributes:
6+
org:
7+
description: org
98
type: string
10-
info.hostname:
9+
hostname:
1110
description: hostname.
12-
enabled: true
1311
type: string
14-
info.cpu.num:
12+
cpu.num:
1513
description: cpu num.
16-
enabled: true
1714
type: int
1815

1916
metrics:
2017
info.now:
2118
enabled: true
2219
description: unix timestamp.
2320
unit: 1
24-
gauge:
25-
value_type: double
21+
sum:
22+
value_type: int
23+
aggregation: cumulative
24+
monotonic: false
25+
attributes: [org, hostname, cpu.num]

0 commit comments

Comments
 (0)