Skip to content

Commit

Permalink
Include stable attrs in incubating
Browse files Browse the repository at this point in the history
  • Loading branch information
bryannaegele committed Jul 29, 2024
1 parent 841992e commit e3d0e46
Show file tree
Hide file tree
Showing 19 changed files with 83 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
%% See the License for the specific language governing permissions and
%% limitations under the License.
%%%-------------------------------------------------------------------------
-include("attributes/http_attributes.hrl").

%% @deprecated Replaced by `client.address`.
%% Deprecated, use `client.address` instead.
-define('HTTP_CLIENT_IP', 'http.client_ip').
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
%% See the License for the specific language governing permissions and
%% limitations under the License.
%%%-------------------------------------------------------------------------
-include("attributes/messaging_attributes.hrl").


%% The number of messages sent, received, or processed in the scope of the batching operation.
-define('MESSAGING_BATCH_MESSAGE_COUNT', 'messaging.batch.message_count').
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
%% See the License for the specific language governing permissions and
%% limitations under the License.
%%%-------------------------------------------------------------------------
-include("attributes/network_attributes.hrl").

%% @deprecated Replaced by `network.local.address`.
%% Deprecated, use `network.local.address`.
-define('NET_HOST_IP', 'net.host.ip').
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
%% See the License for the specific language governing permissions and
%% limitations under the License.
%%%-------------------------------------------------------------------------
-include("attributes/service_attributes.hrl").


%% The string ID of the service instance.
%%
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
%% See the License for the specific language governing permissions and
%% limitations under the License.
%%%-------------------------------------------------------------------------
-include("attributes/telemetry_attributes.hrl").


%% The name of the auto instrumentation agent or distribution, if used.
%%
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
%% See the License for the specific language governing permissions and
%% limitations under the License.
%%%-------------------------------------------------------------------------
-include("attributes/url_attributes.hrl").


%% Domain extracted from the `url.full`, such as "opentelemetry.io".
%%
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
%% See the License for the specific language governing permissions and
%% limitations under the License.
%%%-------------------------------------------------------------------------
-include("attributes/user_agent_attributes.hrl").


%% Name of the user-agent extracted from original. Usually refers to the browser's name.
%%
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,19 @@ defmodule OpenTelemetry.SemConv.Incubating.HTTPAttributes do
@moduledoc """
OpenTelemetry Semantic Conventions for HTTP attributes.
"""
defdelegate http_request_header(), to: OpenTelemetry.SemConv.HTTPAttributes

defdelegate http_request_method(), to: OpenTelemetry.SemConv.HTTPAttributes

defdelegate http_request_method_original(), to: OpenTelemetry.SemConv.HTTPAttributes

defdelegate http_request_resend_count(), to: OpenTelemetry.SemConv.HTTPAttributes

defdelegate http_response_header(), to: OpenTelemetry.SemConv.HTTPAttributes

defdelegate http_response_status_code(), to: OpenTelemetry.SemConv.HTTPAttributes

defdelegate http_route(), to: OpenTelemetry.SemConv.HTTPAttributes

@deprecated """
Replaced by `client.address`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,21 @@ defmodule OpenTelemetry.SemConv.Incubating.NetworkAttributes do
@moduledoc """
OpenTelemetry Semantic Conventions for Network attributes.
"""
defdelegate network_local_address(), to: OpenTelemetry.SemConv.NetworkAttributes

defdelegate network_local_port(), to: OpenTelemetry.SemConv.NetworkAttributes

defdelegate network_peer_address(), to: OpenTelemetry.SemConv.NetworkAttributes

defdelegate network_peer_port(), to: OpenTelemetry.SemConv.NetworkAttributes

defdelegate network_protocol_name(), to: OpenTelemetry.SemConv.NetworkAttributes

defdelegate network_protocol_version(), to: OpenTelemetry.SemConv.NetworkAttributes

defdelegate network_transport(), to: OpenTelemetry.SemConv.NetworkAttributes

defdelegate network_type(), to: OpenTelemetry.SemConv.NetworkAttributes

@deprecated """
Replaced by `network.local.address`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ defmodule OpenTelemetry.SemConv.Incubating.ServiceAttributes do
@moduledoc """
OpenTelemetry Semantic Conventions for Service attributes.
"""
defdelegate service_name(), to: OpenTelemetry.SemConv.ServiceAttributes

defdelegate service_version(), to: OpenTelemetry.SemConv.ServiceAttributes

