Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
Igor Urisman authored and Igor Urisman committed May 13, 2024
1 parent af74d4e commit 6a1dfac
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 19 deletions.
2 changes: 1 addition & 1 deletion bin/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Build server SPI standard library.
#

version=1.0.1-RC1
version=1.2.0
root_dir=$(cd $(dirname $0)/..; pwd)

cd $root_dir
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<variant.version>1.0.1-RC1</variant.version>
<variant.version>1.2.0</variant.version>

</properties>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public TraceEventFlusherCsv(String init) throws Exception {
.orElse(Map.of());
out = Files.newBufferedWriter(Paths.get(parseFileName(map)), CREATE, WRITE, TRUNCATE_EXISTING );
if (parseHeader(map)) {
writeLine("event_id", "event_name", "created_on", "session_id", "owner", "attributes", "variation", "experience", "is_control");
writeLine("event_id", "event_name", "created_on", "session_id", "owner", "live_experiences", "attributes");
out.flush();
}
}
Expand All @@ -64,27 +64,40 @@ public void flush(FlushableTraceEvent[] events, int size) throws Exception {
for (int i = 0; i < size; i++) {

FlushableTraceEvent event = events[i];
StringBuilder attrsBuffer = new StringBuilder();
StringBuilder stringBuilder = new StringBuilder();

// Attributes
boolean first = true;
stringBuilder.append("{");
for (Map.Entry<String, String> param: event.getAttributes().entrySet()) {
if (first) first = false;
else attrsBuffer.append(';');
attrsBuffer.append(param.getKey()).append('=').append(param.getValue());
else stringBuilder.append(',');
stringBuilder.append(param.getKey()).append(':').append(param.getValue());
}
String attrs = attrsBuffer.toString();

for (Experience e: event.getLiveExperiences()) {
writeLine(
event.getId(),
event.getName(),
DateTimeFormatter.ISO_INSTANT.format(event.getTimestamp()),
event.getSessionId(),
event.getSessionOwner().orElse(""),
attrs,
e.getVariation().getName(),
e.getName(),
e.isControl());
stringBuilder.append("}");
String attrs = stringBuilder.toString();

// Live experiences
stringBuilder.setLength(0);
first = true;
stringBuilder.append("[");
for (Experience le: event.getLiveExperiences()) {
if (first) first = false;
else stringBuilder.append(",");
stringBuilder.append(le.toString()); // prints varname.expname
}
stringBuilder.append("]");

String liveExperiences = stringBuilder.toString();

writeLine(
event.getId(),
event.getName(),
DateTimeFormatter.ISO_INSTANT.format(event.getTimestamp()),
event.getSessionId(),
event.getSessionOwner().orElse("?"),
liveExperiences,
attrs);
}
out.flush();
}
Expand Down

0 comments on commit 6a1dfac

Please sign in to comment.