Skip to content

Commit 6cf4cf9

Browse files
authored
feature/ts-in-metric: add ts in metric (#6)
1 parent 87a726a commit 6cf4cf9

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ install the sdk in using maven
4545
<dependency>
4646
<groupId>co.featbit</groupId>
4747
<artifactId>Featbit-Java-SDK</artifactId>
48-
<version>1.0.2</version>
48+
<version>1.0.3</version>
4949
</dependency>
5050
</dependencies>
5151
```

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>co.featbit</groupId>
88
<artifactId>featbit-java-sdk</artifactId>
9-
<version>1.0.2</version>
9+
<version>1.0.3</version>
1010

1111
<name>featbit/featbit-java-sdk</name>
1212

src/main/java/co/featbit/server/InsightTypes.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
import java.util.ArrayList;
1414
import java.util.List;
1515
import java.util.Map;
16-
import java.util.concurrent.Semaphore;
1716

1817
public abstract class InsightTypes {
1918

@@ -160,14 +159,18 @@ static final class Metric {
160159
private final String eventName;
161160
private final Double numericValue;
162161
private final String appType = "javaserverside";
162+
private final long timestamp;
163163

164-
Metric(String eventName, Double numericValue) {
164+
Metric(String eventName, Double numericValue, long timestamp) {
165165
this.eventName = eventName;
166166
this.numericValue = numericValue;
167+
this.timestamp = timestamp;
167168
}
168169

169170
static Metric of(String eventName, Double numericValue) {
170-
return new Metric(eventName, numericValue == null ? 1.0D : numericValue);
171+
return new Metric(eventName,
172+
numericValue == null ? 1.0D : numericValue,
173+
Instant.now().toEpochMilli());
171174
}
172175

173176
public String getEventName() {
@@ -189,6 +192,10 @@ public String getType() {
189192
public String getAppType() {
190193
return appType;
191194
}
195+
196+
public long getTimestamp() {
197+
return timestamp;
198+
}
192199
}
193200

194201
final static class UserEventSerializer implements JsonSerializer<UserEvent> {
@@ -235,6 +242,7 @@ public JsonElement serialize(MetricEvent metricEvent, Type type, JsonSerializati
235242
var.addProperty("eventName", metric.getEventName());
236243
var.addProperty("numericValue", metric.getNumericValue());
237244
var.addProperty("appType", metric.getAppType());
245+
var.addProperty("timestamp", metric.getTimestamp());
238246
array1.add(var);
239247
}
240248
json.add("metrics", array1);

0 commit comments

Comments
 (0)