Skip to content

Commit 7162d31

Browse files
committed
Fix grammatical errors and remove duplicate code in logs_router
This commit addresses several minor issues across the codebase: - connector: Removed duplicate `Consumer` and `PipelineIDs` methods from `logsRouter` that shadowed the embedded `BaseRouter` methods. This also resolves a variable shadowing issue where `var errors error` shadowed the imported `errors` package. - service/internal/graph: Fixed grammatically incorrect error messages in the graph builders that produced strings like "error creating exporter X is not supported". - exporter/exporterhelper: Fixed grammar in queue comments ("consumer don't" to "consumers don't", and "allow distinguish" to "allow distinguishing"). - processor/batchprocessor: Fixed godoc grammar ("batcher is describes").
1 parent 52e6bf4 commit 7162d31

7 files changed

Lines changed: 7 additions & 41 deletions

File tree

connector/logs_router.go

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,6 @@
44
package connector // import "go.opentelemetry.io/collector/connector"
55

66
import (
7-
"errors"
8-
"fmt"
9-
10-
"go.uber.org/multierr"
11-
127
"go.opentelemetry.io/collector/connector/internal"
138
"go.opentelemetry.io/collector/consumer"
149
"go.opentelemetry.io/collector/internal/fanoutconsumer"
@@ -39,33 +34,4 @@ func NewLogsRouter(cm map[pipeline.ID]consumer.Logs) LogsRouterAndConsumer {
3934
}
4035
}
4136

42-
func (r *logsRouter) PipelineIDs() []pipeline.ID {
43-
ids := make([]pipeline.ID, 0, len(r.Consumers))
44-
for id := range r.Consumers {
45-
ids = append(ids, id)
46-
}
47-
return ids
48-
}
49-
50-
func (r *logsRouter) Consumer(pipelineIDs ...pipeline.ID) (consumer.Logs, error) {
51-
if len(pipelineIDs) == 0 {
52-
return nil, errors.New("missing consumers")
53-
}
54-
consumers := make([]consumer.Logs, 0, len(pipelineIDs))
55-
var errors error
56-
for _, pipelineID := range pipelineIDs {
57-
c, ok := r.Consumers[pipelineID]
58-
if ok {
59-
consumers = append(consumers, c)
60-
} else {
61-
errors = multierr.Append(errors, fmt.Errorf("missing consumer: %q", pipelineID))
62-
}
63-
}
64-
if errors != nil {
65-
// TODO potentially this could return a NewLogs with the valid consumers
66-
return nil, errors
67-
}
68-
return fanoutconsumer.NewLogs(consumers), nil
69-
}
70-
7137
func (r *logsRouter) privateFunc() {}

exporter/exporterhelper/internal/queue/memory_queue.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ func (mq *memoryQueue[T]) Read(context.Context) (context.Context, T, Done, bool)
152152
return context.Background(), el, nil, false
153153
}
154154

155-
// TODO: Need to change the Queue interface to return an error to allow distinguish between shutdown and context canceled.
155+
// TODO: Need to change the Queue interface to return an error to allow distinguishing between shutdown and context canceled.
156156
// Until then use the sync.Cond.
157157
mq.hasMoreElements.Wait()
158158
}

exporter/exporterhelper/internal/queue/persistent_queue.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ func (pq *persistentQueue[T]) Shutdown(ctx context.Context) error {
250250

251251
pq.mu.Lock()
252252
defer pq.mu.Unlock()
253-
// Mark this queue as stopped, so consumer don't start any more work.
253+
// Mark this queue as stopped, so consumers don't start any more work.
254254
pq.stopped = true
255255
pq.hasMoreElements.Broadcast()
256256
return pq.unrefClient(ctx)
@@ -345,7 +345,7 @@ func (pq *persistentQueue[T]) Read(ctx context.Context) (context.Context, T, Don
345345
pq.hasMoreSpace.Signal()
346346
}
347347

348-
// TODO: Need to change the Queue interface to return an error to allow distinguish between shutdown and context canceled.
348+
// TODO: Need to change the Queue interface to return an error to allow distinguishing between shutdown and context canceled.
349349
// Until then use the sync.Cond.
350350
pq.hasMoreElements.Wait()
351351
}

processor/batchprocessor/batch_processor.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ type batchProcessor[T any] struct {
5757
batcher batcher[T]
5858
}
5959

60-
// batcher is describes a *singletonBatcher or *multiBatcher.
60+
// batcher describes a *singletonBatcher or *multiBatcher.
6161
type batcher[T any] interface {
6262
// start initializes background resources used by this batcher.
6363
start(ctx context.Context) error

service/internal/graph/exporter.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ func (n *exporterNode) buildComponent(
9898
n.consumer = obsconsumer.NewProfiles(n.Component.(xconsumer.Profiles), consumedSettings)
9999
n.consumer = refconsumer.NewProfiles(n.consumer.(xconsumer.Profiles))
100100
default:
101-
return fmt.Errorf("error creating exporter %q for data type %q is not supported", set.ID, n.pipelineType)
101+
return fmt.Errorf("failed to create exporter %q: data type %q is not supported", set.ID, n.pipelineType)
102102
}
103103
return nil
104104
}

service/internal/graph/processor.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ func (n *processorNode) buildComponent(ctx context.Context,
108108
n.consumer = obsconsumer.NewProfiles(n.Component.(xconsumer.Profiles), consumedSettings)
109109
n.consumer = refconsumer.NewProfiles(n.consumer.(xconsumer.Profiles))
110110
default:
111-
return fmt.Errorf("error creating processor %q in pipeline %q, data type %q is not supported", set.ID, n.pipelineID.String(), n.pipelineID.Signal())
111+
return fmt.Errorf("failed to create processor %q in pipeline %q: data type %q is not supported", set.ID, n.pipelineID.String(), n.pipelineID.Signal())
112112
}
113113
return nil
114114
}

service/internal/graph/receiver.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ func (n *receiverNode) buildComponent(ctx context.Context,
9292
n.Component, err = builder.CreateProfiles(ctx, set,
9393
obsconsumer.NewProfiles(fanoutconsumer.NewProfiles(consumers), producedSettings))
9494
default:
95-
return fmt.Errorf("error creating receiver %q for data type %q is not supported", set.ID, n.pipelineType)
95+
return fmt.Errorf("failed to create receiver %q: data type %q is not supported", set.ID, n.pipelineType)
9696
}
9797
if err != nil {
9898
return fmt.Errorf("failed to create %q receiver for data type %q: %w", set.ID, n.pipelineType, err)

0 commit comments

Comments
 (0)