Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
lzchen authored Apr 23, 2024
2 parents b024c84 + d213e02 commit f45e1cc
Show file tree
Hide file tree
Showing 35 changed files with 174 additions and 145 deletions.
4 changes: 4 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ ignore =
# allow whitespace before ':' (https://github.com/psf/black#slices)
E203

# conflicts with black
E701
E704

exclude =
.bzr
.git
Expand Down
2 changes: 1 addition & 1 deletion dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pylint==3.0.2
flake8==6.1.0
isort==5.12.0
black==22.3.0
black==24.3.0
httpretty==1.1.4
mypy==1.9.0
sphinx==7.1.2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ click==8.1.7
Flask==2.3.3
googleapis-common-protos==1.52.0
grpcio==1.56.0
gunicorn==20.0.4
gunicorn==22.0.0
itsdangerous==2.1.2
Jinja2==3.1.3
MarkupSafe==2.1.3
Expand Down
2 changes: 1 addition & 1 deletion exporter/opentelemetry-exporter-opencensus/LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright The OpenTelemetry Authors
Copyright [yyyy] [name of copyright owner]

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,11 @@ def translate_to_collector(spans: Sequence[ReadableSpan]):
collector_span.parent_span_id = parent_id.to_bytes(8, "big")

if span.context.trace_state is not None:
for (key, value) in span.context.trace_state.items():
for key, value in span.context.trace_state.items():
collector_span.tracestate.entries.add(key=key, value=value)

if span.attributes:
for (key, value) in span.attributes.items():
for key, value in span.attributes.items():
utils.add_proto_attribute_value(
collector_span.attributes, key, value
)
Expand All @@ -150,7 +150,7 @@ def translate_to_collector(spans: Sequence[ReadableSpan]):
)

if event.attributes:
for (key, value) in event.attributes.items():
for key, value in event.attributes.items():
utils.add_proto_attribute_value(
collector_annotation.attributes, key, value
)
Expand Down Expand Up @@ -183,7 +183,7 @@ def translate_to_collector(spans: Sequence[ReadableSpan]):
)

if link.attributes:
for (key, value) in link.attributes.items():
for key, value in link.attributes.items():
utils.add_proto_attribute_value(
collector_span_link.attributes, key, value
)
Expand Down
2 changes: 1 addition & 1 deletion exporter/opentelemetry-exporter-otlp-proto-common/LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright The OpenTelemetry Authors
Copyright [yyyy] [name of copyright owner]

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion exporter/opentelemetry-exporter-otlp-proto-grpc/LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright The OpenTelemetry Authors
Copyright [yyyy] [name of copyright owner]

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion exporter/opentelemetry-exporter-otlp-proto-http/LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright The OpenTelemetry Authors
Copyright [yyyy] [name of copyright owner]

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion exporter/opentelemetry-exporter-otlp/LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright The OpenTelemetry Authors
Copyright [yyyy] [name of copyright owner]

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion exporter/opentelemetry-exporter-prometheus/LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright The OpenTelemetry Authors
Copyright [yyyy] [name of copyright owner]

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,9 @@ def collect(self) -> None:
self._target_info = self._create_info_metric(
_TARGET_INFO_NAME, _TARGET_INFO_DESCRIPTION, attributes
)
metric_family_id_metric_family[
_TARGET_INFO_NAME
] = self._target_info
metric_family_id_metric_family[_TARGET_INFO_NAME] = (
self._target_info
)

