Skip to content

Commit e69f2f3

Browse files
authored
[componentstatus] Continue DataType rename (#11313)
#### Description Continues the DataType rename process for `NewInstanceIDWithPipelineIDs`, `AllPipelineIDsWithPipelineIDs`, and `WithPipelineIDs`. #### Link to tracking issue Related to #9429
1 parent 597afa8 commit e69f2f3

File tree

7 files changed

+66
-80
lines changed

7 files changed

+66
-80
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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: deprecation
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver)
7+
component: componentstatus
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: Deprecated `NewInstanceIDWithPipelineIDs`, `AllPipelineIDsWithPipelineIDs`, and `WithPipelineIDs`. Use `NewInstanceID`, `AllPipelineIDs`, and `WithPipelines` instead.
11+
12+
# One or more tracking issues or pull requests related to the change
13+
issues: [11313]
14+
15+
# (Optional) One or more lines of additional information to render under the primary note.
16+
# These lines will be padded with 2 spaces and then inserted directly into the document.
17+
# Use pipe (|) for multiline entries.
18+
subtext:
19+
20+
# Optional: The change log or logs in which this entry should be included.
21+
# e.g. '[user]' or '[user, api]'
22+
# Include 'user' if the change is relevant to end users.
23+
# Include 'api' if there is a change to a library API.
24+
# Default: '[user]'
25+
change_logs: [api]

component/componentstatus/instance.go

Lines changed: 15 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -27,25 +27,20 @@ type InstanceID struct {
2727
}
2828

