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

Adds metrics and tracing to the pulp-content app #3828

Closed
wants to merge 1 commit into from

Conversation

decko
Copy link
Member

@decko decko commented May 15, 2023

Closes #3829

@decko decko force-pushed the vendor_aiohttp_instrumentation branch 3 times, most recently from 8e3242d to 2d62c7b Compare May 15, 2023 15:01
@decko decko marked this pull request as draft May 15, 2023 15:02
@bmbouter
Copy link
Member

Can a feature be filed for this and a user facing release note added associated with that feature also please? Thanks!

@decko decko force-pushed the vendor_aiohttp_instrumentation branch 6 times, most recently from dc1dd41 to 113bf43 Compare May 15, 2023 18:44
CHANGES/3829.misc Outdated Show resolved Hide resolved
@decko decko force-pushed the vendor_aiohttp_instrumentation branch from 113bf43 to 4ca6a62 Compare May 15, 2023 20:20
@decko decko marked this pull request as ready for review May 15, 2023 20:20
Copy link
Member

@bmbouter bmbouter 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 great to me! I agree with vendoring this given the upstream timeline does not seem on the order of days or maybe even weeks.

@bmbouter bmbouter changed the title Vendor the aiohttp instrumentation code and add it to the aiohttp middleware list Adds metrics and tracing to the pulp-content app May 15, 2023
Copy link
Contributor

@ggainey ggainey left a comment

Choose a reason for hiding this comment

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

Looks good, I'm good w/ us carrying until it appears in an upstream release.

# This code is based on the original PR which could be found
# here. https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1800
# The idea is to remove this module when the PR or other alternative
# gets merged into opentelemetry-python-contrib
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

Copy link
Member

Choose a reason for hiding this comment

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

Let's be honest. Instead of calling this an effective copy of a PR (that may or may not be accepted in the current state), let's own this code, make it officialy a part of Pulp and talk about upstreaming it from there.

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think it's possible @mdellweg since we're only part of the authors of that code.

Copy link
Contributor

Choose a reason for hiding this comment

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

Make sure that if the license requires a copyright / license notice in copies of the code, that we're complying with 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 should probably elaborate: With owning i don't mean claiming the authorship, but taking the responsibility.

Copy link
Member

Choose a reason for hiding this comment

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

re licensing: it's unmerged upstream so I think it's actually not even licensed. When it is merged the upstream will be apache V2.

re owning it: we are owning it since we're contributing it upstream and the vendored version here. The thing I'm trying to avoid is to have it adhere to the standards of the Pulp community when it's actual destination is a contribution to the open-telemetry community which has different standards, norms, and expectations. If there's an issue though, I expect we'll fix that both here and in the upstream for example.

Copy link
Member

Choose a reason for hiding this comment

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

re licensing: It's easy then. The original contribution, which we adopt here, was made under the Apache V2 license. So it is that one.

CHANGES/3829.feature Outdated Show resolved Hide resolved
Copy link
Member

@ipanova ipanova left a comment

Choose a reason for hiding this comment

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

Apologies for bringing in last minutes changes requests, but would it be possible to add docs? This is an important feature pulp is adding and users will not see it a word about it except for this one liner changelog.
Can at least a docs paragraph be added? In a similar fashion we have mentions about analytics https://github.com/pulp/pulpcore/blob/main/docs/components.rst#analytics-collection

Copy link
Member

@mdellweg mdellweg left a comment

Choose a reason for hiding this comment

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

Can this work be tested in any reasonable way?

@decko
Copy link
Member Author

decko commented May 16, 2023

Can this work be tested in any reasonable way?

If you're talking about the instrumentation code we have it on the upstream package. I couldn't see a reason to vendor the tests too.
If you're talking about our instance of the aiohttp-server I've found no tests for the authentication middleware or any kind of test that test those pieces together.

Would make sense to have tests for it?

