Skip to content

Commit 919a2c7

Browse files
committed
sem
1 parent d99e101 commit 919a2c7

File tree

1 file changed

+0
-67
lines changed
  • opentelemetry-instrumentation/src/opentelemetry/instrumentation

1 file changed

+0
-67
lines changed

opentelemetry-instrumentation/src/opentelemetry/instrumentation/_semconv.py

Lines changed: 0 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,6 @@
1515
import os
1616
import threading
1717
from enum import Enum
18-
from re import escape, sub
19-
from typing import Dict, Optional, Sequence
20-
21-
2218

2319
from opentelemetry.semconv.trace import SpanAttributes
2420

@@ -103,46 +99,6 @@ def _set_http_network_protocol_version(result, version, sem_conv_opt_in_mode):
10399

104100
_OTEL_SEMCONV_STABILITY_OPT_IN_KEY = "OTEL_SEMCONV_STABILITY_OPT_IN"
105101

106-
# Old to new http semantic convention mappings
107-
_OTEL_HTTP_SEMCONV_MIGRATION_MAPPING = {
108-
SpanAttributes.HTTP_METHOD: SpanAttributes.HTTP_REQUEST_METHOD,
109-
SpanAttributes.HTTP_STATUS_CODE: SpanAttributes.HTTP_RESPONSE_STATUS_CODE,
110-
SpanAttributes.HTTP_SCHEME: SpanAttributes.URL_SCHEME,
111-
SpanAttributes.HTTP_URL: SpanAttributes.URL_FULL,
112-
SpanAttributes.HTTP_REQUEST_CONTENT_LENGTH: SpanAttributes.HTTP_REQUEST_BODY_SIZE,
113-
SpanAttributes.HTTP_RESPONSE_CONTENT_LENGTH: SpanAttributes.HTTP_RESPONSE_BODY_SIZE,
114-
SpanAttributes.NET_HOST_NAME: SpanAttributes.SERVER_ADDRESS,
115-
SpanAttributes.NET_HOST_PORT: SpanAttributes.SERVER_PORT,
116-
SpanAttributes.NET_SOCK_HOST_ADDR: SpanAttributes.SERVER_SOCKET_ADDRESS,
117-
SpanAttributes.NET_SOCK_HOST_PORT: SpanAttributes.SERVER_SOCKET_PORT,
118-
SpanAttributes.NET_TRANSPORT: SpanAttributes.NETWORK_TRANSPORT,
119-
SpanAttributes.NET_PROTOCOL_NAME: SpanAttributes.NETWORK_PROTOCOL_NAME,
120-
SpanAttributes.NET_PROTOCOL_VERSION: SpanAttributes.NETWORK_PROTOCOL_VERSION,
121-
SpanAttributes.NET_SOCK_FAMILY: SpanAttributes.NETWORK_TYPE,
122-
SpanAttributes.NET_PEER_IP: SpanAttributes.CLIENT_SOCKET_ADDRESS,
123-
SpanAttributes.NET_HOST_IP: SpanAttributes.SERVER_SOCKET_ADDRESS,
124-
SpanAttributes.HTTP_SERVER_NAME: SpanAttributes.SERVER_ADDRESS,
125-
SpanAttributes.HTTP_RETRY_COUNT: SpanAttributes.HTTP_RESEND_COUNT,
126-
SpanAttributes.HTTP_REQUEST_CONTENT_LENGTH_UNCOMPRESSED: SpanAttributes.HTTP_REQUEST_BODY_SIZE,
127-
SpanAttributes.HTTP_RESPONSE_CONTENT_LENGTH_UNCOMPRESSED: SpanAttributes.HTTP_RESPONSE_BODY_SIZE,
128-
SpanAttributes.HTTP_USER_AGENT: SpanAttributes.USER_AGENT_ORIGINAL,
129-
SpanAttributes.NET_APP_PROTOCOL_NAME: SpanAttributes.NETWORK_PROTOCOL_NAME,
130-
SpanAttributes.NET_APP_PROTOCOL_VERSION: SpanAttributes.NETWORK_PROTOCOL_VERSION,
131-
SpanAttributes.HTTP_CLIENT_IP: SpanAttributes.CLIENT_ADDRESS,
132-
SpanAttributes.HTTP_FLAVOR: SpanAttributes.NETWORK_PROTOCOL_VERSION,
133-
SpanAttributes.NET_HOST_CONNECTION_TYPE: SpanAttributes.NETWORK_CONNECTION_TYPE,
134-
SpanAttributes.NET_HOST_CONNECTION_SUBTYPE: SpanAttributes.NETWORK_CONNECTION_SUBTYPE,
135-
SpanAttributes.NET_HOST_CARRIER_NAME: SpanAttributes.NETWORK_CARRIER_NAME,
136-
SpanAttributes.NET_HOST_CARRIER_MCC: SpanAttributes.NETWORK_CARRIER_MCC,
137-
SpanAttributes.NET_HOST_CARRIER_MNC: SpanAttributes.NETWORK_CARRIER_MNC,
138-
}
139-
140-
# Special mappings handled case-by-case
141-
_OTEL_HTTP_SEMCONV_MIGRATION_MAPPING_SPECIAL = {
142-
SpanAttributes.HTTP_TARGET: (SpanAttributes.URL_PATH, SpanAttributes.URL_QUERY),
143-
SpanAttributes.HTTP_HOST: (SpanAttributes.SERVER_ADDRESS, SpanAttributes.SERVER_PORT),
144-
}
145-
146102

147103
class _OpenTelemetryStabilitySignalType:
148104
HTTP = "http"
@@ -205,26 +161,3 @@ def _get_opentelemetry_stability_opt_in_mode(
205161
return _OpenTelemetrySemanticConventionStability._OTEL_SEMCONV_STABILITY_SIGNAL_MAPPING.get(
206162
signal_type, _OpenTelemetryStabilityMode.DEFAULT
207163
)
208-
209-
210-
# Get new semantic convention attribute key based off old attribute key
211-
# If no new attribute key exists for old attribute key, returns old attribute key
212-
def _get_new_convention(old: str) -> str:
213-
return _OTEL_HTTP_SEMCONV_MIGRATION_MAPPING.get(old, old)
214-
215-
216-
# Get updated attributes based off of opt-in mode and client/server
217-
def _get_attributes_based_on_stability_mode(
218-
mode: _OpenTelemetryStabilityMode,
219-
old_attributes: Dict[str, str],
220-
) -> Dict[str, str]:
221-
if mode is _OpenTelemetryStabilityMode.DEFAULT:
222-
return old_attributes
223-
attributes = {}
224-
for old_key, value in old_attributes.items():
225-
new_key = _get_new_convention(old_key)
226-
attributes[new_key] = value
227-
if mode is _OpenTelemetryStabilityMode.HTTP_DUP:
228-
attributes[old_key] = value
229-
230-
return attributes

0 commit comments

Comments
 (0)