Skip to content

Commit

Permalink
fix info (#7)
Browse files Browse the repository at this point in the history
Co-authored-by: jimchen <jimchen@easyops.cn>
  • Loading branch information
JimChenWYU and jimchen authored Jun 11, 2023
1 parent 303c027 commit be43a45
Show file tree
Hide file tree
Showing 8 changed files with 77 additions and 160 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ metrics:
unix timestamp.
| Unit | Metric Type | Value Type |
| ---- | ----------- | ---------- |
| 1 | Gauge | Double |
| Unit | Metric Type | Value Type | Aggregation Temporality | Monotonic |
| ---- | ----------- | ---------- | ----------------------- | --------- |
| 1 | Sum | Int | Cumulative | false |
## Resource Attributes
#### Attributes
| Name | Description | Values | Enabled |
| ---- | ----------- | ------ | ------- |
| info.cpu.num | cpu num. | Any Int | true |
| info.hostname | hostname. | Any Str | true |
| info.org | common org. | Any Str | true |
| Name | Description | Values |
| ---- | ----------- | ------ |
| org | org | Any Str |
| hostname | hostname. | Any Str |
| cpu.num | cpu num. | Any Int |
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,19 @@ func (s *scraper) shutdown(ctx context.Context) error {
// scrape
func (s *scraper) scrape(_ context.Context) (pmetric.Metrics, error) {
now := pcommon.NewTimestampFromTime(s.now())
s.mb.RecordInfoNowDataPoint(now, float64(now.AsTime().Unix()))

hostname, err := s.hostname()
if err != nil {
return pmetric.NewMetrics(), scrapererror.NewPartialScrapeError(err, metricsLen)
}
return s.mb.Emit(
metadata.WithInfoOrg(org()),
metadata.WithInfoCPUNum(int64(s.cpuNum())),
metadata.WithInfoHostname(hostname),
), nil
s.mb.RecordInfoNowDataPoint(
now, now.AsTime().Unix(),
org(),
hostname,
int64(s.cpuNum()),
)

return s.mb.Emit(), nil
}

func org() string {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,7 @@ all_set:
metrics:
info.now:
enabled: true
resource_attributes:
info.cpu.num:
enabled: true
info.hostname:
enabled: true
info.org:
enabled: true
none_set:
metrics:
info.now:
enabled: false
resource_attributes:
info.cpu.num:
enabled: false
info.hostname:
enabled: false
info.org:
enabled: false
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,24 @@ type: hostmetricsreceiver/info

sem_conv_version: 1.9.0

resource_attributes:
info.org:
description: common org.
enabled: true
attributes:
org:
description: org
type: string
info.hostname:
hostname:
description: hostname.
enabled: true
type: string
info.cpu.num:
cpu.num:
description: cpu num.
enabled: true
type: int

metrics:
info.now:
enabled: true
description: unix timestamp.
unit: 1
gauge:
value_type: double
sum:
value_type: int
aggregation: cumulative
monotonic: false
attributes: [org, hostname, cpu.num]

0 comments on commit be43a45

Please sign in to comment.