@@ -141,30 +141,29 @@ filter {
141141 if([transactionSummary][serviceContext][service]) {
142142 mutate {
143143 add_field => { "[@metadata][apiName]" => "%{[transactionSummary][serviceContext][service]}" }
144- add_field => { "[@metadata][cacheAPIPerName ]" => "${CACHE_API_PER_NAME :''}" }
144+ add_field => { "[@metadata][cacheAPIPaths ]" => "${CACHE_API_PATHS :''}" }
145145 }
146146 } else {
147147 # Without an API name, only API path is used for the API lookup.
148148 mutate { add_field => { "[@metadata][apiName]" => "" } }
149149 }
150- # Create a cache key for the API either based on the entire request path or using the API-Name, when the request path
151- # contains path parameters. In that case, the user must configure the leading part of the API-Path
150+ # Create a cache key for the API either based on the received request path or the configured path.
152151 # For example: /v1/get/pet/687687678 --> CACHE_API_PER_NAME = /v1/get/pet makes sure the API is cached based on the API-Name
153152 ruby {
154153 code => '
155- cacheAPINames = event.get("[@metadata][cacheAPIPerName ]");
154+ cacheAPIPaths = event.get("[@metadata][cacheAPIPaths ]");
156155 apiRequestPath = event.get("[transactionSummary][path]");
157- if (cacheAPINames .nil? || cacheAPINames .empty?)
156+ if (cacheAPIPaths .nil? || cacheAPIPaths .empty?)
158157 event.set("[@metadata][apiCacheKeyPrefix]", apiRequestPath);
159158 return;
160159 end
161160 apiName = event.get("[transactionSummary][serviceContext][service]");
162- logger.info("Configured paths and current API-Request path: ", { "cacheAPINames " => cacheAPINames , "apiRequestPath" => apiRequestPath } );
161+ logger.info("Configured paths and current API-Request path: ", { "cacheAPIPaths " => cacheAPIPaths , "apiRequestPath" => apiRequestPath } );
163162 event.set("[@metadata][apiCacheKeyPrefix]", apiRequestPath);
164- for configuredPath in cacheAPINames .split(",") do
163+ for configuredPath in cacheAPIPaths .split(",") do
165164 if(apiRequestPath.start_with?(configuredPath) )
166- logger.info("Using API-Name as primary cache key, because of configured path match . ", { "apiName" => apiName, "configuredPath" => configuredPath, "apiRequestPath" => apiRequestPath });
167- event.set("[@metadata][apiCacheKeyPrefix]", apiName );
165+ logger.info("Using configured path as primary cache key as it matches to request path . ", { "configuredPath" => configuredPath, "apiRequestPath" => apiRequestPath });
166+ event.set("[@metadata][apiCacheKeyPrefix]", configuredPath );
168167 break;
169168 end
170169 end
0 commit comments