Skip to content

Commit 7528bbf

Browse files
committed
add mypy and make it happy
1 parent 344f51a commit 7528bbf

File tree

10 files changed

+65
-53
lines changed

10 files changed

+65
-53
lines changed

opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/error_attributes.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@
2323
"""
2424

2525

26-
@deprecated(
27-
reason="Deprecated in favor of stable :py:const:`opentelemetry.semconv.attributes.error_attributes.ErrorTypeValues`."
28-
)
26+
@deprecated(reason="Deprecated in favor of stable :py:const:`opentelemetry.semconv.attributes.error_attributes.ErrorTypeValues`.") # type: ignore
2927
class ErrorTypeValues(Enum):
3028
OTHER: Final = "_OTHER"
3129
"""A fallback error value to be used when the instrumentation doesn't define a custom value."""

opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/http_attributes.py

+2-6
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,7 @@ class HttpConnectionStateValues(Enum):
130130
"""idle state."""
131131

132132

133-
@deprecated(
134-
reason="The attribute http.flavor is deprecated - Replaced by `network.protocol.name`"
135-
)
133+
@deprecated(reason="The attribute http.flavor is deprecated - Replaced by `network.protocol.name`") # type: ignore
136134
class HttpFlavorValues(Enum):
137135
HTTP_1_0: Final = "1.0"
138136
"""HTTP/1.0."""
@@ -148,9 +146,7 @@ class HttpFlavorValues(Enum):
148146
"""QUIC protocol."""
149147

150148

151-
@deprecated(
152-
reason="Deprecated in favor of stable :py:const:`opentelemetry.semconv.attributes.http_attributes.HttpRequestMethodValues`."
153-
)
149+
@deprecated(reason="Deprecated in favor of stable :py:const:`opentelemetry.semconv.attributes.http_attributes.HttpRequestMethodValues`.") # type: ignore
154150
class HttpRequestMethodValues(Enum):
155151
CONNECT: Final = "CONNECT"
156152
"""CONNECT method."""

opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/messaging_attributes.py

+13-9
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,8 @@
1010
# distributed under the License is distributed on an "AS IS" BASIS,
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
13-
# limitations under the License.
14-
15-
from enum import Enum
13+
# limitations under t
14+
from typing from enum import Enum
1615
from typing import Final
1716

1817
MESSAGING_BATCH_MESSAGE_COUNT: Final = "messaging.batch.message_count"
@@ -26,12 +25,6 @@
2625
A unique identifier for the client that consumes or produces a message.
2726
"""
2827

29-
MESSAGING_CLIENT_ID: Final = "messaging.client.id"
30-
"""
31-
TEST ME
32-
"""
33-
34-
3528
MESSAGING_DESTINATION_ANONYMOUS: Final = "messaging.destination.anonymous"
3629
"""
3730
A boolean that is true if the message destination is anonymous (could be unnamed or have auto-generated name).
@@ -319,3 +312,14 @@ class MessagingSystemValues(Enum):
319312
"""RabbitMQ."""
320313
ROCKETMQ: Final = "rocketmq"
321314
"""Apache RocketMQ."""
315+
e Bus."""
316+
GCP_PUBSUB: Final = "gcp_pubsub"
317+
"""Google Cloud Pub/Sub."""
318+
JMS: Final = "jms"
319+
"""Java Message Service."""
320+
KAFKA: Final = "kafka"
321+
"""Apache Kafka."""
322+
RABBITMQ: Final = "rabbitmq"
323+
"""RabbitMQ."""
324+
ROCKETMQ: Final = "rocketmq"
325+
""Apache RocketMQ."""

opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/net_attributes.py

