-
Notifications
You must be signed in to change notification settings - Fork 624
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
Making it easier to create custom distros #551
Making it easier to create custom distros #551
Comments
👍 for Option 2. In addition to the pros/cons listed, Option1 would also require a user to run |
+1 option 2 |
I think I am outvoted here, but I would prefer option 1 😅. A distro class may need to inherit from another distro present in a different distro package, thus making it necessary that more than one distro packages are installed. |
Hey, there is no 🚢 in the available reactions... |
@ocelotl I initially thought the same as you, but I think a good alternative solution is found in open-telemetry/opentelemetry-python#1937 . In this PR we are finding a way to add ALL the useful things all the distros might want to commonly do in a central accessible place. That way distros should really only be setting environment variables or doing very specific logic. Hopefully this way no distro will want to copy "environment variable" setting and can confident create a new distro with only a few lines of code without needing to inherit from other distros. |
How about not requiring an environment variable being set if there is only one distro installed? |
Hm that's interesting. I guess I agree that at the very least it doesn't seem right to error if someone has multiple distros installed, maybe in #571 we can just use a warning and by default use the first one. I think it's more likely that a user accidentally has 2 distros installed rather than them wanting to use only 1 but install 2. I think an environment variable makes it easier to make that mistake? It sounds like you've found an Option 3 though which is a combination of 1&2 😝 |
This is very dangerous because the order in which distros are loaded is totally non-deterministic. This will trip up a lot of people. Imagine someone installing a distro that pulls another one behind the scenes. They test locally and it works as expected with a seemingly harmless warning (because everything works in practice) but once they deploy to production, their service exhibits completely different behaviour by using the other distro. We are mixing up two issues here: a. Should users be able to install multiple distros at the same time or not? If yes, why? What is the use case for this? I think a. is not a real problem at least until someone comes up with a very valid use-case for this. b. is worth solving IMO and that's what we should focus on here. It seems we are trying to solve b. by coming up with a solution for 1. which might not result in the best possible outcome IMO. I still think the simplest solution is to just take out actually useful code and publish it independently of the default distro somewhere. If we establish this pattern, all distros should only contain vendor-specific code/configuration and it wouldn't be useful to use any distro as a base/library anyway. However, if we really want all distros to also be Python libraries, may I suggest a fourth option? :)
(quoted from open-telemetry/opentelemetry-python#1937 (comment)) |
Description
In the June 24th, 2021 SIG meeting we mentioned that the way
Distro
andConfigurator
are set up right now are not friendly for creating new distros because the implementation takes the 1st distro and the 1st configurator it finds installed instead of taking the one the user might want.See:
opentelemetry-python-contrib/opentelemetry-instrumentation/src/opentelemetry/instrumentation/auto_instrumentation/sitecustomize.py
Line 47 in 63e7561
opentelemetry-python-contrib/opentelemetry-instrumentation/src/opentelemetry/instrumentation/auto_instrumentation/sitecustomize.py
Lines 92 to 95 in 63e7561
Auto-instrumentation requires a distro to be installed. The
opentelemetry-distro
package provides aConfigurator
and anOpenTelemetryDistro
class. Auto-instrumentation then hooks into the Configurator AND the Distro to configure instrumentation.Currently the
Configurator
initializes componentsAnd the
OpenTelemetryDistro
sets environment variables:Problem
If I want to create a new
opentelemetry-distro-aws
distro, I really only want to set more environment variables like:but because the current implementation only takes the 1st distro, I have no guarantee my
-aws
distro will be used for configuration.Furthermore, if I like the
Configurator
as is, I have to copy and paste the code in the current setup because again only 1 "distro" can be installed.Potential Solutions
Some solutions we mentioned in the SIG meeting:
Option 1: Use an environment variable to select the distro you want out of all the ones installed
Use
OTEL_PYTHON_SELECTED_DISTRO
to select the one you want.PROs:
CONS:
pip install opentelemetry-distro-aws
andexport OTEL_PYTHON_DISTRO=aws
which is confusing because a distro install should just workOption 2: Move the useful "initalization" methods of the
Configurator
andBaseDistro
into theopentelemetry-sdk
and use more virtual methods (i.e. with a default implementation) insteadThis also means moving
BaseDistro
out ofopentelemetry-instrumentation
package and intoopentelemetry-sdk
.PROs:
Configurator
_initialize_components()
code will probably be helpful to many distros so we should pull it outInstrumentor
"configuration options"CONs:
_initialize_components()
the default means it assumes more of what we want, but it is probably what we want so as long as we expose the right methods to hook into we will still give distros the chance to customizeSummary
I think Option 2 is the clear preference. We just need to move
BaseDistro
and the_initialize_components()
implementation to a common package (opentelemetry-sdk
forBaseDistro
?opentelemetry-instrumentation
for_initialize_components
?) and expose the right virtual/abstract methods in theBaseDistro
class.We might even remove
Configurator
all-together?The text was updated successfully, but these errors were encountered: