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

misc: refactor plugin #52

Merged
merged 12 commits into from
Aug 6, 2024

Conversation

jkroepke
Copy link
Contributor

@jkroepke jkroepke commented Jul 5, 2024

Passing all request contexts to chrome instances
Enable plugin logger for chromedp context

I didn't test that. But on theory, if the http server shutdown gracefully, all requests are canceled first. In conclusion, any chrome contexts should be canceled as well.

@mahendrapaipuri mahendrapaipuri added the enhancement New feature or request label Jul 8, 2024
@mahendrapaipuri
Copy link
Owner

Thanks again for this feature. I agree that it is more clean passing the request context everywhere. Just a minor comment: if we are passing context to Grafana client, shouldnt we make RequestWithContext here?

Cheers for setting up logger for chromedp as well. That can provide more useful logs for users.

@jkroepke
Copy link
Contributor Author

jkroepke commented Jul 8, 2024

shouldnt we make RequestWithContext

Highly recommend to introduce golang-ci, because it would trigger a warning for this case, since it embeds https://github.com/kkHAIKE/contextcheck and https://github.com/sonatard/noctx

@mahendrapaipuri
Copy link
Owner

Agree with golangci-lint. I will set that up in a separate PR. However, I have few ideas and suggestions for #51 and if we implement them, this PR most probably will become obselete. So, I suggest we put this on hold and move the discussion to #51 to discuss the feature further.

@jkroepke
Copy link
Contributor Author

jkroepke commented Jul 9, 2024

the chrome logger and context is still worth.

I would consider to merge it and if some are getting reverted as part of #51 - it is fine.

Otherwise, please close the PR.

@mahendrapaipuri
Copy link
Owner

the chrome logger and context is still worth.

Yes, I agree. But if we manage the lifecycle of chromium from NewApp function, we will setup chromium logger from context logger in NewApp and so as the context. That will make client.go and report.go way more simpler as they will simply the consumers of configured chromium instance without having to do any new configuration on chromium.

Globally what I am suggesting is move all the configuration to NewApp which is supposed to manage the plugin instance and make downstream plugin consumer of configured resources. Does it make sense?

@jkroepke
Copy link
Contributor Author

jkroepke commented Jul 9, 2024

Hi, feel free to commit your suggestions.

I do not have the full overview of the current architecture of the plugin. But I agree that some interfaces feels a bit complicated.

Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de>
@jkroepke jkroepke force-pushed the pass-ctx-logger branch 3 times, most recently from 253e78f to 544037d Compare July 12, 2024 19:58
@jkroepke jkroepke marked this pull request as draft July 13, 2024 00:15
@jkroepke jkroepke force-pushed the pass-ctx-logger branch 3 times, most recently from 6099865 to 020f56c Compare July 13, 2024 21:20
@jkroepke jkroepke changed the title misc: pass context and logger from request to chrome misc: refactor plugin Jul 13, 2024
@jkroepke jkroepke force-pushed the pass-ctx-logger branch 9 times, most recently from 563519f to 452c9b4 Compare July 13, 2024 23:05
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
@jkroepke jkroepke marked this pull request as ready for review July 27, 2024 05:16
@mahendrapaipuri
Copy link
Owner

Thanks a lot for this awesome work @jkroepke

I will need some time to look into it as it is quite a big one. But it looks very promising and I like the refactoring you did. I think it would be great addition to the plugin. Thanks again for all your time and effort. Really appreciate it.

Copy link
Owner

@mahendrapaipuri mahendrapaipuri left a comment

Choose a reason for hiding this comment

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

I have few minor comments. I really like the new sub packages which is more clear and organised. The only major change is I would prefer all the packages taken out of internal. Something like grafana-infinity-datasource organization. I feel that would be more intuitive for developers to follow the code.

I think we should expand e2e test matrix and update docs. We can do it in next step in a separate PR.

.editorconfig Outdated Show resolved Hide resolved
pkg/plugin/app.go Outdated Show resolved Hide resolved
pkg/plugin/app.go Outdated Show resolved Hide resolved
pkg/plugin/app.go Outdated Show resolved Hide resolved
pkg/plugin/app.go Outdated Show resolved Hide resolved
#
skipTlsCheck: false
tlsSkipVerify: false
Copy link
Owner

Choose a reason for hiding this comment

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

The same, please change it back to skipTlsCheck

Copy link
Contributor Author

Choose a reason for hiding this comment

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

please check first comment about that.

provisioning/plugins/app.yaml Outdated Show resolved Hide resolved
src/components/AppConfig/AppConfig.tsx Outdated Show resolved Hide resolved
pkg/plugin/internal/dashboard/errors.go Outdated Show resolved Hide resolved
pkg/plugin/internal/client/errors.go Outdated Show resolved Hide resolved
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
Copy link
Owner

@mahendrapaipuri mahendrapaipuri left a comment

Choose a reason for hiding this comment

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

Please fix the failing CI jobs and I can push the rest of little changes that we need before merging this PR.

Thanks again for this awesome work. You put a lot of effort and time and I really appreciate it. You really improved the quality of code a lot with your insights.

pkg/plugin/resources.go Outdated Show resolved Hide resolved
pkg/plugin/internal/dashboard/errors.go Outdated Show resolved Hide resolved
@jkroepke
Copy link
Contributor Author

jkroepke commented Aug 6, 2024

CI is green now, feel free to finish and feel free revert the error handling, if you are not agree with that.

@mahendrapaipuri
Copy link
Owner

mahendrapaipuri commented Aug 6, 2024

CI is green now, feel free to finish and feel free revert the error handling, if you are not agree with that.

I think we are good. There are very small changes that I will do them in a separate PR.

I dont want to squash merge this PR as we will lose a lot of context doing so. Do you agree squashing the commits with same commit message? If you agree, could you please do so and force push the branch? If not I can do it just let me know.

Thanks again for the work. Codebase looks much better now.

@jkroepke
Copy link
Contributor Author

jkroepke commented Aug 6, 2024

Is this fine now?

jkroepke and others added 5 commits August 6, 2024 14:24
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de>
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
Copy link
Owner

@mahendrapaipuri mahendrapaipuri left a comment

Choose a reason for hiding this comment

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

Amazing work!! Cheers again!

@mahendrapaipuri mahendrapaipuri merged commit c81b247 into mahendrapaipuri:main Aug 6, 2024
5 checks passed
@jkroepke jkroepke deleted the pass-ctx-logger branch August 6, 2024 13:26
@jkroepke
Copy link
Contributor Author

jkroepke commented Aug 6, 2024

@mahendrapaipuri Any plans for a release? I'm happy to start the integration in our eco system.

I'm aware that there are small changes todo, but I would appreciate an release candidate, too.

@mahendrapaipuri
Copy link
Owner

@jkroepke I had a deadline, so, couldnt come back to it. I have put up a PR with final changes and some fixes. Feel free to take a look at it. I will try to do a release if everything goes green by end of the day.

@mahendrapaipuri
Copy link
Owner

@jkroepke New release v1.5.0 has been published!

@jkroepke
Copy link
Contributor Author

jkroepke commented Aug 8, 2024

Thanks alot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants