Debian Codegraph @

pdata/xpdata/entity/resource_entities.go

raw
1 // Copyright The OpenTelemetry Authors
2 // SPDX-License-Identifier: Apache-2.0
3
4 package entity // import "go.opentelemetry.io/collector/pdata/xpdata/entity"
5
6 import (
7 "go.opentelemetry.io/collector/pdata/internal"
8 "go.opentelemetry.io/collector/pdata/pcommon"
9 )
10
11 // ResourceEntityRefs returns the EntityRefs associated with this Resource.
12 // Once EntityRefs is stabilized in the proto definition,
13 // this function will be available in the pcommon package as part of a Resource method.
14 func ResourceEntityRefs(res pcommon.Resource) EntityRefSlice {
15 ir := internal.ResourceWrapper(res)
16 return newEntityRefSlice(&internal.GetResourceOrig(ir).EntityRefs, internal.GetResourceState(ir))
17 }
18
19 // ResourceEntities returns the Entities associated with this Resource.
20 // The returned EntityMap shares the resource's attributes map, so modifications
21 // to entity attributes are immediately reflected in the resource.
22 func ResourceEntities(res pcommon.Resource) EntityMap {
23 return EntityMap{
24 refs: ResourceEntityRefs(res),
25 attributes: res.Attributes(),
26 }
27 }