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

feat: add otelx package #479

Merged
merged 68 commits into from
Apr 20, 2022
Merged

feat: add otelx package #479

merged 68 commits into from
Apr 20, 2022

Conversation

icyphox
Copy link
Contributor

@icyphox icyphox commented Mar 11, 2022

otelx wraps around go.opentelemetry.io/otel to simplify creating and using tracers. This is separate from the ory/x/tracing package as that supports a few more tracers (Zipkin, Instana, ...) which otelx does not, yet.

A note about the tests: the test for Jaeger spans simply spins up a UDP server and passes when data is received. While the byte data looks to be correct, I have not added code to unmarshal it. The reasoning behind this decision:

  • OpenTelemetry's compact Thrift generation is already tested
  • github.com/apache/thrift/lib/go/thrift is fairly complex and would take a lot of time to get setup, just for one test

Related Issue or Design Document

https://github.com/ory-corp/cloud/issues/2191

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 green light (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 necessary documentation within the code base (if
    appropriate).

@icyphox icyphox marked this pull request as ready for review March 14, 2022 11:19
@icyphox icyphox marked this pull request as draft March 15, 2022 06:35
Copy link
Contributor

@Demonsthere Demonsthere left a comment

Choose a reason for hiding this comment

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

Hi there :)
Adding some initial review comments, keep up the good work!

configx/provider.go Outdated Show resolved Hide resolved
configx/provider.go Outdated Show resolved Hide resolved
configx/provider_test.go Outdated Show resolved Hide resolved
otelx/config.go Outdated Show resolved Hide resolved
otelx/middleware.go Outdated Show resolved Hide resolved
otelx/middleware.go Outdated Show resolved Hide resolved
otelx/otel.go Outdated Show resolved Hide resolved
otelx/sql/instrumentedsql.go Outdated Show resolved Hide resolved
popx/migrator.go Outdated Show resolved Hide resolved
@Demonsthere
Copy link
Contributor

Great! It seems all that is left to do now i so to make the tests work :D https://github.com/ory/x/runs/5991843392?check_suite_focus=true#step%3A12%3A1202=

@icyphox icyphox marked this pull request as ready for review April 13, 2022 13:28
Copy link
Contributor

@Demonsthere Demonsthere left a comment

Choose a reason for hiding this comment

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

LGTM :)

Copy link
Member

@zepatrik zepatrik left a comment

Choose a reason for hiding this comment

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

This looks pretty good already 👍
Can we remove the old tracing package as well?
Also, why not stick with the current local_agent_address config key to avoid breaking changes and all the edge cases in the first place?

configx/provider.go Outdated Show resolved Hide resolved
configx/provider.go Show resolved Hide resolved
configx/provider.go Show resolved Hide resolved
otelx/config_test.go Outdated Show resolved Hide resolved
otelx/jaeger.go Outdated Show resolved Hide resolved
otelx/otel_test.go Outdated Show resolved Hide resolved
otelx/otel_test.go Outdated Show resolved Hide resolved
otelx/otel_test.go Outdated Show resolved Hide resolved
otelx/sql/instrumentedsql.go Outdated Show resolved Hide resolved
proxy/proxy.go Outdated Show resolved Hide resolved
@icyphox
Copy link
Contributor Author

icyphox commented Apr 14, 2022

Can we remove the old tracing package as well?

Done.

Also, why not stick with the current local_agent_address config key to avoid breaking changes and all the edge cases in the first place?

Also done. Not sure why that didn't occur to me 😅

Copy link
Member

@zepatrik zepatrik left a comment

Choose a reason for hiding this comment

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

Nice, this looks very good now 👍 Just some minor improvements 😉

otelx/config.schema.json Outdated Show resolved Hide resolved
otelx/middleware.go Outdated Show resolved Hide resolved
otelx/middleware_test.go Show resolved Hide resolved
Copy link
Member

@zepatrik zepatrik left a comment

Choose a reason for hiding this comment

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

Just very minor improvements and we're good to go 🎉

"pattern": "^([0-9]{1,3}\\.){3}[0-9]{1,3}:([0-9]*)$"
},
{
"format": "uri"
Copy link
Member

Choose a reason for hiding this comment

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

Format uri requires a scheme, but the code does not allow for parsing schemes, only hostname:port combinations.

Copy link
Member

Choose a reason for hiding this comment

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

See this example: https://go.dev/play/p/WS8_Bf_JRdR
I.e. for URIs to work, we have to use url.Parse

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah I get that, but removing "format": "urI" causes tests to fail and I'm not sure why.

otelx/config.schema.json Outdated Show resolved Hide resolved
otelx/config.schema.json Outdated Show resolved Hide resolved
otelx/otel.go Outdated Show resolved Hide resolved
popx/migrator.go Outdated Show resolved Hide resolved
@zepatrik zepatrik merged commit 4bf4fdd into ory:master Apr 20, 2022
@aeneasr
Copy link
Member

aeneasr commented Apr 21, 2022

Guys, please don't remove packages just because a new package has been introduced. This makes it impossible to upgrade ory/x without changing all dependent code of the stuff that has been removed.

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.

4 participants