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

[Enhancement] The logical operations in prehandler and posthandler are not reasonable #4551

Closed
1 of 3 tasks
lrhkobe opened this issue Nov 10, 2023 · 15 comments · Fixed by #4822
Closed
1 of 3 tasks

[Enhancement] The logical operations in prehandler and posthandler are not reasonable #4551

lrhkobe opened this issue Nov 10, 2023 · 15 comments · Fixed by #4822
Assignees
Labels
enhancement New feature or request good first issue Issues for first-time contributors help wanted Extra attention is needed

Comments

@lrhkobe
Copy link
Contributor

lrhkobe commented Nov 10, 2023

Search before asking

  • I had searched in the issues and found no similar issues.

Enhancement Request

Time-consuming statistics are more reasonable in posthandler.

Code in HandlerService.java:

企业微信截图_16995834577905

Code in the method of preHandler:

       private void preHandler() {
            metrics.getSummaryMetrics().recordHTTPReqResTimeCost(System.currentTimeMillis() - requestTime);
            LogUtils.debug(httpLogger, "{}", response);
        }

Describe the solution you'd like

Optimize the logic in prehandler and posthandler.

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

@lrhkobe lrhkobe added the enhancement New feature or request label Nov 10, 2023
Copy link
Contributor

github-actions bot commented Apr 6, 2024

It has been 90 days since the last activity on this issue. Apache EventMesh values the voices of the community. Please don't hesitate to share your latest insights on this matter at any time, as the community is more than willing to engage in discussions regarding the development and optimization directions of this feature.

If you feel that your issue has been resolved, please feel free to close it. Should you have any additional information to share, you are welcome to reopen this issue.

@github-actions github-actions bot added the Stale label Apr 6, 2024
@Pil0tXia Pil0tXia added good first issue Issues for first-time contributors help wanted Extra attention is needed and removed Stale labels Apr 6, 2024
@cnzakii
Copy link
Contributor

cnzakii commented Apr 7, 2024

@Pil0tXia I would like to try it, please assign me.
Clarify my task: move metrics.getSummaryMetrics().recordHTTPReqResTimeCost(System.currentTimeMillis() - requestTime); in the method of preHandler to the last line in the method of postHandler.

@Pil0tXia
Copy link
Member

Pil0tXia commented Apr 7, 2024

@cnzakii

Including logger and any time-consuming statistics method.

It's better to finish multiple PRs one by one.

@cnzakii
Copy link
Contributor

cnzakii commented Apr 7, 2024

OK. I will come back to claim the issue after submitting the previous PR (if the issue still exists)

@cnzakii
Copy link
Contributor

cnzakii commented Apr 9, 2024

@Pil0tXia

I've already submitted the previous PR, so I think I can apply to address this issue now.

My solution:
2024-04-09_19 57 54

As shown in the diagram above, move the code from the preHandler method to the postHandler method.

@Pil0tXia
Copy link
Member

Pil0tXia commented Apr 9, 2024

@cnzakii

As you can see that there are also some metrics related statements in postHandler(), so better put them at the top of the postHandler().

@cnzakii
Copy link
Contributor

cnzakii commented Apr 9, 2024

@Pil0tXia

OK. But I noticed that preHandler() is only used within run(), whereas postHandler() is used not only in run() but also in the sendResponse() method. If we move the preHandler() code into postHandler(), will it not add some unnecessary logging and time-consuming statistics?

2024-04-09_20 45 46

@Pil0tXia
Copy link
Member

Pil0tXia commented Apr 9, 2024

The time-consuming statistics in postHandler() is acceptable, however the time recordHTTPReqResTimeCost() method recorded will be a little incorrect. Maybe creating another method and renaming these two methods if necessary will be a better way to resolve this issue.

@cnzakii
Copy link
Contributor

cnzakii commented Apr 9, 2024

@Pil0tXia

Could you further explain your thoughts to me? I'm not quite understanding.

Another idea I had is simply to rearrange the position of the preHandler() method.

2024-04-09_23 12 23

@Pil0tXia
Copy link
Member

Pil0tXia commented Apr 9, 2024

