Skip to content

Commit f9346e4

Browse files
committed
Fixed AppName in LogMsgGroup
1 parent a963896 commit f9346e4

2 files changed

Lines changed: 7 additions & 44 deletions

File tree

src/main/java/com/stackify/api/common/log/LogCollector.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,16 +117,19 @@ public int flush(final LogSender sender) throws IOException, HttpException {
117117
groupBuilder.platform("java");
118118
groupBuilder.logger(logger);
119119
groupBuilder.serverName(envDetail.getDeviceName());
120+
groupBuilder.env(envDetail.getConfiguredEnvironmentName());
121+
groupBuilder.appName(envDetail.getConfiguredAppName());
122+
groupBuilder.appLoc(envDetail.getAppLocation());
120123

121124
if (appIdentity.isPresent()) {
122125
groupBuilder.cdId(appIdentity.get().getDeviceId());
123126
groupBuilder.cdAppId(appIdentity.get().getDeviceAppId());
124127
groupBuilder.appNameId(appIdentity.get().getAppNameId());
125128
groupBuilder.envId(appIdentity.get().getEnvId());
126-
} else {
127-
groupBuilder.appName(envDetail.getConfiguredAppName());
128-
groupBuilder.appLoc(envDetail.getAppLocation());
129-
groupBuilder.env(envDetail.getConfiguredEnvironmentName());
129+
130+
if ((appIdentity.get().getAppName() != null) && (0 < appIdentity.get().getAppName().length())) {
131+
groupBuilder.appName(appIdentity.get().getAppName());
132+
}
130133
}
131134

132135
groupBuilder.msgs(batch);

src/main/java/com/stackify/api/common/log/LogSender.java

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,6 @@ public int send(final LogMsgGroup group) throws IOException {
6565

6666
// convert to json bytes
6767

68-
String jsonString = objectMapper.writer().writeValueAsString(group);
69-
7068
byte[] jsonBytes = objectMapper.writer().writeValueAsBytes(group);
7169

7270
// post to stackify
@@ -83,43 +81,5 @@ public int send(final LogMsgGroup group) throws IOException {
8381
}
8482

8583
return statusCode;
86-
87-
/*
88-
HttpURLConnection connection = null;
89-
90-
try {
91-
URL url = new URL(apiConfig.getApiUrl() + "/Log/Save");
92-
93-
connection = (HttpURLConnection) url.openConnection();
94-
connection.setDoInput(true);
95-
connection.setDoOutput(true);
96-
connection.setRequestProperty("Content-Type", "application/json");
97-
connection.setRequestProperty("Content-Encoding", "gzip");
98-
connection.setRequestProperty("X-Stackify-Key", apiConfig.getApiKey());
99-
connection.setRequestProperty("X-Stackify-PV", "V1");
100-
connection.setRequestMethod("POST");
101-
connection.setConnectTimeout(5000);
102-
connection.setReadTimeout(5000);
103-
104-
OutputStream stream = new BufferedOutputStream(new GZIPOutputStream(connection.getOutputStream()));
105-
106-
try {
107-
objectMapper.writer().writeValue(stream, group);
108-
} catch (JsonGenerationException e) {
109-
throw new RuntimeException(e);
110-
} catch (JsonMappingException e) {
111-
throw new RuntimeException(e);
112-
} catch (IOException e) {
113-
throw new RuntimeException(e);
114-
}
115-
116-
stream.flush();
117-
stream.close();
118-
119-
return connection.getResponseCode();
120-
} finally {
121-
HttpUrlConnections.readAndCloseInputStreams(connection);
122-
}
123-
*/
12484
}
12585
}

0 commit comments

Comments
 (0)