From 94eacf3cd2f2894b9fe19b6733d9a56758ee76b4 Mon Sep 17 00:00:00 2001 From: JINSONG WANG Date: Tue, 19 Nov 2024 13:36:18 -0800 Subject: [PATCH] Fix the model name for UI display --- .../java/com/instana/dc/llm/impl/llm/LLMDc.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/llm/src/main/java/com/instana/dc/llm/impl/llm/LLMDc.java b/llm/src/main/java/com/instana/dc/llm/impl/llm/LLMDc.java index c05118a..7118961 100644 --- a/llm/src/main/java/com/instana/dc/llm/impl/llm/LLMDc.java +++ b/llm/src/main/java/com/instana/dc/llm/impl/llm/LLMDc.java @@ -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; @@ -276,14 +276,16 @@ public void collectData() { System.out.println(" - Interval Request : " + intervalReqCount); Map 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("-----------------------------------------"); }