-
Notifications
You must be signed in to change notification settings - Fork 873
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add instrumentation for graphql 20 that does not use deprecated methods
- Loading branch information
Showing
37 changed files
with
647 additions
and
165 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
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
21 changes: 0 additions & 21 deletions
21
instrumentation/graphql-java-12.0/javaagent/build.gradle.kts
This file was deleted.
Oops, something went wrong.
65 changes: 0 additions & 65 deletions
65
...ibrary/src/main/java/io/opentelemetry/instrumentation/graphql/v12_0/GraphQLTelemetry.java
This file was deleted.
Oops, something went wrong.
File renamed without changes.
26 changes: 26 additions & 0 deletions
26
instrumentation/graphql-java/graphql-java-12.0/javaagent/build.gradle.kts
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,26 @@ | ||
plugins { | ||
id("otel.javaagent-instrumentation") | ||
} | ||
|
||
muzzle { | ||
pass { | ||
group.set("com.graphql-java") | ||
module.set("graphql-java") | ||
versions.set("[12,20)") | ||
skip("230521-nf-execution") | ||
assertInverse.set(true) | ||
} | ||
} | ||
|
||
dependencies { | ||
implementation(project(":instrumentation:graphql-java:graphql-java-12.0:library")) | ||
implementation(project(":instrumentation:graphql-java:graphql-java-common:library")) | ||
|
||
library("com.graphql-java:graphql-java:12.0") | ||
|
||
testInstrumentation(project(":instrumentation:graphql-java:graphql-java-20.0:javaagent")) | ||
|
||
testImplementation(project(":instrumentation:graphql-java:graphql-java-common:testing")) | ||
|
||
latestDepTestLibrary("com.graphql-java:graphql-java:19.+") | ||
} |
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
37 changes: 37 additions & 0 deletions
37
...o/opentelemetry/javaagent/instrumentation/graphql/v12_0/GraphqlInstrumentationModule.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,37 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.javaagent.instrumentation.graphql.v12_0; | ||
|
||
import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.hasClassesNamed; | ||
import static net.bytebuddy.matcher.ElementMatchers.not; | ||
|
||
import com.google.auto.service.AutoService; | ||
import io.opentelemetry.javaagent.extension.instrumentation.InstrumentationModule; | ||
import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation; | ||
import java.util.Collections; | ||
import java.util.List; | ||
import net.bytebuddy.matcher.ElementMatcher; | ||
|
||
@SuppressWarnings("unused") | ||
@AutoService(InstrumentationModule.class) | ||
public class GraphqlInstrumentationModule extends InstrumentationModule { | ||
|
||
public GraphqlInstrumentationModule() { | ||
super("graphql-java", "graphql-java-12.0"); | ||
} | ||
|
||
@Override | ||
public ElementMatcher.Junction<ClassLoader> classLoaderMatcher() { | ||
// added in 20.0 | ||
return not( | ||
hasClassesNamed("graphql.execution.instrumentation.SimplePerformantInstrumentation")); | ||
} | ||
|
||
@Override | ||
public List<TypeInstrumentation> typeInstrumentations() { | ||
return Collections.singletonList(new GraphqlInstrumentation()); | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
...main/java/io/opentelemetry/javaagent/instrumentation/graphql/v12_0/GraphqlSingletons.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,31 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.javaagent.instrumentation.graphql.v12_0; | ||
|
||
import graphql.execution.instrumentation.Instrumentation; | ||
import io.opentelemetry.api.GlobalOpenTelemetry; | ||
import io.opentelemetry.instrumentation.graphql.internal.InstrumentationUtil; | ||
import io.opentelemetry.instrumentation.graphql.v12_0.GraphQLTelemetry; | ||
import io.opentelemetry.javaagent.bootstrap.internal.InstrumentationConfig; | ||
|
||
public final class GraphqlSingletons { | ||
|
||
private static final boolean QUERY_SANITIZATION_ENABLED = | ||
InstrumentationConfig.get() | ||
.getBoolean("otel.instrumentation.graphql.query-sanitizer.enabled", true); | ||
|
||
private static final GraphQLTelemetry TELEMETRY = | ||
GraphQLTelemetry.builder(GlobalOpenTelemetry.get()) | ||
.setSanitizeQuery(QUERY_SANITIZATION_ENABLED) | ||
.build(); | ||
|
||
private GraphqlSingletons() {} | ||
|
||
public static Instrumentation addInstrumentation(Instrumentation instrumentation) { | ||
Instrumentation ourInstrumentation = TELEMETRY.newInstrumentation(); | ||
return InstrumentationUtil.addInstrumentation(instrumentation, ourInstrumentation); | ||
} | ||
} |
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
...ation/graphql-java-12.0/library/README.md → ...-java/graphql-java-12.0/library/README.md
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
10 changes: 10 additions & 0 deletions
10
instrumentation/graphql-java/graphql-java-12.0/library/build.gradle.kts
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,10 @@ | ||
plugins { | ||
id("otel.library-instrumentation") | ||
} | ||
|
||
dependencies { | ||
library("com.graphql-java:graphql-java:12.0") | ||
implementation(project(":instrumentation:graphql-java:graphql-java-common:library")) | ||
|
||
testImplementation(project(":instrumentation:graphql-java:graphql-java-common:testing")) | ||
} |
Oops, something went wrong.