ClockWork

This service provides you information about all queries executed by ORM and performance metrics for every api request. Also gives you ability to set your own log data. All the information it will be visible into your chrome inspector.

It requires installation of Clockwork Chrome extension ClockWork extensionopen in new window

You need to add special header to activate this feature. My recommendation is to install also this extension ModHeader extensionopen in new window You should set header CoreTrix with value equal to the password you will set bellow in your yaml file

clockwork:
    password: "your password here"

1
2
3

Register the service into your main.go file as context service:

registry.ServiceProviderClockWorkForContext()
1

Access the service:

service.DI().ClockWorkForContext(ctx).GetLoggerDataSource()
1

There are 2 steps that also needs to be done:

  1. To add this middleware
	hitrixMiddleware "github.com/coretrix/hitrix/pkg/middleware"
	
	...
	
	hitrixMiddleware.Clockwork(ginEngine)
1
2
3
4
5
  1. To add special route
	hitrixController "github.com/coretrix/hitrix/pkg/controller"

    ...

	var clockwork *hitrixController.ClockworkController
	ginEngine.GET("/__clockwork/:id", clockwork.GetIndexAction)
1
2
3
4
5
6

You also are able to send your own data to clockwork and use it as a logger to debug easily. You can do it in that way anywhere in your code:

	service.DI().ClockWorkForContext(ctx).GetLoggerDataSource().LogDebugString("key", "test")
1