Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions docs/instrumentation-list.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3014,6 +3014,7 @@ libraries:
attributes: []
graphql:
- name: graphql-java-12.0
description: This instrumentation enables spans for GraphQL Java operations.
source_path: instrumentation/graphql-java/graphql-java-12.0
scope:
name: io.opentelemetry.graphql-java-12.0
Expand All @@ -3022,7 +3023,30 @@ libraries:
- com.graphql-java:graphql-java:[12,20)
library:
- com.graphql-java:graphql-java:[12.0,19.+)
configurations:
- name: otel.instrumentation.graphql.query-sanitizer.enabled
description: Enables sanitization of sensitive information from queries so they
aren't added as span attributes.
type: boolean
default: true
- name: otel.instrumentation.graphql.add-operation-name-to-span-name.enabled
description: |
Whether GraphQL operation name is added to the span name. WARNING: The GraphQL operation name is provided by the client and can have high cardinality. Use only when the server is not exposed to malicious clients.
type: boolean
default: false
telemetry:
- when: default
spans:
- span_kind: INTERNAL
attributes:
- name: graphql.document
type: STRING
- name: graphql.operation.name
type: STRING
- name: graphql.operation.type
type: STRING
- name: graphql-java-20.0
description: This instrumentation enables spans for GraphQL Java operations.
source_path: instrumentation/graphql-java/graphql-java-20.0
minimum_java_version: 11
scope:
Expand All @@ -3032,6 +3056,51 @@ libraries:
- com.graphql-java:graphql-java:[20,)
library:
- com.graphql-java:graphql-java:20.0
configurations:
- name: otel.instrumentation.graphql.query-sanitizer.enabled
description: Enables sanitization of sensitive information from queries so they
aren't added as span attributes.
type: boolean
default: true
- name: otel.instrumentation.graphql.add-operation-name-to-span-name.enabled
description: |
Whether GraphQL operation name is added to the span name. WARNING: The GraphQL operation name is provided by the client and can have high cardinality. Use only when the server is not exposed to malicious clients.
type: boolean
default: false
- name: otel.instrumentation.graphql.data-fetcher.enabled
description: Enables span generation for data fetchers.
type: boolean
default: false
- name: otel.instrumentation.graphql.trivial-data-fetcher.enabled
description: Whether to create spans for trivial data fetchers. A trivial data
fetcher is one that simply maps data from an object to a field.
type: boolean
default: false
telemetry:
- when: default
spans:
- span_kind: INTERNAL
attributes:
- name: graphql.document
type: STRING
- name: graphql.operation.name
type: STRING
- name: graphql.operation.type
type: STRING
- when: otel.instrumentation.graphql.data-fetcher.enabled=true
spans:
- span_kind: INTERNAL
attributes:
- name: graphql.document
type: STRING
- name: graphql.field.name
type: STRING
- name: graphql.field.path
type: STRING
- name: graphql.operation.name
type: STRING
- name: graphql.operation.type
type: STRING
grizzly:
- name: grizzly-2.3
description: This instrumentation enables HTTP SERVER spans and metrics for Grizzly
Expand Down
3 changes: 3 additions & 0 deletions instrumentation-docs/instrumentations.sh
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,9 @@ readonly INSTRUMENTATIONS=(
"grails-3.0:javaagent:test"
"grizzly-2.3:javaagent:test"
"gwt-2.0:javaagent:test"
"graphql-java:graphql-java-12.0:javaagent:test"
"graphql-java:graphql-java-20.0:javaagent:test"
"graphql-java:graphql-java-20.0:javaagent:testDataFetcher"
)

