s3rius / FastAPI-template

Feature rich robust FastAPI template.
MIT License
1.9k stars 164 forks source link

Add optional monitoring solution (Prometheus, Datadog ...) #85

Closed sorasful closed 2 years ago

sorasful commented 2 years ago

Hello there !

I thought it would be a nice complement to add one or multiple services to be able to monitor the code, the calls, the performances.

I know that a lot of people use Prometheus, so I thought it could be nice. But I also know that DataDog also provides methods to monitor the code.

What do you think ?

s3rius commented 2 years ago

Hi. This is a great idea. I know about prometheus and personally work with it all the time, but I haven't heard about datadog, so I don't have sufficient experience to add this integration.

s3rius commented 2 years ago

This issue is complex, and I've decided to split it into multiple smaller ones.

Currently I want to add:

I'll keep this thread open in case someone wants to suggest a new integration.

s3rius commented 2 years ago

As I found out. Jaeger, Datadog and Digma can be used with OpenTelemetry collector. You can deploy an opentelemetry collector and add exporters to different systems.

So basically I want to setup an integration with OpenTelemetry and you will have an option to export any tracing information you want in desired systems.

I have to admit, though opentelemetry collector have an integration with sentry, but I have to add this integration manually, since I want to have more information that it sends to collector.

So new scheme would be something like this: image

So now this issue is all about opentelemetry integration. This is the best solution I came up with.

You can read more about opentelemetry collector here: https://opentelemetry.io/docs/collector/

WP-LKL commented 2 years ago

Amazing, and if you complete this feat, then please do add a sponsorship option.

s3rius commented 2 years ago

I've added prometheus and Sentry integrations.

I'm almost ready to add opentelemetry integration, but I have a question. Would it be useful to add an option to generate docker-compose.otlp.yml for the opentelemetry collector and Jaeger containers near with main docker-compose.yml?

What do you guys think about it?

sorasful commented 2 years ago

Wow, nice job !

Hmm, I wonder.. Wouldn't it be a good idea to put it in tbe docker-compose.yml with all the other services ? I think that's an acceptable solution IMHO

s3rius commented 2 years ago

Maybe adding those containers in docker-compose.dev.yml would be a better idea. Since in production you'll have collector, jaeger and datadog running on separate machines and you want to have only one instance of Jaeger for all projects.

I can add opentelemetry collector in main docker-compose.yml, since it collects spans per project, but I'll place Jaeger in a separate one.

Is this ok?

s3rius commented 2 years ago

Opentelemetry support along with prometheus and sentry was released in 3.3.5. I leave this issue open for a while. Here we can discuss if we need to change something.

s3rius commented 2 years ago

Closed due to inactivity.