-
Notifications
You must be signed in to change notification settings - Fork 58
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
Track mapconfig id / template id in logs #1135
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need this?
In Kibana we already have this info. Check layergroup_id
and named_map_template_id
fields.
The idea is to add more info to follow all the mapconfig flow:
Makes sense? |
Do you mean the Maps API instance? If so, we already have that info. See:
That's more interesting. 🤔 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You already have a header where the layergroup-id can be used to be added in the log entry. Check:
Let me explain better:
With all this info, we can know the lifecycle of a mapconfig / template. The idea is to get more info to investigate lost mapconfigs. I know I have added template id / mapconfig id in some places where we already have it (for example in the template update or delete where we get them from the URL) but I want to have a consistent place to have the info. |
Yeah, I know what you want to accomplish here. 😄 Apart from the links that I shared above, which give you most of what you need to be able to add it in the log entry, you'll have to add a new header with the template id ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now I understand better what you want to achieve. I left a couple of comments.
@@ -82,6 +82,7 @@ function getTile ({ tileBackend, label }) { | |||
|
|||
res.statusCode = 200; | |||
res.body = tile; | |||
res.locals.mapConfig = mapConfigProvider.mapConfig; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we don't need it, do we?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it is the only way I found the get the relation between template and mapconfig. But I see now it is possible using the logic from setLayergroupIdHeaderMiddleware
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I explained in the other comment, it seems more complicated to use the logic from setLayergroupIdHeaderMiddleware
instead of saving mapconfig in locals (or simply the id if you see any memory problem)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you already have the layergroup token in multiple places:
- The raw token: req.params.token.
- The layergroup and the timestamp: https://github.com/CartoDB/Windshaft-cartodb/blob/master/lib/api/middlewares/layergroup-token.js#L13-L14
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I was mixing controllers we are in template.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should use mapConfigProvider.getMapConfig()
method instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In fact, why not move this to setTilerInfoHeader
middleware as mapConfigProvider
is already set in res.locals
which is available in that middleware?.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I am going to extract the mapconfig id from mapConfigProvider
in setTilerInfoHeader
You should use mapConfigProvider.getMapConfig() method instead.
As setTilerInfoHeader
happens after all the controller middlewares, if everything goes fine, mapConfigProvider
should already have the mapConfig
property set and we can avoid doing a new redis request.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's already cached after the first fetch, see:
- https://github.com/CartoDB/Windshaft-cartodb/blob/master/lib/models/mapconfig/provider/map-store-provider.js#L37-L39
- https://github.com/CartoDB/Windshaft-cartodb/blob/master/lib/models/mapconfig/provider/named-map-provider.js#L58-L60
Please, use the public interface methods. The member .mapConfig
should be private...
Related to https://github.com/CartoDB/support/issues/2177