2929
// NewInstanceID returns an ID that uniquely identifies a component.
30-
//
31-
// Deprecated: [v0.110.0] Use NewInstanceIDWithPipelineID instead
32-
func NewInstanceID(componentID component.ID, kind component.Kind, pipelineIDs ...component.ID) *InstanceID {
30+
func NewInstanceID(componentID component.ID, kind component.Kind, pipelineIDs ...pipeline.ID) *InstanceID {
3331
instanceID := &InstanceID{
3432
componentID: componentID,
3533
kind: kind,
3634
}
37-
instanceID.addPipelines(convertToPipelineIDs(pipelineIDs))
35+
instanceID.addPipelines(pipelineIDs)
3836
return instanceID
3937
}
4038

4139
// NewInstanceIDWithPipelineIDs returns an InstanceID that uniquely identifies a component.
40+
//
41+
// Deprecated: [v0.111.0] Use NewInstanceIDWithPipelineID instead
4242
func NewInstanceIDWithPipelineIDs(componentID component.ID, kind component.Kind, pipelineIDs ...pipeline.ID) *InstanceID {
43-
instanceID := &InstanceID{
44-
componentID: componentID,
45-
kind: kind,
46-
}
47-
instanceID.addPipelines(pipelineIDs)
48-
return instanceID
43+
return NewInstanceID(componentID, kind, pipelineIDs...)
4944
}
5045

5146
// ComponentID returns the ComponentID associated with this instance.
@@ -60,16 +55,14 @@ func (id *InstanceID) Kind() component.Kind {
6055

6156
// AllPipelineIDs calls f for each pipeline this instance is associated with. If
6257
// f returns false it will stop iteration.
63-
//
64-
// Deprecated: [v0.110.0] Use AllPipelineIDsWithPipelineIDs instead.
65-
func (id *InstanceID) AllPipelineIDs(f func(component.ID) bool) {
58+
func (id *InstanceID) AllPipelineIDs(f func(pipeline.ID) bool) {
6659
var bs []byte
6760
for _, b := range []byte(id.pipelineIDs) {
6861
if b != pipelineDelim {
6962
bs = append(bs, b)
7063
continue
7164
}
72-
pipelineID := component.ID{}
65+
pipelineID := pipeline.ID{}
7366
err := pipelineID.UnmarshalText(bs)
7467
bs = bs[:0]
7568
if err != nil {
@@ -83,49 +76,30 @@ func (id *InstanceID) AllPipelineIDs(f func(component.ID) bool) {
8376

8477
// AllPipelineIDsWithPipelineIDs calls f for each pipeline this instance is associated with. If
8578
// f returns false it will stop iteration.
79+
//
80+
// Deprecated: [v0.111.0] Use AllPipelineIDs instead.
8681
func (id *InstanceID) AllPipelineIDsWithPipelineIDs(f func(pipeline.ID) bool) {
87-
var bs []byte
88-
for _, b := range []byte(id.pipelineIDs) {
89-
if b != pipelineDelim {
90-
bs = append(bs, b)
91-
continue
92-
}
93-
pipelineID := pipeline.ID{}
94-
err := pipelineID.UnmarshalText(bs)
95-
bs = bs[:0]
96-
if err != nil {
97-
continue
98-
}
99-
if !f(pipelineID) {
100-
break
101-
}
102-
}
82+
id.AllPipelineIDs(f)
10383
}
10484

10585
// WithPipelines returns a new InstanceID updated to include the given
10686
// pipelineIDs.
107-
//
108-
// Deprecated: [v0.110.0] Use WithPipelineIDs instead
109-
func (id *InstanceID) WithPipelines(pipelineIDs ...component.ID) *InstanceID {
87+
func (id *InstanceID) WithPipelines(pipelineIDs ...pipeline.ID) *InstanceID {
11088
instanceID := &InstanceID{
11189
componentID: id.componentID,
11290
kind: id.kind,
11391
pipelineIDs: id.pipelineIDs,
11492
}
115-
instanceID.addPipelines(convertToPipelineIDs(pipelineIDs))
93+
instanceID.addPipelines(pipelineIDs)
11694
return instanceID
11795
}
11896

11997
// WithPipelineIDs returns a new InstanceID updated to include the given
12098
// pipelineIDs.
99+
//
100+
// Deprecated: [v0.111.0] Use WithPipelines instead
121101
func (id *InstanceID) WithPipelineIDs(pipelineIDs ...pipeline.ID) *InstanceID {
122-
instanceID := &InstanceID{
123-
componentID: id.componentID,
124-
kind: id.kind,
125-
pipelineIDs: id.pipelineIDs,
126-
}
127-
instanceID.addPipelines(pipelineIDs)
128-
return instanceID
102+
return id.WithPipelines(pipelineIDs...)
129103
}
130104

131105
func (id *InstanceID) addPipelines(pipelineIDs []pipeline.ID) {
@@ -138,16 +112,3 @@ func (id *InstanceID) addPipelines(pipelineIDs []pipeline.ID) {
138112
strIDs = slices.Compact(strIDs)
139113
id.pipelineIDs = strings.Join(strIDs, delim) + delim
140114
}
141-
142-
func convertToPipelineIDs(ids []component.ID) []pipeline.ID {
143-
pipelineIDs := make([]pipeline.ID, len(ids))
144-
for i, id := range ids {
145-
if id.Name() != "" {
146-
pipelineIDs[i] = pipeline.MustNewIDWithName(id.Type().String(), id.Name())
147-
} else {
148-
pipelineIDs[i] = pipeline.MustNewID(id.Type().String())
149-
}
150-
151-
}
152-
return pipelineIDs
153-
}

component/componentstatus/instance_test.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ func TestInstanceID(t *testing.T) {
1818
tracesB := pipeline.MustNewIDWithName("traces", "b")
1919
tracesC := pipeline.MustNewIDWithName("traces", "c")
2020

21-
idTracesA := NewInstanceIDWithPipelineIDs(traces, component.KindReceiver, tracesA)
22-
idTracesAll := NewInstanceIDWithPipelineIDs(traces, component.KindReceiver, tracesA, tracesB, tracesC)
21+
idTracesA := NewInstanceID(traces, component.KindReceiver, tracesA)
22+
idTracesAll := NewInstanceID(traces, component.KindReceiver, tracesA, tracesB, tracesC)
2323
assert.NotEqual(t, idTracesA, idTracesAll)
2424

2525
assertHasPipelines := func(t *testing.T, instanceID *InstanceID, expectedPipelineIDs []pipeline.ID) {
2626
var pipelineIDs []pipeline.ID
27-
instanceID.AllPipelineIDsWithPipelineIDs(func(id pipeline.ID) bool {
27+
instanceID.AllPipelineIDs(func(id pipeline.ID) bool {
2828
pipelineIDs = append(pipelineIDs, id)
2929
return true
3030
})
@@ -40,25 +40,25 @@ func TestInstanceID(t *testing.T) {
4040
{
4141
name: "equal instances",
4242
id1: idTracesA,
43-
id2: NewInstanceIDWithPipelineIDs(traces, component.KindReceiver, tracesA),
43+
id2: NewInstanceID(traces, component.KindReceiver, tracesA),
4444
pipelineIDs: []pipeline.ID{tracesA},
4545
},
4646
{
4747
name: "equal instances - out of order",
4848
id1: idTracesAll,
49-
id2: NewInstanceIDWithPipelineIDs(traces, component.KindReceiver, tracesC, tracesB, tracesA),
49+
id2: NewInstanceID(traces, component.KindReceiver, tracesC, tracesB, tracesA),
5050
pipelineIDs: []pipeline.ID{tracesA, tracesB, tracesC},
5151
},
5252
{
5353
name: "with pipelines",
5454
id1: idTracesAll,
55-
id2: idTracesA.WithPipelineIDs(tracesB, tracesC),
55+
id2: idTracesA.WithPipelines(tracesB, tracesC),
5656
pipelineIDs: []pipeline.ID{tracesA, tracesB, tracesC},
5757
},
5858
{
5959
name: "with pipelines - out of order",
6060
id1: idTracesAll,
61-
id2: idTracesA.WithPipelineIDs(tracesC, tracesB),
61+
id2: idTracesA.WithPipelines(tracesC, tracesB),
6262
pipelineIDs: []pipeline.ID{tracesA, tracesB, tracesC},
6363
},
6464
} {
@@ -70,8 +70,8 @@ func TestInstanceID(t *testing.T) {
7070
}
7171
}
7272

73-
func TestAllPipelineIDsWithPipelineIDs(t *testing.T) {
74-
instanceID := NewInstanceIDWithPipelineIDs(
73+
func TestAllPipelineIDs(t *testing.T) {
74+
instanceID := NewInstanceID(
7575
component.MustNewID("traces"),
7676
component.KindReceiver,
7777
pipeline.MustNewIDWithName("traces", "a"),
@@ -80,14 +80,14 @@ func TestAllPipelineIDsWithPipelineIDs(t *testing.T) {
8080
)
8181

8282
count := 0
83-
instanceID.AllPipelineIDsWithPipelineIDs(func(pipeline.ID) bool {
83+
instanceID.AllPipelineIDs(func(pipeline.ID) bool {
8484
count++
8585
return true
8686
})
8787
assert.Equal(t, 3, count)
8888

8989
count = 0
90-
instanceID.AllPipelineIDsWithPipelineIDs(func(pipeline.ID) bool {
90+
instanceID.AllPipelineIDs(func(pipeline.ID) bool {
9191
count++
9292
return false
9393
})

internal/e2e/status_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ func Test_ComponentStatusReporting_SharedInstance(t *testing.T) {
128128

129129
for instanceID, events := range eventsReceived {
130130
pipelineIDs := ""
131-
instanceID.AllPipelineIDsWithPipelineIDs(func(id pipeline.ID) bool {
131+
instanceID.AllPipelineIDs(func(id pipeline.ID) bool {
132132
pipelineIDs += id.String() + ","
133133
return true
134134
})

service/extensions/extensions.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ func New(ctx context.Context, set Settings, cfg Config, options ...Option) (*Ext
209209
}
210210

211211
for _, extID := range cfg {
212-
instanceID := componentstatus.NewInstanceIDWithPipelineIDs(extID, component.KindExtension)
212+
instanceID := componentstatus.NewInstanceID(extID, component.KindExtension)
213213
extSet := extension.Settings{
214214
ID: extID,
215215
TelemetrySettings: set.Telemetry,

service/internal/graph/graph.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -200,11 +200,11 @@ func (g *Graph) createReceiver(pipelineID pipeline.ID, recvID component.ID) *rec
200200
rcvrNode := newReceiverNode(pipelineID.Signal(), recvID)
201201
if node := g.componentGraph.Node(rcvrNode.ID()); node != nil {
202202
instanceID := g.instanceIDs[node.ID()]
203-
g.instanceIDs[node.ID()] = instanceID.WithPipelineIDs(pipelineID)
203+
g.instanceIDs[node.ID()] = instanceID.WithPipelines(pipelineID)
204204
return node.(*receiverNode)
205205
}
206206
g.componentGraph.AddNode(rcvrNode)
207-
g.instanceIDs[rcvrNode.ID()] = componentstatus.NewInstanceIDWithPipelineIDs(
207+
g.instanceIDs[rcvrNode.ID()] = componentstatus.NewInstanceID(
208208
recvID, component.KindReceiver, pipelineID,
209209
)
210210
return rcvrNode
@@ -213,7 +213,7 @@ func (g *Graph) createReceiver(pipelineID pipeline.ID, recvID component.ID) *rec
213213
func (g *Graph) createProcessor(pipelineID pipeline.ID, procID component.ID) *processorNode {
214214
procNode := newProcessorNode(pipelineID, procID)
215215
g.componentGraph.AddNode(procNode)
216-
g.instanceIDs[procNode.ID()] = componentstatus.NewInstanceIDWithPipelineIDs(
216+
g.instanceIDs[procNode.ID()] = componentstatus.NewInstanceID(
217217
procID, component.KindProcessor, pipelineID,
218218
)
219219
return procNode
@@ -223,11 +223,11 @@ func (g *Graph) createExporter(pipelineID pipeline.ID, exprID component.ID) *exp
223223
expNode := newExporterNode(pipelineID.Signal(), exprID)
224224
if node := g.componentGraph.Node(expNode.ID()); node != nil {
225225
instanceID := g.instanceIDs[expNode.ID()]
226-
g.instanceIDs[expNode.ID()] = instanceID.WithPipelineIDs(pipelineID)
226+
g.instanceIDs[expNode.ID()] = instanceID.WithPipelines(pipelineID)
227227
return node.(*exporterNode)
228228
}
229229
g.componentGraph.AddNode(expNode)
230-
g.instanceIDs[expNode.ID()] = componentstatus.NewInstanceIDWithPipelineIDs(
230+
g.instanceIDs[expNode.ID()] = componentstatus.NewInstanceID(
231231
expNode.componentID, component.KindExporter, pipelineID,
232232
)
233233
return expNode
@@ -237,11 +237,11 @@ func (g *Graph) createConnector(exprPipelineID, rcvrPipelineID pipeline.ID, conn
237237
connNode := newConnectorNode(exprPipelineID.Signal(), rcvrPipelineID.Signal(), connID)
238238
if node := g.componentGraph.Node(connNode.ID()); node != nil {
239239
instanceID := g.instanceIDs[connNode.ID()]
240-
g.instanceIDs[connNode.ID()] = instanceID.WithPipelineIDs(exprPipelineID, rcvrPipelineID)
240+
g.instanceIDs[connNode.ID()] = instanceID.WithPipelines(exprPipelineID, rcvrPipelineID)
241241
return node.(*connectorNode)
242242
}
243243
g.componentGraph.AddNode(connNode)
244-
g.instanceIDs[connNode.ID()] = componentstatus.NewInstanceIDWithPipelineIDs(
244+
g.instanceIDs[connNode.ID()] = componentstatus.NewInstanceID(
245245
connNode.componentID, component.KindConnector, exprPipelineID, rcvrPipelineID,
246246
)
247247
return connNode

service/internal/graph/graph_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2796,12 +2796,12 @@ func TestStatusReportedOnStartupShutdown(t *testing.T) {
27962796
eSdErr := &testNode{id: component.MustNewIDWithName("e_sd_err", "1"), shutdownErr: assert.AnError}
27972797

27982798
instanceIDs := map[*testNode]*componentstatus.InstanceID{
2799-
rNoErr: componentstatus.NewInstanceIDWithPipelineIDs(rNoErr.id, component.KindReceiver),
2800-
rStErr: componentstatus.NewInstanceIDWithPipelineIDs(rStErr.id, component.KindReceiver),
2801-
rSdErr: componentstatus.NewInstanceIDWithPipelineIDs(rSdErr.id, component.KindReceiver),
2802-
eNoErr: componentstatus.NewInstanceIDWithPipelineIDs(eNoErr.id, component.KindExporter),
2803-
eStErr: componentstatus.NewInstanceIDWithPipelineIDs(eStErr.id, component.KindExporter),
2804-
eSdErr: componentstatus.NewInstanceIDWithPipelineIDs(eSdErr.id, component.KindExporter),
2799+
rNoErr: componentstatus.NewInstanceID(rNoErr.id, component.KindReceiver),
2800+
rStErr: componentstatus.NewInstanceID(rStErr.id, component.KindReceiver),
2801+
rSdErr: componentstatus.NewInstanceID(rSdErr.id, component.KindReceiver),
2802+
eNoErr: componentstatus.NewInstanceID(eNoErr.id, component.KindExporter),
2803+
eStErr: componentstatus.NewInstanceID(eStErr.id, component.KindExporter),
2804+
eSdErr: componentstatus.NewInstanceID(eSdErr.id, component.KindExporter),
28052805
}
28062806

28072807
// compare two maps of status events ignoring timestamp

0 commit comments

Comments
 (0)