Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions receiver/jaegerreceiver/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ receivers:
grpc:
remote_sampling:
strategy_file: "/etc/strategy.json"
strategy_file_reload_interval: 10s
```

Note: the `grpc` protocol must be enabled for this to work as Jaeger serves its
Expand Down
10 changes: 8 additions & 2 deletions receiver/jaegerreceiver/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package jaegerreceiver // import "github.com/open-telemetry/opentelemetry-collec

import (
"fmt"
"time"

"go.opentelemetry.io/collector/config"
"go.opentelemetry.io/collector/config/configgrpc"
Expand All @@ -35,8 +36,9 @@ const (

// RemoteSamplingConfig defines config key for remote sampling fetch endpoint
type RemoteSamplingConfig struct {
HostEndpoint string `mapstructure:"host_endpoint"`
StrategyFile string `mapstructure:"strategy_file"`
HostEndpoint string `mapstructure:"host_endpoint"`
StrategyFile string `mapstructure:"strategy_file"`
StrategyFileReloadInterval time.Duration `mapstructure:"strategy_file_reload_interval"`
configgrpc.GRPCClientSettings `mapstructure:",squash"`
}

Expand Down Expand Up @@ -125,6 +127,10 @@ func (cfg *Config) Validate() error {
if len(cfg.RemoteSampling.StrategyFile) != 0 && grpcPort == 0 {
return fmt.Errorf("strategy file requires the gRPC protocol to be enabled")
}

if cfg.RemoteSampling.StrategyFileReloadInterval < 0 {
return fmt.Errorf("strategy file reload interval should be great or equal zero")
}
}

return nil
Expand Down
21 changes: 20 additions & 1 deletion receiver/jaegerreceiver/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package jaegerreceiver
import (
"path"
"testing"
"time"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -80,7 +81,8 @@ func TestLoadConfig(t *testing.T) {
GRPCClientSettings: configgrpc.GRPCClientSettings{
Endpoint: "jaeger-collector:1234",
},
StrategyFile: "/etc/strategies.json",
StrategyFile: "/etc/strategies.json",
StrategyFileReloadInterval: time.Second * 10,
},
})

Expand Down Expand Up @@ -255,6 +257,23 @@ func TestInvalidConfig(t *testing.T) {
},
err: "receiver creation without gRPC and with remote sampling config",
},
{
desc: "reload-interval-outside-of-range",
apply: func(cfg *Config) {
cfg.Protocols.GRPC = &configgrpc.GRPCServerSettings{
NetAddr: confignet.NetAddr{
Endpoint: "1234",
Transport: "tcp",
},
}
cfg.RemoteSampling = &RemoteSamplingConfig{
HostEndpoint: "localhost:5778",
StrategyFile: "strategies.json",
StrategyFileReloadInterval: -time.Second,
}
},
err: "strategy file reload interval should be great zero",
},
}
for _, tC := range testCases {
t.Run(tC.desc, func(t *testing.T) {
Expand Down
1 change: 1 addition & 0 deletions receiver/jaegerreceiver/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ func createTracesReceiver(
// strategies are served over grpc so if grpc is not enabled and strategies are present return an error
if len(remoteSamplingConfig.StrategyFile) != 0 {
config.RemoteSamplingStrategyFile = remoteSamplingConfig.StrategyFile
config.RemoteSamplingStrategyFileReloadInterval = remoteSamplingConfig.StrategyFileReloadInterval
}
}

Expand Down
1 change: 1 addition & 0 deletions receiver/jaegerreceiver/testdata/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ receivers:
host_endpoint: "0.0.0.0:5778"
endpoint: "jaeger-collector:1234"
strategy_file: "/etc/strategies.json"
strategy_file_reload_interval: 10s
# The following demonstrates how to enable protocols with defaults.
jaeger/defaults:
protocols:
Expand Down
17 changes: 10 additions & 7 deletions receiver/jaegerreceiver/trace_receiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"net"
"net/http"
"sync"
"time"

apacheThrift "github.com/apache/thrift/lib/go/thrift"
"github.com/gorilla/mux"
Expand Down Expand Up @@ -65,13 +66,14 @@ type configuration struct {
CollectorGRPCPort int
CollectorGRPCServerSettings configgrpc.GRPCServerSettings

AgentCompactThriftPort int
AgentCompactThriftConfig ServerConfigUDP
AgentBinaryThriftPort int
AgentBinaryThriftConfig ServerConfigUDP
AgentHTTPPort int
RemoteSamplingClientSettings configgrpc.GRPCClientSettings
RemoteSamplingStrategyFile string
AgentCompactThriftPort int
AgentCompactThriftConfig ServerConfigUDP
AgentBinaryThriftPort int
AgentBinaryThriftConfig ServerConfigUDP
AgentHTTPPort int
RemoteSamplingClientSettings configgrpc.GRPCClientSettings
RemoteSamplingStrategyFile string
RemoteSamplingStrategyFileReloadInterval time.Duration
}

// Receiver type is used to receive spans that were originally intended to be sent to Jaeger.
Expand Down Expand Up @@ -484,6 +486,7 @@ func (jr *jReceiver) startCollector(host component.Host) error {
// init and register sampling strategy store
ss, gerr := staticStrategyStore.NewStrategyStore(staticStrategyStore.Options{
StrategiesFile: jr.config.RemoteSamplingStrategyFile,
ReloadInterval: jr.config.RemoteSamplingStrategyFileReloadInterval,
}, jr.settings.Logger)
if gerr != nil {
return fmt.Errorf("failed to create collector strategy store: %v", gerr)
Expand Down