Skip to content

Commit

Permalink
Fix the model name for UI display (#72)
Browse files Browse the repository at this point in the history
  • Loading branch information
jinsongo authored Nov 19, 2024
1 parent 700b9ae commit 2cc9d73
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions llm/src/main/java/com/instana/dc/llm/impl/llm/LLMDc.java
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ public void collectData() {
// This costs are 10000 times the actual value to prevent very small numbers from being rounded off.
// And it will be adjusted to the correct value on UI.
String backwardCompatible = System.getenv("FORCE_BACKWARD_COMPATIBLE");
if (backwardCompatible != null) {
if (backwardCompatible != null && backwardCompatible.equalsIgnoreCase("true")) {
System.out.printf("FORCE_BACKWARD_COMPATIBLE is set.");
} else {
intervalTotalCost = intervalTotalCost * 10000;
Expand All @@ -276,14 +276,16 @@ public void collectData() {
System.out.println(" - Interval Request : " + intervalReqCount);

Map<String, Object> attributes = new HashMap<>();
attributes.put("model_id", modelId);
String replacedId = modelId.replace(".", "/");
String modelIdExt = aiSystem + ":" + replacedId;
attributes.put("model_id", modelIdExt);
attributes.put("ai_system", aiSystem);
getRawMetric(LLM_STATUS_NAME).setValue(1);
getRawMetric(LLM_DURATION_NAME).getDataPoint(modelId).setValue(avgDurationPerReq, attributes);
getRawMetric(LLM_DURATION_MAX_NAME).getDataPoint(modelId).setValue(maxDurationSoFar, attributes);
getRawMetric(LLM_COST_NAME).getDataPoint(modelId).setValue(intervalTotalCost, attributes);
getRawMetric(LLM_TOKEN_NAME).getDataPoint(modelId).setValue(intervalTotalTokens, attributes);
getRawMetric(LLM_REQ_COUNT_NAME).getDataPoint(modelId).setValue(intervalReqCount, attributes);
getRawMetric(LLM_DURATION_NAME).getDataPoint(modelIdExt).setValue(avgDurationPerReq, attributes);
getRawMetric(LLM_DURATION_MAX_NAME).getDataPoint(modelIdExt).setValue(maxDurationSoFar, attributes);
getRawMetric(LLM_COST_NAME).getDataPoint(modelIdExt).setValue(intervalTotalCost, attributes);
getRawMetric(LLM_TOKEN_NAME).getDataPoint(modelIdExt).setValue(intervalTotalTokens, attributes);
getRawMetric(LLM_REQ_COUNT_NAME).getDataPoint(modelIdExt).setValue(intervalReqCount, attributes);
}
logger.info("-----------------------------------------");
}
Expand Down

0 comments on commit 2cc9d73

Please sign in to comment.