Skip to content

Commit

Permalink
Update file_config to honor GRPCServerParameters.Enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
TylerHelmuth committed Jul 7, 2023
1 parent 5c30fbf commit 9a04507
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 11 deletions.
4 changes: 3 additions & 1 deletion config.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Honeycomb Refinery Configuration Documentation

This is the documentation for the configuration file for Honeycomb's Refinery.
It was automatically generated on 2023-06-28 at 21:40:58 UTC.
It was automatically generated on 2023-07-07 at 17:45:03 UTC.

## The Config file

Expand Down Expand Up @@ -885,6 +885,7 @@ If `false`, then the gRPC server is not started and no gRPC traffic is accepted.

- Not eligible for live reload.
- Type: `bool`
- Default: `true`

### `ListenAddr`

Expand All @@ -894,6 +895,7 @@ Incoming traffic is expected to be unencrypted, so if using SSL, then put someth

- Not eligible for live reload.
- Type: `hostport`
- Default: `0.0.0.0:4317`
- Environment variable: `REFINERY_GRPC_LISTEN_ADDRESS`
- Command line switch: `--grpc-listen-address`

Expand Down
3 changes: 3 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ type Config interface {
// data before forwarding it to a peer.
GetCompressPeerCommunication() bool

// GetGRPCEnabled returns or not the GRPC server is enabled.
GetGRPCEnabled() bool

// GetGRPCListenAddr returns the address and port on which to listen for
// incoming events over gRPC
GetGRPCListenAddr() (string, error)
Expand Down
6 changes: 6 additions & 0 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,8 @@ func TestGRPCServerParameters(t *testing.T) {
"GRPCServerParameters.MaxConnectionAgeGrace", "3m",
"GRPCServerParameters.KeepAlive", "4m",
"GRPCServerParameters.KeepAliveTimeout", "5m",
"GRPCServerParameters.ListenAddr", "localhost:4317",
"GRPCServerParameters.Enabled", true,
)
rm := makeYAML("ConfigVersion", 2)
config, rules := createTempConfigs(t, cm, rm)
Expand All @@ -611,6 +613,10 @@ func TestGRPCServerParameters(t *testing.T) {
assert.Equal(t, 3*time.Minute, c.GetGRPCMaxConnectionAgeGrace())
assert.Equal(t, 4*time.Minute, c.GetGRPCKeepAlive())
assert.Equal(t, 5*time.Minute, c.GetGRPCKeepAliveTimeout())
assert.Equal(t, true, c.GetGRPCEnabled())
addr, err := c.GetGRPCListenAddr()
assert.NoError(t, err)
assert.Equal(t, "localhost:4317", addr)
}

func TestHoneycombAdditionalErrorConfig(t *testing.T) {
Expand Down
8 changes: 7 additions & 1 deletion config/file_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ type IDFieldsConfig struct {
// by refinery's own GRPC server:
// https://pkg.go.dev/google.golang.org/grpc/keepalive#ServerParameters
type GRPCServerParameters struct {
Enabled bool `yaml:"Enabled"`
Enabled bool `yaml:"Enabled" default:"true"`
ListenAddr string `yaml:"ListenAddr" cmdenv:"GRPCListenAddr"`
MaxConnectionIdle Duration `yaml:"MaxConnectionIdle" default:"1m"`
MaxConnectionAge Duration `yaml:"MaxConnectionAge" default:"3m"`
Expand Down Expand Up @@ -456,6 +456,12 @@ func (f *fileConfig) GetCompressPeerCommunication() bool {
return f.mainConfig.Specialized.CompressPeerCommunication
}

func (f *fileConfig) GetGRPCEnabled() bool {
f.mux.RLock()
defer f.mux.RUnlock()
return f.mainConfig.GRPCServerParameters.Enabled
}

func (f *fileConfig) GetGRPCListenAddr() (string, error) {
f.mux.RLock()
defer f.mux.RUnlock()
Expand Down
4 changes: 2 additions & 2 deletions config/metadata/configMeta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1128,7 +1128,7 @@ groups:
- name: Enabled
type: bool
valuetype: nondefault
default: false
default: true
reload: false
summary: specifies whether the gRPC server is enabled.
description: >
Expand All @@ -1139,7 +1139,7 @@ groups:
v1name: GRPCListenAddr
type: hostport
valuetype: nondefault
default: ""
default: "0.0.0.0:4317"
reload: false
envvar: REFINERY_GRPC_LISTEN_ADDRESS
commandLine: grpc-listen-address
Expand Down
2 changes: 2 additions & 0 deletions refinery_config.md
Original file line number Diff line number Diff line change
Expand Up @@ -871,6 +871,7 @@ If `false`, then the gRPC server is not started and no gRPC traffic is accepted.

- Not eligible for live reload.
- Type: `bool`
- Default: `true`

### `ListenAddr`

Expand All @@ -880,6 +881,7 @@ Incoming traffic is expected to be unencrypted, so if using SSL, then put someth

- Not eligible for live reload.
- Type: `hostport`
- Default: `0.0.0.0:4317`
- Environment variable: `REFINERY_GRPC_LISTEN_ADDRESS`
- Command line switch: `--grpc-listen-address`

Expand Down
2 changes: 1 addition & 1 deletion refinery_rules.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ The sample rate is calculated from the trace ID, so all spans with the same trac

The duration after which the Dynamic Sampler should reset its internal counters.
It should be specified as a duration string.
For example, "30s" or "1m".
For example,"30s" or "1m".

- Type: `duration`

Expand Down
2 changes: 1 addition & 1 deletion route/route.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ func (r *Router) LnS(incomingOrPeer string) {
Handler: muxxer,
}

if len(grpcAddr) > 0 {
if r.Config.GetGRPCEnabled() && len(grpcAddr) > 0 {
l, err := net.Listen("tcp", grpcAddr)
if err != nil {
r.iopLogger.Error().Logf("failed to listen to grpc addr: " + grpcAddr)
Expand Down
2 changes: 1 addition & 1 deletion rules.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Honeycomb Refinery Rules Documentation

This is the documentation for the rules configuration for Honeycomb's Refinery.
It was automatically generated on 2023-06-28 at 21:40:58 UTC.
It was automatically generated on 2023-07-07 at 17:45:03 UTC.

## The Rules file

Expand Down
10 changes: 6 additions & 4 deletions tools/convert/templates/configV2.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
## Honeycomb Refinery Configuration ##
######################################
#
# created {{ now }} from {{ .Input }} using a template generated on 2023-06-28 at 21:40:56 UTC
# created {{ now }} from {{ .Input }} using a template generated on 2023-07-07 at 17:45:01 UTC

# This file contains a configuration for the Honeycomb Refinery. It is in YAML
# format, organized into named groups, each of which contains a set of
Expand Down Expand Up @@ -900,18 +900,20 @@ GRPCServerParameters:
## If `false`, then the gRPC server is not started and no gRPC traffic is
## accepted.
##
## default: true
## Not eligible for live reload.
{{ nonDefaultOnly .Data "Enabled" "Enabled" false }}
{{ nonDefaultOnly .Data "Enabled" "Enabled" true }}

## ListenAddr is the address Refinery listens to for incoming GRPC
## OpenTelemetry events.
##
## Incoming traffic is expected to be unencrypted, so if using SSL, then
## put something like `nginx` in front to do the decryption.
##
## Should be an ip:port like "".
## Should be an ip:port like "0.0.0.0:4317".
## default: 0.0.0.0:4317
## Not eligible for live reload.
{{ nonDefaultOnly .Data "ListenAddr" "GRPCListenAddr" "" }}
{{ nonDefaultOnly .Data "ListenAddr" "GRPCListenAddr" "0.0.0.0:4317" }}

## MaxConnectionIdle is the amount of time to permit an idle connection.
##
Expand Down

0 comments on commit 9a04507

Please sign in to comment.