Open mike-england opened 5 months ago
I am not able to replicate your behavior in a local environment. Same code as yours but setting the environment variable manually and in a python script.
import os
from azure.monitor.opentelemetry import configure_azure_monitor
os.environ["OTEL_PYTHON_EXCLUDED_URLS"] = "health"
configure_azure_monitor()
import flask
app = flask.Flask(__name__)
@app.route("/")
def test():
print('got one')
return "Test flask request"
@app.route("/health")
def health():
print('health endpoint')
return "Health request"
if __name__ == "__main__":
app.run(host="0.0.0.0", port=8080)
Might be an issue of how you are capturing environment variables in your docker image. Could you verify that the environment variable is indeed read properly and passed into the code as expected?
Yes, I can confirm that the environment variables are being set. If I remove the exclude, everything works fine, and maybe that's my "solution" for now, other than I'll show thousands of kubernetes heartbeat messages.
Describe your environment I've been having problem where excluded URLs are showing up as a kind of phantom error in azure application insights. I've opened a bug under the azure sdk for python project but they suggested I open one here. That ticket is:
https://github.com/Azure/azure-sdk-for-python/issues/34616
Basically, my telemetry is reporting correctly, but I've excluded certain URLs, mostly because kubernetes constantly pings them as a health check and when I do that they report as a failed request with no response code.
Steps to reproduce
I'm going to include some sample code in a docker file that you can try:
app.py:
Dockerfile:
And to run it:
Where OTEL_PYTHON_EXCLUDED_URLS="health,swagger.*"
What is the expected behavior? The transactions don't show up in telemetry at all
What is the actual behavior? Transactions show up as errors
Additional context https://github.com/Azure/azure-sdk-for-python/issues/34616