From 5fac33fcabffa4c95576a41c146e303b618f623e Mon Sep 17 00:00:00 2001 From: Miguel Juarez Lopez Date: Mon, 30 Dec 2024 16:13:05 -0500 Subject: [PATCH 1/2] [andr] Override _path_template field with gql operation --- .../io/bitdrift/capture/apollo3/CaptureApolloInterceptor.kt | 3 ++- .../bitdrift/capture/CaptureOkHttpEventListenerFactoryTest.kt | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/platform/jvm/capture-apollo3/src/main/kotlin/io/bitdrift/capture/apollo3/CaptureApolloInterceptor.kt b/platform/jvm/capture-apollo3/src/main/kotlin/io/bitdrift/capture/apollo3/CaptureApolloInterceptor.kt index 76e490a7..21cecd71 100644 --- a/platform/jvm/capture-apollo3/src/main/kotlin/io/bitdrift/capture/apollo3/CaptureApolloInterceptor.kt +++ b/platform/jvm/capture-apollo3/src/main/kotlin/io/bitdrift/capture/apollo3/CaptureApolloInterceptor.kt @@ -28,9 +28,10 @@ class CaptureApolloInterceptor: ApolloInterceptor { val requestBuilder = request.newBuilder() .addHttpHeader("x-capture-span-key", "gql") .addHttpHeader("x-capture-span-gql-name", "graphql") - .addHttpHeader("x-capture-span-gql-field-operation-name", request.operation.name()) .addHttpHeader("x-capture-span-gql-field-operation-id", request.operation.id()) .addHttpHeader("x-capture-span-gql-field-operation-type", request.operation.type()) + .addHttpHeader("x-capture-span-gql-field-operation-name", request.operation.name()) + .addHttpHeader("x-capture-path-template", request.operation.name()) // set this to override the http _path_template field // TODO(murki): Augment request logs with // request.executionContext[CustomScalarAdapters]?.let { // addHttpHeader("x-capture-span-gql-field-operation-variables", request.operation.variables(it).valueMap.toString()) diff --git a/platform/jvm/capture/src/test/kotlin/io/bitdrift/capture/CaptureOkHttpEventListenerFactoryTest.kt b/platform/jvm/capture/src/test/kotlin/io/bitdrift/capture/CaptureOkHttpEventListenerFactoryTest.kt index 2aab2e28..20adc49c 100644 --- a/platform/jvm/capture/src/test/kotlin/io/bitdrift/capture/CaptureOkHttpEventListenerFactoryTest.kt +++ b/platform/jvm/capture/src/test/kotlin/io/bitdrift/capture/CaptureOkHttpEventListenerFactoryTest.kt @@ -348,12 +348,14 @@ class CaptureOkHttpEventListenerFactoryTest { "x-capture-span-gql-field-operation-name" to "myOperationName", "x-capture-span-gql-field-operation-id" to "myOperationId", "x-capture-span-gql-field-operation-type" to "query", + "x-capture-path-template" to "myOperationName", ) val expectedSpanName = "_mySpanName" val expectedFields = mapOf( "_operation_name" to "myOperationName", "_operation_id" to "myOperationId", "_operation_type" to "query", + "_path_template" to "myOperationName", ) val request = Request.Builder() From b4996f4c7744088f089fa80933bb7dba84d0c449 Mon Sep 17 00:00:00 2001 From: Miguel Juarez Lopez Date: Mon, 30 Dec 2024 16:36:47 -0500 Subject: [PATCH 2/2] Add gql- prefix --- .../io/bitdrift/capture/apollo3/CaptureApolloInterceptor.kt | 2 +- .../bitdrift/capture/CaptureOkHttpEventListenerFactoryTest.kt | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/platform/jvm/capture-apollo3/src/main/kotlin/io/bitdrift/capture/apollo3/CaptureApolloInterceptor.kt b/platform/jvm/capture-apollo3/src/main/kotlin/io/bitdrift/capture/apollo3/CaptureApolloInterceptor.kt index 21cecd71..fe023f1f 100644 --- a/platform/jvm/capture-apollo3/src/main/kotlin/io/bitdrift/capture/apollo3/CaptureApolloInterceptor.kt +++ b/platform/jvm/capture-apollo3/src/main/kotlin/io/bitdrift/capture/apollo3/CaptureApolloInterceptor.kt @@ -31,7 +31,7 @@ class CaptureApolloInterceptor: ApolloInterceptor { .addHttpHeader("x-capture-span-gql-field-operation-id", request.operation.id()) .addHttpHeader("x-capture-span-gql-field-operation-type", request.operation.type()) .addHttpHeader("x-capture-span-gql-field-operation-name", request.operation.name()) - .addHttpHeader("x-capture-path-template", request.operation.name()) // set this to override the http _path_template field + .addHttpHeader("x-capture-path-template", "gql-${request.operation.name()}") // set this to override the http _path_template field // TODO(murki): Augment request logs with // request.executionContext[CustomScalarAdapters]?.let { // addHttpHeader("x-capture-span-gql-field-operation-variables", request.operation.variables(it).valueMap.toString()) diff --git a/platform/jvm/capture/src/test/kotlin/io/bitdrift/capture/CaptureOkHttpEventListenerFactoryTest.kt b/platform/jvm/capture/src/test/kotlin/io/bitdrift/capture/CaptureOkHttpEventListenerFactoryTest.kt index 20adc49c..d48c57c8 100644 --- a/platform/jvm/capture/src/test/kotlin/io/bitdrift/capture/CaptureOkHttpEventListenerFactoryTest.kt +++ b/platform/jvm/capture/src/test/kotlin/io/bitdrift/capture/CaptureOkHttpEventListenerFactoryTest.kt @@ -348,14 +348,14 @@ class CaptureOkHttpEventListenerFactoryTest { "x-capture-span-gql-field-operation-name" to "myOperationName", "x-capture-span-gql-field-operation-id" to "myOperationId", "x-capture-span-gql-field-operation-type" to "query", - "x-capture-path-template" to "myOperationName", + "x-capture-path-template" to "gql-myOperationName", ) val expectedSpanName = "_mySpanName" val expectedFields = mapOf( "_operation_name" to "myOperationName", "_operation_id" to "myOperationId", "_operation_type" to "query", - "_path_template" to "myOperationName", + "_path_template" to "gql-myOperationName", ) val request = Request.Builder()