Skip to content

store order to postgresql from accounting service #2175

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

cuichenli
Copy link

Changes

Add postgresql database, for accounting service to store orders receive from kafka. The current change only reflected in docker-compose and not in the kubernetes deployment yet. It will fallback to not use database if there is no corresponding environment variable. So I think it wont break the kubernetes deployment. But if we think it is necessary to have the kubernetes change in this PR as well, I will update later.

Fixes #912

Merge Requirements

For new features contributions, please make sure you have completed the following
essential items:

  • CHANGELOG.md updated to document new feature additions
  • Appropriate documentation updates in the docs
  • Appropriate Helm chart updates in the helm-charts

Maintainers will not merge until the above have been completed. If you're unsure
which docs need to be changed ping the
@open-telemetry/demo-approvers.

@cuichenli cuichenli requested a review from a team as a code owner May 8, 2025 09:21
@github-actions github-actions bot added the helm-update-required Requires an update to the Helm chart when released label May 8, 2025
@Kielek
Copy link
Contributor

Kielek commented May 14, 2025

https://github.com/open-telemetry/opentelemetry-dotnet-contrib/tree/main/src/OpenTelemetry.Instrumentation.EntityFrameworkCore used to instrument this package is not yet on stable semantic convention. It is using the old one.

Happy to see contributions to move it forward! : )

Copy link
Contributor

@puckpuck puckpuck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't tried to build and run this yet, but some changes that we should do to stay in alignment with how the rest of the Demo is organized.

@@ -829,3 +830,15 @@ services:
timeout: 10s
retries: 10
logging: *logging

postgresql:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move this entire section to the "Dependent Services" section of this file. It should be in that section alphabetically based on the service name, so around line 681.

@@ -829,3 +830,15 @@ services:
timeout: 10s
retries: 10
logging: *logging

postgresql:
image: 'postgres:latest'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be based on an environment variable called POSTGRES_IMAGE, set up similarly to how we do this for Valkey.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file should be in a src/postgres/ folder instead. We would also need to update docker-compose to reference the new location.

@cuichenli
Copy link
Author

@puckpuck all the above comments have been resolved. please kindly take a look. thanks!

@@ -38,6 +58,7 @@ public void StartListening()
{
try
{
using var activity = MyActivitySource.StartActivity("order-consumed");
Copy link
Author

@cuichenli cuichenli May 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

somehow the db activity is not automatically closing. so i added this to group the child spans. otherwise, it would result in recursively nested spans like this
image

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Kielek do you have any insights here?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also have raised in the dotnet repo open-telemetry/opentelemetry-dotnet-contrib#2792

Copy link
Contributor

@lachmatt lachmatt May 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At a first glance, it seems to be connected to interaction of 2 instrumentations active at the same time (EFCore and Npsql).
As a quick workaround, you can try disabling one of them by e.g. setting the following in docker-compose file:
OTEL_DOTNET_AUTO_TRACES_ENTITYFRAMEWORKCORE_INSTRUMENTATION_ENABLED=false
See the docs for a more info how to disable specific instrumentation.
Changes from e191c3e should be reverted. If custom instrumentation is needed, this describes the recommended approach.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for pointing out! did not notice npsql also have native instrumentation. have updated accordingly and it is working as expected now
image

@cuichenli cuichenli requested a review from puckpuck May 15, 2025 09:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
helm-update-required Requires an update to the Helm chart when released
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Adding new service to save orders to database
5 participants