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

Manual instrumentation falcon #1365

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

Conversation

TheAnshul756
Copy link
Contributor

@TheAnshul756 TheAnshul756 commented Sep 30, 2022

Description

Manual Instrumentation in Falcon

Fixes #1342

Type of change

Please delete options that are not relevant.

  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • tox -e test-instrumentation-falcon1
  • tox -e test-instrumentation-falcon2
  • tox -e test-instrumentation-falcon3

Does This PR Require a Core Repo Change?

  • No.

Checklist:

  • Followed the style guidelines of this project
  • Changelogs have been updated
  • Unit tests have been added
  • Documentation has been updated

@TheAnshul756 TheAnshul756 requested a review from a team September 30, 2022 16:37
@TheAnshul756 TheAnshul756 marked this pull request as draft September 30, 2022 16:37
@TheAnshul756 TheAnshul756 marked this pull request as ready for review October 7, 2022 06:25
)
self._is_instrumented_by_opentelemetry = False

app = FalconAPI()
Copy link
Member

Choose a reason for hiding this comment

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

I didn't understand this. The app arg passed is getting replaced by this; how doe this work?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So, here we wanted to add more attributes in the original falcon api, but falcon do not let us add anything to already created app because of the use of __slots__. So, what we did is, we created a new child class of Falcon API and copied all the attributes in the new objects with the additional attributes that we wanted to add and returned the new app instead of the original app.

Copy link
Member

Choose a reason for hiding this comment

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

Does it contain everything? What happens to the rest of the attributes/properties/basically everything other than what __slots__ have on app instance?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. Falcon can not have additional instance variables because of __slots__ and because the new object is of child class so all the methods of falcon class will be inherited.

Copy link
Member

Choose a reason for hiding this comment

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

I am a little skeptical of this. I will try to find an example where this is not true.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I understand your point. What are the other possibilities? Do you have any suggestion? I can not think of anything else.

Copy link
Member

Choose a reason for hiding this comment

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

I would move the tracer/meter/instruments/config state to _TraceMiddleware since it's the one that's actually using them and then add it to middleware list.

Copy link
Contributor Author

@TheAnshul756 TheAnshul756 Nov 9, 2022

Choose a reason for hiding this comment

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

Not just _TraceMiddleware but __call__ function from _InstrumentedFalconAPI also uses those states. If we move all these states to _TraceMiddleware then we'll have to move all the instrumentation logic to middleware. Are you suggesting that?

Copy link
Member

Choose a reason for hiding this comment

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

I think _InstrumentedFalconAPI is a simple WSGI middleware. It's not necessary they maintain separate tracer/meter/instruments on it's own. It can use what will be used for the TraceMiddleware.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry I'm not able to understand. Can you please elaborate?

Copy link
Member

@srikanthccv srikanthccv left a comment

Choose a reason for hiding this comment

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

To prevent accidental merge before the comments are resolved.

@sanketmehta28
Copy link
Member

@ocelotl : I guess you have mentioned that in wrong issue. Please delete your comment from here and paste it on this issue

@ocelotl
Copy link
Contributor

ocelotl commented Nov 21, 2022

@ocelotl : I guess you have mentioned that in wrong issue. Please delete your comment from here and paste it on this issue

Right, moved ✌️

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.

Manual instrumentation in Falcon Framework
4 participants