Skip to content

Commit

Permalink
Renamed ExeName to Command, added Description in start info (#3057)
Browse files Browse the repository at this point in the history
* changed ExeName to Command, added Description to BuildInfo

* upadted LongName entry in CHANGELOG
  • Loading branch information
dhruv-vora authored Apr 30, 2021
1 parent f8d544d commit ed89eb0
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 8 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
- Rename `marshall` to `marshal` in all the occurrences (#2977)
- Remove `componenterror.ErrAlreadyStarted` and `componenterror.ErrAlreadyStopped`, components should not protect against this, Service will start/stop once.
- Rename `ApplicationStartInfo` to `BuildInfo`
- Rename `ApplicationStartInfo.ExeName` to `BuildInfo.Command`
- Rename `ApplicationStartInfo.LongName` to `BuildInfo.Description`

## 💡 Enhancements 💡

Expand Down
5 changes: 3 additions & 2 deletions cmd/otelcol/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ func main() {
}

info := component.BuildInfo{
ExeName: "otelcol",
Version: version.Version,
Command: "otelcol",
Description: "OpenTelemetry Collector",
Version: version.Version,
}

if err := run(service.Parameters{BuildInfo: info, Factories: factories}); err != nil {
Expand Down
10 changes: 7 additions & 3 deletions component/build_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ package component
// passed into each component. This information can be overridden in custom builds.
type BuildInfo struct {
// Executable file name, e.g. "otelcol".
ExeName string
Command string

// Full name of the collector, e.g. "OpenTelemetry Collector".
Description string

// Version string.
Version string
Expand All @@ -27,7 +30,8 @@ type BuildInfo struct {
// DefaultBuildInfo returns the default BuildInfo.
func DefaultBuildInfo() BuildInfo {
return BuildInfo{
ExeName: "otelcol",
Version: "latest",
Command: "otelcol",
Description: "OpenTelemetry Collector",
Version: "latest",
}
}
4 changes: 2 additions & 2 deletions service/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func New(params Parameters) (*Application, error) {
}

rootCmd := &cobra.Command{
Use: params.BuildInfo.ExeName,
Use: params.BuildInfo.Command,
Version: params.BuildInfo.Version,
RunE: func(cmd *cobra.Command, args []string) error {
var err error
Expand Down Expand Up @@ -278,7 +278,7 @@ func (app *Application) setupConfigurationComponents(ctx context.Context) error
}

func (app *Application) execute(ctx context.Context) error {
app.logger.Info("Starting "+app.info.ExeName+"...",
app.logger.Info("Starting "+app.info.Command+"...",
zap.String("Version", app.info.Version),
zap.Int("NumCPU", runtime.NumCPU()),
)
Expand Down
2 changes: 1 addition & 1 deletion testbed/testbed/otelcol_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func (ipp *InProcessCollector) PrepareConfig(configStr string) (configCleanup fu
func (ipp *InProcessCollector) Start(args StartParams) error {
params := service.Parameters{
BuildInfo: component.BuildInfo{
ExeName: "otelcol",
Command: "otelcol",
Version: version.Version,
},
ParserProvider: parserprovider.NewInMemory(strings.NewReader(ipp.configStr)),
Expand Down

0 comments on commit ed89eb0

Please sign in to comment.