while self._metrics_datas:
self._translate_to_prometheus(
Expand Down Expand Up @@ -294,13 +294,13 @@ def _translate_to_prometheus(
)

if metric_family_id not in metric_family_id_metric_family:
metric_family_id_metric_family[
metric_family_id
] = CounterMetricFamily(
name=metric_name,
documentation=metric_description,
labels=label_keys,
unit=metric.unit,
metric_family_id_metric_family[metric_family_id] = (
CounterMetricFamily(
name=metric_name,
documentation=metric_description,
labels=label_keys,
unit=metric.unit,
)
)
metric_family_id_metric_family[
metric_family_id
Expand All @@ -318,13 +318,13 @@ def _translate_to_prometheus(
metric_family_id
not in metric_family_id_metric_family.keys()
):
metric_family_id_metric_family[
metric_family_id
] = GaugeMetricFamily(
name=metric_name,
documentation=metric_description,
labels=label_keys,
unit=metric.unit,
metric_family_id_metric_family[metric_family_id] = (
GaugeMetricFamily(
name=metric_name,
documentation=metric_description,
labels=label_keys,
unit=metric.unit,
)
)
metric_family_id_metric_family[
metric_family_id
Expand All @@ -339,13 +339,13 @@ def _translate_to_prometheus(
metric_family_id
not in metric_family_id_metric_family.keys()
):
metric_family_id_metric_family[
metric_family_id
] = HistogramMetricFamily(
name=metric_name,
documentation=metric_description,
labels=label_keys,
unit=metric.unit,
metric_family_id_metric_family[metric_family_id] = (
HistogramMetricFamily(
name=metric_name,
documentation=metric_description,
labels=label_keys,
unit=metric.unit,
)
)
metric_family_id_metric_family[
metric_family_id
Expand Down
2 changes: 1 addition & 1 deletion exporter/opentelemetry-exporter-zipkin-json/LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright The OpenTelemetry Authors
Copyright [yyyy] [name of copyright owner]

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion exporter/opentelemetry-exporter-zipkin-proto-http/LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright The OpenTelemetry Authors
Copyright [yyyy] [name of copyright owner]

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion exporter/opentelemetry-exporter-zipkin/LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright The OpenTelemetry Authors
Copyright [yyyy] [name of copyright owner]

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion opentelemetry-api/LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright The OpenTelemetry Authors
Copyright [yyyy] [name of copyright owner]

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
20 changes: 12 additions & 8 deletions opentelemetry-api/tests/propagators/test_w3cbaggagepropagator.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,13 @@ def test_header_max_entries_skip_invalid_entry(self):
self._extract(
",".join(
[
f"key{index}=value{index}"
if index != 2
else (
f"key{index}="
f"value{'s' * (W3CBaggagePropagator._MAX_PAIR_LENGTH + 1)}"
(
f"key{index}=value{index}"
if index != 2
else (
f"key{index}="
f"value{'s' * (W3CBaggagePropagator._MAX_PAIR_LENGTH + 1)}"
)
)
for index in range(
W3CBaggagePropagator._MAX_PAIRS + 1
Expand All @@ -162,9 +164,11 @@ def test_header_max_entries_skip_invalid_entry(self):
self._extract(
",".join(
[
f"key{index}=value{index}"
if index != 2
else f"key{index}xvalue{index}"
(
f"key{index}=value{index}"
if index != 2
else f"key{index}xvalue{index}"
)
for index in range(
W3CBaggagePropagator._MAX_PAIRS + 1
)
Expand Down
2 changes: 1 addition & 1 deletion opentelemetry-proto/LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright The OpenTelemetry Authors
Copyright [yyyy] [name of copyright owner]

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion opentelemetry-sdk/LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright The OpenTelemetry Authors
Copyright [yyyy] [name of copyright owner]

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
21 changes: 15 additions & 6 deletions opentelemetry-sdk/src/opentelemetry/sdk/_configuration/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,15 +265,21 @@ def _import_exporters(
metric_exporters = {}
log_exporters = {}

for (exporter_name, exporter_impl,) in _import_config_components(
for (
exporter_name,
exporter_impl,
) in _import_config_components(
trace_exporter_names, "opentelemetry_traces_exporter"
):
if issubclass(exporter_impl, SpanExporter):
trace_exporters[exporter_name] = exporter_impl
else:
raise RuntimeError(f"{exporter_name} is not a trace exporter")

for (exporter_name, exporter_impl,) in _import_config_components(
for (
exporter_name,
exporter_impl,
) in _import_config_components(
metric_exporter_names, "opentelemetry_metrics_exporter"
):
# The metric exporter components may be push MetricExporter or pull exporters which
Expand All @@ -283,7 +289,10 @@ def _import_exporters(
else:
raise RuntimeError(f"{exporter_name} is not a metric exporter")

for (exporter_name, exporter_impl,) in _import_config_components(
for (
exporter_name,
exporter_impl,
) in _import_config_components(
log_exporter_names, "opentelemetry_logs_exporter"
):
if issubclass(exporter_impl, LogExporter):
Expand Down Expand Up @@ -360,9 +369,9 @@ def _initialize_components(auto_instrumentation_version):
auto_resource = {}
# populate version if using auto-instrumentation
if auto_instrumentation_version:
auto_resource[
ResourceAttributes.TELEMETRY_AUTO_VERSION
] = auto_instrumentation_version
auto_resource[ResourceAttributes.TELEMETRY_AUTO_VERSION] = (
auto_instrumentation_version
)
resource = Resource.create(auto_resource)

_init_tracing(
Expand Down
28 changes: 16 additions & 12 deletions opentelemetry-sdk/src/opentelemetry/sdk/_logs/_internal/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,22 +202,26 @@ def to_json(self, indent=4) -> str:
"body": self.body,
"severity_number": repr(self.severity_number),
"severity_text": self.severity_text,
"attributes": dict(self.attributes)
if bool(self.attributes)
else None,
"attributes": (
dict(self.attributes) if bool(self.attributes) else None
),
"dropped_attributes": self.dropped_attributes,
"timestamp": ns_to_iso_str(self.timestamp),
"observed_timestamp": ns_to_iso_str(self.observed_timestamp),
"trace_id": f"0x{format_trace_id(self.trace_id)}"
if self.trace_id is not None
else "",
"span_id": f"0x{format_span_id(self.span_id)}"
if self.span_id is not None
else "",
"trace_id": (
f"0x{format_trace_id(self.trace_id)}"
if self.trace_id is not None
else ""
),
"span_id": (
f"0x{format_span_id(self.span_id)}"
if self.span_id is not None
else ""
),
"trace_flags": self.trace_flags,
"resource": repr(self.resource.attributes)
if self.resource
else "",
"resource": (
repr(self.resource.attributes) if self.resource else ""
),
},
indent=indent,
)
Expand Down
Loading

0 comments on commit f45e1cc

Please sign in to comment.