Skip to content

Commit

Permalink
feat: add --otel-config flag (#53)
Browse files Browse the repository at this point in the history
### Description

OB-34510 feat: add --otel-config flag to read in additional otel config
from file

### Checklist
- [ ] Created tests which fail without the change (if possible)
- [ ] Extended the README / documentation, if necessary
  • Loading branch information
obs-gh-alexlew authored Jul 17, 2024
1 parent 71e9128 commit 759d229
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 3 additions & 1 deletion cmd/commands/start/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"os"

"github.com/spf13/cobra"
"github.com/spf13/viper"
)

var startCmd = &cobra.Command{
Expand Down Expand Up @@ -40,13 +41,14 @@ collector on the current host.`,
}

func init() {
startCmd.PersistentFlags().String("otel-config", "", "Path to additional otel configuration file")
viper.BindPFlag("otelConfigFile", startCmd.PersistentFlags().Lookup("otel-config"))
cmd.RootCmd.AddCommand(startCmd)

// Here you will define your flags and configuration settings.

// Cobra supports Persistent Flags which will work for this command
// and all subcommands, e.g.:
// startCmd.PersistentFlags().String("foo", "", "A help for foo")

// Cobra supports local flags which will only run when this command
// is called directly, e.g.:
Expand Down
4 changes: 4 additions & 0 deletions cmd/config/confighandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ func GetAllOtelConfigFilePaths() ([]string, string, error) {
configFilePaths = append(configFilePaths, conn.GetConfigFilePaths()...)
}
}
// Read in otel-config flag and add to paths if set
if viper.IsSet("otelConfigFile") {
configFilePaths = append(configFilePaths, viper.GetString("otelConfigFile"))
}
// Generate override file and include path if overrides provided
var overridePath string
if viper.IsSet("otel_config_overrides") {
Expand Down

0 comments on commit 759d229

Please sign in to comment.