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

Set default wasb Azure http logging level to warning; fixes #16224 #18896

Merged
merged 1 commit into from
Aug 9, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions airflow/providers/microsoft/azure/hooks/wasb.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@

"""

import logging
import os
from typing import Any, Dict, List, Optional

from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError
Expand Down Expand Up @@ -112,6 +114,12 @@ def __init__(
self.public_read = public_read
self.blob_service_client = self.get_conn()

logger = logging.getLogger("azure.core.pipeline.policies.http_logging_policy")
try:
logger.setLevel(os.environ.get("AZURE_HTTP_LOGGING_LEVEL", logging.WARNING))
Copy link
Member

Choose a reason for hiding this comment

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

Why?

If this configurability is really desired, I’d use airflow.settings for this.

from airflow import settings

logger.setLevel(getattr(settings, "AZURE_HTTP_LOGGING_LEVEL", logging.WARNING))

So a user can add AZURE_HTTP_LOGGING_LEVEL to airflow_local_settings if they so desire. This will need an entry in documentation as well.

With that, I won’t add the ValueError block. If the user provides something that crashes Airflow, that’s the user’s problem and we don’t need to do things too magically.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can make those updates and reopen in a new pull request since the bot closed this one. I was mostly thinking the user might want to tweak the log level for these in particular and I was unaware of the standard settings approach. Thanks for the feedback!

Copy link
Contributor

Choose a reason for hiding this comment

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

I can re-open if you wish to continue work on it (you will need to rebase to latest main)

except ValueError:
logger.setLevel(logging.WARNING)

def get_conn(self) -> BlobServiceClient:
"""Return the BlobServiceClient object."""
conn = self.get_connection(self.conn_id)
Expand Down