Skip to content

Commit

Permalink
Fixing up metric definition values
Browse files Browse the repository at this point in the history
  • Loading branch information
MovieStoreGuy committed Jan 27, 2025
1 parent 93e584a commit 79a9b0b
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -174,11 +174,11 @@ Process threads count.
### process.uptime
The total duration the process has been running for.
The time the process has been running.
| Unit | Metric Type | Value Type | Aggregation Temporality | Monotonic |
| ---- | ----------- | ---------- | ----------------------- | --------- |
| s | Sum | Int | Cumulative | false |
| Unit | Metric Type | Value Type |
| ---- | ----------- | ---------- |
| s | Gauge | Double |
## Resource Attributes
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.

Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,7 @@ metrics:

process.uptime:
enabled: false
description: The total duration the process has been running for.
description: The time the process has been running.
unit: s
sum:
value_type: int
aggregation_temporality: cumulative
monotonic: false
gauge:
value_type: double
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ func (s *processScraper) scrapeAndAppendUptimeMetric(ctx context.Context, now pc
// Since create time is in milliseconds, it needs to be multiplied
// by the constant value so that it can be used as part of the time.Unix function.
uptime := now.AsTime().Sub(time.Unix(0, ts*int64(time.Millisecond)))
s.mb.RecordProcessUptimeDataPoint(now, int64(uptime.Seconds()))
s.mb.RecordProcessUptimeDataPoint(now, uptime.Seconds())

return nil
}
Original file line number Diff line number Diff line change
Expand Up @@ -359,9 +359,9 @@ func assertUptimeMetricValid(t *testing.T, resourceMetrics pmetric.ResourceMetri
m := getMetric(t, "process.uptime", resourceMetrics)
assert.Equal(t, "process.uptime", m.Name())

for i := 0; i < m.Sum().DataPoints().Len(); i++ {
dp := m.Sum().DataPoints().At(i)
assert.Equal(t, int64(199), dp.IntValue(), "Must have an uptime of 199s")
for i := 0; i < m.Gauge().DataPoints().Len(); i++ {
dp := m.Gauge().DataPoints().At(i)
assert.Equal(t, float64(199.9), dp.DoubleValue(), "Must have an uptime of 199s")
}
}

Expand Down

0 comments on commit 79a9b0b

Please sign in to comment.