Skip to content

Commit

Permalink
Don't accept routing keys for metrics.
Browse files Browse the repository at this point in the history
  • Loading branch information
ptodev committed Oct 24, 2023
1 parent a0c6230 commit b8c543b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 14 deletions.
18 changes: 18 additions & 0 deletions component/otelcol/exporter/loadbalancing/loadbalancing.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
package loadbalancing

import (
"fmt"
"time"

"github.com/alecthomas/units"
Expand Down Expand Up @@ -48,6 +49,7 @@ type Arguments struct {
var (
_ exporter.Arguments = Arguments{}
_ river.Defaulter = &Arguments{}
_ river.Validator = &Arguments{}
)

var (
Expand All @@ -72,6 +74,22 @@ func (args *Arguments) SetToDefault() {
*args = DefaultArguments
}

// Validate implements river.Validator.
func (args *Arguments) Validate() error {
//TODO(ptodev): Add support for "resource" and "metric" routing keys later.
// The reason we can't add them yet is that otelcol.exporter.loadbalancing
// is labeled as "beta", but those routing keys are experimental.
// We need a way to label otelcol.exporter.loadbalancing as "beta"
// for logs and traces, but "experimental" for metrics.
switch args.RoutingKey {
case "service", "traceID":
// The routing key is valid.
default:
return fmt.Errorf("invalid routing key %q", args.RoutingKey)
}
return nil
}

// Convert implements exporter.Arguments.
func (args Arguments) Convert() (otelcomponent.Config, error) {
return &loadbalancingexporter.Config{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,20 +65,10 @@ Name | Type | Description | Default | Required
`routing_key` | `string` | Routing strategy for load balancing. | `"traceID"` | no

The `routing_key` attribute determines how to route signals across endpoints. Its value could be one of the following:
* `"service"`:
* Works for logs, spans, and metrics.
* Signals with the same `service.name` will be exported to the same backend.
This is useful when using processors like the span metrics, so all spans for each service are sent to consistent Agent instances
for metric collection. Otherwise, metrics for the same services would be sent to different Agents, making aggregations inaccurate.
* `"traceID"`:
* Works for logs and spans.
* Signals belonging to the same traceID will be exported to the same backend.
* `"resource"`:
* Works for metrics.
* Signals with the same metric name and the same resource attributes will be exported to the same backend.
* `"metric"`:
* Works for metrics.
* Signals with the same metric name will be exported to the same backend.
* `"service"`: spans with the same `service.name` will be exported to the same backend.
This is useful when using processors like the span metrics, so all spans for each service are sent to consistent Agent instances
for metric collection. Otherwise, metrics for the same services would be sent to different Agents, making aggregations inaccurate.
* `"traceID"`: spans belonging to the same traceID will be exported to the same backend.

## Blocks

Expand Down

0 comments on commit b8c543b

Please sign in to comment.