Skip to content

Commit

Permalink
deprecated attribute enums
Browse files Browse the repository at this point in the history
  • Loading branch information
lmolkova committed Jun 9, 2024
1 parent a9db0c4 commit 316aaa3
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,17 @@

from enum import Enum

from deprecated import deprecated

ERROR_TYPE = "error.type"
"""
Deprecated in favor of stable :py:const:`opentelemetry.semconv.attributes.error_attributes.ERROR_TYPE`.
"""


@deprecated(
reason="Deprecated in favor of stable :py:const:`opentelemetry.semconv.attributes.error_attributes.ErrorTypeValues`."
)
class ErrorTypeValues(Enum):
OTHER = "_OTHER"
"""Deprecated in favor of stable :py:const:`opentelemetry.semconv.attributes.error_attributes.ErrorTypeValues.OTHER`."""
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,9 @@ class HttpFlavorValues(Enum):
"""QUIC protocol."""


@deprecated(
reason="Deprecated in favor of stable :py:const:`opentelemetry.semconv.attributes.http_attributes.HttpRequestMethodValues`."
)
class HttpRequestMethodValues(Enum):
CONNECT = "CONNECT"
"""Deprecated in favor of stable :py:const:`opentelemetry.semconv.attributes.http_attributes.HttpRequestMethodValues.CONNECT`."""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,9 @@ class NetworkIoDirectionValues(Enum):
"""receive."""


@deprecated(
reason="Deprecated in favor of stable :py:const:`opentelemetry.semconv.attributes.network_attributes.NetworkTransportValues`."
)
class NetworkTransportValues(Enum):
TCP = "tcp"
"""Deprecated in favor of stable :py:const:`opentelemetry.semconv.attributes.network_attributes.NetworkTransportValues.TCP`."""
Expand All @@ -272,6 +275,9 @@ class NetworkTransportValues(Enum):
"""Deprecated in favor of stable :py:const:`opentelemetry.semconv.attributes.network_attributes.NetworkTransportValues.UNIX`."""


@deprecated(
reason="Deprecated in favor of stable :py:const:`opentelemetry.semconv.attributes.network_attributes.NetworkTypeValues`."
)
class NetworkTypeValues(Enum):
IPV4 = "ipv4"
"""Deprecated in favor of stable :py:const:`opentelemetry.semconv.attributes.network_attributes.NetworkTypeValues.IPV4`."""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

from enum import Enum

from deprecated import deprecated

OTEL_LIBRARY_NAME = "otel.library.name"
"""
Deprecated: use the `otel.scope.name` attribute.
Expand Down Expand Up @@ -46,6 +48,9 @@
"""


@deprecated(
reason="Deprecated in favor of stable :py:const:`opentelemetry.semconv.attributes.otel_attributes.OtelStatusCodeValues`."
)
class OtelStatusCodeValues(Enum):
OK = "OK"
"""Deprecated in favor of stable :py:const:`opentelemetry.semconv.attributes.otel_attributes.OtelStatusCodeValues.OK`."""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

from enum import Enum

from deprecated import deprecated

TELEMETRY_DISTRO_NAME = "telemetry.distro.name"
"""
The name of the auto instrumentation agent or distribution, if used.
Expand Down Expand Up @@ -43,6 +45,9 @@
"""


@deprecated(
reason="Deprecated in favor of stable :py:const:`opentelemetry.semconv.attributes.telemetry_attributes.TelemetrySdkLanguageValues`."
)
class TelemetrySdkLanguageValues(Enum):
CPP = "cpp"
"""Deprecated in favor of stable :py:const:`opentelemetry.semconv.attributes.telemetry_attributes.TelemetrySdkLanguageValues.CPP`."""
Expand Down
2 changes: 1 addition & 1 deletion scripts/semconv/templates/registry/common.j2
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
{%- endmacro %}

{%- macro import_deprecated(semconv) -%}
{%- if (semconv | rejectattr("deprecated", "none") | list | count > 0) or (filter == "any" and semconv | selectattr("stability", "equalto", "stable") | list | count > 0) %}
{%- if (semconv | rejectattr("deprecated", "none") | list | count > 0) or (ctx.filter == "any" and semconv | selectattr("stability", "equalto", "stable") | list | count > 0) %}
from deprecated import deprecated
{%- endif %}
{%- endmacro-%}
2 changes: 1 addition & 1 deletion scripts/semconv/templates/registry/semantic_attributes.j2
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
{% for attribute in enum_attributes %}{%- set class_name = c.to_class_name(attribute.name) ~ "Values" -%}
{%- if c.str_or_empty(attribute.deprecated) | length %}
@deprecated(reason="The attribute {{attribute.name}} is deprecated - {{ c.to_docstring(attribute.deprecated, "") }}")
{%- elif attribute.stability == "stable" and filter == "any" %}
{%- elif attribute.stability == "stable" and ctx.filter == "any" %}
@deprecated(reason="Deprecated in favor of stable :py:const:`{{stable_class_ref(class_name, '.')}}`.")
{%- endif %}
class {{class_name}}(Enum):
Expand Down

0 comments on commit 316aaa3

Please sign in to comment.