+2-6
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,7 @@
8383
"""
8484

8585

86-
@deprecated(
87-
reason="The attribute net.sock.family is deprecated - Split to `network.transport` and `network.type`"
88-
)
86+
@deprecated(reason="The attribute net.sock.family is deprecated - Split to `network.transport` and `network.type`") # type: ignore
8987
class NetSockFamilyValues(Enum):
9088
INET: Final = "inet"
9189
"""IPv4 address."""
@@ -95,9 +93,7 @@ class NetSockFamilyValues(Enum):
9593
"""Unix domain socket path."""
9694

9795

98-
@deprecated(
99-
reason="The attribute net.transport is deprecated - Replaced by `network.transport`"
100-
)
96+
@deprecated(reason="The attribute net.transport is deprecated - Replaced by `network.transport`") # type: ignore
10197
class NetTransportValues(Enum):
10298
IP_TCP: Final = "ip_tcp"
10399
"""ip_tcp."""

opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/network_attributes.py

+2-6
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,7 @@ class NetworkIoDirectionValues(Enum):
158158
"""receive."""
159159

160160

161-
@deprecated(
162-
reason="Deprecated in favor of stable :py:const:`opentelemetry.semconv.attributes.network_attributes.NetworkTransportValues`."
163-
)
161+
@deprecated(reason="Deprecated in favor of stable :py:const:`opentelemetry.semconv.attributes.network_attributes.NetworkTransportValues`.") # type: ignore
164162
class NetworkTransportValues(Enum):
165163
TCP: Final = "tcp"
166164
"""TCP."""
@@ -172,9 +170,7 @@ class NetworkTransportValues(Enum):
172170
"""Unix domain socket."""
173171

174172

175-
@deprecated(
176-
reason="Deprecated in favor of stable :py:const:`opentelemetry.semconv.attributes.network_attributes.NetworkTypeValues`."
177-
)
173+
@deprecated(reason="Deprecated in favor of stable :py:const:`opentelemetry.semconv.attributes.network_attributes.NetworkTypeValues`.") # type: ignore
178174
class NetworkTypeValues(Enum):
179175
IPV4: Final = "ipv4"
180176
"""IPv4."""

opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/otel_attributes.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,7 @@
4848
"""
4949

5050

51-
@deprecated(
52-
reason="Deprecated in favor of stable :py:const:`opentelemetry.semconv.attributes.otel_attributes.OtelStatusCodeValues`."
53-
)
51+
@deprecated(reason="Deprecated in favor of stable :py:const:`opentelemetry.semconv.attributes.otel_attributes.OtelStatusCodeValues`.") # type: ignore
5452
class OtelStatusCodeValues(Enum):
5553
OK: Final = "OK"
5654
"""The operation has been validated by an Application developer or Operator to have completed successfully."""

opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/system_attributes.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -201,9 +201,7 @@ class SystemProcessStatusValues(Enum):
201201
"""defunct."""
202202

203203

204-
@deprecated(
205-
reason="The attribute system.processes.status is deprecated - Replaced by `system.process.status`"
206-
)
204+
@deprecated(reason="The attribute system.processes.status is deprecated - Replaced by `system.process.status`") # type: ignore
207205
class SystemProcessesStatusValues(Enum):
208206
RUNNING: Final = "running"
209207
"""running."""

opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/telemetry_attributes.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,7 @@
4545
"""
4646

4747

48-
@deprecated(
49-
reason="Deprecated in favor of stable :py:const:`opentelemetry.semconv.attributes.telemetry_attributes.TelemetrySdkLanguageValues`."
50-
)
48+
@deprecated(reason="Deprecated in favor of stable :py:const:`opentelemetry.semconv.attributes.telemetry_attributes.TelemetrySdkLanguageValues`.") # type: ignore
5149
class TelemetrySdkLanguageValues(Enum):
5250
CPP: Final = "cpp"
5351
"""cpp."""

opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/metrics/process_metrics.py

+17-3
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,29 @@
1313
# limitations under the License.
1414

1515

16-
from typing import Callable, Final, Sequence
16+
from typing import (
17+
Callable,
18+
Final,
19+
Generator,
20+
Iterable,
21+
Optional,
22+
Sequence,
23+
Union,
24+
)
1725

1826
from opentelemetry.metrics import (
27+
CallbackOptions,
1928
Counter,
2029
Meter,
2130
ObservableGauge,
31+
Observation,
2232
UpDownCounter,
2333
)
2434

35+
CallbackT = Union[
36+
Callable[[CallbackOptions], Iterable[Observation]],
37+
Generator[Iterable[Observation], CallbackOptions, None],
38+
]
2539
PROCESS_CONTEXT_SWITCHES: Final = "process.context_switches"
2640
"""
2741
Number of times the process has been context switched
@@ -65,12 +79,12 @@ def create_process_cpu_time(meter: Meter) -> Counter:
6579

6680

