Skip to content
Open
Changes from all commits
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
6 changes: 2 additions & 4 deletions modbus/modbus.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package modbus
import (
"encoding/binary"
"fmt"
"maps"
"math"
"strconv"
"time"
Expand Down Expand Up @@ -90,9 +91,6 @@ func registerMetrics(reg prometheus.Registerer, moduleName string, metrics []met
registeredCounters := map[string]*prometheus.CounterVec{}

for _, m := range metrics {
if m.Labels == nil {
m.Labels = map[string]string{}
}
m.Labels["module"] = moduleName

switch m.MetricType {
Expand Down Expand Up @@ -262,7 +260,7 @@ func scrapeMetric(definition config.MetricDef, f modbusFunc, modAddress uint64)
return metric{}, err
}

return metric{definition.Name, definition.Help, definition.Labels, v, definition.MetricType}, nil
return metric{definition.Name, definition.Help, maps.Clone(definition.Labels), v, definition.MetricType}, nil
}

// InsufficientRegistersError is returned in Parse() whenever not enough
Expand Down