I have created a service to store log info in a DynamoDB from the activity on REST endpoint. In order to create the primary key I get the invoked method using the following static method:
public static String getMethodName(){
return Thread.currentThread().getStackTrace()[2].getMethodName();
}
But I was told by a peer reviewer that this is a reflection invocation, hence it could create a performance issue. I don't think it uses reflection, maybe getStackTrace() can be a bit heavy. Anyway, I was recommended to use a Hash function or GUID kind of function in order to generate the primary key. But my question is how can it be done without having the method or endpoint name. I think it is really important information for the primary key, or maybe how could I get this data in other way.
Aucun commentaire:
Enregistrer un commentaire