From a1c4f3bed94e5f6215c22b238a93e8b37074f9f8 Mon Sep 17 00:00:00 2001 From: Maciej Walkowiak Date: Mon, 9 Aug 2021 21:59:22 +0200 Subject: [PATCH 1/7] Java: Add OpenFeign integration docs. Fixes #3971 --- .../instrumentation/open-feign.mdx | 96 +++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 src/platforms/java/performance/instrumentation/open-feign.mdx diff --git a/src/platforms/java/performance/instrumentation/open-feign.mdx b/src/platforms/java/performance/instrumentation/open-feign.mdx new file mode 100644 index 0000000000000..271635d1c72ea --- /dev/null +++ b/src/platforms/java/performance/instrumentation/open-feign.mdx @@ -0,0 +1,96 @@ +--- +title: OpenFeign Integration +sidebar_order: 20 +description: "Learn how to capture OpenFeign based HTTP clients performance" +--- + + + +Capturing transactions requires that you first set up performance monitoring if you haven't already. + + + +Sentry OpenFeign integration provides `SentryFeignClient` that creates a span for each outgoing HTTP request executed with a [Feign](https://github.com/OpenFeign/feign) based HTTP client. + +### Install + +```xml {tabTitle:Maven} + + io.sentry + sentry-openfeign + {{ packages.version('sentry.java.openfeign', '5.1.0') }} + +``` + +```groovy {tabTitle:Gradle} +implementation 'io.sentry:sentry-openfeign:{{ packages.version('sentry.java.openfeign', '5.1.0') }}' +``` + +```scala {tabTitle: SBT} +libraryDependencies += "io.sentry" % "sentry-openfeign" % "{{ packages.version('sentry.java.openfeign', '5.1.0') }}" +``` + +For other dependency managers see the [central Maven repository](https://search.maven.org/artifact/io.sentry/sentry-openfeign). + +## Configure + +Add `SentryCapability` to Feign builder: + +```java +import feign.Feign; +import io.sentry.openfeign.SentryCapability; + +YourApi api = Feign.builder() + .addCapability(new SentryCapability()) + ... + .target(YourApi.class, "https://your-api-host/"); +``` + +```kotlin +import feign.Feign +import io.sentry.openfeign.SentryCapability + +val api = Feign.builder() + .addCapability(SentryCapability()) + ... + .target(YourApi::class.java, "https://your-api-host/") +``` + +## Modify or Drop spans + +Spans created around HTTP requests can be modified or dropped using `SentryFeignClient.BeforeSpanCallback` passed to `SentryCapability`: + +```java +import feign.Feign; +import io.sentry.openfeign.SentryCapability; + +YourApi api = Feign.builder() + .addCapability( + new SentryCapability( + (span, request, response) -> { + // modify span or return `null` to drop + if (request.url().endsWith("/todos")) { + span.setTag("tag-name", "tag-value"); + } + return span; + })) + ... + .target(YourApi.class, "https://your-api-host/"); +``` + +```kotlin +import feign.Feign +import io.sentry.openfeign.SentryCapability + +val api = Feign.builder() + .addCapability( + SentryCapability( + BeforeSpanCallback { span: ISpan, request: Request, response: Response? -> + // modify span or return `null` to drop + if (request.url().endsWith("/todos")) { + span.setTag("tag-name", "tag-value") + } + span + })) + .target(TodoApi::class.java, "https://jsonplaceholder.typicode.com/") +``` From 1c9f726e20c791a5a24c62b6b8efa8dab24c077a Mon Sep 17 00:00:00 2001 From: Maciej Walkowiak Date: Tue, 17 Aug 2021 11:37:59 +0200 Subject: [PATCH 2/7] Add missing imports. --- src/platforms/java/performance/instrumentation/open-feign.mdx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/platforms/java/performance/instrumentation/open-feign.mdx b/src/platforms/java/performance/instrumentation/open-feign.mdx index 271635d1c72ea..9b54bce5449ed 100644 --- a/src/platforms/java/performance/instrumentation/open-feign.mdx +++ b/src/platforms/java/performance/instrumentation/open-feign.mdx @@ -80,7 +80,11 @@ YourApi api = Feign.builder() ```kotlin import feign.Feign +import feign.Request +import feign.Response +import io.sentry.ISpan import io.sentry.openfeign.SentryCapability +import io.sentry.openfeign.SentryFeignClient.BeforeSpanCallback val api = Feign.builder() .addCapability( From f8f0c637dec9db752a4305630a5c820dee18cd17 Mon Sep 17 00:00:00 2001 From: Maciej Walkowiak Date: Tue, 17 Aug 2021 11:39:08 +0200 Subject: [PATCH 3/7] Polish. --- src/platforms/java/performance/instrumentation/open-feign.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/platforms/java/performance/instrumentation/open-feign.mdx b/src/platforms/java/performance/instrumentation/open-feign.mdx index 9b54bce5449ed..3f5aabd6b0e96 100644 --- a/src/platforms/java/performance/instrumentation/open-feign.mdx +++ b/src/platforms/java/performance/instrumentation/open-feign.mdx @@ -96,5 +96,5 @@ val api = Feign.builder() } span })) - .target(TodoApi::class.java, "https://jsonplaceholder.typicode.com/") + .target(YourApi.class, "https://your-api-host/"); ``` From 8e195b6bb268fc4af59491af128fbb5cb2c924bb Mon Sep 17 00:00:00 2001 From: Manoel Aranda Neto <5731772+marandaneto@users.noreply.github.com> Date: Tue, 17 Aug 2021 16:00:24 +0200 Subject: [PATCH 4/7] Update src/platforms/java/performance/instrumentation/open-feign.mdx Co-authored-by: Isabel <76437239+imatwawana@users.noreply.github.com> --- src/platforms/java/performance/instrumentation/open-feign.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/platforms/java/performance/instrumentation/open-feign.mdx b/src/platforms/java/performance/instrumentation/open-feign.mdx index 3f5aabd6b0e96..7286f5f3e58bf 100644 --- a/src/platforms/java/performance/instrumentation/open-feign.mdx +++ b/src/platforms/java/performance/instrumentation/open-feign.mdx @@ -1,7 +1,7 @@ --- title: OpenFeign Integration sidebar_order: 20 -description: "Learn how to capture OpenFeign based HTTP clients performance" +description: "Learn how to capture the performance of OpenFeign-based HTTP clients." --- From 29a9fbed3283d45a885199f175801e31304a73b8 Mon Sep 17 00:00:00 2001 From: Manoel Aranda Neto <5731772+marandaneto@users.noreply.github.com> Date: Tue, 17 Aug 2021 16:01:56 +0200 Subject: [PATCH 5/7] Update src/platforms/java/performance/instrumentation/open-feign.mdx Co-authored-by: Isabel <76437239+imatwawana@users.noreply.github.com> --- src/platforms/java/performance/instrumentation/open-feign.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/platforms/java/performance/instrumentation/open-feign.mdx b/src/platforms/java/performance/instrumentation/open-feign.mdx index 7286f5f3e58bf..020d7a220b622 100644 --- a/src/platforms/java/performance/instrumentation/open-feign.mdx +++ b/src/platforms/java/performance/instrumentation/open-feign.mdx @@ -10,7 +10,7 @@ Capturing transactions requires that you first -Sentry OpenFeign integration provides `SentryFeignClient` that creates a span for each outgoing HTTP request executed with a [Feign](https://github.com/OpenFeign/feign) based HTTP client. +Sentry OpenFeign integration provides the `SentryFeignClient`, which creates a span for each outgoing HTTP request executed with a [Feign](https://github.com/OpenFeign/feign)-based HTTP client. ### Install From 0ee32eb242914a6b372e8f3189664a79daa4469a Mon Sep 17 00:00:00 2001 From: Manoel Aranda Neto <5731772+marandaneto@users.noreply.github.com> Date: Tue, 17 Aug 2021 16:02:01 +0200 Subject: [PATCH 6/7] Update src/platforms/java/performance/instrumentation/open-feign.mdx Co-authored-by: Isabel <76437239+imatwawana@users.noreply.github.com> --- src/platforms/java/performance/instrumentation/open-feign.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/platforms/java/performance/instrumentation/open-feign.mdx b/src/platforms/java/performance/instrumentation/open-feign.mdx index 020d7a220b622..61750ec822845 100644 --- a/src/platforms/java/performance/instrumentation/open-feign.mdx +++ b/src/platforms/java/performance/instrumentation/open-feign.mdx @@ -56,7 +56,7 @@ val api = Feign.builder() .target(YourApi::class.java, "https://your-api-host/") ``` -## Modify or Drop spans +## Modify or Drop Spans Spans created around HTTP requests can be modified or dropped using `SentryFeignClient.BeforeSpanCallback` passed to `SentryCapability`: From b291b5ba9639901cfc339ccae8c1049dc8cb9f00 Mon Sep 17 00:00:00 2001 From: Maciej Walkowiak Date: Thu, 19 Aug 2021 11:56:05 +0200 Subject: [PATCH 7/7] Update src/platforms/java/performance/instrumentation/open-feign.mdx Co-authored-by: Manoel Aranda Neto <5731772+marandaneto@users.noreply.github.com> --- src/platforms/java/performance/instrumentation/open-feign.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/platforms/java/performance/instrumentation/open-feign.mdx b/src/platforms/java/performance/instrumentation/open-feign.mdx index 61750ec822845..9893c67ed95cc 100644 --- a/src/platforms/java/performance/instrumentation/open-feign.mdx +++ b/src/platforms/java/performance/instrumentation/open-feign.mdx @@ -96,5 +96,5 @@ val api = Feign.builder() } span })) - .target(YourApi.class, "https://your-api-host/"); + .target(YourApi::class.java, "https://your-api-host/") ```