Repository: open-telemetry/opentelemetry-python

Issue:
Update default port for OTLP exporter to 4317
With this change https://github.com/open-telemetry/opentelemetry-specification/pull/1221 default port for OTLP exporter is 4317, the current default port in the OTLP exporter is 55680. This should be updated.


Discussion:

Resolving patch:
diff --git a/exporter/opentelemetry-exporter-otlp/src/opentelemetry/exporter/otlp/__init__.py b/exporter/opentelemetry-exporter-otlp/src/opentelemetry/exporter/otlp/__init__.py
--- a/exporter/opentelemetry-exporter-otlp/src/opentelemetry/exporter/otlp/__init__.py
+++ b/exporter/opentelemetry-exporter-otlp/src/opentelemetry/exporter/otlp/__init__.py
@@ -53,7 +53,7 @@
     trace.set_tracer_provider(TracerProvider(resource=resource))
     tracer = trace.get_tracer(__name__)
 
-    otlp_exporter = OTLPSpanExporter(endpoint="localhost:55680", insecure=True)
+    otlp_exporter = OTLPSpanExporter(endpoint="localhost:4317", insecure=True)
 
     span_processor = BatchExportSpanProcessor(otlp_exporter)
 
diff --git a/exporter/opentelemetry-exporter-otlp/src/opentelemetry/exporter/otlp/exporter.py b/exporter/opentelemetry-exporter-otlp/src/opentelemetry/exporter/otlp/exporter.py
--- a/exporter/opentelemetry-exporter-otlp/src/opentelemetry/exporter/otlp/exporter.py
+++ b/exporter/opentelemetry-exporter-otlp/src/opentelemetry/exporter/otlp/exporter.py
@@ -160,7 +160,7 @@ def __init__(
         endpoint = (
             endpoint
             or Configuration().EXPORTER_OTLP_ENDPOINT
-            or "localhost:55680"
+            or "localhost:4317"
         )
 
         if insecure is None:


Test patch:
diff --git a/exporter/opentelemetry-exporter-otlp/tests/test_otlp_metric_exporter.py b/exporter/opentelemetry-exporter-otlp/tests/test_otlp_metric_exporter.py
--- a/exporter/opentelemetry-exporter-otlp/tests/test_otlp_metric_exporter.py
+++ b/exporter/opentelemetry-exporter-otlp/tests/test_otlp_metric_exporter.py
@@ -70,7 +70,7 @@ def tearDown(self):
     @patch.dict(
         "os.environ",
         {
-            "OTEL_EXPORTER_OTLP_METRIC_ENDPOINT": "collector:55680",
+            "OTEL_EXPORTER_OTLP_METRIC_ENDPOINT": "collector:4317",
             "OTEL_EXPORTER_OTLP_METRIC_CERTIFICATE": THIS_DIR
             + "/fixtures/test.cert",
             "OTEL_EXPORTER_OTLP_METRIC_HEADERS": "key1=value1,key2=value2",
@@ -84,7 +84,7 @@ def test_env_variables(self, mock_exporter_mixin):
         self.assertTrue(len(mock_exporter_mixin.call_args_list) == 1)
         _, kwargs = mock_exporter_mixin.call_args_list[0]
 
-        self.assertEqual(kwargs["endpoint"], "collector:55680")
+        self.assertEqual(kwargs["endpoint"], "collector:4317")
         self.assertEqual(kwargs["headers"], "key1=value1,key2=value2")
         self.assertEqual(kwargs["timeout"], 10)
         self.assertIsNotNone(kwargs["credentials"])
diff --git a/exporter/opentelemetry-exporter-otlp/tests/test_otlp_trace_exporter.py b/exporter/opentelemetry-exporter-otlp/tests/test_otlp_trace_exporter.py
--- a/exporter/opentelemetry-exporter-otlp/tests/test_otlp_trace_exporter.py
+++ b/exporter/opentelemetry-exporter-otlp/tests/test_otlp_trace_exporter.py
@@ -116,7 +116,7 @@ def setUp(self):
 
         self.server = server(ThreadPoolExecutor(max_workers=10))
 
-        self.server.add_insecure_port("[::]:55680")
+        self.server.add_insecure_port("[::]:4317")
 
         self.server.start()
 
@@ -169,7 +169,7 @@ def tearDown(self):
     @patch.dict(
         "os.environ",
         {
-            "OTEL_EXPORTER_OTLP_SPAN_ENDPOINT": "collector:55680",
+            "OTEL_EXPORTER_OTLP_SPAN_ENDPOINT": "collector:4317",
             "OTEL_EXPORTER_OTLP_SPAN_CERTIFICATE": THIS_DIR
             + "/fixtures/test.cert",
             "OTEL_EXPORTER_OTLP_SPAN_HEADERS": "key1=value1,key2=value2",
@@ -183,7 +183,7 @@ def test_env_variables(self, mock_exporter_mixin):
         self.assertTrue(len(mock_exporter_mixin.call_args_list) == 1)
         _, kwargs = mock_exporter_mixin.call_args_list[0]
 
-        self.assertEqual(kwargs["endpoint"], "collector:55680")
+        self.assertEqual(kwargs["endpoint"], "collector:4317")
         self.assertEqual(kwargs["headers"], "key1=value1,key2=value2")
         self.assertEqual(kwargs["timeout"], 10)
         self.assertIsNotNone(kwargs["credentials"])