Skip to content

Commit

Permalink
exporter provided timestamp preferred
Browse files Browse the repository at this point in the history
  • Loading branch information
lts120784620 committed Jun 16, 2020
1 parent 2fbce00 commit f951e14
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion collector/gather.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func gatherExporterUrl(url string) ([]byte, error) {
}

client := &http.Client{
Timeout: time.Duration(config.Get().TimeOut) * time.Millisecond,
Timeout: time.Duration(config.Get().Timeout) * time.Millisecond,
}

var resp *http.Response
Expand Down
5 changes: 4 additions & 1 deletion collector/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,10 @@ func Parse(buf []byte) ([]*dataobj.MetricValue, error) {
metric.Metric = strings.Replace(metric.Metric, "_", ".", -1)
metric.Endpoint = cfg.Endpoint
metric.Tags = makeAppendTags(metric.TagsMap, config.AppendTagsMap)

// set provided Time, ms to s
if m.GetTimestampMs() > 0 {
metric.Timestamp = m.GetTimestampMs() / 1000
}
metricList = append(metricList, metric)
}
}
Expand Down
4 changes: 2 additions & 2 deletions config/plugin_cfg.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ type PluginCfg struct {
Endpoint string `json:"endpoint"`
Username string `json:"username"`
Password string `json:"password"`
TimeOut int `json:"timeout"`
Timeout int `json:"timeout"`
IgnoreMetricsPrefix []string `json:"ignore_metrics_prefix"`
}

Expand All @@ -32,7 +32,7 @@ func Parse(bs []byte) error {
Endpoint: "",
Username: "",
Password: "",
TimeOut: 500,
Timeout: 500,
IgnoreMetricsPrefix: []string{},
}

Expand Down

0 comments on commit f951e14

Please sign in to comment.