-
Notifications
You must be signed in to change notification settings - Fork 15
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
Path is not handled per the specification for OTLP/HTTP #94
Comments
Hi, @smoyer64! Thanks for finding and opening this issue! We're inclined philosophically towards Option 3: let upstream logic figure out as much auto-config as possible. I agree that Option 2 is valuable for developers configuring the SDK programmatically. That could be included in a PR to close this issue or in a follow-up PR. In reviewing this issue and what it would take to implement Option 3, I have some vague concerns about how to add this better and correct behavior while maintaining backwards compatibility for the current users of |
I think it's pretty easy to accomplish this without breaking existing users - how confident are we that the unit and smoke tests cover the current user scenarios? My very crudely patched version simply adds the The bigger issue is that the |
Sorry for the delay on this. If possible we'd like to keep the existing functions to avoid any possible breakage for current users of the library. If we can use the existing functions but extend them to also be able to handle a more spec-compliant provided endpoint, we would prefer that option. If that's not possible, then it may be best to add additional spec-compliant options but I think we want to avoid adding too much extra code surface at this time. Feel free to open a PR and we can take a look at it. Thanks! |
I looked at this further and believe that's possible but I also re-read the specification and am leaning towards creating a fork with that doesn't intercept environment variables at all with the exception of those that are required to actually choose the signal and protocol. There's a lot of duplication (causing conflicts with the specification) between this library and the underlying library. According the the specification, an environment variable should only be overridden if a value is provided by an option. This library currently incorrectly interprets the specified environment variables and then sets options based on that incorrect interpretation. This leads to instances where you can set environment variables in a way that should be valid according to I'd argue that even breaking changes are worth it in the long run if it aligns the behavior of this library and the underlying OTEL library. How would you feel about a v2.0? |
Hey @smoyer64 - thanks for your help and thoughts on this. I'm not against a v2 but would prefer not to where possible. v2+ go packages has very mixed success. The intent of this package was to add an easy to use configuration layer on top the OTel SDK because it was not the easiest to use. We did offer to donate this package to OTel but it didn't quite happen for a few reasons. With the aim of making this library ease configuration, I see deviations from spec and unintuitive configuration outcomes as bugs. I would love to look into if we could |
Per the OpenTelemetry
exporter
specifications, theOTEL_EXPORTER_OTLP_ENDPOINT
environment variable as well as the more specificOTEL_EXPORTER_OTLP_TRACES_ENDPOINT
,OTEL_EXPORTER_OTLP_METRICS_ENDPOINT
andOTEL_EXPORTER_OTLP_LOGS_ENDPOINT
environment variables, are URLs. The specification for the configuration options reads as follows:The specification for OTLP/HTTP endpoint URLs also contains a section that provides specific instructions for how the paths should be constructed if they're missing. Since this specification is polyglot, there is no discussion about how the
opentelemetry-go
library might effect these behaviors.Now for the problem ... the
otlpmetrichttp.WithEndpoint()
andotlptracehttp.WithEndpoint()
Option
functions accepthost
orhost:port
strings, not URLs. At some point, theotelconfig
library was adapted to strip the URLScheme
but thePath
is not processed at all. Since theotelconfig
library uses the these functions whether the value is provided by anOption
or an environment variable, thePath
is included and the error occurs when it's parsed as part of thePort
string.There are three ways this could be solved:
Process the port per the rules in the specification and call
otlpmetrichttp.WithURLPath()
and/orotlptracehttp.WithURLPath()
as needed with the exporter(s) are instantiated. In this case, theWithExporterEndpoint()
function would continue to take a URL.Add a
WithExporterURLPath()
,WithMetricsExporterURLPath()
andWithTracesExporterURLPath()
to mimic the use of the underlyingopentelemetry-go
library. The environment variables would still have to be parsed but the rules for sending paths are pretty clear.If the generic or signal-specific end-points are provided via environment variables, don't add
WithEndpoint()
,WithInsecure()
,WithTLSClientConfig()
andWithURLPath()
to the options when constructing the exporters. Since theotelconfig
environment variables for the endpoints have the same names as those in theopentelemetry-go
library, let that library do the work! For those that are configuring OTEL programmatically, the functions in bullet two above would still be beneficial.Feel free to assign this to me if you can provide guidance on which of the options above would be best.
Versions
v1.13.0
Steps to reproduce
The following test provided at https://github.com/selesy/otel-config-go/blob/99aa2a853854e0e2eae464bd34d89cc4a7c08d79/otelconfig/pipelines/metrics_test.go#L10-L19 fails with the message:
Additional context
There is a real-world example where this fails. If a developer is testing against Grafana cloud and using this service as the OTEL collector, the generic end-point URL has the path
/otlp
as described in the documentation at https://grafana.com/docs/grafana-cloud/send-data/otlp/send-data-otlp/#push-directly-from-applications-using-the-opentelemetry-sdks. This is a really convenient way to test that an application is fully instrumented without running the services locally.The text was updated successfully, but these errors were encountered: