Skip to content
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

fix(backend): tempo cloud connection string #3515

Merged
merged 3 commits into from Jan 11, 2024
Merged

Conversation

xoscar
Copy link
Collaborator

@xoscar xoscar commented Jan 10, 2024

This PR fixes a confusing way of dealing with the tempo cloud http connection, as pasting the given endpoint from the webapp uses :443 instead of https

Changes

  • Defaults :443 port to https

Fixes

Checklist

  • tested locally
  • added new dependencies
  • updated the docs
  • added a test

@@ -27,6 +27,10 @@ type HttpClient struct {

func NewHttpClient(name string, config *datastore.HttpClientConfig, callback HttpCallback) DataSource {
endpoint, _ := urlx.Parse(config.Url)
if endpoint.Port() == "443" {
endpoint.Scheme = "https"
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

With a url like this:

tempo-us-central1.grafana.net:443

The parsing method returns

http://tempo-us-central1.grafana.net:443

Which breaks the getTraceById logic.

@@ -23,7 +23,7 @@ import (
)

func tempoDefaultPorts() []string {
return []string{"9095", ""}
return []string{"9095", "443", "1"}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

443 and 1 (using https://tempo-us-central1.grafana.net) should be also valid ports

Copy link
Collaborator

Choose a reason for hiding this comment

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

I've never seen port 1 being used. Is there any docs about this port?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

For some reason the url parser uses 1 as port when using something like https://tempo-us-central1.grafana.net/

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Screen Shot 2024-01-10 at 1 57 31 p m

Copy link
Collaborator

Choose a reason for hiding this comment

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

That looks like a bug in the URL parsing library. Do you know why we're using an URL parser other than the go's stdlib one?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah the standard makes it worse in some cases, here's a table
Screen Shot 2024-01-10 at 2 00 28 p m

Copy link
Collaborator

Choose a reason for hiding this comment

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

I see. That makes sense. What I would do is handle the case of port "1" and replace it by a correct default port, for example:

if port == 1 {
  if schema == "http" {
    port = 80
  }
  if schema == "https" {
    port = 43
  }
}

@xoscar xoscar self-assigned this Jan 10, 2024
@xoscar xoscar marked this pull request as ready for review January 10, 2024 18:36
@adnanrahic
Copy link
Contributor

This is awesome. When will this be ready for me to try it?

@xoscar xoscar merged commit dc5f609 into main Jan 11, 2024
37 checks passed
@xoscar xoscar deleted the fix-tempo-cloud-connection branch January 11, 2024 15:19
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.

None yet

4 participants