@doc """
The string ID of the service instance.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ defmodule OpenTelemetry.SemConv.Incubating.TelemetryAttributes do
@moduledoc """
OpenTelemetry Semantic Conventions for Telemetry attributes.
"""
defdelegate telemetry_sdk_language(), to: OpenTelemetry.SemConv.TelemetryAttributes

defdelegate telemetry_sdk_name(), to: OpenTelemetry.SemConv.TelemetryAttributes

defdelegate telemetry_sdk_version(), to: OpenTelemetry.SemConv.TelemetryAttributes

@doc """
The name of the auto instrumentation agent or distribution, if used.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@ defmodule OpenTelemetry.SemConv.Incubating.URLAttributes do
@moduledoc """
OpenTelemetry Semantic Conventions for URL attributes.
"""
defdelegate url_fragment(), to: OpenTelemetry.SemConv.URLAttributes

defdelegate url_full(), to: OpenTelemetry.SemConv.URLAttributes

defdelegate url_path(), to: OpenTelemetry.SemConv.URLAttributes

defdelegate url_query(), to: OpenTelemetry.SemConv.URLAttributes

defdelegate url_scheme(), to: OpenTelemetry.SemConv.URLAttributes

@doc """
Domain extracted from the `url.full`, such as "opentelemetry.io".
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ defmodule OpenTelemetry.SemConv.Incubating.UserAgentAttributes do
@moduledoc """
OpenTelemetry Semantic Conventions for User_Agent attributes.
"""
defdelegate user_agent_original(), to: OpenTelemetry.SemConv.UserAgentAttributes

@doc """
Name of the user-agent extracted from original. Usually refers to the browser's name.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,25 @@
{{ template.set_file_name(file_name) }}

{%- set module_name = ctx.id | pascal_case | acronym ~ "Attributes" -%}
{%- set incubating_module_namespace = "OpenTelemetry.SemConv.Incubating" -%}
{%- set stable_module_namespace = "OpenTelemetry.SemConv" -%}
{%- if params.stability == "experimental" -%}
{%- set module_namespace = "OpenTelemetry.SemConv.Incubating" -%}
{%- set module_namespace = incubating_module_namespace -%}
{%- else -%}
{%- set module_namespace = "OpenTelemetry.SemConv" -%}
{%- set module_namespace = stable_module_namespace -%}
{%- endif -%}
defmodule {{ module_namespace }}.{{ module_name }} do
# This is an auto-generated file
@moduledoc """
OpenTelemetry Semantic Conventions for {{ ctx.id | title | acronym }} attributes.
"""
{%- if params.stability == "experimental" and (ctx.all_attributes | length) > (ctx.attributes | length) %}
{%- for attribute in ctx.all_attributes | sort(attribute="name") %}
{%- if attribute is stable %}
defdelegate {{ c.func_name(attribute.name) }}(), to: {{ stable_module_namespace }}.{{ module_name }}
{% endif -%}
{% endfor %}
{% endif -%}
{%- for attribute in ctx.attributes | sort(attribute="name") %}
{% if attribute.type is mapping %}
@typedoc """
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ templates:
| map({
id: .[0].group_id,
attributes: [.[].attributes[] | select(.stability == $stability) | (select( .name as $id | any( $excluded_attrs[]; . == $id ) | not ))] | sort_by(.id),
all_attributes: [.[].attributes[]] | sort_by(.id),
output: $output + "/attributes/"
})
| map(select( .id as $id | any( $excluded[]; . == $id) | not ))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
%% See the License for the specific language governing permissions and
%% limitations under the License.
%%%-------------------------------------------------------------------------

{%- if params.stability == "experimental" and (ctx.all_attributes | length) > (ctx.attributes | length) %}
-include("attributes/{{ c.file_name(ctx.id) }}_attributes.hrl").
{% endif -%}
{%- for attribute in ctx.attributes | sort(attribute="name") %}
{% if attribute is deprecated -%}
%% @deprecated {{ attribute.deprecated | replace("\n", "\n%% ") }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ templates:
| map({
id: .[0].group_id,
attributes: [.[].attributes[] | select(.stability == $stability) | (select( .name as $id | any( $excluded_attrs[]; . == $id ) | not ))] | sort_by(.id),
all_attributes: [.[].attributes[]],
output: $output + "/attributes/"
})
| map(select( .id as $id | any( $excluded[]; . == $id) | not ))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,9 @@ defmodule OpenTelemetry.SemConvTest do
System.delete_env("OTEL_SEMCONV_STABILITY_OPT_IN")
end
end

test "stable attrs are delegated in incubating module" do
assert SemConv.Incubating.HTTPAttributes.http_route() ==
SemConv.HTTPAttributes.http_route()
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@
-include_lib("common_test/include/ct.hrl").

-include("incubating/attributes/db_attributes.hrl").
-include("incubating/attributes/http_attributes.hrl").

all() ->
[registry_macros].

registry_macros(_Config) ->
?assertEqual('db.system', ?'DB_SYSTEM'),
?assertEqual('postgresql', ?'DB_SYSTEM_VALUES_POSTGRESQL'),
?assertEqual('http.route', ?'HTTP_ROUTE'),
ok.

0 comments on commit e3d0e46

Please sign in to comment.