Skip to content

Commit 9411fb3

Browse files
authored
fix(bug): app agent over-count in AppAgentAPM sheet. (#178)
1 parent 8d501ca commit 9411fb3

File tree

3 files changed

+46
-39
lines changed

3 files changed

+46
-39
lines changed

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v1.7.1
1+
v1.7.2

backend/extractionSteps/maturityAssessment/apm/AppAgentsAPM.py

Lines changed: 44 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -180,43 +180,50 @@ def analyze(self, controllerData, thresholds):
180180
application["appAgentVersions"] = []
181181

182182
for node in application["nodes"]:
183-
app_agent_present = node.get("appAgentPresent") is True
184-
if app_agent_present and node["appAgentVersion"] in nodeVersionMap:
185-
nodeVersionMap[node["appAgentVersion"]] += 1
186-
elif app_agent_present:
187-
nodeVersionMap[node["appAgentVersion"]] = 1
188-
189-
# Calculate version age
190-
numberNodesWithAppAgentInstalled += 1
191-
if not app_agent_present:
192-
continue
193-
194-
version = semanticVersionRegex.search(node["appAgentVersion"])[0].split(".") # e.g. 'Server Agent v21.6.1.2 GA ...'
195-
majorVersion = int(version[0])
196-
minorVersion = int(version[1])
197-
198-
hostInfo["appAgentVersions"].add((majorVersion, minorVersion, node["agentType"]))
199-
application["appAgentVersions"].append(f"{node['agentType']}:{version[0]}.{version[1]}")
200-
201-
if majorVersion == 4: # Agents with version 4 and below will always fail.
202-
node["appAgentAge"] = 3
203-
else:
204-
years = currYear - majorVersion
205-
if minorVersion < currMonth:
206-
years += 1
207-
node["appAgentAge"] = years
208-
209-
if years <= 2:
210-
numberAppAgentsLessThan2YearsOld += 1
211-
if years == 1:
212-
numberAppAgentsLessThan1YearOld += 1
213-
214-
# Determine application load
215-
if node["appAgentAvailability"] != 0:
216-
numberAppAgentsReportingData += 1
217-
218-
if node["nodeMetricsUploadRequestsExceedingLimit"] != 0:
219-
analysisDataEvaluatedMetrics["metricLimitNotHit"] = False
183+
# Support both APIs: new (explicit flag) and old (implicit via non-empty version string)
184+
app_agent_present_flag = node.get("appAgentPresent", None)
185+
app_agent_present = (
186+
app_agent_present_flag is True
187+
or (app_agent_present_flag is None and node.get("appAgentVersion", "") != "")
188+
)
189+
190+
if app_agent_present:
191+
version_str = node.get("appAgentVersion", "")
192+
if version_str in nodeVersionMap:
193+
nodeVersionMap[version_str] += 1
194+
else:
195+
nodeVersionMap[version_str] = 1
196+
197+
numberNodesWithAppAgentInstalled += 1
198+
199+
match = semanticVersionRegex.search(version_str)
200+
if not match:
201+
continue # Cannot parse semantic version, skip aging logic
202+
203+
version = match[0].split(".")
204+
majorVersion = int(version[0])
205+
minorVersion = int(version[1])
206+
207+
hostInfo["appAgentVersions"].add((majorVersion, minorVersion, node.get("agentType")))
208+
application["appAgentVersions"].append(f"{node.get('agentType')}:{version[0]}.{version[1]}")
209+
210+
if majorVersion == 4:
211+
node["appAgentAge"] = 3
212+
else:
213+
years = currYear - majorVersion
214+
if minorVersion < currMonth:
215+
years += 1
216+
node["appAgentAge"] = years
217+
if years <= 2:
218+
numberAppAgentsLessThan2YearsOld += 1
219+
if years == 1:
220+
numberAppAgentsLessThan1YearOld += 1
221+
222+
if node.get("appAgentAvailability", 0) != 0:
223+
numberAppAgentsReportingData += 1
224+
225+
if node.get("nodeMetricsUploadRequestsExceedingLimit", 0) != 0:
226+
analysisDataEvaluatedMetrics["metricLimitNotHit"] = False
220227

221228
# In the case of multiple versions, will return the largest common agent count regardless of version.
222229
try:

input/thresholds/DefaultThresholds.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "v1.7.1",
2+
"version": "v1.7.2",
33
"apm": {
44
"AppAgentsAPM": {
55
"platinum": {

0 commit comments

Comments
 (0)