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

[BUG] /connectionLogs/{channelId} API doesn't respect fetch size #4748

Open
mkopinsky opened this issue Sep 23, 2021 · 0 comments
Open

[BUG] /connectionLogs/{channelId} API doesn't respect fetch size #4748

mkopinsky opened this issue Sep 23, 2021 · 0 comments
Labels
bug Something isn't working

Comments

@mkopinsky
Copy link

Describe the bug
A request to /api/extensions/dashboardstatus/connectionLogs/{channelId}?fetchSize=1 should per the docs only return a single entry. It returns more than that - doesn't seem to be limiting.

I'm pretty sure this boils down to the fact that the fetchSize argument is never used here:

public synchronized LinkedList<ConnectionLogItem> getChannelLog(String serverId, String channelId, int fetchSize, Long lastLogId) {
LinkedList<ConnectionLogItem> channelLog;
if (channelId == null) {
/*
* object is null - no channel is selected. return the latest entire log entries of all
* channels combined. ONLY new entries.
*/
channelId = "No Channel Selected";
channelLog = entireConnectorInfoLogs;
} else {
// object is not null - a channel is selected. return the latest
// (LOG_SIZE) of that particular channel.
// return only the newly added log entries for the client with
// matching sessionId.
channelLog = connectorInfoLogs.get(channelId);
if (channelLog == null) {
channelLog = new LinkedList<>();
connectorInfoLogs.put(channelId, channelLog);
}
}
if (lastLogId != null) {
LinkedList<ConnectionLogItem> newChannelLogEntries = new LinkedList<>();
// FYI, channelLog.size() will never be larger than LOG_SIZE
// = 1000.
for (ConnectionLogItem aChannelLog : channelLog) {
if (lastLogId < aChannelLog.getLogId()) {
newChannelLogEntries.addLast(aChannelLog);
}
}
try {
return SerializationUtils.clone(newChannelLogEntries);
} catch (SerializationException e) {
logger.error(e);
}
} else {
/*
* new channel viewing on an already open client. -> all log entries are new. display
* them all. put the lastDisplayedLogId into the HashMap. index0 is the most recent
* entry, and index0 of that entry object contains the logId.
*/
try {
return SerializationUtils.clone(channelLog);
} catch (SerializationException e) {
logger.error(e);
}
}

Environment (please complete the following information):

<com.mirth.connect.model.SystemInfo>
  <jvmVersion>11.0.5</jvmVersion>
  <osName>Linux</osName>
  <osVersion>3.10.0-1160.41.1.el7.x86_64</osVersion>
  <osArchitecture>amd64</osArchitecture>
  <dbName>PostgreSQL</dbName>
  <dbVersion>10.15</dbVersion>
</com.mirth.connect.model.SystemInfo>

Workaround(s)
It's pretty rare to need to fetch only a single entry. My use case is that I want to expose a mirth_channel_last_activity metric from our open source Prometheus exporter and want to try to minimize the amount of data being pulled from Mirth since the exporter will probably be polled every 15 or 30 seconds.

@mkopinsky mkopinsky added the bug Something isn't working label Sep 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant