Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
vNext
----------

- [MINOR] Add helper method to record elapsed time (#2768)
- [MINOR] Implement TenantUtil (#2761)
- [MAJOR] Update proguard rules in common (#2756)
- [MINOR] Add query parameter for Android Release OS Version (#2754)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,4 +124,20 @@ public static LongCounter createLongCounter(@NonNull final String name, @NonNull
.setUnit("count")
.build();
}

/**
* Helper method to calculate and record the elapsed time since the provided start time.
*
* @param attributeName The name of the attribute to record in the telemetry.
* @param startTimeMillis The start time in milliseconds.
* The time unit recorded is milliseconds.
* If {@code startTimeMillis} is negative or in the future (greater than the current time),
* the method will record a negative or unexpected elapsed time value.
* No validation is performed on the input value.
*/
public static void recordElapsedTime(@NonNull final String attributeName, final long startTimeMillis) {
final long endTimeMillis = System.currentTimeMillis();
final long elapsedTimeMillis = endTimeMillis - startTimeMillis;
SpanExtension.current().setAttribute(attributeName, elapsedTimeMillis);
}
}