Skip to content

Commit c530bf4

Browse files
committed
Merge branch 'dev' into dev-proxy2
# Conflicts: # pkg/etc/init.d/wavefront-proxy # proxy/pom.xml # proxy/src/main/java/com/wavefront/agent/AbstractAgent.java # proxy/src/main/java/com/wavefront/agent/ProxyConfig.java # proxy/src/main/java/com/wavefront/agent/PushAgent.java # proxy/src/main/java/com/wavefront/agent/data/LogDataSubmissionTask.java # proxy/src/main/java/com/wavefront/agent/listeners/WavefrontPortUnificationHandler.java # proxy/src/main/java/com/wavefront/common/Utils.java # proxy/src/test/java/com/wavefront/agent/HttpEndToEndTest.java
2 parents 3416b68 + 1334eee commit c530bf4

11 files changed

Lines changed: 156 additions & 87 deletions

File tree

Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ jenkins: .info build-jar build-linux push-linux docker-multi-arch clean
2424
build-jar: .info
2525
mvn -f proxy --batch-mode clean package ${MVN_ARGS}
2626
cp proxy/target/${ARTIFACT_ID}-${VERSION}-spring-boot.jar ${out}
27-
cp proxy/target/${ARTIFACT_ID}-${VERSION}-jar-with-dependencies.jar ${out}
2827

2928
#####
3029
# Build single docker image

proxy/pom.xml

Lines changed: 8 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -67,25 +67,6 @@
6767
</resource>
6868
</resources>
6969
<plugins>
70-
<plugin>
71-
<!-- need it for linux //TODO: review-->
72-
<artifactId>maven-assembly-plugin</artifactId>
73-
<version>3.3.0</version>
74-
<configuration>
75-
<descriptorRefs>
76-
<descriptorRef>jar-with-dependencies</descriptorRef>
77-
</descriptorRefs>
78-
</configuration>
79-
<executions>
80-
<execution>
81-
<id>make-assembly</id> <!-- this is used for inheritance merges -->
82-
<phase>package</phase> <!-- bind to the packaging phase -->
83-
<goals>
84-
<goal>single</goal>
85-
</goals>
86-
</execution>
87-
</executions>
88-
</plugin>
8970
<plugin>
9071
<groupId>com.cosium.code</groupId>
9172
<artifactId>git-code-format-maven-plugin</artifactId>
@@ -397,14 +378,14 @@
397378
</dependencyManagement>
398379

399380
<dependencies>
400-
<dependency>
401-
<groupId>org.apache.logging.log4j</groupId>
402-
<artifactId>log4j-core</artifactId>
403-
</dependency>
404-
<dependency>
405-
<groupId>org.apache.logging.log4j</groupId>
406-
<artifactId>log4j-slf4j2-impl</artifactId>
407-
</dependency>
381+
<dependency>
382+
<groupId>org.apache.logging.log4j</groupId>
383+
<artifactId>log4j-core</artifactId>
384+
</dependency>
385+
<dependency>
386+
<groupId>org.apache.logging.log4j</groupId>
387+
<artifactId>log4j-slf4j2-impl</artifactId>
388+
</dependency>
408389
<dependency>
409390
<groupId>org.apache.activemq</groupId>
410391
<artifactId>artemis-server</artifactId>

proxy/src/main/java/com/wavefront/agent/AbstractAgent.java

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,8 @@ private void initPreprocessors() {
109109
}
110110

