Skip to content

Commit aae5333

Browse files
committed
HHH-18907 improve how statistics are logged
1 parent c9fa8aa commit aae5333

File tree

3 files changed

+129
-206
lines changed

3 files changed

+129
-206
lines changed

hibernate-core/src/main/java/org/hibernate/internal/CoreMessageLogger.java

Lines changed: 87 additions & 165 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,6 @@ public interface CoreMessageLogger extends BasicLogger {
5151
@Message(value = "Already session bound on call to bind(); make sure you clean up your sessions", id = 2)
5252
void alreadySessionBound();
5353

54-
@LogMessage(level = WARN)
55-
@Message(value = "JTASessionContext being used with JDBC transactions; auto-flush will not operate correctly with getCurrentSession()",
56-
id = 8)
57-
void autoFlushWillNotWork();
58-
5954
@LogMessage(level = WARN)
6055
@Message(value = "Configuration settings with for connection provider '%s' are set, but the connection provider is not on the classpath; these properties will be ignored",
6156
id = 22)
@@ -81,26 +76,6 @@ public interface CoreMessageLogger extends BasicLogger {
8176
@Message(value = "Closing", id = 31)
8277
void closing();
8378

84-
@LogMessage(level = INFO)
85-
@Message(value = "Collections fetched (minimize this): %s", id = 32)
86-
void collectionsFetched(long collectionFetchCount);
87-
88-
@LogMessage(level = INFO)
89-
@Message(value = "Collections loaded: %s", id = 33)
90-
void collectionsLoaded(long collectionLoadCount);
91-
92-
@LogMessage(level = INFO)
93-
@Message(value = "Collections recreated: %s", id = 34)
94-
void collectionsRecreated(long collectionRecreateCount);
95-
96-
@LogMessage(level = INFO)
97-
@Message(value = "Collections removed: %s", id = 35)
98-
void collectionsRemoved(long collectionRemoveCount);
99-
100-
@LogMessage(level = INFO)
101-
@Message(value = "Collections updated: %s", id = 36)
102-
void collectionsUpdated(long collectionUpdateCount);
103-
10479
@LogMessage(level = WARN)
10580
@Message(value = "Composite-id class does not override equals(): %s", id = 38)
10681
void compositeIdClassDoesNotOverrideEquals(String name);
@@ -109,10 +84,6 @@ public interface CoreMessageLogger extends BasicLogger {
10984
@Message(value = "Composite-id class does not override hashCode(): %s", id = 39)
11085
void compositeIdClassDoesNotOverrideHashCode(String name);
11186

112-
@LogMessage(level = INFO)
113-
@Message(value = "Connections obtained: %s", id = 48)
114-
void connectionsObtained(long connectCount);
115-
11687
@LogMessage(level = WARN)
11788
@Message(value = "Ignoring bag join fetch [%s] due to prior collection join fetch", id = 51)
11889
void containsJoinFetchedCollection(String role);
@@ -137,26 +108,6 @@ public interface CoreMessageLogger extends BasicLogger {
137108
@Message(value = "Found more than one <persistence-unit-metadata>, subsequent ignored", id = 74)
138109
void duplicateMetadata();
139110

140-
@LogMessage(level = INFO)
141-
@Message(value = "Entities deleted: %s", id = 76)
142-
void entitiesDeleted(long entityDeleteCount);
143-
144-
@LogMessage(level = INFO)
145-
@Message(value = "Entities fetched (minimize this): %s", id = 77)
146-
void entitiesFetched(long entityFetchCount);
147-
148-
@LogMessage(level = INFO)
149-
@Message(value = "Entities inserted: %s", id = 78)
150-
void entitiesInserted(long entityInsertCount);
151-
152-
@LogMessage(level = INFO)
153-
@Message(value = "Entities loaded: %s", id = 79)
154-
void entitiesLoaded(long entityLoadCount);
155-
156-
@LogMessage(level = INFO)
157-
@Message(value = "Entities updated: %s", id = 80)
158-
void entitiesUpdated(long entityUpdateCount);
159-
160111
@LogMessage(level = WARN)
161112
@Message(value = "Entity [%s] is abstract-class/interface explicitly mapped as non-abstract; be sure to supply entity-names",
162113
id = 84)
@@ -184,10 +135,6 @@ void expectedType(String name,
184135
+ " to unsafe use of the session): %s", id = 99)
185136
void failed(Throwable throwable);
186137

187-
@LogMessage(level = INFO)
188-
@Message(value = "Flushes: %s", id = 105)
189-
void flushes(long flushCount);
190-
191138
@LogMessage(level = INFO)
192139
@Message(value = "Forcing table use for sequence-style generator due to pooled optimizer selection where db does not support pooled sequences",
193140
id = 107)
@@ -246,14 +193,6 @@ void honoringOptimizerSetting(
246193
@Message(value = "Lazy property fetching available for: %s", id = 157)
247194
void lazyPropertyFetchingAvailable(String name);
248195

249-
@LogMessage(level = INFO)
250-
@Message(value = "Logging statistics....", id = 161)
251-
void loggingStatistics();
252-
253-
@LogMessage(level = INFO)
254-
@Message(value = "Max query time: %sms", id = 173)
255-
void maxQueryTime(long queryExecutionMaxTime);
256-
257196
@LogMessage(level = WARN)
258197
@Message(value = "Function template anticipated %s arguments, but %s arguments encountered", id = 174)
259198
void missingArguments(
@@ -274,10 +213,6 @@ void missingArguments(
274213
id = 182)
275214
void noDefaultConstructor(String name);
276215

277-
@LogMessage(level = INFO)
278-
@Message(value = "Optimistic lock failures: %s", id = 187)
279-
void optimisticLockFailures(long optimisticFailureCount);
280-
281216
@LogMessage(level = WARN)
282217
@Message(value = "Overriding %s is dangerous, this might break the EJB3 specification implementation", id = 193)
283218
void overridingTransactionStrategyDangerous(String transactionStrategy);
@@ -307,22 +242,6 @@ void missingArguments(
307242
@Message(value = "'hibernate.properties' not found", id = 206)
308243
void propertiesNotFound();
309244

310-
@LogMessage(level = INFO)
311-
@Message(value = "Queries executed to database: %s", id = 210)
312-
void queriesExecuted(long queryExecutionCount);
313-
314-
@LogMessage(level = INFO)
315-
@Message(value = "Query cache hits: %s", id = 213)
316-
void queryCacheHits(long queryCacheHitCount);
317-
318-
@LogMessage(level = INFO)
319-
@Message(value = "Query cache misses: %s", id = 214)
320-
void queryCacheMisses(long queryCacheMissCount);
321-
322-
@LogMessage(level = INFO)
323-
@Message(value = "Query cache puts: %s", id = 215)
324-
void queryCachePuts(long queryCachePutCount);
325-
326245
@LogMessage(level = INFO)
327246
@Message(value = "Reading mappings from cache file: %s", id = 219)
328247
void readingCachedMappings(File cachedFile);
@@ -354,26 +273,6 @@ void scopingTypesToSessionFactoryAfterAlreadyScoped(
354273
SessionFactoryImplementor factory,
355274
SessionFactoryImplementor factory2);
356275

357-
@LogMessage(level = INFO)
358-
@Message(value = "Second level cache hits: %s", id = 237)
359-
void secondLevelCacheHits(long secondLevelCacheHitCount);
360-
361-
@LogMessage(level = INFO)
362-
@Message(value = "Second level cache misses: %s", id = 238)
363-
void secondLevelCacheMisses(long secondLevelCacheMissCount);
364-
365-
@LogMessage(level = INFO)
366-
@Message(value = "Second level cache puts: %s", id = 239)
367-
void secondLevelCachePuts(long secondLevelCachePutCount);
368-
369-
@LogMessage(level = INFO)
370-
@Message(value = "Sessions closed: %s", id = 241)
371-
void sessionsClosed(long sessionCloseCount);
372-
373-
@LogMessage(level = INFO)
374-
@Message(value = "Sessions opened: %s", id = 242)
375-
void sessionsOpened(long sessionOpenCount);
376-
377276
@LogMessage(level = WARN)
378277
@Message(value = "SQL Error: %s, SQLState: %s", id = 247)
379278
void sqlWarning(int errorCode, String sqlState);
@@ -382,27 +281,13 @@ void scopingTypesToSessionFactoryAfterAlreadyScoped(
382281
@Message(value = "Start time: %s", id = 251)
383282
void startTime(long startTime);
384283

385-
@LogMessage(level = INFO)
386-
@Message(value = "Statements closed: %s", id = 252)
387-
void statementsClosed(long closeStatementCount);
388-
389-
@LogMessage(level = INFO)
390-
@Message(value = "Statements prepared: %s", id = 253)
391-
void statementsPrepared(long prepareStatementCount);
392-
393-
@LogMessage(level = INFO)
394-
@Message(value = "Successful transactions: %s", id = 258)
395-
void successfulTransactions(long committedTransactionCount);
396-
397284
@LogMessage(level = INFO)
398285
@Message(value = "Synchronization [%s] was already registered", id = 259)
399286
void synchronizationAlreadyRegistered(Synchronization synchronization);
400287

401288
@LogMessage(level = ERROR)
402289
@Message(value = "Exception calling user Synchronization [%s]: %s", id = 260)
403-
void synchronizationFailed(
404-
Synchronization synchronization,
405-
Throwable t);
290+
void synchronizationFailed(Synchronization synchronization, Throwable t);
406291

407292
@LogMessage(level = INFO)
408293
@Message(value = "Table not found: %s", id = 262)
@@ -579,12 +464,9 @@ void synchronizationFailed(
579464
void unregisteredStatement();
580465

581466
@LogMessage(level = WARN)
582-
@Message(value = "The %s.%s.%s version of H2 implements temporary table creation such that it commits current transaction; multi-table, bulk hql/jpaql will not work properly",
467+
@Message(value = "The %s.%s.%s version of H2 implements temporary table creation such that it commits current transaction; multi-table, bulk HQL/JPQL will not work properly",
583468
id = 393)
584-
void unsupportedMultiTableBulkHqlJpaql(
585-
int majorVersion,
586-
int minorVersion,
587-
int buildId);
469+
void unsupportedMultiTableBulkHqlJpaql(int majorVersion, int minorVersion, int buildId);
588470

589471
@LogMessage(level = INFO)
590472
@Message(value = "Explicit segment value for id generator [%s.%s] suggested; using default [%s]", id = 398)
@@ -612,49 +494,24 @@ void unsupportedMultiTableBulkHqlJpaql(
612494
void writeLocksNotSupported(String entityName);
613495

614496
@LogMessage(level = DEBUG)
615-
@Message(value = "Closing un-released batch", id = 420)
497+
@Message(value = "Closing unreleased batch", id = 420)
616498
void closingUnreleasedBatch();
617499

618-
@LogMessage(level = INFO)
619-
@Message(value = "update timestamps cache puts: %s", id = 433)
620-
void timestampCachePuts(long updateTimestampsCachePutCount);
621-
622-
@LogMessage(level = INFO)
623-
@Message(value = "update timestamps cache hits: %s", id = 434)
624-
void timestampCacheHits(long updateTimestampsCachePutCount);
625-
626-
@LogMessage(level = INFO)
627-
@Message(value = "update timestamps cache misses: %s", id = 435)
628-
void timestampCacheMisses(long updateTimestampsCachePutCount);
629-
630500
@LogMessage(level = WARN)
631-
@Message(value = "Attempting to save one or more entities that have a non-nullable association with an unsaved transient entity. The unsaved transient entity must be saved in an operation prior to saving these dependent entities.\n" +
632-
"\tUnsaved transient entity: (%s)\n\tDependent entities: (%s)\n\tNon-nullable association(s): (%s)", id = 437)
501+
@Message(
502+
id = 437,
503+
value = """
504+
Attempting to save one or more entities that have a non-nullable association with an unsaved transient entity.
505+
The unsaved transient entity must be saved in an operation prior to saving these dependent entities.
506+
Unsaved transient entity: %s
507+
Dependent entities: %s
508+
Non-nullable associations: %s"""
509+
)
633510
void cannotResolveNonNullableTransientDependencies(
634511
String transientEntityString,
635512
Set<String> dependentEntityStrings,
636513
Set<String> nonNullableAssociationPaths);
637514

638-
@LogMessage(level = INFO)
639-
@Message(value = "NaturalId cache puts: %s", id = 438)
640-
void naturalIdCachePuts(long naturalIdCachePutCount);
641-
642-
@LogMessage(level = INFO)
643-
@Message(value = "NaturalId cache hits: %s", id = 439)
644-
void naturalIdCacheHits(long naturalIdCacheHitCount);
645-
646-
@LogMessage(level = INFO)
647-
@Message(value = "NaturalId cache misses: %s", id = 440)
648-
void naturalIdCacheMisses(long naturalIdCacheMissCount);
649-
650-
@LogMessage(level = INFO)
651-
@Message(value = "Max NaturalId query time: %sms", id = 441)
652-
void naturalIdMaxQueryTime(long naturalIdQueryExecutionMaxTime);
653-
654-
@LogMessage(level = INFO)
655-
@Message(value = "NaturalId queries executed to database: %s", id = 442)
656-
void naturalIdQueriesExecuted(long naturalIdQueriesExecutionCount);
657-
658515
@LogMessage(level = WARN)
659516
@Message(
660517
value = "Dialect [%s] limits the number of elements in an IN predicate to %s entries. " +
@@ -774,14 +631,6 @@ void cannotResolveNonNullableTransientDependencies(
774631
"@OneToOne associations mapped with @NotFound are forced to EAGER fetching.", id = 491)
775632
void ignoreNotFoundWithFetchTypeLazy(String entity, String association);
776633

777-
@LogMessage(level = INFO)
778-
@Message(value = "Query plan cache hits: %s", id = 492)
779-
void queryPlanCacheHits(long queryPlanCacheHitCount);
780-
781-
@LogMessage(level = INFO)
782-
@Message(value = "Query plan cache misses: %s", id = 493)
783-
void queryPlanCacheMisses(long queryPlanCacheMissCount);
784-
785634
@LogMessage(level = WARN)
786635
@Message(value = "Attempt to merge an uninitialized collection with queued operations; queued operations will be ignored: %s", id = 494)
787636
void ignoreQueuedOperationsOnMerge(String collectionInfoString);
@@ -890,7 +739,7 @@ void unableToLocateStaticMetamodelField(
890739

891740
@LogMessage(level = DEBUG)
892741
@Message(
893-
id = 425,
742+
id = 401,
894743
value = """
895744
Logging session metrics:
896745
%s ns acquiring %s JDBC connections
@@ -933,4 +782,77 @@ void sessionMetrics(
933782
int partialFlushCount,
934783
long partialFlushEntityCount,
935784
long partialFlushCollectionCount);
785+
786+
@LogMessage(level = INFO)
787+
@Message(
788+
id = 400,
789+
value = """
790+
Logging statistics:
791+
Start time: %s
792+
Sessions opened (closed): %s (%s)
793+
Transactions started (successful): %s (%s)
794+
Optimistic lock failures: %s
795+
Flushes: %s
796+
Connections obtained: %s
797+
Statements prepared (closed): %s (%s)
798+
Second-level cache puts: %s
799+
Second-level cache hits (misses): %s (%s)
800+
Entities loaded: %s
801+
Entities fetched: %s (minimize this)
802+
Entities updated, inserted, deleted: %s, %s, %s
803+
Collections loaded: %s
804+
Collections fetched: %s (minimize this)
805+
Collections updated, removed, recreated: %s, %s, %s
806+
Natural id queries executed on database: %s
807+
Natural id cache puts: %s
808+
Natural id cache hits (misses): %s (%s)
809+
Max natural id query execution time: %s ms
810+
Queries executed on database: %s
811+
Query cache puts: %s
812+
Query cache hits (misses): %s (%s)
813+
Max query execution time: %s ms
814+
Update timestamps cache puts: %s
815+
Update timestamps cache hits (misses): %s (%s)
816+
Query plan cache hits (misses): %s (%s)
817+
"""
818+
)
819+
void logStatistics(
820+
long startTime,
821+
long sessionOpenCount,
822+
long sessionCloseCount,
823+
long transactionCount,
824+
long committedTransactionCount,
825+
long optimisticFailureCount,
826+
long flushCount,
827+
long connectCount,
828+
long prepareStatementCount,
829+
long closeStatementCount,
830+
long secondLevelCachePutCount,
831+
long secondLevelCacheHitCount,
832+
long secondLevelCacheMissCount,
833+
long entityLoadCount,
834+
long entityFetchCount,
835+
long entityUpdateCount,
836+
long entityInsertCount,
837+
long entityDeleteCount,
838+
long collectionLoadCount,
839+
long collectionFetchCount,
840+
long collectionUpdateCount,
841+
long collectionRemoveCount,
842+
long collectionRecreateCount,
843+
long naturalIdQueryExecutionCount,
844+
long naturalIdCachePutCount,
845+
long naturalIdCacheHitCount,
846+
long naturalIdCacheMissCount,
847+
long naturalIdQueryExecutionMaxTime,
848+
long queryExecutionCount,
849+
long queryCachePutCount,
850+
long queryCacheHitCount,
851+
long queryCacheMissCount,
852+
long queryExecutionMaxTime,
853+
long updateTimestampsCachePutCount,
854+
long updateTimestampsCacheHitCount,
855+
long updateTimestampsCacheMissCount,
856+
long queryPlanCacheHitCount,
857+
long queryPlanCacheMissCount);
936858
}

0 commit comments

Comments
 (0)