-
Notifications
You must be signed in to change notification settings - Fork 438
Introducing Performance Loggers #2706
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
machavan
wants to merge
5
commits into
main
Choose a base branch
from
dev/machavan/perflogger
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
9e5b628
POC Perf Logger
machavan 678bed6
Added Log prefix to PerformanceLog
machavan eba9a83
Added callback handling logic and test case to validate logger behaviour
muskan124947 2a5d3d7
Addressed comments
muskan124947 33aad19
Updated token acquisition scope to onFedAuthInfo()
muskan124947 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
src/main/java/com/microsoft/sqlserver/jdbc/PerformanceActivity.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.microsoft.sqlserver.jdbc; | ||
|
||
public enum PerformanceActivity { | ||
CONNECTION("Connection"), | ||
TOKEN_ACQUISITION("Token acquisition"), | ||
LOGIN("Login"), | ||
PRELOGIN("Prelogin"); | ||
|
||
private final String activity; | ||
|
||
PerformanceActivity(String activity) { | ||
this.activity = activity; | ||
} | ||
|
||
public String activity() { | ||
return activity; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return activity; | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
src/main/java/com/microsoft/sqlserver/jdbc/PerformanceLog.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package com.microsoft.sqlserver.jdbc; | ||
|
||
import java.util.logging.Level; | ||
import java.util.logging.Logger; | ||
|
||
public class PerformanceLog { | ||
muskan124947 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
static final java.util.logging.Logger perfLoggerConnection = java.util.logging.Logger | ||
.getLogger("com.microsoft.sqlserver.jdbc.PerformanceMetrics.Connection"); | ||
|
||
//TODO | ||
//More loggers to be added here e.g. com.microsoft.sqlserver.jdbc.PerformanceMetrics.Statement | ||
|
||
public static class Scope implements AutoCloseable { | ||
private Logger logger; | ||
private String logPrefix; | ||
private PerformanceActivity activity; | ||
private long startTime; | ||
private final boolean enabled; | ||
|
||
public Scope(Logger logger, String logPrefix, PerformanceActivity activity) { | ||
this.enabled = logger.isLoggable(Level.INFO); | ||
if (enabled) { | ||
this.logger = logger; | ||
this.logPrefix = logPrefix; | ||
this.activity = activity; | ||
this.startTime = enabled ? System.currentTimeMillis() : 0; | ||
muskan124947 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
logger.info(String.format("%d %s %s start", startTime, logPrefix, activity)); | ||
} | ||
} | ||
|
||
@Override | ||
public void close() { | ||
if (enabled) { | ||
long endTime = System.currentTimeMillis(); | ||
long duration = endTime - startTime; | ||
logger.info(String.format("%d %s %s end, duration: %dms", endTime, logPrefix, activity, duration)); | ||
} | ||
} | ||
} | ||
|
||
public static Scope createScope(Logger logger, String logPrefix, PerformanceActivity activity) { | ||
return new Scope(logger, logPrefix, activity); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.