Debian Codegraph @

pdata/pprofile/profileid.go

raw
1 // Copyright The OpenTelemetry Authors
2 // SPDX-License-Identifier: Apache-2.0
3
4 package pprofile // import "go.opentelemetry.io/collector/pdata/pprofile"
5
6 import (
7 "encoding/hex"
8
9 "go.opentelemetry.io/collector/pdata/internal"
10 )
11
12 var emptyProfileID = ProfileID([16]byte{})
13
14 // ProfileID is a profile identifier.
15 type ProfileID [16]byte
16
17 // NewProfileIDEmpty returns a new empty (all zero bytes) ProfileID.
18 func NewProfileIDEmpty() ProfileID {
19 return emptyProfileID
20 }
21
22 // String returns string representation of the ProfileID.
23 //
24 // Important: Don't rely on this method to get a string identifier of ProfileID.
25 // Use hex.EncodeToString explicitly instead.
26 // This method is meant to implement Stringer interface for display purposes only.
27 func (ms ProfileID) String() string {
28 if ms.IsEmpty() {
29 return ""
30 }
31 return hex.EncodeToString(ms[:])
32 }
33
34 // IsEmpty returns true if id doesn't contain at least one non-zero byte.
35 func (ms ProfileID) IsEmpty() bool {
36 return internal.ProfileID(ms).IsEmpty()
37 }