Skip to content

Commit f299243

Browse files
committed
test
1 parent 919a2c7 commit f299243

File tree

1 file changed

+46
-1
lines changed

1 file changed

+46
-1
lines changed

instrumentation/opentelemetry-instrumentation-requests/tests/test_requests_integration.py

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@
2727
from opentelemetry.context import _SUPPRESS_HTTP_INSTRUMENTATION_KEY
2828
from opentelemetry.instrumentation.requests import RequestsInstrumentor
2929
from opentelemetry.instrumentation.utils import _SUPPRESS_INSTRUMENTATION_KEY
30+
from opentelemetry.instrumentation._semconv import (
31+
_OTEL_SEMCONV_STABILITY_OPT_IN_KEY,
32+
_OpenTelemetrySemanticConventionStability,
33+
)
3034
from opentelemetry.propagate import get_global_textmap, set_global_textmap
3135
from opentelemetry.sdk import resources
3236
from opentelemetry.semconv.trace import SpanAttributes
@@ -64,17 +68,30 @@ class RequestsIntegrationTestBase(abc.ABC):
6468
# pylint: disable=too-many-public-methods
6569

6670
URL = "http://mock/status/200"
71+
HOST = "mock/status"
6772

6873
# pylint: disable=invalid-name
6974
def setUp(self):
7075
super().setUp()
7176

77+
test_name = ""
78+
if hasattr(self, "_testMethodName"):
79+
test_name = self._testMethodName
80+
sem_conv_mode = "default"
81+
if "new_semconv" in test_name:
82+
sem_conv_mode = "http"
83+
elif "both_semconv" in test_name:
84+
sem_conv_mode = "http/dup"
7285
self.env_patch = mock.patch.dict(
7386
"os.environ",
7487
{
75-
"OTEL_PYTHON_REQUESTS_EXCLUDED_URLS": "http://localhost/env_excluded_arg/123,env_excluded_noarg"
88+
"OTEL_PYTHON_REQUESTS_EXCLUDED_URLS": "http://localhost/env_excluded_arg/123,env_excluded_noarg",
89+
_OTEL_SEMCONV_STABILITY_OPT_IN_KEY: sem_conv_mode,
7690
},
7791
)
92+
93+
_OpenTelemetrySemanticConventionStability._initialized = False
94+
7895
self.env_patch.start()
7996

8097
self.exclude_patch = mock.patch(
@@ -133,6 +150,34 @@ def test_basic(self):
133150
span, opentelemetry.instrumentation.requests
134151
)
135152

153+
154+
# def test_basic_new_semconv(self):
155+
# print("here2")
156+
# result = self.perform_request(self.URL)
157+
# self.assertEqual(result.text, "Hello!")
158+
# span = self.assert_span()
159+
160+
# self.assertIs(span.kind, trace.SpanKind.CLIENT)
161+
# self.assertEqual(span.name, "GET")
162+
163+
# self.assertEqual(
164+
# span.attributes,
165+
# {
166+
# SpanAttributes.HTTP_REQUEST_METHOD: "GET",
167+
# SpanAttributes.HTTP_REQUEST_METHOD_ORIGINAL: "GET",
168+
# SpanAttributes.URL_FULL: self.URL,
169+
# SpanAttributes.HTTP_RESPONSE_STATUS_CODE: 200,
170+
# SpanAttributes.SERVER_ADDRESS: self.HOST,
171+
# },
172+
# )
173+
174+
# self.assertIs(span.status.status_code, trace.StatusCode.UNSET)
175+
176+
# self.assertEqualSpanInstrumentationInfo(
177+
# span, opentelemetry.instrumentation.requests
178+
# )
179+
180+
136181
def test_hooks(self):
137182
def request_hook(span, request_obj):
138183
span.update_name("name set from hook")

0 commit comments

Comments
 (0)