Skip to content

Commit 8026972

Browse files
authored
[xpdata/entity] Rename methods to use updated entity terminology (#14275)
Rename Entity API methods to align with OpenTelemetry specification terminology for attributes in entity context: - IDAttributes() → IdentifyingAttributes() - DescriptionAttributes() → DescriptiveAttributes() This change applies the "Identifying" and "Descriptive" terms specifically to Attributes (not Entity or Entity Keys), as clarified in open-telemetry/opentelemetry-specification#4700
1 parent 8f51a17 commit 8026972

File tree

5 files changed

+62
-42
lines changed

5 files changed

+62
-42
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Use this changelog template to create an entry for release notes.
2+
3+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
4+
change_type: breaking
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. receiver/otlp)
7+
component: pdata/xpdata
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: "Rename `Entity.IDAttributes()` to `Entity.IdentifyingAttributes()` and `Entity.DescriptionAttributes()` to `Entity.DescriptiveAttributes()` to align with OpenTelemetry specification terminology for attributes."
11+
12+
# One or more tracking issues or pull requests related to the change
13+
issues: [14275]
14+
15+
# Optional: The change log or logs in which this entry should be included.
16+
# e.g. '[user]' or '[user, api]'
17+
# Include 'user' if the change is relevant to end users.
18+
# Include 'api' if there is a change to a library API.
19+
# Default: '[user]'
20+
change_logs: [api]

pdata/xpdata/entity/entity.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,16 @@ func (e Entity) SetSchemaURL(schemaURL string) {
2828
e.ref.SetSchemaUrl(schemaURL)
2929
}
3030