111111
// convert block/allow list fields to filters for full backwards compatibility.
112-
// "block" and "allow" regexes are applied to pushListenerPorts, graphitePorts and
112+
// "block" and "allow" regexes are applied to pushListenerPorts, graphitePorts
113+
// and
113114
// picklePorts
114115
String allPorts =
115116
StringUtils.join(
@@ -140,15 +141,19 @@ protected LogsIngestionConfig loadLogsIngestionConfig() {
140141
}
141142

142143
private void postProcessConfig() {
143-
// disable useless info messages when httpClient has to retry a request due to a stale
144-
// connection. the alternative is to always validate connections before reuse, but since
145-
// it happens fairly infrequently, and connection re-validation performance penalty is
146-
// incurred every time, suppressing that message seems to be a more reasonable approach.
144+
// disable useless info messages when httpClient has to retry a request due to a
145+
// stale
146+
// connection. the alternative is to always validate connections before reuse,
147+
// but since
148+
// it happens fairly infrequently, and connection re-validation performance
149+
// penalty is
150+
// incurred every time, suppressing that message seems to be a more reasonable
151+
// approach.
147152
// org.apache.log4j.LoggerFactory.getLogger("org.apache.http.impl.execchain.RetryExec").
148-
// setLevel(org.apache.log4j.Level.WARN);
153+
// setLevel(org.apache.log4j.Level.WARN);
149154
// LoggerFactory.getLogger("org.apache.http.impl.execchain.RetryExec").setLevel(Level.WARNING);
150155

151-
if (StringUtils.isBlank(proxyConfig.getHostname().trim())) {
156+
if (StringUtils.isBlank(proxyConfig.getHostname())) {
152157
throw new IllegalArgumentException(
153158
"hostname cannot be blank! Please correct your configuration settings.");
154159
}
@@ -157,24 +162,14 @@ private void postProcessConfig() {
157162
@VisibleForTesting
158163
void parseArguments(String[] args) {
159164
// read build information and print version.
160-
String versionStr =
161-
"Wavefront Proxy version "
162-
+ getBuildVersion()
163-
+ " (pkg:"
164-
+ getPackage()
165-
+ ")"
166-
+ ", runtime: "
167-
+ getJavaVersion();
168165
try {
169166
if (!proxyConfig.parseArguments(args, this.getClass().getCanonicalName())) {
170167
System.exit(0);
171168
}
172169
} catch (ParameterException e) {
173-
logger.info(versionStr);
174170
logger.error("Parameter exception: " + e.getMessage());
175171
System.exit(1);
176172
}
177-
logger.info(versionStr);
178173
logger.info(
179174
"Arguments: "
180175
+ IntStream.range(0, args.length)
@@ -192,9 +187,13 @@ void parseArguments(String[] args) {
192187
public void start(String[] args) {
193188
try {
194189

195-
/* ------------------------------------------------------------------------------------
190+
/*
191+
* -----------------------------------------------------------------------------
192+
* -------
196193
* Configuration Setup.
197-
* ------------------------------------------------------------------------------------ */
194+
* -----------------------------------------------------------------------------
195+
* -------
196+
*/
198197

199198
// Parse commandline arguments and load configuration file
200199
parseArguments(args);
@@ -229,7 +228,7 @@ public void start(String[] args) {
229228
} else {
230229
throw new IllegalStateException();
231230
}
232-
//noinspection StatementWithEmptyBody
231+
// noinspection StatementWithEmptyBody
233232
while (interactiveTester.interactiveTest()) {
234233
// empty
235234
}
@@ -295,7 +294,7 @@ public void run() {
295294
5000);
296295
} catch (Exception e) {
297296
logger.error(e.getMessage(), e);
298-
// logger.error(e.getMessage());
297+
// logger.error(e.getMessage());
299298
System.exit(1);
300299
}
301300
}

proxy/src/main/java/com/wavefront/agent/ProxyConfig.java

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -749,13 +749,13 @@ public class ProxyConfig extends Configuration {
749749
@Parameter(
750750
names = {"--hostname"},
751751
description = "Hostname for the proxy. Defaults to FQDN of machine.")
752-
String hostname = getLocalHostName();
752+
String hostname = null;
753753

754754
/** This property holds the proxy name. Default proxyname to FQDN of machine. */
755755
@Parameter(
756756
names = {"--proxyname"},
757757
description = "Name for the proxy. Defaults to hostname.")
758-
String proxyname = getLocalHostName();
758+
String proxyname = null;
759759

760760
@Parameter(
761761
names = {"--idFile"},
@@ -2035,15 +2035,21 @@ public void verifyAndInit() {
20352035
token = ObjectUtils.firstNonNull(config.getRawProperty("token", token), "undefined").trim();
20362036
server = config.getString("server", server);
20372037

2038-
String FQDN = getLocalHostName();
2039-
hostname = config.getString("hostname", hostname);
2040-
proxyname = config.getString("proxyname", proxyname);
2041-
if (!hostname.equals(FQDN)) {
2038+
String _hostname = config.getString("hostname", hostname);
2039+
if (!Strings.isNullOrEmpty(_hostname)) {
20422040
logger.warn(
20432041
"Deprecated field hostname specified in config setting. Please use "
20442042
+ "proxyname config field to set proxy name.");
2045-
if (proxyname.equals(FQDN)) proxyname = hostname;
2043+
hostname = _hostname;
2044+
} else {
2045+
hostname = getLocalHostName();
2046+
}
2047+
2048+
proxyname = config.getString("proxyname", proxyname);
2049+
if (Strings.isNullOrEmpty(proxyname)) {
2050+
proxyname = hostname;
20462051
}
2052+
20472053
logger.info("Using proxyname:'" + proxyname + "' hostname:'" + hostname + "'");
20482054

20492055
idFile = config.getString("idFile", idFile);
@@ -2492,7 +2498,6 @@ public void verifyAndInit() {
24922498
* @throws ParameterException if configuration parsing failed
24932499
*/
24942500
public boolean parseArguments(String[] args, String programName) throws ParameterException {
2495-
String versionStr = "Wavefront Proxy version " + getBuildVersion();
24962501
JCommander jCommander =
24972502
JCommander.newBuilder()
24982503
.programName(programName)
@@ -2501,11 +2506,9 @@ public boolean parseArguments(String[] args, String programName) throws Paramete
25012506
.build();
25022507
jCommander.parse(args);
25032508
if (this.isVersion()) {
2504-
System.out.println(versionStr);
25052509
return false;
25062510
}
25072511
if (this.isHelp()) {
2508-
System.out.println(versionStr);
25092512
jCommander.usage();
25102513
return false;
25112514
}

proxy/src/main/java/com/wavefront/agent/PushAgent.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
import static com.wavefront.agent.ProxyUtil.createInitializer;
77
import static com.wavefront.agent.api.APIContainer.CENTRAL_TENANT_NAME;
88
import static com.wavefront.agent.data.EntityProperties.NO_RATE_LIMIT;
9-
import static com.wavefront.common.Utils.csvToList;
10-
import static com.wavefront.common.Utils.lazySupplier;
9+
import static com.wavefront.common.Utils.*;
1110

1211
import com.google.common.annotations.VisibleForTesting;
1312
import com.google.common.base.Preconditions;
@@ -160,6 +159,15 @@ public class PushAgent extends AbstractAgent {
160159

161160
public static void main(String[] args) {
162161
// Start the ssh daemon
162+
String versionStr =
163+
"Wavefront Proxy version "
164+
+ getBuildVersion()
165+
+ " (pkg:"
166+
+ getPackage()
167+
+ ")"
168+
+ ", runtime: "
169+
+ getJavaVersion();
170+
logger.info(versionStr);
163171
new PushAgent().start(args);
164172
}
165173

proxy/src/main/java/com/wavefront/agent/core/senders/LogSenderTask.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,12 @@
1010
import java.util.List;
1111
import java.util.UUID;
1212
import javax.ws.rs.core.Response;
13+
import org.slf4j.Logger;
14+
import org.slf4j.LoggerFactory;
1315

1416
/** This class is responsible for accumulating logs and uploading them in batches. */
1517
public class LogSenderTask extends SenderTask {
18+
private static final Logger LOGGER = LoggerFactory.getLogger("LogDataSubmission");
1619
public static final String AGENT_PREFIX = "WF-PROXY-AGENT-";
1720

1821
private final QueueInfo queue;
@@ -40,6 +43,11 @@ public class LogSenderTask extends SenderTask {
4043
}
4144

4245
protected Response submit(List<String> logs) {
46+
if (LOGGER.isDebugEnabled()) {
47+
for (String log : logs) {
48+
LOGGER.debug("Sending a log to the backend: " + log);
49+
}
50+
}
4351
return logAPI.proxyLogsStr(
4452
AGENT_PREFIX + proxyId.toString(), "[" + String.join(",", logs) + "]");
4553
}

proxy/src/main/java/com/wavefront/agent/formatter/DataFormat.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ public enum DataFormat {
1313
EVENT,
1414
SPAN,
1515
SPAN_LOG,
16-
LOGS_JSON_ARR;
16+
LOGS_JSON_ARR,
17+
LOGS_JSON_LINES;
1718

1819
public static DataFormat autodetect(final String input) {
1920
if (input.length() < 2) return DEFAULT;
@@ -56,6 +57,8 @@ public static DataFormat parse(String format) {
5657
return DataFormat.SPAN_LOG;
5758
case Constants.PUSH_FORMAT_LOGS_JSON_ARR:
5859
return DataFormat.LOGS_JSON_ARR;
60+
case Constants.PUSH_FORMAT_LOGS_JSON_LINES:
61+
return DataFormat.LOGS_JSON_LINES;
5962
default:
6063
return null;
6164
}

0 commit comments

Comments
 (0)