8000 feat: move OTEL to a new 'InstrumentedFosite' by vivshankar · Pull Request #763 · ory/fosite · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat: move OTEL to a new 'InstrumentedFosite' #763

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

Closed
wants to merge 2 commits into from

Conversation

vivshankar
Copy link
Contributor

The recent change in [#761 ] introduces OTEL as part of Fosite. While this is valuable, this should
be provided as a wrapper and not as a hard wired part of Fosite, which is meant to be a SDK. Also,
popular instrumentation options and APM vendors have some level of support for OTEL but shine
when their wrapper SDKs are used that do not always comply with OTEL interfaces. See New Relic
and Instana SDKs for reference.

This change proposes that OTEL should be an opt-in as part of a wrapper implementation of Fosite
that is called InstrumentedFosite under the otel package. It also offers a pattern that can be applied
to any code blocks and handlers that should be instrumented to derive maximum benefits from a telemetry
perspective. For example - there may be no value in instrumenting a code block that interfaces with no
external components beyond the overall telemetry offered at a HTTP middleware level, whereas there
may be a great deal of value instrumenting call outs to external APIs and databases.

Related Issue or Design Document

#761

Checklist

  • I have read the contributing guidelines and signed the CLA.
  • I have referenced an issue containing the design document if my change introduces a new feature.
  • I have read the security policy.
  • I confirm that this pull request does not address a security vulnerability.
    If this pull request addresses a security vulnerability,
    I confirm that I got approval (please contact security@ory.sh) from the maintainers to push the changes.
  • I have added tests that prove my fix is effective or that my feature works.
  • I have added the necessary documentation within the code base (if appropriate).

Further comments

@vivshankar vivshankar requested a review from aeneasr as a code owner August 5, 2023 03:34
@james-d-elliott
Copy link
Contributor

Tests seem to just be failing due ory/hydra using a PR in go.mod. I like this change, I did some experimentation with it in making github.com/ory/fosite/otel it's own module so it's entirely standalone however I could not get it working, maybe it's unnecessary due to pruning and github.com/ory/x contains the imports anyway.

@vivshankar vivshankar changed the title feat: Move OTEL to a new 'InstrumentedFosite' feat: move OTEL to a new 'InstrumentedFosite' Aug 5, 2023
Copy link
Member
@aeneasr aeneasr left a comment

Choose a reason for hiding this comment

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

Thank you for the PR! I think it's nice to abstract away tracing and at the same time am critical of this approach. We will most likely add more OTEL tracing to lower-level functions and then this approach will no longer work (as well) without significant code wiring.

I think otel is a solid standard and would recommend to just go with it for now. If you want wrapping - you still can do that in your own codebase consuming Fosite!

@vivshankar
Copy link
Contributor Author
vivshankar commented Aug 7, 2023

The way we abstracted this for future proofing is to introduce a metrics interface that allows you to swap in providers as needed. OTEL is great but is not completely adopted by major vendors (referenced in my post and from actual usage of said vendor SDK and providers). Also the current implementation takes away any flexibility for adopters to use different libraries.

I am happy to take another stab at this to put it in Fosite directly if that will be acceptable.

With regards to adopters wrapping Fosite, the current implementation doesn't let me do that because OTEL is used directly without an opt-out

@vivshankar
Copy link
Contributor Author

@aeneasr Just got to my machine. To substantiate further, we could minimally add a config parameter to control the instrumentation. I was also thinking for handlers to add a wrapper handler that basically does the same thing and it becomes a simple matter of adding that to your compose factory/handler list.

For custom code blocks, it is simple enough to add an interface for spans and transactions.

@aeneasr
Copy link
Member
aeneasr commented Aug 7, 2023

I don't think that we want to maintain an abstraction for telemetry in Fosite, especially as we are quite happy with otel at the moment.

If you don't have an otel compatible system, you can set the otel tracer to noop/nil in which case nothing happens. And you can still wrap Fosite any way you want to add instrumentation that works with vendor XYZ.

Being honest, I don't see the value of doing a lot of work here right now.

@vivshankar vivshankar closed this Aug 7, 2023
@vivshankar vivshankar deleted the refactor-otel-impl branch August 7, 2023 12:03
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.

3 participants
0