-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
[cmd/telemetrygen] Better defaults for HTTP exporter mode #27007
[cmd/telemetrygen] Better defaults for HTTP exporter mode #27007
Conversation
b2bc3e0
to
b8c2fe9
Compare
…trics and traces - the default value for each differs therefore it is not a common flag
- returns the default http endpoint whenever http mode is enabled and no endpoint was provided (i.e. its still the default grpc endpoint) - if the endpoint has been set or we're not in http mode return the underlying value
- whenever no custom endpoint is provided telemetrygen then defaults to either the gRPC or HTTP exporter endpoint
…atically included
b8c2fe9
to
c77b37e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR @jmsnll, could the path be added for logs as well?
@@ -23,6 +23,9 @@ type Config struct { | |||
// Flags registers config flags. | |||
func (c *Config) Flags(fs *pflag.FlagSet) { | |||
c.CommonFlags(fs) | |||
|
|||
fs.StringVar(&c.HTTPPath, "otlp-http-url-path", "/v1/traces", "Which URL path to write to") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
likewise, would be great to have a test for this as well
And thanks for the review @codeboten! I could be wrong here, but Isn't the URL path only relevant for HTTP? I can add it to the the |
Of course... i forgot that logs aren't supported for http yet 🤦🏻 ignore my comment 👍🏻 |
612b55f
to
d3bdb2d
Compare
This PR was marked stale due to lack of activity. It will be closed in 14 days. |
@jmsnll Could you fix the linting errors? |
@evan-bradley this is my bad... tried to resolve a conflict via the github UI... will fix |
…etry#27007) **Description:** - Refactored and moved `otlp-http-url-path` flag from the common flags for each command - Added flag to the `traces` command with the default `/v1/traces` - Added flag to the `metrics` command with the default `/v1/metrics` - Flag was not used for the `logs` command so no longer exposed - Handle changing the default endpoint based on the communication mode (gRPC or HTTP) - Flag `--otlp-endpoint` now defaults to empty string and targets a new attribute `CustomEndpoint` on `common.Config` - Added the `Endpoint()` getter function to the `common.Config` struct for retrieving the correct endpoint - When `CustomEndpoint` is empty then either `DefaultGRPCEndpoint` or `DefaultHTTPEndpoint` are chosen based upon the value of `config.UseHTTP` - **Misc**: Split out the creation of trace/metric exporters into standalone factory functions with docstrings available in `exporters.go` in both modules - **Misc**: Removed the "default value is" from the descriptions of some flags as it was repeated information **Link to tracking Issue:** open-telemetry#26999 **Testing:** Added new set of unit tests to cover the addition of the `config.Endpoint()` getter. Running `telemetrygen traces --otlp-http --otlp-insecure` now correctly sends traces using HTTP to the default HTTP endpoint. **Documentation:** No documentation added/changed but updated some command flag descriptions. --------- Co-authored-by: Alex Boten <[email protected]>
Description:
otlp-http-url-path
flag from the common flags for each commandtraces
command with the default/v1/traces
metrics
command with the default/v1/metrics
logs
command so no longer exposed--otlp-endpoint
now defaults to empty string and targets a new attributeCustomEndpoint
oncommon.Config
Endpoint()
getter function to thecommon.Config
struct for retrieving the correct endpointCustomEndpoint
is empty then eitherDefaultGRPCEndpoint
orDefaultHTTPEndpoint
are chosen based upon the value ofconfig.UseHTTP
exporters.go
in both modulesLink to tracking Issue: #26999
Testing:
Added new set of unit tests to cover the addition of the
config.Endpoint()
getter.Running
telemetrygen traces --otlp-http --otlp-insecure
now correctly sends traces using HTTP to the default HTTP endpoint.Documentation:
No documentation added/changed but updated some command flag descriptions.