Skip to content

Commit

Permalink
Adding connector metadata to useragent. (#348)
Browse files Browse the repository at this point in the history
  • Loading branch information
mzitnik authored Aug 4, 2024
1 parent 5779763 commit 6dd82f1
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,20 @@ object NodeClient {

class NodeClient(val nodeSpec: NodeSpec) extends AutoCloseable with Logging {

private lazy val userAgent = {
val title = getClass.getPackage.getImplementationTitle
val version = getClass.getPackage.getImplementationVersion
if (version != null) {
val versions = version.split("_")
val sparkVersion = versions(0)
val scalaVersion = versions(1)
val connectorVersion = versions(2)
s"${title}/${connectorVersion} (fv:spark/${sparkVersion}, lv:scala/${scalaVersion})"
} else {
"Spark-ClickHouse-Connector"
}
}

private val node: ClickHouseNode = ClickHouseNode.builder()
.options(nodeSpec.options)
.host(nodeSpec.host)
Expand All @@ -50,6 +64,10 @@ class NodeClient(val nodeSpec: NodeSpec) extends AutoCloseable with Logging {

private val client: ClickHouseClient = ClickHouseClient.builder()
.option(ClickHouseClientOption.FORMAT, ClickHouseFormat.RowBinary)
.option(
ClickHouseClientOption.PRODUCT_NAME,
userAgent
)
.nodeSelector(ClickHouseNodeSelector.of(node.getProtocol))
.build()

Expand Down
6 changes: 6 additions & 0 deletions spark-3.3/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ project(":clickhouse-spark-runtime-${spark_binary_version}_$scala_binary_version

jar {
archiveClassifier="empty"
manifest {
attributes(
'Implementation-Title': 'Spark-ClickHosue-Connnector',
'Implementation-Version': "${spark_binary_version}_${scala_binary_version}_${getProjectVersion()}"
)
}
}
}

Expand Down
6 changes: 6 additions & 0 deletions spark-3.4/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ project(":clickhouse-spark-runtime-${spark_binary_version}_$scala_binary_version

jar {
archiveClassifier="empty"
manifest {
attributes(
'Implementation-Title': 'Spark-ClickHosue-Connnector',
'Implementation-Version': "${spark_binary_version}_${scala_binary_version}_${getProjectVersion()}"
)
}
}
}

Expand Down
7 changes: 7 additions & 0 deletions spark-3.5/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ project.ext {
spark_binary_version = "3.5"
}


project(":clickhouse-spark-${spark_binary_version}_$scala_binary_version") {
dependencies {
api project(":clickhouse-core")
Expand Down Expand Up @@ -58,6 +59,12 @@ project(":clickhouse-spark-runtime-${spark_binary_version}_$scala_binary_version

jar {
archiveClassifier="empty"
manifest {
attributes(
'Implementation-Title': 'Spark-ClickHouse-Connector',
'Implementation-Version': "${spark_binary_version}_${scala_binary_version}_${getProjectVersion()}"
)
}
}
}

Expand Down

0 comments on commit 6dd82f1

Please sign in to comment.