@cnzakii You may wrap one method to another and call different methods under certain circumstances.

@cnzakii
Copy link
Contributor

cnzakii commented Apr 9, 2024

@cnzakii You may wrap one method to another and call different methods under certain circumstances.

@Pil0tXia

Is it similar to the concept of the wrapper pattern, where we create a wrapper method for postHandler(), which would perform the tasks of preHandler() within this method before calling postHandler()?

image

ps: Maybe the method name is not accurate

@Pil0tXia
Copy link
Member

Pil0tXia commented Apr 10, 2024

@cnzakii yeah 😉

@cnzakii
Copy link
Contributor

cnzakii commented Apr 10, 2024

@Pil0tXia

OK. Please assign the issue to me. By the way, do you have any good suggestions for naming methods?

@Pil0tXia
Copy link
Member

@Pil0tXia You can exert your abilities and make your own decisions. After you submit a PR, I will review it again.

@cnzakii
Copy link
Contributor

cnzakii commented Apr 10, 2024

@Pil0tXia PTAL

xwm1992 added a commit that referenced this issue Apr 22, 2024
* [ISSUE #4812] Set up Admin Endpoints v2 (#4813)

* Remove redundant overloaded methods

* Simplify write() result param

* Add writeJson(); Add PUT; Add JavaDoc

* Rename EventHttpHandler to EventMeshHttpHandler

* Correct server thread name

* Clean up messy & non-hierarchical overloading

* No need to set headers manually any more

* Set up v1&v2 endpoints

* Set up v1&v2 response dto

* Introduce fastjson2

* Fix fastjson2 "level too large : 2048" error caused by IPAddress

* Correct @ConfigField naming

* Return properties format json key

* Add format option to query string

* Introduce Result

* Reduce duplicate builder code

* Fix all checkstyle warnings in eventmesh-runtime

* Add known dependency

* [ISSUE #4814] Migrate from fastjson 1.2.83 to fastjson2 (#4819)

* [Enhancement] Migrate from fastjson 1.2.83 to fastjson2 #4814

* fix_dependencies_problem

* fix_check

* [ISSUE #4551] modify the logic of time-consumption statistics (#4822)

* init connector runtime v2

* [ISSUE #4804] Fix SubStreamHandler exception loop by closeOnError (#4807)

* Handle exception loop by closeOnError

* Lombok optimization

* some format optimization

* Avoid closing multiple times

* Remove redundant set null

* Revert "Avoid closing multiple times"

This reverts commit 774397f.

* Use synchronized latch to keep senderOnComplete called once

* Use boolean to prevent latch called by somebody else

* Remove the unique callee/caller close() of onCompleted()

* [ISSUE #4838] Deprecate unused `eventMesh.connector.plugin.type` etc. properties (#4839)

* Remove all references of `eventMesh.connector.plugin.type`

* Deprecate `eventMesh.connector.plugin.type` and sort properties

* Remove misconfigured & not-used `registerIntervalInMills`, `fetchRegistryAddrIntervalInMills`

* Remove 'defibus' related un-used usages

* Supplement #4809 for `null != object`

* [ISSUE #4832] Downgrade stale bot to v8 to resolve state cache reserving error (#4833)

* Revert stale bot to v8 to resolve state cache reserving error

* Reduce operations-per-run to default value to ease pressure

* Unify yaml to yml

* [ISSUE #4820] Bug fix EventHandler not return json (#4821)

* bug fix

* bug fix

* bug fix

* update runtime v2

* update connector runtime

* update connector runtime

* update connector runtime

* update connector runtime

* update connector runtime

---------

Co-authored-by: Pil0tXia <xiatian@apache.org>
Co-authored-by: Zaki <91261012+cnzakii@users.noreply.github.com>
Co-authored-by: Karson <karsontao@hotmail.com>
xwm1992 added a commit that referenced this issue May 31, 2024
* EventMesh function admin (#4851)

* own

* dependency

* finish registry

* EventMesh function admin (#4853)

* own

* dependency

* finish registry

* init

* Eventmesh function admin (#4854)

* own

* dependency

* finish registry

* init

* 0419

* 0419

* more discovery and move gRPC

* fix dependency

* EventMesh function connector runtime (#4858)

* [ISSUE #4812] Set up Admin Endpoints v2 (#4813)

* Remove redundant overloaded methods

* Simplify write() result param

* Add writeJson(); Add PUT; Add JavaDoc

* Rename EventHttpHandler to EventMeshHttpHandler

* Correct server thread name

* Clean up messy & non-hierarchical overloading

* No need to set headers manually any more

* Set up v1&v2 endpoints

* Set up v1&v2 response dto

* Introduce fastjson2

* Fix fastjson2 "level too large : 2048" error caused by IPAddress

* Correct @ConfigField naming

* Return properties format json key

* Add format option to query string

* Introduce Result

* Reduce duplicate builder code

* Fix all checkstyle warnings in eventmesh-runtime

* Add known dependency

* [ISSUE #4814] Migrate from fastjson 1.2.83 to fastjson2 (#4819)

* [Enhancement] Migrate from fastjson 1.2.83 to fastjson2 #4814

* fix_dependencies_problem

* fix_check

* [ISSUE #4551] modify the logic of time-consumption statistics (#4822)

* init connector runtime v2

* [ISSUE #4804] Fix SubStreamHandler exception loop by closeOnError (#4807)

* Handle exception loop by closeOnError

* Lombok optimization

* some format optimization

* Avoid closing multiple times

* Remove redundant set null

* Revert "Avoid closing multiple times"

This reverts commit 774397f.

* Use synchronized latch to keep senderOnComplete called once

* Use boolean to prevent latch called by somebody else

* Remove the unique callee/caller close() of onCompleted()

* [ISSUE #4838] Deprecate unused `eventMesh.connector.plugin.type` etc. properties (#4839)

* Remove all references of `eventMesh.connector.plugin.type`

* Deprecate `eventMesh.connector.plugin.type` and sort properties

* Remove misconfigured & not-used `registerIntervalInMills`, `fetchRegistryAddrIntervalInMills`

* Remove 'defibus' related un-used usages

* Supplement #4809 for `null != object`

* [ISSUE #4832] Downgrade stale bot to v8 to resolve state cache reserving error (#4833)

* Revert stale bot to v8 to resolve state cache reserving error

* Reduce operations-per-run to default value to ease pressure

* Unify yaml to yml

* [ISSUE #4820] Bug fix EventHandler not return json (#4821)

* bug fix

* bug fix

* bug fix

* update runtime v2

* update connector runtime

* update connector runtime

* update connector runtime

* update connector runtime

* update connector runtime

---------

Co-authored-by: Pil0tXia <xiatian@apache.org>
Co-authored-by: Zaki <91261012+cnzakii@users.noreply.github.com>
Co-authored-by: Karson <karsontao@hotmail.com>

* [ISSUE #4931]Add Registry Module for Discovery AdminServer

* [ISSUES #4933]Add Admin Module

* [ISSUE #4935] Add and Move the Pojo Used By Both Runtime and Admin to Common

* [ISSUE #4937]fix gradle dependecy and add runtime v2

* [ISSUES #4939]add canal connector

* fix missing apache header

* fix missing apache header

* fix missing apache header

* update gradle dependencies

* fix admin server ci check error

* fix admin server ci check error

* fix ci checkStyle error

* fix ci check error

---------

Co-authored-by: sodaRyCN <35725024+sodaRyCN@users.noreply.github.com>
Co-authored-by: Pil0tXia <xiatian@apache.org>
Co-authored-by: Zaki <91261012+cnzakii@users.noreply.github.com>
Co-authored-by: Karson <karsontao@hotmail.com>
xwm1992 added a commit that referenced this issue Jul 2, 2024
* EventMesh function admin (#4851)

* own

* dependency

* finish registry

* EventMesh function admin (#4853)

* own

* dependency

* finish registry

* init

* Eventmesh function admin (#4854)

* own

* dependency

* finish registry

* init

* 0419

* 0419

* more discovery and move gRPC

* fix dependency

* EventMesh function connector runtime (#4858)

* [ISSUE #4812] Set up Admin Endpoints v2 (#4813)

* Remove redundant overloaded methods

* Simplify write() result param

* Add writeJson(); Add PUT; Add JavaDoc

* Rename EventHttpHandler to EventMeshHttpHandler

* Correct server thread name

* Clean up messy & non-hierarchical overloading

* No need to set headers manually any more

* Set up v1&v2 endpoints

* Set up v1&v2 response dto

* Introduce fastjson2

* Fix fastjson2 "level too large : 2048" error caused by IPAddress

* Correct @ConfigField naming

* Return properties format json key

* Add format option to query string

* Introduce Result

* Reduce duplicate builder code

* Fix all checkstyle warnings in eventmesh-runtime

* Add known dependency

* [ISSUE #4814] Migrate from fastjson 1.2.83 to fastjson2 (#4819)

* [Enhancement] Migrate from fastjson 1.2.83 to fastjson2 #4814

* fix_dependencies_problem

* fix_check

* [ISSUE #4551] modify the logic of time-consumption statistics (#4822)

* init connector runtime v2

* [ISSUE #4804] Fix SubStreamHandler exception loop by closeOnError (#4807)

* Handle exception loop by closeOnError

* Lombok optimization

* some format optimization

* Avoid closing multiple times

* Remove redundant set null

* Revert "Avoid closing multiple times"

This reverts commit 774397f.

* Use synchronized latch to keep senderOnComplete called once

* Use boolean to prevent latch called by somebody else

* Remove the unique callee/caller close() of onCompleted()

* [ISSUE #4838] Deprecate unused `eventMesh.connector.plugin.type` etc. properties (#4839)

* Remove all references of `eventMesh.connector.plugin.type`

* Deprecate `eventMesh.connector.plugin.type` and sort properties

* Remove misconfigured & not-used `registerIntervalInMills`, `fetchRegistryAddrIntervalInMills`

* Remove 'defibus' related un-used usages

* Supplement #4809 for `null != object`

* [ISSUE #4832] Downgrade stale bot to v8 to resolve state cache reserving error (#4833)

* Revert stale bot to v8 to resolve state cache reserving error

* Reduce operations-per-run to default value to ease pressure

* Unify yaml to yml

* [ISSUE #4820] Bug fix EventHandler not return json (#4821)

* bug fix

* bug fix

* bug fix

* update runtime v2

* update connector runtime

* update connector runtime

* update connector runtime

* update connector runtime

* update connector runtime

---------

Co-authored-by: Pil0tXia <xiatian@apache.org>
Co-authored-by: Zaki <91261012+cnzakii@users.noreply.github.com>
Co-authored-by: Karson <karsontao@hotmail.com>

* [ISSUE #4931]Add Registry Module for Discovery AdminServer

* [ISSUES #4933]Add Admin Module

* [ISSUE #4935] Add and Move the Pojo Used By Both Runtime and Admin to Common

* [ISSUE #4937]fix gradle dependecy and add runtime v2

* [ISSUES #4939]add canal connector

* fix missing apache header

* fix missing apache header

* fix missing apache header

* update gradle dependencies

* fix admin server ci check error

* fix admin server ci check error

* fix ci checkStyle error

* fix ci check error

* [ISSUE #4979]Canal Connector supports bidirectional data synchronization

* add bash files for admin & runtime-v2

* fix ack offset read & persist

* fix checkStyle error

* [ISSUE #4979] Canal Connector supports bidirectional data synchronization (#5011)

* [ISSUE #4979]Canal Connector supports bidirectional data synchronization

* add bash files for admin & runtime-v2

* fix ack offset read & persist

* fix checkStyle error

* fix http source connector test error

---------

Co-authored-by: sodaRyCN <35725024+sodaRyCN@users.noreply.github.com>
Co-authored-by: Pil0tXia <xiatian@apache.org>
Co-authored-by: Zaki <91261012+cnzakii@users.noreply.github.com>
Co-authored-by: Karson <karsontao@hotmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Issues for first-time contributors help wanted Extra attention is needed
Projects
None yet
3 participants