Skip to content

Commit 7641ca5

Browse files
committed
Fix lint: remove unused import and apply ruff format
1 parent cb3b456 commit 7641ca5

5 files changed

Lines changed: 19 additions & 63 deletions

File tree

opentelemetry-configuration/src/opentelemetry/configuration/_logger_provider.py

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -297,20 +297,14 @@ def _create_log_record_limits(
297297

298298
attribute_value_length_limit = config.attribute_value_length_limit
299299
if attribute_value_length_limit is None and global_limits is not None:
300-
attribute_value_length_limit = (
301-
global_limits.attribute_value_length_limit
302-
)
300+
attribute_value_length_limit = global_limits.attribute_value_length_limit
303301

304302
return LogRecordLimits(
305303
max_attributes=(
306-
attribute_count_limit
307-
if attribute_count_limit is not None
308-
else _DEFAULT_OTEL_LOG_ATTRIBUTE_COUNT_LIMIT
304+
attribute_count_limit if attribute_count_limit is not None else _DEFAULT_OTEL_LOG_ATTRIBUTE_COUNT_LIMIT
309305
),
310306
max_attribute_length=(
311-
attribute_value_length_limit
312-
if attribute_value_length_limit is not None
313-
else LogRecordLimits.UNSET
307+
attribute_value_length_limit if attribute_value_length_limit is not None else LogRecordLimits.UNSET
314308
),
315309
)
316310

@@ -341,16 +335,12 @@ def create_logger_provider(
341335
)
342336

343337
if config is not None and config.limits is not None:
344-
345338
limits = config.limits
346339

347340
else:
348-
349341
limits = LogRecordLimitsConfig()
350342

351-
log_record_limits = _create_log_record_limits(
352-
limits, global_attribute_limits
353-
)
343+
log_record_limits = _create_log_record_limits(limits, global_attribute_limits)
354344

355345
provider = LoggerProvider(
356346
resource=resource,
@@ -385,6 +375,4 @@ def configure_logger_provider(
385375
"""
386376
if config is None:
387377
return
388-
set_logger_provider(
389-
create_logger_provider(config, resource, global_attribute_limits)
390-
)
378+
set_logger_provider(create_logger_provider(config, resource, global_attribute_limits))

opentelemetry-configuration/src/opentelemetry/configuration/_sdk.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
configure_instrumentation,
2828
)
2929
from opentelemetry.configuration.models import (
30-
AttributeLimits,
3130
OpenTelemetryConfiguration,
3231
SeverityNumber,
3332
)
@@ -102,12 +101,8 @@ def configure_sdk(config: OpenTelemetryConfiguration) -> None:
102101

103102
global_attribute_limits = config.attribute_limits
104103
resource = create_resource(config.resource)
105-
configure_tracer_provider(
106-
config.tracer_provider, resource, global_attribute_limits
107-
)
104+
configure_tracer_provider(config.tracer_provider, resource, global_attribute_limits)
108105
configure_meter_provider(config.meter_provider, resource)
109-
configure_logger_provider(
110-
config.logger_provider, resource, global_attribute_limits
111-
)
106+
configure_logger_provider(config.logger_provider, resource, global_attribute_limits)
112107
configure_propagator(config.propagator)
113108
configure_instrumentation(config.instrumentation_development)

opentelemetry-configuration/src/opentelemetry/configuration/_tracer_provider.py

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -385,15 +385,11 @@ def _create_span_limits(
385385

386386
attribute_value_length_limit = config.attribute_value_length_limit
387387
if attribute_value_length_limit is None and global_limits is not None:
388-
attribute_value_length_limit = (
389-
global_limits.attribute_value_length_limit
390-
)
388+
attribute_value_length_limit = global_limits.attribute_value_length_limit
391389

392390
return SpanLimits(
393391
max_span_attributes=(
394-
attribute_count_limit
395-
if attribute_count_limit is not None
396-
else _DEFAULT_OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT
392+
attribute_count_limit if attribute_count_limit is not None else _DEFAULT_OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT
397393
),
398394
max_events=(
399395
config.event_count_limit if config.event_count_limit is not None else _DEFAULT_OTEL_SPAN_EVENT_COUNT_LIMIT
@@ -412,14 +408,10 @@ def _create_span_limits(
412408
else _DEFAULT_OTEL_LINK_ATTRIBUTE_COUNT_LIMIT
413409
),
414410
max_attribute_length=(
415-
attribute_value_length_limit
416-
if attribute_value_length_limit is not None
417-
else SpanLimits.UNSET
411+
attribute_value_length_limit if attribute_value_length_limit is not None else SpanLimits.UNSET
418412
),
419413
max_span_attribute_length=(
420-
attribute_value_length_limit
421-
if attribute_value_length_limit is not None
422-
else SpanLimits.UNSET
414+
attribute_value_length_limit if attribute_value_length_limit is not None else SpanLimits.UNSET
423415
),
424416
)
425417

@@ -482,16 +474,12 @@ def create_tracer_provider(
482474
_create_id_generator(config.id_generator) if config is not None and config.id_generator is not None else None
483475
)
484476
if config is not None and config.limits is not None:
485-
486477
limits = config.limits
487478

488479
else:
489-
490480
limits = SpanLimitsConfig()
491481

492-
span_limits = _create_span_limits(
493-
limits, global_attribute_limits
494-
)
482+
span_limits = _create_span_limits(limits, global_attribute_limits)
495483

496484
tracer_configurator = (
497485
_create_tracer_configurator(config.tracer_configurator_development)
@@ -533,6 +521,4 @@ def configure_tracer_provider(
533521
"""
534522
if config is None:
535523
return
536-
trace.set_tracer_provider(
537-
create_tracer_provider(config, resource, global_attribute_limits)
538-
)
524+
trace.set_tracer_provider(create_tracer_provider(config, resource, global_attribute_limits))

opentelemetry-configuration/tests/test_logger_provider.py

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
from opentelemetry.configuration.models import (
2727
AttributeLimits,
2828
NameStringValuePair,
29+
SeverityNumber,
2930
)
3031
from opentelemetry.configuration.models import (
3132
BatchLogRecordProcessor as BatchLogRecordProcessorConfig,
@@ -54,10 +55,6 @@
5455
from opentelemetry.configuration.models import (
5556
LogRecordProcessor as LogRecordProcessorConfig,
5657
)
57-
from opentelemetry.configuration.models import (
58-
NameStringValuePair,
59-
SeverityNumber,
60-
)
6158
from opentelemetry.configuration.models import (
6259
OtlpGrpcExporter as OtlpGrpcExporterConfig,
6360
)
@@ -471,34 +468,26 @@ def test_no_limits_no_warning():
471468

472469
def test_global_attribute_count_limit_used_when_no_per_signal_limits(self):
473470
global_limits = AttributeLimits(attribute_count_limit=42)
474-
provider = create_logger_provider(
475-
None, global_attribute_limits=global_limits
476-
)
471+
provider = create_logger_provider(None, global_attribute_limits=global_limits)
477472
self.assertEqual(provider._log_record_limits.max_attributes, 42)
478473

479474
def test_global_attribute_value_length_limit_used_when_no_per_signal_limits(
480475
self,
481476
):
482477
global_limits = AttributeLimits(attribute_value_length_limit=64)
483-
provider = create_logger_provider(
484-
None, global_attribute_limits=global_limits
485-
)
478+
provider = create_logger_provider(None, global_attribute_limits=global_limits)
486479
self.assertEqual(provider._log_record_limits.max_attribute_length, 64)
487480

488481
def test_per_signal_limits_override_global(self):
489-
global_limits = AttributeLimits(
490-
attribute_count_limit=100, attribute_value_length_limit=200
491-
)
482+
global_limits = AttributeLimits(attribute_count_limit=100, attribute_value_length_limit=200)
492483
config = LoggerProviderConfig(
493484
processors=[],
494485
limits=LogRecordLimitsConfig(
495486
attribute_count_limit=7,
496487
attribute_value_length_limit=16,
497488
),
498489
)
499-
provider = create_logger_provider(
500-
config, global_attribute_limits=global_limits
501-
)
490+
provider = create_logger_provider(config, global_attribute_limits=global_limits)
502491
self.assertEqual(provider._log_record_limits.max_attributes, 7)
503492
self.assertEqual(provider._log_record_limits.max_attribute_length, 16)
504493

opentelemetry-configuration/tests/test_sdk.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,7 @@ def test_calls_each_signal_with_resource(
7070
configure_sdk(config)
7171

7272
mock_create_resource.assert_called_once_with(resource_cfg)
73-
mock_tracer.assert_called_once_with(
74-
tracer_cfg, sentinel_resource, None
75-
)
73+
mock_tracer.assert_called_once_with(tracer_cfg, sentinel_resource, None)
7674
mock_meter.assert_called_once_with(None, sentinel_resource)
7775
mock_logger.assert_called_once_with(None, sentinel_resource, None)
7876
mock_propagator.assert_called_once_with(propagator_cfg)

0 commit comments

Comments
 (0)