Skip to content

Commit

Permalink
Replaced warnings with exception and replaced "lazy logging"
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremydvoss committed Mar 30, 2023
1 parent 0591db0 commit c2c06b3
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 60 deletions.
2 changes: 0 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## Unreleased
- Fix exporting of ExponentialBucketHistogramAggregation from opentelemetry.sdk.metrics.view
([#3240](https://github.com/open-telemetry/opentelemetry-python/pull/3240))

- Fix headers types mismatch for OTLP Exporters
([#3226](https://github.com/open-telemetry/opentelemetry-python/pull/3226))
- Fix suppress instrumentation for log batch processor
([#3223](https://github.com/open-telemetry/opentelemetry-python/pull/3223))

- Add speced out environment variables and arguments for BatchLogRecordProcessor
([#3237](https://github.com/open-telemetry/opentelemetry-python/pull/3237))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
_DEFAULT_EXPORT_TIMEOUT_MILLIS = 30000
_DEFAULT_MAX_QUEUE_SIZE = 2048
_ENV_VAR_INT_VALUE_ERROR_MESSAGE = (
"Unable to parse value for %s as integer. Defaulting to %s: %s"
"Unable to parse value for %s as integer. Defaulting to %s."
)

_logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -182,15 +182,12 @@ def __init__(
_DEFAULT_SCHEDULE_DELAY_MILLIS,
)
)
except ValueError as e:
except ValueError:
schedule_delay_millis = _DEFAULT_SCHEDULE_DELAY_MILLIS
_logger.warning(
_ENV_VAR_INT_VALUE_ERROR_MESSAGE
% (
OTEL_BLRP_SCHEDULE_DELAY,
_DEFAULT_SCHEDULE_DELAY_MILLIS,
e,
)
_logger.exception(
_ENV_VAR_INT_VALUE_ERROR_MESSAGE,
OTEL_BLRP_SCHEDULE_DELAY,
_DEFAULT_SCHEDULE_DELAY_MILLIS,
)

if max_export_batch_size is None:
Expand All @@ -201,15 +198,12 @@ def __init__(
_DEFAULT_MAX_EXPORT_BATCH_SIZE,
)
)
except ValueError as e:
except ValueError:
max_export_batch_size = _DEFAULT_MAX_EXPORT_BATCH_SIZE
_logger.warning(
_ENV_VAR_INT_VALUE_ERROR_MESSAGE
% (
OTEL_BLRP_SCHEDULE_DELAY,
_DEFAULT_MAX_EXPORT_BATCH_SIZE,
e,
)
_logger.exception(
_ENV_VAR_INT_VALUE_ERROR_MESSAGE,
OTEL_BLRP_SCHEDULE_DELAY,
_DEFAULT_MAX_EXPORT_BATCH_SIZE,
)

if export_timeout_millis is None:
Expand All @@ -220,15 +214,12 @@ def __init__(
_DEFAULT_EXPORT_TIMEOUT_MILLIS,
)
)
except ValueError as e:
except ValueError:
export_timeout_millis = _DEFAULT_EXPORT_TIMEOUT_MILLIS
_logger.warning(
_ENV_VAR_INT_VALUE_ERROR_MESSAGE
% (
OTEL_BLRP_SCHEDULE_DELAY,
_DEFAULT_EXPORT_TIMEOUT_MILLIS,
e,
)
_logger.exception(
_ENV_VAR_INT_VALUE_ERROR_MESSAGE,
OTEL_BLRP_SCHEDULE_DELAY,
_DEFAULT_EXPORT_TIMEOUT_MILLIS,
)

if max_queue_size is None:
Expand All @@ -238,11 +229,12 @@ def __init__(
OTEL_BLRP_MAX_QUEUE_SIZE, _DEFAULT_MAX_QUEUE_SIZE
)
)
except ValueError as e:
except ValueError:
max_queue_size = _DEFAULT_MAX_QUEUE_SIZE
_logger.warning(
_ENV_VAR_INT_VALUE_ERROR_MESSAGE
% (OTEL_BLRP_SCHEDULE_DELAY, _DEFAULT_MAX_QUEUE_SIZE, e)
_logger.exception(
_ENV_VAR_INT_VALUE_ERROR_MESSAGE,
OTEL_BLRP_SCHEDULE_DELAY,
_DEFAULT_MAX_QUEUE_SIZE,
)

if max_queue_size <= 0:
Expand Down
50 changes: 21 additions & 29 deletions opentelemetry-sdk/src/opentelemetry/sdk/trace/export/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
_DEFAULT_EXPORT_TIMEOUT_MILLIS = 30000
_DEFAULT_MAX_QUEUE_SIZE = 2048
_ENV_VAR_INT_VALUE_ERROR_MESSAGE = (
"Unable to parse value for %s as integer. Defaulting to %s: %s"
"Unable to parse value for %s as integer. Defaulting to %s."
)

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -168,11 +168,12 @@ def __init__(
OTEL_BSP_MAX_QUEUE_SIZE, _DEFAULT_MAX_QUEUE_SIZE
)
)
except ValueError as e:
except ValueError:
max_queue_size = _DEFAULT_MAX_QUEUE_SIZE
logger.warning(
_ENV_VAR_INT_VALUE_ERROR_MESSAGE
% (OTEL_BSP_MAX_QUEUE_SIZE, _DEFAULT_MAX_QUEUE_SIZE, e)
logger.exception(
_ENV_VAR_INT_VALUE_ERROR_MESSAGE,
OTEL_BSP_MAX_QUEUE_SIZE,
_DEFAULT_MAX_QUEUE_SIZE,
)

if schedule_delay_millis is None:
Expand All @@ -182,15 +183,12 @@ def __init__(
OTEL_BSP_SCHEDULE_DELAY, _DEFAULT_SCHEDULE_DELAY_MILLIS
)
)
except ValueError as e:
except ValueError:
schedule_delay_millis = _DEFAULT_SCHEDULE_DELAY_MILLIS
logger.warning(
_ENV_VAR_INT_VALUE_ERROR_MESSAGE
% (
OTEL_BSP_SCHEDULE_DELAY,
_DEFAULT_SCHEDULE_DELAY_MILLIS,
e,
)
logger.exception(
_ENV_VAR_INT_VALUE_ERROR_MESSAGE,
OTEL_BSP_SCHEDULE_DELAY,
_DEFAULT_SCHEDULE_DELAY_MILLIS,
)

if max_export_batch_size is None:
Expand All @@ -201,15 +199,12 @@ def __init__(
_DEFAULT_MAX_EXPORT_BATCH_SIZE,
)
)
except ValueError as e:
except ValueError:
max_export_batch_size = _DEFAULT_MAX_EXPORT_BATCH_SIZE
logger.warning(
_ENV_VAR_INT_VALUE_ERROR_MESSAGE
% (
OTEL_BSP_MAX_EXPORT_BATCH_SIZE,
_DEFAULT_MAX_EXPORT_BATCH_SIZE,
e,
)
logger.exception(
_ENV_VAR_INT_VALUE_ERROR_MESSAGE,
OTEL_BSP_MAX_EXPORT_BATCH_SIZE,
_DEFAULT_MAX_EXPORT_BATCH_SIZE,
)

if export_timeout_millis is None:
Expand All @@ -219,15 +214,12 @@ def __init__(
OTEL_BSP_EXPORT_TIMEOUT, _DEFAULT_EXPORT_TIMEOUT_MILLIS
)
)
except ValueError as e:
except ValueError:
export_timeout_millis = _DEFAULT_EXPORT_TIMEOUT_MILLIS
logger.warning(
_ENV_VAR_INT_VALUE_ERROR_MESSAGE
% (
OTEL_BSP_EXPORT_TIMEOUT,
_DEFAULT_EXPORT_TIMEOUT_MILLIS,
e,
)
logger.exception(
_ENV_VAR_INT_VALUE_ERROR_MESSAGE,
OTEL_BSP_EXPORT_TIMEOUT,
_DEFAULT_EXPORT_TIMEOUT_MILLIS,
)

if max_queue_size <= 0:
Expand Down

0 comments on commit c2c06b3

Please sign in to comment.