@decko decko force-pushed the vendor_aiohttp_instrumentation branch from 4ca6a62 to 66b99af Compare May 16, 2023 16:21
@bmbouter
Copy link
Member

Can this work be tested in any reasonable way?

If you're talking about the instrumentation code we have it on the upstream package. I couldn't see a reason to vendor the tests too. If you're talking about our instance of the aiohttp-server I've found no tests for the authentication middleware or any kind of test that test those pieces together.

Would make sense to have tests for it?

I agree with this. This isn't really Pulp code, it's just being included here so we can start using it because the upstream is very slow to respond. Given that the only actual Pulp part is the part enabling it. We'd add tests here just to then remove them when we remove it in favor of the upstream release also.

@decko decko force-pushed the vendor_aiohttp_instrumentation branch 3 times, most recently from 0c25639 to 50ea8ac Compare May 16, 2023 17:24
@decko
Copy link
Member Author

decko commented May 16, 2023

Apologies for bringing in last minutes changes requests, but would it be possible to add docs? This is an important feature pulp is adding and users will not see it a word about it except for this one liner changelog. Can at least a docs paragraph be added? In a similar fashion we have mentions about analytics https://github.com/pulp/pulpcore/blob/main/docs/components.rst#analytics-collection

I "drafted" a first version of it @ipanova. Can you check and left more suggestions?

@decko decko force-pushed the vendor_aiohttp_instrumentation branch from 50ea8ac to 0ee2cbc Compare May 16, 2023 17:39
@decko decko force-pushed the vendor_aiohttp_instrumentation branch from 0ee2cbc to 9d23ce9 Compare May 16, 2023 18:20
@decko decko force-pushed the vendor_aiohttp_instrumentation branch from 9d23ce9 to 375a081 Compare May 16, 2023 18:21
docs/components.rst Outdated Show resolved Hide resolved

To enable it you will need to set the following environment variables:

* ``PULP_OTEL_ENABLED`` set to ``True``.
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 this needs to become it's own paragraph expanding on it. What this actually does is run the workers with a different prefix so these docs should give an example of running pulp-api and pulp-content with and without open telemetry support. Then after explaining that we can state that the pulp-oci-images automatically handles that if the PULP_OTEL_ENABLED is set.

Copy link
Member

Choose a reason for hiding this comment

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

@bmbouter is it pulp-oci-images that handles this automatically? that means not only single container but also operator should be well set here too as well.

@mdellweg
Copy link
Member

mdellweg commented May 17, 2023

Can this work be tested in any reasonable way?

If you're talking about the instrumentation code we have it on the upstream package. I couldn't see a reason to vendor the tests too. If you're talking about our instance of the aiohttp-server I've found no tests for the authentication middleware or any kind of test that test those pieces together.
Would make sense to have tests for it?

I agree with this. This isn't really Pulp code, it's just being included here so we can start using it because the upstream is very slow to respond. Given that the only actual Pulp part is the part enabling it. We'd add tests here just to then remove them when we remove it in favor of the upstream release also.

Well, it is surely not upstream code. Hence my ask to really own it here. If we do not make it Pulp code, it's nobody's code. Whatever may or may not be merged upstream eventually, nobody can say. And what is not tested, must be considered broken. Adding all of this to pulp is supposed to generate some side effects. If those are not observable, it's not a feature. Maybe for clarification, I am talking about pulp tests, not unittests for the otel library. However, the latter should also come with the code.

edit: Re unittests: I shifted my mind. Yes, unittest should absolutely come and go with this piece of code, which we also just add to remove it later.

@decko decko force-pushed the vendor_aiohttp_instrumentation branch from 375a081 to 01dc215 Compare May 17, 2023 14:51
CHANGES/3829.doc Outdated
@@ -0,0 +1 @@
Adds the Telemetry section to the docs with information about OpenTelemetry and its usage on Pulp.
Copy link
Member

Choose a reason for hiding this comment

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

added. keep it past simple

docs/components.rst Outdated Show resolved Hide resolved

To enable it you will need to set the following environment variables:

