Skip to content

Commit

Permalink
chore(): 添加进程启动时间 (#20)
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 Oct 13, 2023
1 parent b8f1cb5 commit c4a3dce
Show file tree
Hide file tree
Showing 8 changed files with 113 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,14 @@ This metric is only available on Linux.
| ---- | ----------- | ---------- | ----------------------- | --------- |
| {signals} | Sum | Int | Cumulative | false |
### process.start.time
Start time of the process since unix epoch in seconds.
| Unit | Metric Type | Value Type | Aggregation Temporality | Monotonic |
| ---- | ----------- | ---------- | ----------------------- | --------- |
| s | Sum | Double | Cumulative | true |
### process.threads
Process threads count.
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 @@ -29,6 +29,8 @@ all_set:
enabled: true
process.signals_pending:
enabled: true
process.start.time:
enabled: true
process.threads:
enabled: true
resource_attributes:
Expand Down Expand Up @@ -78,6 +80,8 @@ none_set:
enabled: false
process.signals_pending:
enabled: false
process.start.time:
enabled: false
process.threads:
enabled: false
resource_attributes:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,3 +236,12 @@ metrics:
aggregation: cumulative
monotonic: true
attributes: [direction]

process.start.time:
enabled: false
description: Start time of the process since unix epoch in seconds.
unit: s
sum:
value_type: double
aggregation: cumulative
monotonic: true
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,8 @@ func (s *scraper) scrape(_ context.Context) (pmetric.Metrics, error) {
errs.AddPartial(signalMetricsLen, fmt.Errorf("error reading pending signals for process %q (pid %v): %w", md.executable.name, md.pid, err))
}

s.scrapeAndAppendStartTimeMetric(now, md.createTime)

options := append(md.resourceOptions(), metadata.WithStartTimeOverride(pcommon.Timestamp(md.createTime*1e6)))
s.mb.EmitForResource(options...)
}
Expand Down Expand Up @@ -485,3 +487,11 @@ func (s *scraper) scrapeAndAppendSignalsPendingMetric(now pcommon.Timestamp, han

return nil
}

func (s *scraper) scrapeAndAppendStartTimeMetric(now pcommon.Timestamp, ctime int64) {
if !s.config.MetricsBuilderConfig.Metrics.ProcessStartTime.Enabled {
return
}

s.mb.RecordProcessStartTimeDataPoint(now, float64(ctime))
}

0 comments on commit c4a3dce

Please sign in to comment.