Debian Codegraph @

exporter/exporterhelper/internal/sizer/profiles_sizer.go

raw symbols SCIP
1 // Copyright The OpenTelemetry Authors
2 // SPDX-License-Identifier: Apache-2.0
3
4 package sizer // import "go.opentelemetry.io/collector/exporter/exporterhelper/internal/sizer"
5
6 import (
7 "go.opentelemetry.io/collector/pdata/pprofile"
8 )
9
10 type ProfilesSizer interface {
11 ProfilesSize(pd pprofile.Profiles) int
12 ResourceProfilesSize(rp pprofile.ResourceProfiles) int
13 ScopeProfilesSize(sp pprofile.ScopeProfiles) int
14 ProfileSize(p pprofile.Profile) int
15 DeltaSize(newItemSize int) int
16 }
17
18 // TracesBytesSizer returns the byte size of serialized protos.
19 type ProfilesBytesSizer struct {
20 pprofile.ProtoMarshaler
21 protoDeltaSizer
22 }
23
24 var _ ProfilesSizer = (*ProfilesBytesSizer)(nil)
25
26 // ProfilesCountSizer returns the number of profiles in the profiles.
27 type ProfilesCountSizer struct{}
28
29 var _ ProfilesSizer = (*ProfilesCountSizer)(nil)
30
31 func (s *ProfilesCountSizer) ProfilesSize(pd pprofile.Profiles) int {
32 return pd.SampleCount()
33 }
34
35 func (s *ProfilesCountSizer) ResourceProfilesSize(rp pprofile.ResourceProfiles) int {
36 count := 0
37 for k := 0; k < rp.ScopeProfiles().Len(); k++ {
38 count += rp.ScopeProfiles().At(k).Profiles().Len()
39 }
40 return count
41 }
42
43 func (s *ProfilesCountSizer) ScopeProfilesSize(sp pprofile.ScopeProfiles) int {
44 return sp.Profiles().Len()
45 }
46
47 func (s *ProfilesCountSizer) ProfileSize(_ pprofile.Profile) int {
48 return 1
49 }
50
51 func (s *ProfilesCountSizer) DeltaSize(newItemSize int) int {
52 return newItemSize
53 }