Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix!: change the instrumentation config to circumvent viper bug #1144

Merged
merged 8 commits into from
Dec 4, 2023
Merged
Show file tree
Hide file tree
Changes from 3 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
6 changes: 4 additions & 2 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -1202,7 +1202,8 @@ type InstrumentationConfig struct {
InfluxBatchSize int `mapstructure:"influx_batch_size"`

// InfluxTables is the list of tables that will be traced. See the
rootulp marked this conversation as resolved.
Show resolved Hide resolved
// pkg/trace/schema for a complete list of tables.
// pkg/trace/schema for a complete list of tables. It is represented as a
// comma separate string. For example: "consensus_round_state,mempool_tx".
InfluxTables string `mapstructure:"influx_tables"`

// PyroscopeURL is the pyroscope url used to establish a connection with a
Expand All @@ -1215,7 +1216,8 @@ type InstrumentationConfig struct {
// PyroscopeProfileTypes is a list of profile types to be traced with
// pyroscope. Available profile types are: cpu, alloc_objects, alloc_space,
// inuse_objects, inuse_space, goroutines, mutex_count, mutex_duration,
// block_count, block_duration.
// block_count, block_duration. It is represented as a comma separate
// string. For example: "goroutines,alloc_objects".
PyroscopeProfileTypes string `mapstructure:"pyroscope_profile_types"`
rootulp marked this conversation as resolved.
Show resolved Hide resolved
}

Expand Down
10 changes: 6 additions & 4 deletions config/toml.go
Original file line number Diff line number Diff line change
Expand Up @@ -558,8 +558,9 @@ influx_org = "{{ .Instrumentation.InfluxOrg }}"
influx_batch_size = {{ .Instrumentation.InfluxBatchSize }}

# The list of tables that are updated when tracing. All available tables and
# their schema can be found in the pkg/trace/schema package.
influx_tables = {{ .Instrumentation.InfluxTables }}
# their schema can be found in the pkg/trace/schema package. It is represented as a
// comma separate string. For example: "consensus_round_state,mempool_tx".
rootulp marked this conversation as resolved.
Show resolved Hide resolved
influx_tables = "{{ .Instrumentation.InfluxTables }}"

# The URL of the pyroscope instance to use for continuous profiling.
# If empty, continuous profiling is disabled.
Expand All @@ -572,8 +573,9 @@ pyroscope_trace = {{ .Instrumentation.PyroscopeTrace }}
# pyroscope_profile_types is a list of profile types to be traced with
# pyroscope. Available profile types are: cpu, alloc_objects, alloc_space,
# inuse_objects, inuse_space, goroutines, mutex_count, mutex_duration,
# block_count, block_duration.
pyroscope_profile_types = {{ .Instrumentation.PyroscopeProfileTypes }}
# block_count, block_duration. It is represented as a comma separate
// string. For example: "goroutines,alloc_objects".
rootulp marked this conversation as resolved.
Show resolved Hide resolved
pyroscope_profile_types = "{{ .Instrumentation.PyroscopeProfileTypes }}"

`

Expand Down
8 changes: 8 additions & 0 deletions pkg/trace/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,14 @@ func stringToMap(tables string) map[string]struct{} {
return m
}

// splitAndTrimEmpty slices s into all subslices separated by sep and returns a
// slice of the string s with all leading and trailing Unicode code points
// contained in cutset removed. If sep is empty, SplitAndTrim splits after each
// UTF-8 sequence. First part is equivalent to strings.SplitN with a count of
// -1. also filter out empty strings, only return non-empty strings.
//
// NOTE: this is copy pasted from the config pacakage to avoid a circular
// dependency. See the function of the same name for tests.
func splitAndTrimEmpty(s, sep, cutset string) []string {
staheri14 marked this conversation as resolved.
Show resolved Hide resolved
if s == "" {
return []string{}
Expand Down
Loading