-
Notifications
You must be signed in to change notification settings - Fork 812
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support tracing the ClickHouse Java HTTP client #11660
Support tracing the ClickHouse Java HTTP client #11660
Conversation
instrumentation/clickhouse/clickhouse-client/javaagent/build.gradle.kts
Outdated
Show resolved
Hide resolved
instrumentation/clickhouse/clickhouse-client/javaagent/build.gradle.kts
Outdated
Show resolved
Hide resolved
...n/java/io/opentelemetry/javaagent/instrumentation/clickhouse/ClickHouseAttributesGetter.java
Outdated
Show resolved
Hide resolved
...n/java/io/opentelemetry/javaagent/instrumentation/clickhouse/ClickHouseAttributesGetter.java
Outdated
Show resolved
Hide resolved
...a/io/opentelemetry/javaagent/instrumentation/clickhouse/ClickHouseClientInstrumentation.java
Outdated
Show resolved
Hide resolved
…ference to internal utility class, add call depth checking
instrumentation/clickhouse/clickhouse-client/javaagent/build.gradle.kts
Outdated
Show resolved
Hide resolved
...a/io/opentelemetry/javaagent/instrumentation/clickhouse/ClickHouseClientInstrumentation.java
Outdated
Show resolved
Hide resolved
|
||
@Override | ||
public List<TypeInstrumentation> typeInstrumentations() { | ||
return Collections.singletonList(new ClickHouseClientInstrumentation()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggest to use static import here.
public class ClickHouseInstrumentationModule extends InstrumentationModule { | ||
|
||
public ClickHouseInstrumentationModule() { | ||
super("clickhouse", "clickhouse-client"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to previous convention, the module should be named to clickhouse-client-0.5
. Please pay attention to modify other places together.
settings.gradle.kts
Outdated
@@ -204,6 +204,7 @@ include(":instrumentation:cassandra:cassandra-4.4:library") | |||
include(":instrumentation:cassandra:cassandra-4.4:testing") | |||
include(":instrumentation:cassandra:cassandra-4-common:testing") | |||
include(":instrumentation:cdi-testing") | |||
include(":instrumentation:clickhouse:clickhouse-client:javaagent") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If there is a module, according to convention, please remove extra clickhouse
directory. use clickhouse-client-0.5
directly.
I tried the OpenTelemetry JavaAgent 2.6.0 with our application (Java 11, Clojure 1.11.3, ClickHouse HTTP Client 0.6.2, using the Java HTTP Client). I still only see the spans created by Do we need to do something to enable the instrumentation? We create (defn- make-client
^ClickHouseClient [endpoint]
(let [{:keys [scheme]} (uri/parse endpoint)
protocol (ClickHouseProtocol/fromUriScheme scheme)]
(ClickHouseClient/newInstance (into-array ClickHouseProtocol [protocol])))) We use (defn- make-read-request
^ClickHouseRequest [^ClickHouseClient client ^ClickHouseNodes nodes ^String query & {:as params}]
(let [^Map raw-params (-> params
(update-keys name)
(update-vals #(ClickHouseValues/convertToSqlExpression %)))]
(doto (.read client nodes)
(.format ClickHouseFormat/RowBinaryWithNamesAndTypes)
(.query query)
(.params raw-params)))) And also (defn- make-write-request
^ClickHouseRequest$Mutation [^ClickHouseClient client ^ClickHouseNodes nodes ^String query & {::keys [^InputStream input-stream]
:as params}]
(let [^Map raw-params (-> params
(dissoc ::input-stream)
(update-keys name)
(update-vals #(ClickHouseValues/convertToSqlExpression %)))]
(doto (.write (.read client nodes))
(.format ClickHouseFormat/RowBinaryWithNamesAndTypes)
(.query query)
(.params raw-params)
(cond-> input-stream (.data input-stream))))) |
@devurandom in the code examples you cite from the documentation, each method chain ends in an I'm not too familiar with clojure, so maybe i'm missing something, but I don't see how your query is actually invoked in your example code. I would think you would need to add in the (defn- make-read-request
^ClickHouseRequest [^ClickHouseClient client ^ClickHouseNodes nodes ^String query & {:as params}]
(let [^Map raw-params (-> params
(update-keys name)
(update-vals #(ClickHouseValues/convertToSqlExpression %)))]
(doto (.read client nodes)
(.format ClickHouseFormat/RowBinaryWithNamesAndTypes)
(.query query)
(.params raw-params)
(.executeAndWait)))) If this is not the case, could you help me with putting together a small basic sample app in clojure that I could experiment with? I tried writing something using some of your provided example code but I'm having issues getting everything working. |
I created #11851 and https://github.com/devurandom/opentelemetry-java-instrumentation-clickhouse-clojure-mwe to reproduce this in a small example application. Thanks for looking into this! |
Contributes to #11562
Instruments v1 of the clickhouse-client (https://github.com/ClickHouse/clickhouse-java/tree/main/clickhouse-client)
A few notes:
The tests cover all the same scenarios, but I also created a repo to experiment with the tracing and visualize with jaeger and all seems to work as expected:
https://github.com/jaydeluca/clickhouse-tracing
Example Async query (
execute
)Example error: