-
Notifications
You must be signed in to change notification settings - Fork 828
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Hibernate: set span name only on method entry (#3603)
- Loading branch information
Showing
18 changed files
with
208 additions
and
98 deletions.
There are no files selected for viewing
This file contains 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
30 changes: 30 additions & 0 deletions
30
...c/main/java/io/opentelemetry/javaagent/instrumentation/hibernate/v3_3/EntityNameUtil.java
This file contains 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,30 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.javaagent.instrumentation.hibernate.v3_3; | ||
|
||
import java.util.function.Function; | ||
import org.hibernate.impl.AbstractSessionImpl; | ||
|
||
public final class EntityNameUtil { | ||
|
||
private EntityNameUtil() {} | ||
|
||
private static String bestGuessEntityName(Object session, Object entity) { | ||
if (entity == null) { | ||
return null; | ||
} | ||
|
||
if (session instanceof AbstractSessionImpl) { | ||
return ((AbstractSessionImpl) session).bestGuessEntityName(entity); | ||
} | ||
|
||
return null; | ||
} | ||
|
||
public static Function<Object, String> bestGuessEntityName(Object session) { | ||
return (entity) -> bestGuessEntityName(session, entity); | ||
} | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
34 changes: 34 additions & 0 deletions
34
...c/main/java/io/opentelemetry/javaagent/instrumentation/hibernate/v4_0/EntityNameUtil.java
This file contains 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,34 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.javaagent.instrumentation.hibernate.v4_0; | ||
|
||
import java.util.function.Function; | ||
import org.hibernate.SharedSessionContract; | ||
import org.hibernate.internal.SessionImpl; | ||
import org.hibernate.internal.StatelessSessionImpl; | ||
|
||
public final class EntityNameUtil { | ||
|
||
private EntityNameUtil() {} | ||
|
||
private static String bestGuessEntityName(SharedSessionContract session, Object entity) { | ||
if (entity == null) { | ||
return null; | ||
} | ||
|
||
if (session instanceof SessionImpl) { | ||
return ((SessionImpl) session).bestGuessEntityName(entity); | ||
} else if (session instanceof StatelessSessionImpl) { | ||
return ((StatelessSessionImpl) session).bestGuessEntityName(entity); | ||
} | ||
|
||
return null; | ||
} | ||
|
||
public static Function<Object, String> bestGuessEntityName(SharedSessionContract session) { | ||
return (entity) -> bestGuessEntityName(session, entity); | ||
} | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.