Skip to content

feat: rename config flag to observe-config, use default otel command for our start command #146

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

Merged
merged 1 commit into from
Jan 8, 2025

Conversation

obs-gh-mattcotter
Copy link
Collaborator

@obs-gh-mattcotter obs-gh-mattcotter commented Dec 18, 2024

Description

OB-38651 Rename --config flag to --observe-config and use the default OTel collector command for our start command. This adds all otelcol flags to our start command and gives us full functionality for the new --config flag (which specifies OTel configs).

Checklist

  • Created tests which fail without the change (if possible)
  • Extended the README / documentation, if necessary

inService, err := svc.IsWindowsService()
if err != nil {
// If we're not running as a service, we run normally.
if inService, err := svc.IsWindowsService(); err != nil {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reorganized this method so it now looks more like the default OCB method. The diff for this condition is just code motion.

if err != nil {
return err
}
colSettings := observecol.GenerateCollectorSettingsWithConfigFiles(configFilePaths)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NB: Generating the settings this way instead of using the otel command means it won't work with --config. That's fine though, since we have a hard assert that the windows service is only ever run with two args and we have never supported --config this way.

if err != nil {
return err
}
if cleanup != nil {
defer cleanup()
configFlag := otleCmd.Flags().Lookup("config")
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The flags for the otel collector are hidden behind private implementations of interfaces, args passed by value, and function scope locals. It's really not possible to access and set them directly if you aren't passing args to the cmd flags. Because of this, I think using the otelcol command itself for our start subcommand is the best way to go.

@@ -14,15 +14,7 @@ import (
"go.opentelemetry.io/collector/otelcol"
)

func makeMapProvidersMap(providers ...confmap.Provider) map[string]confmap.Provider {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was unused.

if err != nil {
return false, nil, err
}
colSettings := observecol.GenerateCollectorSettingsWithConfigFiles(configFilePaths)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Diagnose won't run against otel config overrides, but we never supported this:

$ observe-agent diagnose --otel-config ./tmp.config
Error: unknown flag: --otel-config
Usage:
  observe-agent diagnose [flags]

Flags:
  -h, --help   help for diagnose

Global Flags:
      --config string   config file path

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you make a ticket to support the new --observe-config flag in diagnose?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@obs-gh-mattcotter obs-gh-mattcotter merged commit 11ca37e into v2 Jan 8, 2025
8 checks passed
@obs-gh-mattcotter obs-gh-mattcotter deleted the OB-38651-config-flag branch January 8, 2025 16:09
obs-gh-mattcotter added a commit that referenced this pull request Jan 14, 2025
…for our start command (#146)

### Description

OB-38651 Rename `--config` flag to `--observe-config` and use the
default OTel collector command for our start command. This adds all
`otelcol` flags to our `start` command and gives us full functionality
for the new `--config` flag (which specifies OTel configs).

### Checklist
- [ ] Created tests which fail without the change (if possible)
- [ ] Extended the README / documentation, if necessary
obs-gh-mattcotter added a commit that referenced this pull request Jan 27, 2025
…for our start command (#146)

### Description

OB-38651 Rename `--config` flag to `--observe-config` and use the
default OTel collector command for our start command. This adds all
`otelcol` flags to our `start` command and gives us full functionality
for the new `--config` flag (which specifies OTel configs).

### Checklist
- [ ] Created tests which fail without the change (if possible)
- [ ] Extended the README / documentation, if necessary
obs-gh-mattcotter added a commit that referenced this pull request Feb 3, 2025
…for our start command (#146)

### Description

OB-38651 Rename `--config` flag to `--observe-config` and use the
default OTel collector command for our start command. This adds all
`otelcol` flags to our `start` command and gives us full functionality
for the new `--config` flag (which specifies OTel configs).

### Checklist
- [ ] Created tests which fail without the change (if possible)
- [ ] Extended the README / documentation, if necessary
obs-gh-mattcotter added a commit that referenced this pull request Feb 5, 2025
…for our start command (#146)

### Description

OB-38651 Rename `--config` flag to `--observe-config` and use the
default OTel collector command for our start command. This adds all
`otelcol` flags to our `start` command and gives us full functionality
for the new `--config` flag (which specifies OTel configs).

### Checklist
- [ ] Created tests which fail without the change (if possible)
- [ ] Extended the README / documentation, if necessary
obs-gh-mattcotter added a commit that referenced this pull request Feb 5, 2025
… for our start command (#146)

OB-38651 Rename `--config` flag to `--observe-config` and use the
default OTel collector command for our start command. This adds all
`otelcol` flags to our `start` command and gives us full functionality
for the new `--config` flag (which specifies OTel configs).

- [ ] Created tests which fail without the change (if possible)
- [ ] Extended the README / documentation, if necessary
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants