Skip to content

Commit

Permalink
[connector/routing] warn if a routing table entry already exists (#31297
Browse files Browse the repository at this point in the history
)

**Description:** <Describe what has changed.>
Based on discussion in #30663, a warning is logged if there are two or
more routing items with the same routing statement.

**Link to tracking Issue:** #30663
  • Loading branch information
kristofgyuracz committed Feb 28, 2024
1 parent 3e176e2 commit aa2a246
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
27 changes: 27 additions & 0 deletions .chloggen/kristofgyuracz-routing-table-warning.yaml
@@ -0,0 +1,27 @@
# Use this changelog template to create an entry for release notes.

# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: enhancement

# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
component: routingconnector

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: "a warning is logged if there are two or more routing items with the same routing statement"

# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
issues: [ 30663 ]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext:

# If your change doesn't affect end users or the exported elements of any package,
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
# Optional: The change log or logs in which this entry should be included.
# e.g. '[user]' or '[user, api]'
# Include 'user' if the change is relevant to end users.
# Include 'api' if there is a change to a library API.
# Default: '[user]'
change_logs: [user]
8 changes: 8 additions & 0 deletions connector/routingconnector/router.go
Expand Up @@ -6,6 +6,7 @@ package routingconnector // import "github.com/open-telemetry/opentelemetry-coll
import (
"errors"
"fmt"
"strings"

"go.opentelemetry.io/collector/component"
"go.uber.org/zap"
Expand Down Expand Up @@ -119,6 +120,13 @@ func (r *router[C]) registerRouteConsumers() error {
route, ok := r.routes[key(item)]
if !ok {
route.statement = statement
} else {
pipelineNames := []string{}
for _, pipeline := range item.Pipelines {
pipelineNames = append(pipelineNames, pipeline.String())
}
exporters := strings.Join(pipelineNames, ", ")
r.logger.Warn(fmt.Sprintf(`Statement %q already exists in the routing table, the route with target pipeline(s) %q will be ignored.`, item.Statement, exporters))
}

consumer, err := r.consumerProvider(item.Pipelines...)
Expand Down

0 comments on commit aa2a246

Please sign in to comment.