Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to omit timestamp #108

Merged
merged 3 commits into from
Dec 1, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
tests
  • Loading branch information
anegrin committed Nov 30, 2022
commit ae387c23aeb3332753677212bb74c4407e5fa81f
26 changes: 26 additions & 0 deletions pkg/metrics/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,32 @@ func TestParser_parseMetric(t *testing.T) {
want Metric
wantErr bool
}{
{
name: "value without timestamp",
fields: fields{
map[string][]config.MetricConfig{
"temperature": []config.MetricConfig{
{
PrometheusName: "temperature",
ValueType: "gauge",
OmitTimestamp: true,
},
},
},
},
args: args{
metricPath: "temperature",
deviceID: "dht22",
value: 12.6,
},
want: Metric{
Description: prometheus.NewDesc("temperature", "", []string{"sensor", "topic"}, nil),
ValueType: prometheus.GaugeValue,
Value: 12.6,
IngestTime: time.Time{},
Topic: "",
},
},
{
name: "string value",
fields: fields{
Expand Down