Skip to content
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

add missing tracer for Dgraph datasource #1235

Open
wants to merge 5 commits into
base: development
Choose a base branch
from

Conversation

Umang01-hash
Copy link
Contributor

@Umang01-hash Umang01-hash commented Nov 22, 2024

Pull Request Template

Description:

Checklist:

  • I have formatted my code using goimport and golangci-lint.
  • All new code is covered by unit tests.
  • This PR does not decrease the overall code coverage.
  • I have reviewed the code comments and documentation for clarity.

Thank you for your contribution!

Comment on lines +124 to +126
tracer := otel.GetTracerProvider().Tracer("gofr-dgraph")

db.UseTracer(tracer)
Copy link
Contributor

Choose a reason for hiding this comment

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

While this change might fix the issue, there might be a problem somewhere else.

A tracer cannot be considered as mandatory.

I mean it's a feature to have a tracer. What was the panic ?

There must be code that implies a tracer to be always present, while it could be simply absent.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ccoVeille I agree with your suggestion that making tracer necessary can be avoided, but since we are implementing these external datasources ourselves and as a framework we feel that observability is crucial to application, so we try to add it everywhere possible.

We just missed it in DGraph when adding for other datasources thatswhy this issue and this solution is here, but we will be extra careful when implementing datasources on our end so that it doesn't repeat.

Copy link
Contributor

Choose a reason for hiding this comment

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

My problem is not functional.

I'm OK with having a tracer.

My problem is having code that panic if a tracer is not set.

Did you find where the code was panicking?

I mean was it something like foo.Bar where bar is nil, or a code that raise a panic when some variable is checked.

If it's the first option, the code needs to be updated to raise an error. Either a non blocking one, or a functional panic if the tracer is mandatory.

Also, this panic should be covered by a test that will help to either check there is no panic, or we have the expected panic

Here your change is about putting a patch on a wooden leg.

My 2 cents

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ccoVeille addressing your comments, I have added the checks before setting the attributes to the span(which was causing panic earlier). Now even if you don't provide a tracer code will not panic and work as expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants