Skip to content

Commit 7b9a22e

Browse files
committed
fix lint errors and regenerate workflows
1 parent ef1af4f commit 7b9a22e

File tree

8 files changed

+81
-50
lines changed

8 files changed

+81
-50
lines changed

.github/workflows/lint.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,25 @@ jobs:
233233
- name: Run tests
234234
run: tox -e lint-opentelemetry-exporter-otlp-proto-common
235235

236+
lint-opentelemetry-exporter-otlp-json-common:
237+
name: opentelemetry-exporter-otlp-json-common
238+
runs-on: ubuntu-latest
239+
timeout-minutes: 30
240+
steps:
241+
- name: Checkout repo @ SHA - ${{ github.sha }}
242+
uses: actions/checkout@v4
243+
244+
- name: Set up Python 3.14
245+
uses: actions/setup-python@v5
246+
with:
247+
python-version: "3.14"
248+
249+
- name: Install tox
250+
run: pip install tox-uv
251+
252+
- name: Run tests
253+
run: tox -e lint-opentelemetry-exporter-otlp-json-common
254+
236255
lint-opentelemetry-exporter-otlp-combined:
237256
name: opentelemetry-exporter-otlp-combined
238257
runs-on: ubuntu-latest

exporter/opentelemetry-exporter-otlp-json-common/benchmarks/test_benchmark_metrics_encoder.py

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,17 @@ def test_benchmark_encode_gauge(benchmark):
3939

4040

4141
def test_benchmark_encode_histogram(benchmark):
42-
data = make_metrics_data([
43-
make_histogram(
44-
exemplars=[
45-
Exemplar({"sampled": "true"}, 298.0, TIME, SPAN_ID, TRACE_ID),
46-
],
47-
)
48-
])
42+
data = make_metrics_data(
43+
[
44+
make_histogram(
45+
exemplars=[
46+
Exemplar(
47+
{"sampled": "true"}, 298.0, TIME, SPAN_ID, TRACE_ID
48+
),
49+
],
50+
)
51+
]
52+
)
4953
benchmark(encode_metrics, data)
5054

5155

@@ -55,15 +59,19 @@ def test_benchmark_encode_exponential_histogram(benchmark):
5559

5660

5761
def test_benchmark_encode_mixed_metrics(benchmark):
58-
data = make_metrics_data([
59-
make_sum(name="counter"),
60-
make_gauge(name="gauge"),
61-
make_histogram(
62-
name="histogram",
63-
exemplars=[
64-
Exemplar({"sampled": "true"}, 298.0, TIME, SPAN_ID, TRACE_ID),
65-
],
66-
),
67-
make_exponential_histogram(name="exp_histogram"),
68-
])
62+
data = make_metrics_data(
63+
[
64+
make_sum(name="counter"),
65+
make_gauge(name="gauge"),
66+
make_histogram(
67+
name="histogram",
68+
exemplars=[
69+
Exemplar(
70+
{"sampled": "true"}, 298.0, TIME, SPAN_ID, TRACE_ID
71+
),
72+
],
73+
),
74+
make_exponential_histogram(name="exp_histogram"),
75+
]
76+
)
6977
benchmark(encode_metrics, data)

exporter/opentelemetry-exporter-otlp-json-common/benchmarks/test_benchmark_trace_encoder.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
# pylint: disable=protected-access
16+
1517
import pytest
1618

1719
from opentelemetry.exporter.otlp.json.common.trace_encoder import encode_spans
@@ -20,7 +22,6 @@
2022
from opentelemetry.sdk.util.instrumentation import InstrumentationScope
2123
from opentelemetry.trace import Link
2224
from opentelemetry.trace.status import Status, StatusCode
23-
2425
from tests import BASE_TIME, TRACE_ID, make_span
2526

2627

exporter/opentelemetry-exporter-otlp-json-common/tests/__init__.py

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,10 @@ def assert_proto_json_equal(
9797
len(obj_b),
9898
f"List length mismatch at {path}: {len(obj_a)} != {len(obj_b)}",
9999
)
100-
for i, (item_a, item_b) in enumerate(zip(obj_a, obj_b)):
101-
assert_proto_json_equal(test_case, item_a, item_b, f"{path}[{i}]")
100+
for idx, (item_a, item_b) in enumerate(zip(obj_a, obj_b)):
101+
assert_proto_json_equal(
102+
test_case, item_a, item_b, f"{path}[{idx}]"
103+
)
102104
elif _is_none_equivalent(obj_a, obj_b):
103105
pass
104106
else:
@@ -196,28 +198,28 @@ def make_log(
196198
context=None,
197199
limits=None,
198200
):
199-
kwargs = dict(
200-
timestamp=timestamp,
201-
observed_timestamp=observed_timestamp,
202-
severity_text=severity_text,
203-
severity_number=severity_number,
204-
body=body,
205-
attributes=attributes or {},
206-
event_name=event_name,
207-
)
201+
kwargs = {
202+
"timestamp": timestamp,
203+
"observed_timestamp": observed_timestamp,
204+
"severity_text": severity_text,
205+
"severity_number": severity_number,
206+
"body": body,
207+
"attributes": attributes or {},
208+
"event_name": event_name,
209+
}
208210
if context is not None:
209211
kwargs["context"] = context
210212

