Skip to content

Commit dc9a838

Browse files
authored
Change size and capacity to explicit int64 (#12076)
Signed-off-by: Bogdan Drutu <[email protected]>
1 parent 7f4664e commit dc9a838

File tree

9 files changed

+95
-70
lines changed

9 files changed

+95
-70
lines changed

.chloggen/mv-int64.yaml

+25
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: breaking
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver)
7+
component: exporterqueue
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: Change Queue Size and Capacity to return explicit int64.
11+
12+
# One or more tracking issues or pull requests related to the change
13+
issues: [12076]
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]

exporter/exporterhelper/internal/queue_sender.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ func (qs *QueueSender) Start(ctx context.Context, host component.Host) error {
131131

132132
dataTypeAttr := attribute.String(DataTypeKey, qs.obsrep.Signal.String())
133133

134-
reg1, err1 := qs.obsrep.TelemetryBuilder.InitExporterQueueSize(func() int64 { return int64(qs.queue.Size()) },
134+
reg1, err1 := qs.obsrep.TelemetryBuilder.InitExporterQueueSize(func() int64 { return qs.queue.Size() },
135135
metric.WithAttributeSet(attribute.NewSet(qs.traceAttribute, dataTypeAttr)))
136136

137137
if reg1 != nil {
@@ -140,7 +140,7 @@ func (qs *QueueSender) Start(ctx context.Context, host component.Host) error {
140140
})
141141
}
142142

143-
reg2, err2 := qs.obsrep.TelemetryBuilder.InitExporterQueueCapacity(func() int64 { return int64(qs.queue.Capacity()) },
143+
reg2, err2 := qs.obsrep.TelemetryBuilder.InitExporterQueueCapacity(func() int64 { return qs.queue.Capacity() },
144144
metric.WithAttributeSet(attribute.NewSet(qs.traceAttribute)))
145145

146146
if reg2 != nil {

exporter/exporterhelper/internal/queue_sender_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ func TestQueuedRetry_StopWhileWaiting(t *testing.T) {
5454
require.NoError(t, be.Send(context.Background(), secondMockR))
5555
})
5656

57-
require.LessOrEqual(t, 1, be.QueueSender.(*QueueSender).queue.Size())
57+
require.LessOrEqual(t, int64(1), be.QueueSender.(*QueueSender).queue.Size())
5858

5959
require.NoError(t, be.Shutdown(context.Background()))
6060

exporter/exporterqueue/bounded_memory_queue_test.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,15 @@ func TestBoundedQueue(t *testing.T) {
3535
return nil
3636
}))
3737
assert.Equal(t, 1, numConsumed)
38-
assert.Equal(t, 0, q.Size())
38+
assert.Equal(t, int64(0), q.Size())
3939

4040
// produce two more items. The first one should be accepted, but not consumed.
4141
require.NoError(t, q.Offer(context.Background(), "b"))
42-
assert.Equal(t, 1, q.Size())
42+
assert.Equal(t, int64(1), q.Size())
4343

4444
// the second should be rejected since the queue is full
4545
require.ErrorIs(t, q.Offer(context.Background(), "c"), ErrQueueIsFull)
46-
assert.Equal(t, 1, q.Size())
46+
assert.Equal(t, int64(1), q.Size())
4747

4848
assert.True(t, consume(q, func(_ context.Context, item string) error {
4949
assert.Equal(t, "b", item)
@@ -82,7 +82,7 @@ func TestShutdownWhileNotEmpty(t *testing.T) {
8282
}
8383
assert.NoError(t, q.Shutdown(context.Background()))
8484

85-
assert.Equal(t, 10, q.Size())
85+
assert.Equal(t, int64(10), q.Size())
8686
numConsumed := 0
8787
for i := 0; i < 10; i++ {
8888
assert.True(t, consume(q, func(_ context.Context, item string) error {
@@ -92,7 +92,7 @@ func TestShutdownWhileNotEmpty(t *testing.T) {
9292
}))
9393
}
9494
assert.Equal(t, 10, numConsumed)
95-
assert.Equal(t, 0, q.Size())
95+
assert.Equal(t, int64(0), q.Size())
9696

9797
assert.False(t, consume(q, func(_ context.Context, item string) error {
9898
panic(item)

exporter/exporterqueue/persistent_queue.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -112,14 +112,14 @@ func (pq *persistentQueue[T]) Start(ctx context.Context, host component.Host) er
112112
return nil
113113
}
114114

115-
func (pq *persistentQueue[T]) Size() int {
115+
func (pq *persistentQueue[T]) Size() int64 {
116116
pq.mu.Lock()
117117
defer pq.mu.Unlock()
118-
return int(pq.queueSize)
118+
return pq.queueSize
119119
}
120120

121-
func (pq *persistentQueue[T]) Capacity() int {
122-
return int(pq.set.capacity)
121+
func (pq *persistentQueue[T]) Capacity() int64 {
122+
return pq.set.capacity
123123
}
124124

125125
func (pq *persistentQueue[T]) initClient(ctx context.Context, client storage.Client) {

0 commit comments

Comments
 (0)