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

Fix few bugs related to AI APIs #12643

Merged
merged 9 commits into from
Oct 15, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public Map<String, String> getResponseMetadata(String payload, Map<String, Strin
throws APIManagementException {

if (metadataList == null || metadataList.isEmpty()) {
log.warn("Metadata list is null or empty.");
log.debug("Metadata list is null or empty.");
return metadataMap;
}
try {
Expand All @@ -56,13 +56,13 @@ public Map<String, String> getResponseMetadata(String payload, Map<String, Strin
String extractedValue = JsonPath.read(payload, attributeIdentifier).toString();
metadataMap.put(attributeName, extractedValue);
} catch (PathNotFoundException e) {
log.warn("Attribute not found in the payload for identifier: " + attributeIdentifier);
log.debug("Attribute not found in the payload for identifier: " + attributeIdentifier);
}
} else {
log.warn("Payload is null, cannot extract metadata for attribute: " + attributeName);
log.debug("Payload is null, cannot extract metadata for attribute: " + attributeName);
}
} else {
log.warn("Unsupported input source: " + inputSource + " for attribute: " + attributeName);
log.debug("Unsupported input source: " + inputSource + " for attribute: " + attributeName);
}
}
} catch (PathNotFoundException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -448,10 +448,8 @@ public static int getHourByUTC(long timestampMillis) {
return offsetDateTime.getHour();
}

private void getAiAnalyticsData(
Map aiApiResponseMetadata,
int requestStartHour,
Map<String, Object> customProperties
private void getAiAnalyticsData(Map aiApiResponseMetadata, int requestStartHour,
Map<String, Object> customProperties
) {
Map<String, String> aiMetadata = new HashMap<>();
Map<String, Integer> aiTokenUsage = new HashMap<>();
Expand Down Expand Up @@ -608,7 +606,8 @@ public int getResponseSize() {
buildResponseMessage = false;
}
}
Map headers = (Map) messageContext.getProperty(TRANSPORT_HEADERS);
Map headers = (Map) ((Axis2MessageContext) messageContext).getAxis2MessageContext()
.getProperty(TRANSPORT_HEADERS);
if (headers != null && headers.get(HttpHeaders.CONTENT_LENGTH) != null) {
responseSize = Integer.parseInt(headers.get(HttpHeaders.CONTENT_LENGTH).toString());
}
Expand Down Expand Up @@ -637,7 +636,7 @@ public int getResponseSize() {
}

public String getResponseContentType() {
Map headers = (Map) messageContext.getProperty(TRANSPORT_HEADERS);
Map headers = (Map) ((Axis2MessageContext) messageContext).getAxis2MessageContext().getProperty(TRANSPORT_HEADERS);
if (headers != null && headers.get(HttpHeaders.CONTENT_TYPE) != null) {
return headers.get(HttpHeaders.CONTENT_TYPE).toString();
}
Expand Down
Loading
Loading