Comments (8)
Do this and it should suppress those verbose logs.
configure_azure_monitor(connection_string=os.environ["APPLICATIONINSIGHTS_CONNECTION_STRING"])
logging.getLogger("azure.core.pipeline.policies.http_logging_policy").setLevel(logging.WARNING)
logging.getLogger("azure.monitor.opentelemetry.exporter.export").setLevel(logging.WARNING)
from applicationinsights-python.
I have seen that those logs come from:
Request URL: 'https://westeurope-5.in.applicationinsights.azure.com//v2.1/track'
Request method: 'POST'
Request headers:
'Content-Type': 'application/json'
'Content-Length': '12891'
'Accept': 'application/json'
'User-Agent': 'azsdk-python-azuremonitorclient/unknown Python/3.9.17 (Linux-5.15.116.1-1.cm2-x86_64-with-glibc2.31)'
A body is sent with the request
sdkVersion
py3.9.17:otel1.20.0:ext1.0.0b17
Same as the explicit log that I do.
from applicationinsights-python.
I have tried raising logs to:
logging.basicConfig(level=logging.WARNING)
But I still see them
from applicationinsights-python.
Fixed with following code:
from azure.monitor.opentelemetry import configure_azure_monitor
from opentelemetry import trace
import logging
logging.getLogger().handlers = []
configure_azure_monitor(connection_string=os.environ["APPLICATIONINSIGHTS_CONNECTION_STRING"])
logging.getLogger().setLevel(logging.WARNING)
tracer = trace.get_tracer(__name__)
app = fastapi.FastAPI()
@app.get("/x")
async def x():
with tracer.start_as_current_span("aaaaa"):
logging.warning("a",extras={"b":1})
def main(req: func.HttpRequest, context: func.Context) -> func.HttpResponse:
return func.AsgiMiddleware(app).handle(req, context)
from applicationinsights-python.
This helped, thank you very much @macieyng . The only thing that I don't understand is why disabling the automatic instrumentations and excluding urls didn't help
from applicationinsights-python.
It didn't work because Azure SDK is instrumenting itself while suppressing any other instrumentation. Read this comment: Azure/azure-sdk-for-python#31292 (comment)
from applicationinsights-python.
These additional logs are appearing in the "traces" table in your Application Insights resource correct? We have recently implemented a feature to define the specific logger that you want to collect traces telemetry. This should allow you to define the logger to your application logger instead of the default which is the root logger. This is why you are seeing logs collected from the SDK itself. This feature should be available soon in the next release.
from applicationinsights-python.
Migrating to Azure sdk: Azure/azure-sdk-for-python#32503
from applicationinsights-python.
Related Issues (20)
- Log level cannot be configured through `logging_level` argument HOT 1
- Vendor instrumentations
- Add custom exporter support for all pillars HOT 1
- Separate Attach logic into new package that depends on distro HOT 1
- Add documentation for useful instrumentation configurations. HOT 1
- This repo is missing important files HOT 1
- Confirm licensing approach for vendoring is correct HOT 1
- Support for OpenTelemetry instrumentation aiohttp-client HOT 2
- Support for OpenTelemetry instrumentation grpc HOT 2
- Benefit from this package without using AzureInsights? (Offline Use within docker-compose?) HOT 4
- Inbound requests to FastAPI Route are not getting logged in App Insights HOT 3
- No tracing with Opentelemetry distro for Azure + Python + Fastapi HOT 3
- Unwanted dependencies are tracked which are not required HOT 3
- Not able to set cloudrole name HOT 3
- Flask auto-instrumentation doesn't configure itself properly HOT 9
- No insights in application map from sample code correlated logs HOT 2
- 'MessageData' is required but missing or empty HOT 3
- What's the problem with duplicated logs? HOT 12
- Resource error HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from applicationinsights-python.