211-
rw_kwargs = dict(
212-
resource=resource or Resource({}),
213-
instrumentation_scope=InstrumentationScope("test_scope", "1.0")
213+
rkwargs = {
214+
"resource": resource or Resource({}),
215+
"instrumentation_scope": InstrumentationScope("test_scope", "1.0")
214216
if instrumentation_scope is _UNSET
215217
else instrumentation_scope,
216-
)
218+
}
217219
if limits is not None:
218-
rw_kwargs["limits"] = limits
220+
rkwargs["limits"] = limits
219221

220-
return ReadableLogRecord(LogRecord(**kwargs), **rw_kwargs)
222+
return ReadableLogRecord(LogRecord(**kwargs), **rkwargs)
221223

222224

223225
# ---------------------------------------------------------------------------

exporter/opentelemetry-exporter-otlp-json-common/tests/test_log_encoder.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
# pylint: disable=unsubscriptable-object
16+
1517
import json
1618
import unittest
1719

@@ -45,7 +47,6 @@
4547
TraceFlags,
4648
set_span_in_context,
4749
)
48-
4950
from tests import (
5051
SPAN_ID,
5152
TIME,
@@ -238,6 +239,7 @@ def test_encode_log_grouping_by_resource(self):
238239
self.assertEqual(len(result.resource_logs), 2)
239240

240241
groups = {}
242+
# pylint: disable-next=not-an-iterable
241243
for rl in result.resource_logs:
242244
svc_val = rl.resource.attributes[0].value.string_value
243245
bodies = [

exporter/opentelemetry-exporter-otlp-json-common/tests/test_metrics_encoder.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
# pylint: disable=protected-access
15+
# pylint: disable=protected-access,unsubscriptable-object
1616

1717
import json
1818
import unittest
@@ -30,7 +30,6 @@
3030
Buckets,
3131
Metric,
3232
)
33-
3433
from tests import (
3534
SPAN_ID,
3635
TIME,

exporter/opentelemetry-exporter-otlp-json-common/tests/test_proto_json_compatibility.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@
6161
from opentelemetry.sdk.trace import Event, SpanContext
6262
from opentelemetry.sdk.util.instrumentation import InstrumentationScope
6363
from opentelemetry.trace import Link
64-
6564
from tests import (
6665
BASE_TIME,
6766
PARENT_SPAN_ID,

exporter/opentelemetry-exporter-otlp-json-common/tests/test_trace_encoder.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
# pylint: disable=protected-access
15+
# pylint: disable=protected-access,unsubscriptable-object
1616

1717
import json
1818
import unittest
@@ -45,7 +45,6 @@
4545
from opentelemetry.trace import Link, SpanKind
4646
from opentelemetry.trace.span import TraceState
4747
from opentelemetry.trace.status import Status, StatusCode
48-
4948
from tests import (
5049
BASE_TIME,
5150
PARENT_SPAN_ID,
@@ -61,6 +60,7 @@ def _get_span(result, rs_idx=0, ss_idx=0, s_idx=0):
6160
return result.resource_spans[rs_idx].scope_spans[ss_idx].spans[s_idx]
6261

6362

63+
# pylint: disable=too-many-public-methods
6464
class TestOTLPTraceEncoder(unittest.TestCase):
6565
def test_encode_single_span(self):
6666
span = make_span()
@@ -183,6 +183,7 @@ def test_encode_span_grouping_by_resource(self):
183183
self.assertEqual(len(result.resource_spans), 2)
184184

185185
groups = {}
186+
# pylint: disable-next=not-an-iterable
186187
for rs in result.resource_spans:
187188
svc_val = rs.resource.attributes[0].value.string_value
188189
span_names = [s.name for ss in rs.scope_spans for s in ss.spans]
@@ -339,14 +340,14 @@ def test_encode_spans_to_dict(self):
339340
result_dict = result.to_dict()
340341

341342
self.assertIn("resourceSpans", result_dict)
342-
s = result_dict["resourceSpans"][0]["scopeSpans"][0]["spans"][0]
343-
344-
self.assertIsInstance(s["traceId"], str)
345-
self.assertEqual(len(s["traceId"]), 32)
346-
self.assertIsInstance(s["spanId"], str)
347-
self.assertEqual(len(s["spanId"]), 16)
348-
self.assertIsInstance(s["startTimeUnixNano"], str)
349-
self.assertIsInstance(s["endTimeUnixNano"], str)
343+
sp = result_dict["resourceSpans"][0]["scopeSpans"][0]["spans"][0]
344+
345+
self.assertIsInstance(sp["traceId"], str)
346+
self.assertEqual(len(sp["traceId"]), 32)
347+
self.assertIsInstance(sp["spanId"], str)
348+
self.assertEqual(len(sp["spanId"]), 16)
349+
self.assertIsInstance(sp["startTimeUnixNano"], str)
350+
self.assertIsInstance(sp["endTimeUnixNano"], str)
350351

351352
def test_encode_spans_json_roundtrip(self):
352353
parent_ctx = SpanContext(TRACE_ID, PARENT_SPAN_ID, is_remote=True)

0 commit comments

Comments
 (0)