6781
def create_process_cpu_utilization(
68-
meter: Meter, callback: Sequence[Callable]
82+
meter: Meter, callbacks: Optional[Sequence[CallbackT]]
6983
) -> ObservableGauge:
7084
"""Difference in process.cpu.time since the last measurement, divided by the elapsed time and number of CPUs available to the process"""
7185
return meter.create_observable_gauge(
7286
name="process.cpu.utilization",
73-
callback=callback,
87+
callbacks=callbacks,
7488
description="Difference in process.cpu.time since the last measurement, divided by the elapsed time and number of CPUs available to the process.",
7589
unit="1",
7690
)

opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/metrics/system_metrics.py

+25-11
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,29 @@
1313
# limitations under the License.
1414

1515

16-
from typing import Callable, Final, Sequence
16+
from typing import (
17+
Callable,
18+
Final,
19+
Generator,
20+
Iterable,
21+
Optional,
22+
Sequence,
23+
Union,
24+
)
1725

1826
from opentelemetry.metrics import (
27+
CallbackOptions,
1928
Counter,
2029
Meter,
2130
ObservableGauge,
31+
Observation,
2232
UpDownCounter,
2333
)
2434

35+
CallbackT = Union[
36+
Callable[[CallbackOptions], Iterable[Observation]],
37+
Generator[Iterable[Observation], CallbackOptions, None],
38+
]
2539
SYSTEM_CPU_FREQUENCY: Final = "system.cpu.frequency"
2640
"""
2741
Reports the current frequency of the CPU in Hz
@@ -31,12 +45,12 @@
3145

3246

3347
def create_system_cpu_frequency(
34-
meter: Meter, callback: Sequence[Callable]
48+
meter: Meter, callbacks: Optional[Sequence[CallbackT]]
3549
) -> ObservableGauge:
3650
"""Reports the current frequency of the CPU in Hz"""
3751
return meter.create_observable_gauge(
3852
name="system.cpu.frequency",
39-
callback=callback,
53+
callbacks=callbacks,
4054
description="Reports the current frequency of the CPU in Hz",
4155
unit="{Hz}",
4256
)
@@ -102,12 +116,12 @@ def create_system_cpu_time(meter: Meter) -> Counter:
102116

103117

104118
def create_system_cpu_utilization(
105-
meter: Meter, callback: Sequence[Callable]
119+
meter: Meter, callbacks: Optional[Sequence[CallbackT]]
106120
) -> ObservableGauge:
107121
"""Difference in system.cpu.time since the last measurement, divided by the elapsed time and number of logical CPUs"""
108122
return meter.create_observable_gauge(
109123
name="system.cpu.utilization",
110-
callback=callback,
124+
callbacks=callbacks,
111125
description="Difference in system.cpu.time since the last measurement, divided by the elapsed time and number of logical CPUs",
112126
unit="1",
113127
)
@@ -225,11 +239,11 @@ def create_system_filesystem_usage(meter: Meter) -> UpDownCounter:
225239

226240

227241
def create_system_filesystem_utilization(
228-
meter: Meter, callback: Sequence[Callable]
242+
meter: Meter, callbacks: Optional[Sequence[CallbackT]]
229243
) -> ObservableGauge:
230244
return meter.create_observable_gauge(
231245
name="system.filesystem.utilization",
232-
callback=callback,
246+
callbacks=callbacks,
233247
description="",
234248
unit="1",
235249
)
@@ -302,11 +316,11 @@ def create_system_memory_usage(meter: Meter) -> UpDownCounter:
302316

303317

304318
def create_system_memory_utilization(
305-
meter: Meter, callback: Sequence[Callable]
319+
meter: Meter, callbacks: Optional[Sequence[CallbackT]]
306320
) -> ObservableGauge:
307321
return meter.create_observable_gauge(
308322
name="system.memory.utilization",
309-
callback=callback,
323+
callbacks=callbacks,
310324
description="",
311325
unit="1",
312326
)
@@ -456,11 +470,11 @@ def create_system_paging_usage(meter: Meter) -> UpDownCounter:
456470

457471

458472
def create_system_paging_utilization(
459-
meter: Meter, callback: Sequence[Callable]
473+
meter: Meter, callbacks: Optional[Sequence[CallbackT]]
460474
) -> ObservableGauge:
461475
return meter.create_observable_gauge(
462476
name="system.paging.utilization",
463-
callback=callback,
477+
callbacks=callbacks,
464478
description="",
465479
unit="1",
466480
)

0 commit comments

Comments
 (0)