-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Description
Feature Request
Is your feature request related to a problem?
Yes. Currently, the OpenTelemetry Demo only supports PostgreSQL as the database for the Accounting service (which saves records retrieved from Kafka). However, there are situations (I've experienced a few myself) where it's valuable to see how connections to different database types (such as MySQL or MongoDB) appear in the OpenTelemetry backend. Not having this flexibility makes it harder to demonstrate and compare OpenTelemetry’s behavior across popular database technologies.
Describe the solution you'd like:
I would like to enhance the current demo so that the Account service can flexibly connect to PostgreSQL, MySQL, or MongoDB, based on user configuration. This would help end users to select the database type. Supporting this selection seamlessly for both Docker and Kubernetes deployments.
- For Kubernetes, configuration can be handled easily via the Helm chart, so rather no issue here.
- For Docker, I was thinking about using Docker Compose Profiles (docker compose --profile [postgres|mysql|mongo] up), although currently there’s no support for a default profile, so there is no way to fallback to default database (e.g. PostgreSQL) if there is no profile selected or some typo. I opened GH Issue in Docker Compose asking if there are any works on that feature --> Link
Describe alternatives you've considered.
N/A
Additional Context
Here is an example of how the environment variables could look:
# For PostgreSQL
DB_TYPE=postgres
DB_CONNECTION_STRING=Host=postgresql;Username=otelu;Password=otelp;Database=otel
# For MySQL
# DB_TYPE=mysql
# DB_CONNECTION_STRING=Server=mysql;Uid=otelu;Pwd=otelp;Database=otel
# For MongoDB
# DB_TYPE=mongo
# DB_CONNECTION_STRING=mongodb://otelu:otelp@mongo:27017/otel?authSource=admin
For Docker Compose, each supported database would have its own profile. Example commands:
docker compose --profile postgres up
docker compose --profile mysql up
docker compose --profile mongo up
My main concern here is balancing flexibility with ease of use, especially for Docker users...
I’ve created a prototype of this enhancement which can be found on my GH. Feel free to test it out to see how this feature could be implemented for Docker users by leveraging existing tools and features -> GitHub Repo.
Let me know if this makes sense or if I’m missing something obvious. I'm open to any feedback or ideas! If you think there’s a better way to do this or make it more user friendly, just let me know.
EDIT:
I just found an even easier and more user-friendly way to achieve it than Docker Compose profiles. We can use Docker Compose’s merge feature to swap out PostgreSQL for MySQL or MongoDB, and automatically update the app’s environment variables for the correct DB type and connection string. There’s no need to edit a .env file - just include the override files in our repo and end users can easily switch databases by specifying the desired override :) I’ve tested this and added it to the prototype app on my GitHub. -> GitHub Repo.