Skip to content

Commit

Permalink
Remove nil entries.
Browse files Browse the repository at this point in the history
  • Loading branch information
joliver committed Nov 2, 2023
1 parent 27c0060 commit 9ed1a38
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion default_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,14 @@ func NewExporter() Exporter {
}

func (this *defaultExporter) Add(items ...Metric) {
this.metrics = append(this.metrics, items...)
parsed := make([]Metric, 0, len(items))
for _, item := range items {
if item != nil {
parsed = append(parsed, item)
}
}

this.metrics = append(this.metrics, parsed...)
}
func (this *defaultExporter) ServeHTTP(response http.ResponseWriter, _ *http.Request) {
response.Header().Set("Content-Type", "text/plain; version=0.0.4")
Expand Down

0 comments on commit 9ed1a38

Please sign in to comment.