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

x/tools/gopls: recognize templ user agent in telemetry #70205

Open
hyangah opened this issue Nov 5, 2024 · 6 comments
Open

x/tools/gopls: recognize templ user agent in telemetry #70205

hyangah opened this issue Nov 5, 2024 · 6 comments
Labels
gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@hyangah
Copy link
Contributor

hyangah commented Nov 5, 2024

Templ language server uses gopls to process go syntax.
Currently, gopls spawned by Templ language server is not distinguishable from gopls editors manage directly.

As Templ is getting popular, I think it is beneficial for both gopls and templ teams to track templ's gopls usage more closely. Hopefully, this information can help when we need to track the protocol compatibility and minimize accidental breakages like in golang/vscode-go#3435 (comment).

In a-h/templ#966 I am proposing to adjust the client info so we can record the chain of lsp participants. I use ; but I am open to other characters. Or even other fields if there are.

Whatever format is chosen, we also need to adjust gopls side to process this format. For example,

https://github.com/golang/tools/blob/f1f7c26696be8f94198beafd05b36843515ac2ba/gopls/internal/cache/snapshot.go#L950
and telemetry.

@gopherbot gopherbot added Tools This label describes issues relating to any tools in the x/tools repository. gopls Issues related to the Go language server, gopls. labels Nov 5, 2024
@gopherbot gopherbot added this to the Unreleased milestone Nov 5, 2024
@adonovan
Copy link
Member

adonovan commented Nov 6, 2024

Templ language server uses gopls to process go syntax.

Does that mean that snippets of Go syntax within Templ files are handled by delegating the RPC from one language server to another?

Do Templ template appear within Go string literals (or are they usually standalone files)? If so, should gopls similarly delegate queries for Templ strings within Go files to the Templ language server? Or should we support some limited subset of queries directly, as we currently do (sort of) for text/template?

@findleyr
Copy link
Member

findleyr commented Nov 7, 2024

I agree that it would be good to recognize templ, but why can't templ simply specify a unique user agent for communication with gopls. I don't see a need to capture the user agent that is interacting with templ.

@hyangah
Copy link
Contributor Author

hyangah commented Nov 7, 2024

Do you mean the gopls team is not interested in what editor invokes templ (more likely there will be another gopls in the report) and gopls shouldn't change its behavior based on editor. So templ can just set the client info to 'templ' and drop the editor name?

As long as there is no more behavior change based on client ( https://github.com/golang/tools/blob/f1f7c26696be8f94198beafd05b36843515ac2ba/gopls/internal/cache/snapshot.go#L950) I think that will work.

@hyangah
Copy link
Contributor Author

hyangah commented Nov 7, 2024

Thinking more, I am more convinced that gopls shouldn't use the ClientName in adjusting its functionality.
For example, we should've used an explicit setting instead of using the ClientName in https://github.com/golang/tools/blob/f1f7c26696be8f94198beafd05b36843515ac2ba/gopls/internal/cache/snapshot.go#L950

@findleyr
Copy link
Member

@hyangah agreed: having VS Code inject a setting would have been a better solution.

@findleyr
Copy link
Member

findleyr commented Nov 11, 2024

Opened #70285 to track switching to an explicit setting. Backlogged as not a high priority, but we can state that we won't specialize behavior in this way any more.
EDIT repurposing this issue to track recognizing templ in telemetry.

@findleyr findleyr changed the title x/tools/gopls: clarify the format of ClientInfo.Name x/tools/gopls: recognize templ user agent in telemetry Nov 11, 2024
@findleyr findleyr modified the milestones: Unreleased, gopls/v0.18.0 Nov 11, 2024
hyangah added a commit to hyangah/templ that referenced this issue Nov 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

4 participants