Skip to content

Conversation

@machavan
Copy link
Contributor

@machavan machavan commented Jul 15, 2025

Description

This is a foundational change for introducing performance loggers to the mssql-jdbc driver. The new logging infrastructure is designed to enable tracking the performance of various critical activities within the driver, such as:

  • Connection time
  • Prelogin time
  • Login time
  • Token acquisition time
  • (Additional activities can be added in the future)

New Logger

  • A new java.util.logging logger named com.microsoft.sqlserver.jdbc.PerformanceMetrics.Connection has been introduced.
    • Applications can subscribe to this logger to receive performance metrics.
    • In future updates, more loggers (e.g., com.microsoft.sqlserver.jdbc.PerformanceMetrics.Statement) will be introduced to cover other areas such as statement execution, result set handling, etc.

Performance Activities

  • Performance activities to be tracked are defined in a new PerformanceActivity enum.
    • This enum currently includes connection, login, prelogin, and token acquisition times.
    • The enum is designed to be easily extended as new tracking needs arise.

Callback Handling

  • The logger and tracking framework handle callbacks to ensure performance data is captured at the appropriate lifecycle points within connection and login processes.
  • The design supports clean extensibility for adding new callback hooks in the future.

Working of Performance Logger

When a performance-sensitive activity such as connection or login begins, a logger instance is created and records the start time. The activity is then executed within the logger’s scope. Once the activity completes or fails, the logger’s close() method is called to capture the end time and calculate the duration. If a callback is registered, the logger publishes the activity type, connection ID, duration, and any exception to it. The same information is also logged using the Java logger, making the metrics available for monitoring and diagnostics.

Testing

  • Unit tests have been added to verify that the performance logger records the expected events and metrics for connection, login, and token acquisition activities.
  • Manual testing was performed to ensure that subscribing to the logger yields the correct log output during normal driver usage.
    -All existing tests ensure testing of newly added code.

This change lays the groundwork for a robust, extensible performance monitoring framework in the mssql-jdbc driver, enabling users to better observe, analyze, and optimize their application's interactions with SQL Server.

@codecov
Copy link

codecov bot commented Jul 15, 2025

Codecov Report

❌ Patch coverage is 71.42857% with 16 lines in your changes missing coverage. Please review.
✅ Project coverage is 56.33%. Comparing base (ed649c4) to head (8a757bc).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...a/com/microsoft/sqlserver/jdbc/PerformanceLog.java 67.39% 8 Missing and 7 partials ⚠️
.../microsoft/sqlserver/jdbc/PerformanceActivity.java 90.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #2706      +/-   ##
============================================
- Coverage     56.35%   56.33%   -0.03%     
+ Complexity     4531     4525       -6     
============================================
  Files           149      151       +2     
  Lines         34376    34478     +102     
  Branches       5734     5745      +11     
============================================
+ Hits          19373    19423      +50     
- Misses        12393    12421      +28     
- Partials       2610     2634      +24     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@machavan machavan added this to the 13.3.0 milestone Aug 26, 2025
@muskan124947 muskan124947 changed the title Introducing Performance Loggers Introducing Performance Logger and callback handling mechanism Oct 31, 2025
@machavan
Copy link
Contributor Author

machavan commented Nov 4, 2025

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@muskan124947 muskan124947 merged commit 6788aa3 into main Nov 6, 2025
18 of 19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants