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

dotenv integration #68

Open
codefromthecrypt opened this issue Sep 7, 2024 · 4 comments
Open

dotenv integration #68

codefromthecrypt opened this issue Sep 7, 2024 · 4 comments

Comments

@codefromthecrypt
Copy link

Right now, I am not using pytest_otel, yet. I would like to be able to use a dotenv file to provide variables as opposed to launching pytest with dotenv.

Right now, I run tests like this, with opentelemetry-instrument, and I get spans for httpx calls, but not pytest. I would like to try this plugin.

uv run dotenv -f ./tests/otel.env run -- opentelemetry-instrument pytest tests -m integration {{FLAGS}}

./tests/otel.env

OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318
OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf
OTEL_RESOURCE_ATTRIBUTES=service.name=MY_SERVICE
OTEL_METRIC_EXPORT_INTERVAL=100
OTEL_BSP_SCHEDULE_DELAY=100

Note: I have the following dev dependencies, which makes it incompatible with this plugin, as the dependencies here are strict ==

dev-dependencies = [
    "pytest>=8.3.2",
    "codecov>=2.1.13",
    "opentelemetry-sdk>=1.27.0",
    "opentelemetry-exporter-otlp-proto-http>=1.27.0",
    "opentelemetry-distro>=0.48b0",
    "opentelemetry-instrumentation-httpx>=0.48b0",
    "python-dotenv[cli]>=1.0.1"
]

I understand this is a combination of a feature request (dotenv support) and dependency leniency (something besides ==), so if you want this split up I can do that.

@codefromthecrypt
Copy link
Author

suggestion for the revlock problem is to change the deps here to >= instead of == and not increment it on every patch. That will give downstream users the flexibility to use later versions of whatever or delay upgrading depending on what happens here. my 2p

@kuisathaverat
Copy link
Owner

kuisathaverat commented Sep 9, 2024

Note: I have the following dev dependencies, which makes it incompatible with this plugin, as the dependencies here are strict
suggestion for the revlock problem is to change the deps here to >= instead of == and not increment it on every patch. That will give downstream users the flexibility to use later versions of whatever or delay upgrading depending on what happens here. my 2p

I preferred to keep dependencies strict to avoid compatibility issues, and ensure replicability.

@kuisathaverat
Copy link
Owner

For the dotenv support, you can use your shell capabilities as a workaround.

source ./tests/otel.env
uv run dotenv -f ./tests/otel.env run -- opentelemetry-instrument pytest tests -m integration {{FLAGS}}

I will add a flag to allow passing a dotenv file.

@codefromthecrypt
Copy link
Author

I preferred to keep dependencies strict to avoid compatibility issues, and ensure replicability.

I understand what you are aiming at, but doing so makes conflicts downstream. most notably the pytest version. This may limit adoption even if it achieves what you mention. I'm not arguing, just saying because I don't think I can use it due to this, even if others can match versions with you whenever a release occurs.

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

No branches or pull requests

2 participants