Repository: open-telemetry/opentelemetry-python-contrib

Issue:
Make metrics public
Similar to [this](https://github.com/open-telemetry/opentelemetry-python/pull/2684).


Discussion:

Resolving patch:
diff --git a/instrumentation/opentelemetry-instrumentation-system-metrics/src/opentelemetry/instrumentation/system_metrics/__init__.py b/instrumentation/opentelemetry-instrumentation-system-metrics/src/opentelemetry/instrumentation/system_metrics/__init__.py
--- a/instrumentation/opentelemetry-instrumentation-system-metrics/src/opentelemetry/instrumentation/system_metrics/__init__.py
+++ b/instrumentation/opentelemetry-instrumentation-system-metrics/src/opentelemetry/instrumentation/system_metrics/__init__.py
@@ -42,10 +42,10 @@
 
 .. code:: python
 
-    from opentelemetry._metrics import set_meter_provider
+    from opentelemetry.metrics import set_meter_provider
     from opentelemetry.instrumentation.system_metrics import SystemMetricsInstrumentor
-    from opentelemetry.sdk._metrics import MeterProvider
-    from opentelemetry.sdk._metrics.export import ConsoleMetricExporter, PeriodicExportingMetricReader
+    from opentelemetry.sdk.metrics import MeterProvider
+    from opentelemetry.sdk.metrics.export import ConsoleMetricExporter, PeriodicExportingMetricReader
 
     exporter = ConsoleMetricExporter()
 
@@ -76,13 +76,12 @@
 
 import psutil
 
-from opentelemetry._metrics import CallbackOptions, Observation, get_meter
-
 # FIXME Remove this pyling disabling line when Github issue is cleared
 # pylint: disable=no-name-in-module
 from opentelemetry.instrumentation.instrumentor import BaseInstrumentor
 from opentelemetry.instrumentation.system_metrics.package import _instruments
 from opentelemetry.instrumentation.system_metrics.version import __version__
+from opentelemetry.metrics import CallbackOptions, Observation, get_meter
 from opentelemetry.sdk.util import get_dict_as_key
 
 _DEFAULT_CONFIG = {


Test patch:
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -6,7 +6,7 @@ on:
     - 'release/*'
   pull_request:
 env:
-  CORE_REPO_SHA: f367ec2045b2588be95dfa11913868c1d4fcbbc2
+  CORE_REPO_SHA: 741389585b5d6d1af808a8939c5348113158f969
 
 jobs:
   build:
@@ -37,7 +37,7 @@ jobs:
         run: pip install -U tox-factor
       - name: Cache tox environment
         # Preserves .tox directory between runs for faster installs
-        uses: actions/cache@v2
+        uses: actions/cache@v1
         with:
           path: |
             .tox
@@ -113,7 +113,7 @@ jobs:
         run: sudo apt-get install -y libsnappy-dev
       - name: Cache tox environment
         # Preserves .tox directory between runs for faster installs
-        uses: actions/cache@v2
+        uses: actions/cache@v1
         with:
           path: |
             .tox
diff --git a/instrumentation/opentelemetry-instrumentation-system-metrics/tests/test_system_metrics.py b/instrumentation/opentelemetry-instrumentation-system-metrics/tests/test_system_metrics.py
--- a/instrumentation/opentelemetry-instrumentation-system-metrics/tests/test_system_metrics.py
+++ b/instrumentation/opentelemetry-instrumentation-system-metrics/tests/test_system_metrics.py
@@ -21,8 +21,8 @@
 from opentelemetry.instrumentation.system_metrics import (
     SystemMetricsInstrumentor,
 )
-from opentelemetry.sdk._metrics import MeterProvider
-from opentelemetry.sdk._metrics.export import InMemoryMetricReader
+from opentelemetry.sdk.metrics import MeterProvider
+from opentelemetry.sdk.metrics.export import InMemoryMetricReader
 from opentelemetry.test.test_base import TestBase
 
 
@@ -70,8 +70,11 @@ def test_system_metrics_instrument(self):
         meter_provider = MeterProvider(metric_readers=[reader])
         system_metrics = SystemMetricsInstrumentor()
         system_metrics.instrument(meter_provider=meter_provider)
-        metrics = reader.get_metrics()
-        metric_names = list({x.name for x in metrics})
+        metric_names = []
+        for resource_metrics in reader.get_metrics_data().resource_metrics:
+            for scope_metrics in resource_metrics.scope_metrics:
+                for metric in scope_metrics.metrics:
+                    metric_names.append(metric.name)
         self.assertEqual(len(metric_names), 17)
 
         observer_names = [
@@ -100,17 +103,22 @@ def test_system_metrics_instrument(self):
 
     def _assert_metrics(self, observer_name, reader, expected):
         assertions = 0
-        for metric in reader.get_metrics():  # pylint: disable=protected-access
-            for expect in expected:
-                if (
-                    metric.attributes == expect.attributes
-                    and metric.name == observer_name
-                ):
-                    self.assertEqual(
-                        metric.point.value,
-                        expect.value,
-                    )
-                    assertions += 1
+        # pylint: disable=too-many-nested-blocks
+        for resource_metrics in reader.get_metrics_data().resource_metrics:
+            for scope_metrics in resource_metrics.scope_metrics:
+                for metric in scope_metrics.metrics:
+                    for data_point in metric.data.data_points:
+                        for expect in expected:
+                            if (
+                                dict(data_point.attributes)
+                                == expect.attributes
+                                and metric.name == observer_name
+                            ):
+                                self.assertEqual(
+                                    data_point.value,
+                                    expect.value,
+                                )
+                                assertions += 1
         self.assertEqual(len(expected), assertions)
 
     def _test_metrics(self, observer_name, expected):