Skip to content

Commit 3dd4171

Browse files
colinmjjGitHub Enterprise
authored andcommitted
[CARMEL-7391] Backport Collect and expose metrics in HiveExternalCatalog to monitor the performance of HiveMetastore (apache#110)
1 parent 9602f5d commit 3dd4171

File tree

2 files changed

+23
-8
lines changed

2 files changed

+23
-8
lines changed

core/src/main/scala/org/apache/spark/metrics/source/StaticSources.scala

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ object HiveCatalogMetrics extends Source {
104104
"databaseExists" ::
105105
"listDatabases" ::
106106
"tableExists" ::
107+
"getTablesByName" ::
107108
"getTableOption" ::
108109
"createTable" ::
109110
"dropTable" ::
@@ -118,7 +119,8 @@ object HiveCatalogMetrics extends Source {
118119
"getPartitions" ::
119120
"getPartitionsByFilter" ::
120121
"listTables" ::
121-
"listTables" ::
122+
"getTablesByPattern" ::
123+
"getTablesByType" ::
122124
"loadPartition" ::
123125
"loadTable" ::
124126
"loadDynamicPartitions" ::
@@ -127,15 +129,28 @@ object HiveCatalogMetrics extends Source {
127129
"renameFunction" ::
128130
"alterFunction" ::
129131
"getFunctionOption" ::
130-
"listFunctions" :: Nil
131-
132-
private lazy val hiveCallCountMetrics =
132+
"listFunctions" ::
133+
"createRole" ::
134+
"dropRole" ::
135+
"listRoleNames" ::
136+
"grantRole" ::
137+
"revokeRole" ::
138+
"listRoles" ::
139+
"getPrivilegeGrants" ::
140+
"listPrivileges" ::
141+
"grantPrivileges" ::
142+
"revokePrivileges" ::
143+
"getPrincipalsInRole" ::
144+
"getRoleGrantsForPrincipal" ::
145+
Nil
146+
147+
private val hiveCallCountMetrics =
133148
hiveCatalogCalls.map { call =>
134149
val name = call + "Count"
135150
name -> metricRegistry.counter(name)
136151
}.toMap
137152

138-
private lazy val hiveCallDurationMetrics =
153+
private val hiveCallDurationMetrics =
139154
hiveCatalogCalls.map { call =>
140155
val name = call + "Duration"
141156
name -> metricRegistry.histogram(name)

sql/hive/src/main/scala/org/apache/spark/sql/hive/client/HiveClientImpl.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1055,7 +1055,7 @@ private[hive] class HiveClientImpl(
10551055

10561056
override def listFunctions(db: String, pattern: String): Seq[String] = withHiveState( {
10571057
shim.listFunctions(client, db, pattern)
1058-
}, "getFunctionOption")
1058+
}, "listFunctions")
10591059

10601060
override def createRole(role: CatalogPrincipal, grantorName: String): Boolean = withHiveState( {
10611061
msClient.create_role(new Role(role.name, 0, grantorName))
@@ -1094,7 +1094,7 @@ private[hive] class HiveClientImpl(
10941094

10951095
override def getPrivilegeGrants(privilegeObject: CatalogPrivilegeObject,
10961096
user: String,
1097-
groupNames: Seq[String]): Seq[CatalogPrivilegeGrant] = withHiveState {
1097+
groupNames: Seq[String]): Seq[CatalogPrivilegeGrant] = withHiveState ({
10981098
val ret = msClient.get_privilege_set(
10991099
toHivePrivilegeObject(privilegeObject), user, groupNames.asJava)
11001100

@@ -1132,7 +1132,7 @@ private[hive] class HiveClientImpl(
11321132
}
11331133

11341134
userPrivilegeGrants ++ rolePrivilegeGrants ++ groupPrivilegeGrants
1135-
}
1135+
}, "getPrivilegeGrants")
11361136

11371137
override def listPrivileges(
11381138
principal: Option[CatalogPrincipal],

0 commit comments

Comments
 (0)