From d2028958d75b6399af1331c261f024993a4da476 Mon Sep 17 00:00:00 2001 From: Yang Sun Date: Mon, 30 Nov 2020 17:21:02 +0000 Subject: [PATCH] Fixes #1390 - Remove unexpected keyword argument in metrics_example (#1433) Co-authored-by: Leighton Chen --- docs/getting_started/metrics_example.py | 1 - docs/getting_started/tests/test_metrics.py | 29 ++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 docs/getting_started/tests/test_metrics.py diff --git a/docs/getting_started/metrics_example.py b/docs/getting_started/metrics_example.py index 08751e9864f..9efcab6403b 100644 --- a/docs/getting_started/metrics_example.py +++ b/docs/getting_started/metrics_example.py @@ -32,7 +32,6 @@ description="number of requests", unit="1", value_type=int, - label_keys=("environment",), ) requests_counter.add(25, staging_labels) diff --git a/docs/getting_started/tests/test_metrics.py b/docs/getting_started/tests/test_metrics.py new file mode 100644 index 00000000000..a9d7dbe45b9 --- /dev/null +++ b/docs/getting_started/tests/test_metrics.py @@ -0,0 +1,29 @@ +# Copyright The OpenTelemetry Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +import os +import subprocess +import sys +import unittest + + +class TestBasicMetricsExample(unittest.TestCase): + def test_basic_meter(self): + dirpath = os.path.dirname(os.path.realpath(__file__)) + test_script = "{}/../metrics_example.py".format(dirpath) + output = subprocess.check_output( + (sys.executable, test_script) + ).decode() + + self.assertIn('name="requests"', output) + self.assertIn('description="number of requests"', output)