spring-tips / spring-boot-3-aot

Hi, Spring fans! In this installment we briefly look at some of the new support for building native applications in Spring Framework 6 and Spring Boot 3
Apache License 2.0
90 stars 19 forks source link

Request: Full DataDog tracing guide #4

Open colin-riddell opened 1 year ago

colin-riddell commented 1 year ago

Hi @joshlong

Hope it's ok to put this request here.

I'd really, really appreciate if you could add something to this guide on how to correctly setup monitoring and distributed tracing such that it works on an AOT build of Spring Boot 3 and can be sent to DataDog.

I've had nothing but bother trying to get this to work, and there are no useful guides or documentation that conclusively show how to do this. (some are too old, some reference different libraries, some use zipkin (which I don't want)) Thanks

jonatan-ivanov commented 1 year ago

Hey Colin,

Disclaimer: I'm a member of the Spring Observability team. I haven’t tried this with Datadog but it should work since Datadog should have support to one of the tracing data formats that we support.

Spring has its own instrumentation that you can leverage regardless of your backend. Spring projects instrument themselves "natively" using Micrometer. More accurately, using Micrometer’s Observation API that gives you support for metrics and tracing (and more).

The tracing support is implemented via Micrometer Tracing. You can imagine it like SLF4J but for tracing: it has a simple API that let’s you plug Tracing libs in and out. The two supported libs are Brave and OpenTelemetry. Brave only supports the Zipkin format but as far as I know Datadog does not support it (this might have changed) but OpenTelemetry supports more exporters for example OTLP which is supported by Datadog as far as I know.

What you will need:

Here’s a working sample that sets almost everything up for you, except it uses a different exporter. Right now the OTLP exporter is not auto-configured in Boot so you need to create a bean manually but I already have a PR for this, hopefully it will make it to Boot 3.1. Though, since it should be simple to set this up with OTLP (“just” bean creation), please feel free to try it out with the OTLP exporter. Since we fixed AOT metadata in OTel, this should work with AOT too.

colin-riddell commented 1 year ago

hey @jonatan-ivanov - apologies for the late response to this.

this is really useful and I appreciate your the time you taken to contribute this. . I'm still working away on this in the background, so will keep the thread open and post updates so others can get even more value from it.