-
Notifications
You must be signed in to change notification settings - Fork 1k
ClickHouse client v0.8 instrumentation #14501
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
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
9cf7c6f
support ClickHouse Client v2
mznet c16c75c
update clickhouse-client to 0.8
mznet 6fa8042
delete useless ClickHouseClientV2ExampleData.java
mznet 5b44e25
get error response from ServerException
mznet a243942
update fossa and supported-libraries.md
mznet 1b1d794
rename clickhouse-client-0.8 to clickhouse-clientv2-0.8
mznet f466ba7
Merge branch 'main' into clickhouse-client-v0.8
mznet 3f4d8c7
move the advices into instrumentation
mznet ff22d97
add comment says only one endpoint is supported
mznet 1dc624c
Update instrumentation/clickhouse/clickhouse-clientv2-0.8/javaagent/b…
mznet 5bdd827
review
laurit ba7169a
review
laurit 08c457e
Merge branch 'main' into clickhouse-client-v0.8
laurit f6f4ab8
update fossaa config
laurit 7194f3b
fix instrumentation name
laurit 294446c
rename metaDataConfig to metadataConfig
mznet 53a2b43
Merge branch 'main' into clickhouse-client-v0.8
laurit File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
39 changes: 0 additions & 39 deletions
39
.../src/main/java/io/opentelemetry/javaagent/instrumentation/clickhouse/ClickHouseScope.java
This file was deleted.
Oops, something went wrong.
40 changes: 0 additions & 40 deletions
40
...main/java/io/opentelemetry/javaagent/instrumentation/clickhouse/ClickHouseSingletons.java
This file was deleted.
Oops, something went wrong.
8 changes: 8 additions & 0 deletions
8
instrumentation/clickhouse/clickhouse-client-common/javaagent/build.gradle.kts
This file contains hidden or 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,8 @@ | ||
plugins { | ||
id("otel.javaagent-instrumentation") | ||
} | ||
|
||
dependencies { | ||
compileOnly("com.google.auto.value:auto-value-annotations") | ||
annotationProcessor("com.google.auto.value:auto-value") | ||
} |
This file contains hidden or 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 hidden or 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
36 changes: 36 additions & 0 deletions
36
...ntelemetry/javaagent/instrumentation/clickhouse/common/ClickHouseInstrumenterFactory.java
This file contains hidden or 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,36 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.javaagent.instrumentation.clickhouse.common; | ||
|
||
import io.opentelemetry.api.GlobalOpenTelemetry; | ||
import io.opentelemetry.instrumentation.api.incubator.semconv.db.DbClientAttributesExtractor; | ||
import io.opentelemetry.instrumentation.api.incubator.semconv.db.DbClientMetrics; | ||
import io.opentelemetry.instrumentation.api.incubator.semconv.db.DbClientSpanNameExtractor; | ||
import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter; | ||
import io.opentelemetry.instrumentation.api.instrumenter.SpanKindExtractor; | ||
import io.opentelemetry.instrumentation.api.semconv.network.ServerAttributesExtractor; | ||
import java.util.function.Function; | ||
|
||
public final class ClickHouseInstrumenterFactory { | ||
|
||
public static Instrumenter<ClickHouseDbRequest, Void> createInstrumenter( | ||
String instrumenterName, Function<Throwable, String> errorCodeExtractor) { | ||
ClickHouseAttributesGetter dbAttributesGetter = | ||
new ClickHouseAttributesGetter(errorCodeExtractor); | ||
|
||
return Instrumenter.<ClickHouseDbRequest, Void>builder( | ||
GlobalOpenTelemetry.get(), | ||
instrumenterName, | ||
DbClientSpanNameExtractor.create(dbAttributesGetter)) | ||
.addAttributesExtractor(DbClientAttributesExtractor.create(dbAttributesGetter)) | ||
.addAttributesExtractor( | ||
ServerAttributesExtractor.create(new ClickHouseNetworkAttributesGetter())) | ||
.addOperationMetrics(DbClientMetrics.get()) | ||
.buildInstrumenter(SpanKindExtractor.alwaysClient()); | ||
} | ||
|
||
private ClickHouseInstrumenterFactory() {} | ||
} |
This file contains hidden or 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
46 changes: 46 additions & 0 deletions
46
...in/java/io/opentelemetry/javaagent/instrumentation/clickhouse/common/ClickHouseScope.java
This file contains hidden or 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,46 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.javaagent.instrumentation.clickhouse.common; | ||
|
||
import io.opentelemetry.context.Context; | ||
import io.opentelemetry.context.Scope; | ||
import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter; | ||
|
||
/** Container used to carry state between enter and exit advices */ | ||
public final class ClickHouseScope { | ||
private final ClickHouseDbRequest clickHouseDbRequest; | ||
private final Context context; | ||
private final Scope scope; | ||
private final Instrumenter<ClickHouseDbRequest, Void> instrumenter; | ||
|
||
private ClickHouseScope( | ||
ClickHouseDbRequest clickHouseDbRequest, | ||
Context context, | ||
Scope scope, | ||
Instrumenter<ClickHouseDbRequest, Void> instrumenter) { | ||
this.clickHouseDbRequest = clickHouseDbRequest; | ||
this.context = context; | ||
this.scope = scope; | ||
this.instrumenter = instrumenter; | ||
} | ||
|
||
public static ClickHouseScope start( | ||
Instrumenter<ClickHouseDbRequest, Void> instrumenter, | ||
Context parentContext, | ||
ClickHouseDbRequest clickHouseDbRequest) { | ||
if (!instrumenter.shouldStart(parentContext, clickHouseDbRequest)) { | ||
return null; | ||
} | ||
|
||
Context context = instrumenter.start(parentContext, clickHouseDbRequest); | ||
return new ClickHouseScope(clickHouseDbRequest, context, context.makeCurrent(), instrumenter); | ||
} | ||
|
||
public void end(Throwable throwable) { | ||
scope.close(); | ||
instrumenter.end(context, clickHouseDbRequest, null, throwable); | ||
} | ||
} |
This file contains hidden or 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
File renamed without changes.
This file contains hidden or 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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.