forked from open-telemetry/opentelemetry-go
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support multiple entity refs in the Resource
- Loading branch information
1 parent
781faa5
commit 7f149b1
Showing
12 changed files
with
551 additions
and
208 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package resource | ||
|
||
import "go.opentelemetry.io/otel/attribute" | ||
|
||
type Entity struct { | ||
Type string | ||
Id attribute.Set | ||
Attrs attribute.Set | ||
SchemaURL string | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package resource | ||
|
||
import "go.opentelemetry.io/otel/attribute" | ||
|
||
type resourceEntityRef struct { | ||
schemaUrl string | ||
|
||
// Defines the entity type, e.g "service", "k8s.pod", etc. | ||
typ string | ||
|
||
// Set of Resource attribute keys that identify the entity. | ||
id map[attribute.Key]bool | ||
|
||
// Set of Resource attribute keys that describe the entity. | ||
attrs map[attribute.Key]bool | ||
|
||
// id and attrs are cached as slices for faster exporting. | ||
idAsSlice []string | ||
attrsAsSlice []string | ||
} | ||
|
||
// updateCache must be called after id or attrs are modified to make | ||
// sure the cache is up to date. | ||
func (r *resourceEntityRef) updateCache() { | ||
r.idAsSlice = r.idAsSlice[:0] | ||
for k := range r.id { | ||
r.idAsSlice = append(r.idAsSlice, string(k)) | ||
} | ||
r.attrsAsSlice = r.attrsAsSlice[:0] | ||
for k := range r.attrs { | ||
r.attrsAsSlice = append(r.attrsAsSlice, string(k)) | ||
} | ||
} | ||
|
||
func (r *resourceEntityRef) SchemaUrl() string { | ||
return r.schemaUrl | ||
} | ||
|
||
func (r *resourceEntityRef) Type() string { | ||
return r.typ | ||
} | ||
|
||
func (r *resourceEntityRef) Id() []string { | ||
return r.idAsSlice | ||
} | ||
|
||
func (r *resourceEntityRef) Attrs() []string { | ||
return r.attrsAsSlice | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.