* ``PULP_OTEL_ENABLED`` set to ``True``.
Copy link
Member

Choose a reason for hiding this comment

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

@bmbouter is it pulp-oci-images that handles this automatically? that means not only single container but also operator should be well set here too as well.

docs/components.rst Outdated Show resolved Hide resolved
@bmbouter
Copy link
Member

@ipanova yes it's pulp-oci-images that does it with this. I also expect that to work correctly for the operator too.

@bmbouter
Copy link
Member

Given that there is not an agreement on the testing requirements for this code, I think we should split the docs into their own PR.

This PR was designed to save time for the upstream to accept and release the work. I believe if we need to write tests also here it will take more time than it saves. We can just let the upstream contribution process work it out and close this PR.

@decko decko requested a review from ipanova May 19, 2023 14:23
@decko decko force-pushed the vendor_aiohttp_instrumentation branch from 01dc215 to af9191e Compare May 19, 2023 17:03
@decko
Copy link
Member Author

decko commented May 21, 2023

Given that there is not an agreement on the testing requirements for this code, I think we should split the docs into their own PR.

This PR was designed to save time for the upstream to accept and release the work. I believe if we need to write tests also here it will take more time than it saves. We can just let the upstream contribution process work it out and close this PR.

I'm closing this PR until further decision about how we should deal with this kind of situation.
And I'm opening another PR just for the documentation.

@decko decko closed this May 21, 2023
@mdellweg
Copy link
Member

If you're talking about our instance of the aiohttp-server I've found no tests for the authentication middleware or any kind of test that test those pieces together.

We do test the authentication middleware, because it's purpose is to set the user attribute on the request object. We test the domain middleware, because without the domain set, pulp would not work properly. So I read that the otel middleware is supposed to generate some data that is to be collected somewhere. Why is it so hard to assert that this happens according to some expectations?

This PR was designed to save time for the upstream to accept and release the work. I believe if we need to write tests also here it will take more time than it saves. We can just let the upstream contribution process work it out and close this PR.

If closing this PR was meant to prevent writing any tests at all, I must still say functional test that read like a specification for what kind of collected data we expect are still a requirement in my not so humble opinion.

@bmbouter
Copy link
Member

This is a different situation from those examples. In those examples the features provided by dependencies are consumed by Pulp and because of that they are able to be asserted on via the Pulp APIs. In this case this feature is offered from the opentelemetry dependency and consumed directly by the user. There is no Pulp API that we can actually make an API assertion on.

That's "why its so hard". There isn't a Pulp API that we can call to intercept this data. We'd be spending time and effort adding this capability to the CI and then assertions to a component other than Pulp. Additionally, consider that we are only temporarily carrying this code until it's available upstream. That info together means we'd be doing a lot of work just to throw it away, and that isn't something we can afford to do.

My ask is the same as it was. Think over my claim that this is not "pulp code". Allow this code to be temporarily carried as-is, and let the actual test contribution happen upstream. That PR does have tests. This is the #1 request from a large upstream user and I'd like us to let them test it prior to the upstream accept + release timeline.

Comment on lines -32 to +35
app = web.Application(middlewares=[authenticate])
app = web.Application(middlewares=[authenticate, instrumentation])
Copy link
Member

Choose a reason for hiding this comment

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

@bmbouter
This change is Pulp code and it deserves a good set of functional tests regardless. How else are we ever to know whether it's safe to pick up a new version of all the otel dependencies.

Your arguments only target the question of whether unittests for the unit that is supposed to be removed again are worth the trouble. I'm trying to readjust my request here.

And yes the hard barriers you are talking about for implementing functional tests (it's not accessible from pulp api) are exactly what I expect to be contributed to the pulp set of tests that are supposed to be staying even after bringing the vendored unit upstream.

@ggainey ggainey deleted the vendor_aiohttp_instrumentation branch April 17, 2024 19:37
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.

Add Open Telemetry support to the pulp-content app
7 participants