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

feat(parser.prometheusremotewrite, serializer.prometheusremotewrite): Native histogram support end-to-end #16121

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Prev Previous commit
Next Next commit
fix type assertion err
  • Loading branch information
yulong-db committed Nov 4, 2024
commit 283389a8caf5fc28eec09b18008959f2680c3fac
Original file line number Diff line number Diff line change
@@ -138,7 +138,17 @@ func (s *Serializer) SerializeBatch(metrics []telegraf.Metric) ([]byte, error) {
// This is a native histogram, if all above suffixes are not found
// we should unmarshal the json string back
var h prompb.Histogram
err := json.Unmarshal(field.Value.([]byte), &h)
var data []byte
switch v := field.Value.(type) {
case []byte:
data = v
case string:
data = []byte(v)
default:
traceAndKeepErr("unexpected type for field.Value: %T", field.Value)
continue
}
err := json.Unmarshal(data, &h)
if err != nil {
traceAndKeepErr("failed to unmarshal native histogram %q: %w", metricName, err)
continue