Skip to content

Commit

Permalink
Merge branch 'async'
Browse files Browse the repository at this point in the history
Signed-off-by: Karsten Schnitter <[email protected]>
  • Loading branch information
KarstenSchnitter committed Jul 2, 2018
2 parents db9ffd6 + 01076fa commit 8e76c9d
Show file tree
Hide file tree
Showing 23 changed files with 726 additions and 278 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ All in all, you should do the following:
* adjust your logging configuration accordingly.


Say, you want to make use of the *servlet filter* feature, then you need to add the following dependency to your POM with property `cf-logging-version` referring to the latest nexus version (currently `2.1.5`):
Say, you want to make use of the *servlet filter* feature, then you need to add the following dependency to your POM with property `cf-logging-version` referring to the latest nexus version (currently `2.2.0`):

```xml
<properties>
Expand Down
2 changes: 1 addition & 1 deletion cf-java-logging-support-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<parent>
<groupId>com.sap.hcp.cf.logging</groupId>
<artifactId>cf-java-logging-support-parent</artifactId>
<version>2.1.5</version>
<version>2.2.0</version>
<relativePath>../pom.xml</relativePath>
</parent>
<build>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.sap.hcp.cf.logging.common;

import java.io.Closeable;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
Expand Down Expand Up @@ -39,7 +38,7 @@
*
*
*/
public class RequestRecord implements Closeable {
public class RequestRecord {

/*
* -- default values for request fields that are marked as "required"
Expand Down Expand Up @@ -100,7 +99,6 @@ public RequestRecord(String layerKey, Direction direction) {
addTag(Fields.DIRECTION, direction.toString());
setDefaults();
start();
RequestRecordHolder.add(this);
}

/**
Expand Down Expand Up @@ -198,11 +196,6 @@ public long stop() {
return endMs;
}

@Override
public void close() {
RequestRecordHolder.remove(this);
}

@Override
public String toString() {
/*
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ public void testAddingSingleActivatedOptionalTagToRequestRecord() throws JSONObj
String tag = "TestTag";

to(requestRecord).addOptionalTag(canBeLogged, key, tag);
requestRecord.close();

assertEquals(tag, getFieldFromRequestRecord(requestRecord, key));
}
Expand All @@ -33,7 +32,6 @@ public void testAddingSingleForbiddenOptionalTagToRequestRecord() throws JSONObj
String tag = "TestTag";

to(requestRecord).addOptionalTag(canBeLogged, key, tag);
requestRecord.close();

assertEquals(Defaults.REDACTED, getFieldFromRequestRecord(requestRecord, key));
}
Expand All @@ -46,7 +44,6 @@ public void testAddingSingleForbiddenOptionalNullTagToRequestRecord() throws JSO
String tag = Defaults.UNKNOWN;

to(requestRecord).addOptionalTag(canBeLogged, key, tag);
requestRecord.close();

assertEquals(Defaults.UNKNOWN, getFieldFromRequestRecord(requestRecord, key));
}
Expand All @@ -59,7 +56,6 @@ public void testAddingSingleActivatedOptionalNullTagToRequestRecord() throws JSO
String tag = Defaults.UNKNOWN;

to(requestRecord).addOptionalTag(canBeLogged, key, tag);
requestRecord.close();

assertEquals(Defaults.UNKNOWN, getFieldFromRequestRecord(requestRecord, key));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ public void testLogRecordMsgNotFlattened() {
RequestRecord lrec = new RequestRecord(LOG_PROVIDER);
String lmsg = lrec.toString();
assertThat(formatMsg(jmc, lmsg), is(lmsg));
lrec.close();
}

@Test
Expand All @@ -68,7 +67,6 @@ public void testLogRecordMsgFlattened() {
RequestRecord lrec = new RequestRecord(LOG_PROVIDER);
String lmsg = lrec.toString();
assertThat(formatMsg(jmc, lmsg), is(lmsg.substring(1, lmsg.length() - 1)));
lrec.close();
}

@Test
Expand Down
2 changes: 1 addition & 1 deletion cf-java-logging-support-jersey/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<relativePath>../pom.xml</relativePath>
<groupId>com.sap.hcp.cf.logging</groupId>
<artifactId>cf-java-logging-support-parent</artifactId>
<version>2.1.5</version>
<version>2.2.0</version>
</parent>

<name>cf-java-logging-support-jersey</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ public void handle(ResponseContextAdapter responseContext, RequestRecord rr) {
rr.addValue(Fields.RESPONSE_STATUS, new LongValue(responseContext.getStatus()));
rr.stop();
LOGGER.info(Markers.REQUEST_MARKER, "{}", rr);
/*
* -- close this instance
*/
rr.close();
} else {
LOGGER.error("No record found to handle response {}", responseContext);
}
Expand Down
2 changes: 1 addition & 1 deletion cf-java-logging-support-log4j2/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<relativePath>../pom.xml</relativePath>
<groupId>com.sap.hcp.cf.logging</groupId>
<artifactId>cf-java-logging-support-parent</artifactId>
<version>2.1.5</version>
<version>2.2.0</version>
</parent>

<dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ public void testLogRecordMsgNotFlattened() {
RequestRecord lrec = new RequestRecord(LOG_PROVIDER);
String lmsg = lrec.toString();
assertThat(format(jmc, makeEvent(lmsg, NO_ARGS)), is(lmsg));
lrec.close();
}

@Test
Expand All @@ -65,7 +64,6 @@ public void testLogRecordMsgFlattened() {
RequestRecord lrec = new RequestRecord(LOG_PROVIDER);
String lmsg = lrec.toString();
assertThat(format(jmc, makeEvent(lmsg, NO_ARGS)), is(lmsg.substring(1, lmsg.length() - 1)));
lrec.close();
}

@Test
Expand Down
2 changes: 1 addition & 1 deletion cf-java-logging-support-logback/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<relativePath>../pom.xml</relativePath>
<groupId>com.sap.hcp.cf.logging</groupId>
<artifactId>cf-java-logging-support-parent</artifactId>
<version>2.1.5</version>
<version>2.2.0</version>
</parent>

<dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,44 +12,39 @@

public class PerfTestRequestRecord {

private static final int DEF_ITERATIONS = 1000000;
private final int iterations;
private static final Logger LOGGER = LoggerFactory.getLogger(PerfTestRequestRecord.class);

public PerfTestRequestRecord(int iterations) {
if (iterations > 0) {
this.iterations = iterations;
} else {
this.iterations = DEF_ITERATIONS;
}
}

public static void main(String[] args) {
new PerfTestRequestRecord(DEF_ITERATIONS).run(args);
}

private void run(String[] args) {
long start = System.nanoTime();
PrintStream defOut = System.out;
System.setOut(new PrintStream(new OutputStream() {

@Override
public void write(int b) throws IOException {
}
}));
for (int i = 0; i < iterations; i++) {
RequestRecord rrec = null;
try {
rrec = new RequestRecord(PerfTestRequestRecord.class.getName());
LOGGER.info(Markers.REQUEST_MARKER, rrec.toString());
} finally {
rrec.close();
}
}
double delta = (System.nanoTime() - start) / 1000000.0;
System.setOut(defOut);
System.out.println("Writing " + iterations + " records took " + delta + " msecs, " + delta / iterations +
" msecs per record");
}
private static final int DEF_ITERATIONS = 1000000;
private final int iterations;
private static final Logger LOGGER = LoggerFactory.getLogger(PerfTestRequestRecord.class);

public PerfTestRequestRecord(int iterations) {
if (iterations > 0) {
this.iterations = iterations;
} else {
this.iterations = DEF_ITERATIONS;
}
}

public static void main(String[] args) {
new PerfTestRequestRecord(DEF_ITERATIONS).run(args);
}

private void run(String[] args) {
long start = System.nanoTime();
PrintStream defOut = System.out;
System.setOut(new PrintStream(new OutputStream() {

@Override
public void write(int b) throws IOException {
}
}));
for (int i = 0; i < iterations; i++) {
RequestRecord rrec = new RequestRecord(PerfTestRequestRecord.class.getName());
LOGGER.info(Markers.REQUEST_MARKER, rrec.toString());
}
double delta = (System.nanoTime() - start) / 1000000.0;
System.setOut(defOut);
System.out.println("Writing " + iterations + " records took " + delta + " msecs, " + delta / iterations
+ " msecs per record");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ public void testLogRecordMsgNotFlattened() {
RequestRecord lrec = new RequestRecord(LOG_PROVIDER);
String lmsg = lrec.toString();
assertThat(jmc.convert(makeEvent(lmsg, NO_ARGS)), is(lmsg));
lrec.close();
}

@Test
Expand All @@ -77,7 +76,6 @@ public void testLogRecordMsgFlattened() {
RequestRecord lrec = new RequestRecord(LOG_PROVIDER);
String lmsg = lrec.toString();
assertThat(jmc.convert(makeEvent(lmsg, NO_ARGS)), is(lmsg.substring(1, lmsg.length() - 1)));
lrec.close();
}

@Test
Expand Down
2 changes: 1 addition & 1 deletion cf-java-logging-support-servlet/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<parent>
<groupId>com.sap.hcp.cf.logging</groupId>
<artifactId>cf-java-logging-support-parent</artifactId>
<version>2.1.5</version>
<version>2.2.0</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
Loading

0 comments on commit 8e76c9d

Please sign in to comment.