31-
// IDAttributes returns an EntityAttributeMap for managing the entity's id attributes.
32-
func (e Entity) IDAttributes() EntityAttributeMap {
31+
// IdentifyingAttributes returns an EntityAttributeMap for managing the entity's identifying attributes.
32+
func (e Entity) IdentifyingAttributes() EntityAttributeMap {
3333
return EntityAttributeMap{
3434
keys: e.ref.IdKeys(),
3535
attributes: e.attributes,
3636
}
3737
}
3838

39-
// DescriptionAttributes returns an EntityAttributeMap for managing the entity's description attributes.
40-
func (e Entity) DescriptionAttributes() EntityAttributeMap {
39+
// DescriptiveAttributes returns an EntityAttributeMap for managing the entity's descriptive attributes.
40+
func (e Entity) DescriptiveAttributes() EntityAttributeMap {
4141
return EntityAttributeMap{
4242
keys: e.ref.DescriptionKeys(),
4343
attributes: e.attributes,

pdata/xpdata/entity/entity_attribute_map.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ func (m EntityAttributeMap) Get(key string) (pcommon.Value, bool) {
3535
//
3636
// Use this method before calling Put* methods to avoid conflicts:
3737
//
38-
// if entity.IDAttributes().CanPut("service.name") {
39-
// entity.IDAttributes().PutStr("service.name", "my-service")
38+
// if entity.IdentifyingAttributes().CanPut("service.name") {
39+
// entity.IdentifyingAttributes().PutStr("service.name", "my-service")
4040
// }
4141
func (m EntityAttributeMap) CanPut(key string) bool {
4242
if m.containsKey(key) {

pdata/xpdata/entity/entity_map_test.go

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,13 @@ func TestEntityMap_PutEmpty(t *testing.T) {
3535
func TestEntityMap_PutEmpty_Override(t *testing.T) {
3636
em := NewEntityMap()
3737
e1 := em.PutEmpty("service")
38-
e1.IDAttributes().PutStr("service.name", "my-service")
38+
e1.IdentifyingAttributes().PutStr("service.name", "my-service")
3939
assert.Equal(t, 1, em.Len())
4040

4141
e2 := em.PutEmpty("service")
4242
assert.Equal(t, 1, em.Len())
4343

44-
_, ok := e2.IDAttributes().Get("service.name")
44+
_, ok := e2.IdentifyingAttributes().Get("service.name")
4545
assert.False(t, ok)
4646
}
4747

@@ -61,39 +61,39 @@ func TestEntityMap_AttributesIsolation(t *testing.T) {
6161
em := NewEntityMap()
6262

6363
e1 := em.PutEmpty("service")
64-
e1.IDAttributes().PutStr("service.name", "my-service")
64+
e1.IdentifyingAttributes().PutStr("service.name", "my-service")
6565

6666
e2 := em.PutEmpty("host")
67-
e2.IDAttributes().PutStr("host.name", "my-host")
67+
e2.IdentifyingAttributes().PutStr("host.name", "my-host")
6868

6969
service, ok := em.Get("service")
7070
assert.True(t, ok)
71-
val, ok := service.IDAttributes().Get("service.name")
71+
val, ok := service.IdentifyingAttributes().Get("service.name")
7272
assert.True(t, ok)
7373
assert.Equal(t, "my-service", val.Str())
7474

7575
host, ok := em.Get("host")
7676
assert.True(t, ok)
77-
val, ok = host.IDAttributes().Get("host.name")
77+
val, ok = host.IdentifyingAttributes().Get("host.name")
7878
assert.True(t, ok)
7979
assert.Equal(t, "my-host", val.Str())
8080

81-
_, ok = service.IDAttributes().Get("host.name")
81+
_, ok = service.IdentifyingAttributes().Get("host.name")
8282
assert.False(t, ok)
8383

84-
_, ok = host.IDAttributes().Get("service.name")
84+
_, ok = host.IdentifyingAttributes().Get("service.name")
8585
assert.False(t, ok)
8686
}
8787

8888
func TestEntityMap_Get(t *testing.T) {
8989
em := NewEntityMap()
9090
e1 := em.PutEmpty("service")
91-
e1.IDAttributes().PutStr("service.name", "my-service")
91+
e1.IdentifyingAttributes().PutStr("service.name", "my-service")
9292

9393
e2, ok := em.Get("service")
9494
assert.True(t, ok)
9595
assert.Equal(t, "service", e2.Type())
96-
val, ok := e2.IDAttributes().Get("service.name")
96+
val, ok := e2.IdentifyingAttributes().Get("service.name")
9797
assert.True(t, ok)
9898
assert.Equal(t, "my-service", val.Str())
9999

@@ -104,8 +104,8 @@ func TestEntityMap_Get(t *testing.T) {
104104
func TestEntityMap_Remove(t *testing.T) {
105105
em := NewEntityMap()
106106
e1 := em.PutEmpty("service")
107-
e1.IDAttributes().PutStr("service.name", "my-service")
108-
e1.DescriptionAttributes().PutStr("service.version", "1.0.0")
107+
e1.IdentifyingAttributes().PutStr("service.name", "my-service")
108+
e1.DescriptiveAttributes().PutStr("service.version", "1.0.0")
109109

110110
assert.Equal(t, 1, em.Len())
111111
assert.Equal(t, 2, em.attributes.Len())
@@ -121,13 +121,13 @@ func TestEntityMap_Remove(t *testing.T) {
121121
func TestEntityMap_All(t *testing.T) {
122122
em := NewEntityMap()
123123
e1 := em.PutEmpty("service")
124-
e1.IDAttributes().PutStr("service.name", "my-service")
124+
e1.IdentifyingAttributes().PutStr("service.name", "my-service")
125125

126126
e2 := em.PutEmpty("host")
127-
e2.IDAttributes().PutStr("host.name", "my-host")
127+
e2.IdentifyingAttributes().PutStr("host.name", "my-host")
128128

129129
e3 := em.PutEmpty("process")
130-
e3.IDAttributes().PutStr("process.pid", "1234")
130+
e3.IdentifyingAttributes().PutStr("process.pid", "1234")
131131

132132
types := make(map[string]bool)
133133
attributes := make(map[string]string)
@@ -136,15 +136,15 @@ func TestEntityMap_All(t *testing.T) {
136136
types[entityType] = true
137137
switch entityType {
138138
case "service":
139-
val, ok := entity.IDAttributes().Get("service.name")
139+
val, ok := entity.IdentifyingAttributes().Get("service.name")
140140
assert.True(t, ok)
141141
attributes[entityType] = val.Str()
142142
case "host":
143-
val, ok := entity.IDAttributes().Get("host.name")
143+
val, ok := entity.IdentifyingAttributes().Get("host.name")
144144
assert.True(t, ok)
145145
attributes[entityType] = val.Str()
146146
case "process":
147-
val, ok := entity.IDAttributes().Get("process.pid")
147+
val, ok := entity.IdentifyingAttributes().Get("process.pid")
148148
assert.True(t, ok)
149149
attributes[entityType] = val.Str()
150150
}

pdata/xpdata/entity/entity_test.go

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -29,26 +29,26 @@ func TestEntity_SchemaURL(t *testing.T) {
2929
assert.Equal(t, "https://opentelemetry.io/schemas/1.1.0", e.SchemaURL())
3030
}
3131

32-
func TestEntity_IDAttributes(t *testing.T) {
32+
func TestEntity_IdentifyingAttributes(t *testing.T) {
3333
em := NewEntityMap()
3434
e := em.PutEmpty("service")
3535

36-
idAttrs := e.IDAttributes()
36+
idAttrs := e.IdentifyingAttributes()
3737
idAttrs.PutStr("key1", "value1")
3838

39-
val, ok := e.IDAttributes().Get("key1")
39+
val, ok := e.IdentifyingAttributes().Get("key1")
4040
assert.True(t, ok)
4141
assert.Equal(t, "value1", val.Str())
4242
}
4343

44-
func TestEntity_DescriptionAttributes(t *testing.T) {
44+
func TestEntity_DescriptiveAttributes(t *testing.T) {
4545
em := NewEntityMap()
4646
e := em.PutEmpty("service")
4747

48-
descAttrs := e.DescriptionAttributes()
48+
descAttrs := e.DescriptiveAttributes()
4949
descAttrs.PutStr("key1", "value1")
5050

51-
val, ok := e.DescriptionAttributes().Get("key1")
51+
val, ok := e.DescriptiveAttributes().Get("key1")
5252
assert.True(t, ok)
5353
assert.Equal(t, "value1", val.Str())
5454
}
@@ -57,40 +57,40 @@ func TestEntity_IdAndDescriptionAttributes_Isolated(t *testing.T) {
5757
em := NewEntityMap()
5858
e := em.PutEmpty("service")
5959

60-
e.IDAttributes().PutStr("id.key", "id-value")
61-
e.DescriptionAttributes().PutStr("desc.key", "desc-value")
60+
e.IdentifyingAttributes().PutStr("id.key", "id-value")
61+
e.DescriptiveAttributes().PutStr("desc.key", "desc-value")
6262

63-
val, ok := e.IDAttributes().Get("id.key")
63+
val, ok := e.IdentifyingAttributes().Get("id.key")
6464
assert.True(t, ok)
6565
assert.Equal(t, "id-value", val.Str())
6666

67-
_, ok = e.IDAttributes().Get("desc.key")
67+
_, ok = e.IdentifyingAttributes().Get("desc.key")
6868
assert.False(t, ok)
6969

70-
val, ok = e.DescriptionAttributes().Get("desc.key")
70+
val, ok = e.DescriptiveAttributes().Get("desc.key")
7171
assert.True(t, ok)
7272
assert.Equal(t, "desc-value", val.Str())
7373

74-
_, ok = e.DescriptionAttributes().Get("id.key")
74+
_, ok = e.DescriptiveAttributes().Get("id.key")
7575
assert.False(t, ok)
7676
}
7777

7878
func TestEntity_IdAndDescriptionAttributes_CanPut(t *testing.T) {
7979
em := NewEntityMap()
8080
e := em.PutEmpty("service")
8181

82-
e.IDAttributes().PutStr("shared.key", "id-value")
82+
e.IdentifyingAttributes().PutStr("shared.key", "id-value")
8383

84-
assert.True(t, e.IDAttributes().CanPut("shared.key"))
85-
assert.False(t, e.DescriptionAttributes().CanPut("shared.key"))
84+
assert.True(t, e.IdentifyingAttributes().CanPut("shared.key"))
85+
assert.False(t, e.DescriptiveAttributes().CanPut("shared.key"))
8686

87-
e.DescriptionAttributes().PutStr("shared.key", "desc-value")
87+
e.DescriptiveAttributes().PutStr("shared.key", "desc-value")
8888

89-
val, ok := e.IDAttributes().Get("shared.key")
89+
val, ok := e.IdentifyingAttributes().Get("shared.key")
9090
assert.True(t, ok)
9191
assert.Equal(t, "desc-value", val.Str())
9292

93-
val, ok = e.DescriptionAttributes().Get("shared.key")
93+
val, ok = e.DescriptiveAttributes().Get("shared.key")
9494
assert.True(t, ok)
9595
assert.Equal(t, "desc-value", val.Str())
9696
}

0 commit comments

Comments
 (0)