1313import java .util .ArrayList ;
1414import java .util .List ;
1515import java .util .Map ;
16- import java .util .concurrent .Semaphore ;
1716
1817public 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