mirror of
https://github.com/hanzoai/metrics.git
synced 2026-10-30 20:03:39 +00:00
31 lines
718 B
Go
31 lines
718 B
Go
// Copyright The OpenTelemetry Authors
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
package internal // import "go.opentelemetry.io/collector/pdata/internal"
|
|
|
|
import (
|
|
"encoding/hex"
|
|
|
|
"go.opentelemetry.io/collector/pdata/internal/json"
|
|
)
|
|
|
|
// unmarshalJSON inflates trace id from hex string, possibly enclosed in quotes.
|
|
// Called by Protobuf JSON deserialization.
|
|
func unmarshalJSON(dst []byte, iter *json.Iterator) {
|
|
src := iter.ReadStringAsSlice()
|
|
if len(src) == 0 {
|
|
return
|
|
}
|
|
|
|
if len(dst) != hex.DecodedLen(len(src)) {
|
|
iter.ReportError("ID.UnmarshalJSONIter", "length mismatch")
|
|
return
|
|
}
|
|
|
|
_, err := hex.Decode(dst, src)
|
|
if err != nil {
|
|
iter.ReportError("ID.UnmarshalJSONIter", err.Error())
|
|
return
|
|
}
|
|
}
|