# Some instrumentation test suites don't run ARM, so we use colima to run them in an x86_64
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,6 @@ dependencies {

tasks.withType<Test>().configureEach {
jvmArgs("-Dotel.instrumentation.graphql.add-operation-name-to-span-name.enabled=true")

systemProperty("collectMetadata", findProperty("collectMetadata")?.toString() ?: "false")
}
13 changes: 13 additions & 0 deletions instrumentation/graphql-java/graphql-java-12.0/metadata.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
description: This instrumentation enables spans for GraphQL Java operations.
configurations:
- name: otel.instrumentation.graphql.query-sanitizer.enabled
description: Enables sanitization of sensitive information from queries so they aren't added as span attributes.
type: boolean
default: true
- name: otel.instrumentation.graphql.add-operation-name-to-span-name.enabled
description: >
Whether GraphQL operation name is added to the span name. WARNING: The GraphQL operation name is
provided by the client and can have high cardinality. Use only when the server is not exposed to malicious
clients.
type: boolean
default: false
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,20 @@ dependencies {
testImplementation(project(":instrumentation:graphql-java:graphql-java-common:testing"))
}

tasks.withType<Test>().configureEach {
jvmArgs("-Dotel.instrumentation.graphql.data-fetcher.enabled=true")
jvmArgs("-Dotel.instrumentation.graphql.add-operation-name-to-span-name.enabled=true")
tasks {
withType<Test>().configureEach {
jvmArgs("-Dotel.instrumentation.graphql.add-operation-name-to-span-name.enabled=true")
systemProperty("collectMetadata", findProperty("collectMetadata")?.toString() ?: "false")
}

val testDataFetcher by registering(Test::class) {
jvmArgs("-Dotel.instrumentation.graphql.data-fetcher.enabled=true")
systemProperty("metadataConfig", "otel.instrumentation.graphql.data-fetcher.enabled=true")
}

check {
dependsOn(testDataFetcher)
}
}

if (findProperty("testLatestDeps") as Boolean) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,7 @@ if (findProperty("testLatestDeps") as Boolean) {
minJavaVersionSupported.set(JavaVersion.VERSION_11)
}
}

tasks.withType<Test>().configureEach {
jvmArgs("-Dotel.instrumentation.graphql.data-fetcher.enabled=true")
}
21 changes: 21 additions & 0 deletions instrumentation/graphql-java/graphql-java-20.0/metadata.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
description: This instrumentation enables spans for GraphQL Java operations.
configurations:
- name: otel.instrumentation.graphql.query-sanitizer.enabled
description: Enables sanitization of sensitive information from queries so they aren't added as span attributes.
type: boolean
default: true
- name: otel.instrumentation.graphql.add-operation-name-to-span-name.enabled
description: >
Whether GraphQL operation name is added to the span name. WARNING: The GraphQL operation name is
provided by the client and can have high cardinality. Use only when the server is not exposed to malicious
clients.
type: boolean
default: false
- name: otel.instrumentation.graphql.data-fetcher.enabled
description: Enables span generation for data fetchers.
type: boolean
default: false
- name: otel.instrumentation.graphql.trivial-data-fetcher.enabled
description: Whether to create spans for trivial data fetchers. A trivial data fetcher is one that simply maps data from an object to a field.
type: boolean
default: false
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
public abstract class AbstractGraphqlTest {

private static final String DATA_FETCHER_PROPERTY =
"otel.instrumentation.graphql.data-fetcher.enabled";

private final List<Map<String, String>> books = new ArrayList<>();
private final List<Map<String, String>> authors = new ArrayList<>();

Expand All @@ -58,6 +61,10 @@ protected boolean hasDataFetcherSpans() {
return false;
}

private boolean includeDataFetcher() {
return Boolean.getBoolean(DATA_FETCHER_PROPERTY) && hasDataFetcherSpans();
}

@BeforeAll
void setup() throws IOException {
addAuthor("author-1", "John");
Expand Down Expand Up @@ -162,7 +169,7 @@ void successfulQuery() {
normalizedQueryEqualsTo(
GraphqlIncubatingAttributes.GRAPHQL_DOCUMENT,
"query findBookById { bookById(id: ?) { name } }")));
if (hasDataFetcherSpans()) {
if (includeDataFetcher()) {
assertions.add(
span ->
span.hasName("bookById")
Expand All @@ -174,7 +181,7 @@ void successfulQuery() {
assertions.add(
span ->
span.hasName("fetchBookById")
.hasParent(trace.getSpan(hasDataFetcherSpans() ? 1 : 0)));
.hasParent(trace.getSpan(includeDataFetcher() ? 1 : 0)));

trace.hasSpansSatisfyingExactly(assertions);
});
Expand Down Expand Up @@ -207,7 +214,7 @@ void successfulQueryWithoutName() {
normalizedQueryEqualsTo(
AttributeKey.stringKey("graphql.document"),
"{ bookById(id: ?) { name } }")));
if (hasDataFetcherSpans()) {
if (includeDataFetcher()) {
assertions.add(
span ->
span.hasName("bookById")
Expand All @@ -219,7 +226,7 @@ void successfulQueryWithoutName() {
assertions.add(
span ->
span.hasName("fetchBookById")
.hasParent(trace.getSpan(hasDataFetcherSpans() ? 1 : 0)));
.hasParent(trace.getSpan(includeDataFetcher() ? 1 : 0)));
trace.hasSpansSatisfyingExactly(assertions);
});
}
Expand Down