From 34959d3b372cfe197066c2a0deecb56583676ebd Mon Sep 17 00:00:00 2001 From: erichsueh3 Date: Thu, 25 Jun 2020 10:21:01 -0700 Subject: [PATCH 1/8] updated bazel version from 3.2.0 to 3.3.0 --- .bazelversion | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.bazelversion b/.bazelversion index 944880fa15..15a2799817 100644 --- a/.bazelversion +++ b/.bazelversion @@ -1 +1 @@ -3.2.0 +3.3.0 From e09943c3a93fc223f216e5945f4c12fb0bdc8774 Mon Sep 17 00:00:00 2001 From: erichsueh3 Date: Tue, 4 Aug 2020 10:52:18 -0700 Subject: [PATCH 2/8] Added MetricExporter interface, ReturnCode class --- .../opentelemetry/sdk/metrics/exporter.h | 38 ++++++++++++++ .../opentelemetry/sdk/metrics/return_code.h | 51 +++++++++++++++++++ 2 files changed, 89 insertions(+) create mode 100644 sdk/include/opentelemetry/sdk/metrics/exporter.h create mode 100644 sdk/include/opentelemetry/sdk/metrics/return_code.h diff --git a/sdk/include/opentelemetry/sdk/metrics/exporter.h b/sdk/include/opentelemetry/sdk/metrics/exporter.h new file mode 100644 index 0000000000..c5c1f7d4fa --- /dev/null +++ b/sdk/include/opentelemetry/sdk/metrics/exporter.h @@ -0,0 +1,38 @@ +#pragma once + +#include + +#include "opentelemetry/sdk/metrics/record.h" +#include "opentelemetry/sdk/metrics/return_code.h" +#include "opentelemetry/version.h" + +/** + * This class is an interface that defines all basic behaviors of an exporter. + * This interface should be available to use for metrics exporters, and + * the design of this interface has been based on the SpanExporter class. + */ + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace sdk +{ +namespace metrics +{ +class MetricsExporter +{ +public: + /** + * Exports a batch of Metric Records. + * @param records: a collection of records to export + * @return: returns a ReturnCode detailing a success, or type of failure + */ + virtual ReturnCode Export(std::vector &records) noexcept = 0; + + /** + * Shuts down the exporter and does cleanup. + */ + virtual void Shutdown() noexcept = 0; +}; +} // namespace metrics +} // namespace sdk + +OPENTELEMETRY_END_NAMESPACE diff --git a/sdk/include/opentelemetry/sdk/metrics/return_code.h b/sdk/include/opentelemetry/sdk/metrics/return_code.h new file mode 100644 index 0000000000..d56ab914d5 --- /dev/null +++ b/sdk/include/opentelemetry/sdk/metrics/return_code.h @@ -0,0 +1,51 @@ +#pragma once + +#include + +#include "opentelemetry/version.h" + +/** + * ReturnCodes Class + * + * This class provides an expansion on the possible return codes + * for the Export() function in the PrometheusExporter class. + * Previously, only SUCCESS and FAILURE were available as + * return codes; FAILURE has been expanded to specify what type + * of failure has occurred. + */ + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace sdk +{ +namespace metrics +{ +enum class ReturnCode : uint8_t +{ + /** + * Batch exported successfully. + */ + SUCCESS = 0, + + /** + * The collection does not have enough space to receive the export batch. + */ + FAILURE_FULL_COLLECTION = 1, + + /** + * The export has timed out. + */ + FAILURE_TIMEOUT = 2, + + /** + * The export() function was passed an invalid argument. + */ + FAILURE_INVALID_ARGUMENT = 3, + + /** + * The exporter is already shutdown. + */ + FAILURE_ALREADY_SHUTDOWN = 4, +}; +} // namespace metrics +} // namespace sdk +OPENTELEMETRY_END_NAMESPACE \ No newline at end of file From a4d26756dcd1d95cc869092305fa6df7339dd7e3 Mon Sep 17 00:00:00 2001 From: erichsueh3 Date: Tue, 4 Aug 2020 15:42:12 -0700 Subject: [PATCH 3/8] Merged ReturnCode into ExportResult, removed return_code.h, removed Shutdown() function not in Metrics specification --- .../opentelemetry/sdk/metrics/exporter.h | 62 ++++++++++++++----- .../opentelemetry/sdk/metrics/return_code.h | 51 --------------- 2 files changed, 45 insertions(+), 68 deletions(-) delete mode 100644 sdk/include/opentelemetry/sdk/metrics/return_code.h diff --git a/sdk/include/opentelemetry/sdk/metrics/exporter.h b/sdk/include/opentelemetry/sdk/metrics/exporter.h index c5c1f7d4fa..18551c0914 100644 --- a/sdk/include/opentelemetry/sdk/metrics/exporter.h +++ b/sdk/include/opentelemetry/sdk/metrics/exporter.h @@ -1,38 +1,66 @@ #pragma once -#include - +#include #include "opentelemetry/sdk/metrics/record.h" -#include "opentelemetry/sdk/metrics/return_code.h" #include "opentelemetry/version.h" -/** - * This class is an interface that defines all basic behaviors of an exporter. - * This interface should be available to use for metrics exporters, and - * the design of this interface has been based on the SpanExporter class. - */ - OPENTELEMETRY_BEGIN_NAMESPACE namespace sdk { namespace metrics { +/** + * ExportResult is returned as result of exporting a batch of records. + */ +enum class ExportResult +{ + /** + * Batch was successfully exported. + */ + kSuccess = 0, + /** + * Exporting failed. The caller must not retry exporting the same batch; the + * batch must be dropped. + */ + kFailure = 1, + + /** + * The collection does not have enough space to receive the export batch. + */ + kFailureFull = 2, + + /** + * The export has timed out. + */ + kFailureTimeout = 3, + + /** + * The export() function was passed an invalid argument. + */ + kFailureInvalidArgument = 4, +}; +/** + * MetricsExporter defines the interface that protocol-specific span exporters must + * implement. + */ class MetricsExporter { public: + virtual ~MetricsExporter() = default; + /** - * Exports a batch of Metric Records. - * @param records: a collection of records to export - * @return: returns a ReturnCode detailing a success, or type of failure + * Exports a vector of Records. This method must not be called + * concurrently for the same exporter instance. + * @param records a vector of unique pointers to metric records */ - virtual ReturnCode Export(std::vector &records) noexcept = 0; + virtual ExportResult Export(const std::vector &records) noexcept = 0; /** - * Shuts down the exporter and does cleanup. + * In the Metrics specification, there is no Shutdown function required for exporters + * The Shutdown function can be implemented within exporters that wish to have one, + * but will not be enforced through this header */ - virtual void Shutdown() noexcept = 0; }; } // namespace metrics } // namespace sdk - -OPENTELEMETRY_END_NAMESPACE +OPENTELEMETRY_END_NAMESPACE \ No newline at end of file diff --git a/sdk/include/opentelemetry/sdk/metrics/return_code.h b/sdk/include/opentelemetry/sdk/metrics/return_code.h deleted file mode 100644 index d56ab914d5..0000000000 --- a/sdk/include/opentelemetry/sdk/metrics/return_code.h +++ /dev/null @@ -1,51 +0,0 @@ -#pragma once - -#include - -#include "opentelemetry/version.h" - -/** - * ReturnCodes Class - * - * This class provides an expansion on the possible return codes - * for the Export() function in the PrometheusExporter class. - * Previously, only SUCCESS and FAILURE were available as - * return codes; FAILURE has been expanded to specify what type - * of failure has occurred. - */ - -OPENTELEMETRY_BEGIN_NAMESPACE -namespace sdk -{ -namespace metrics -{ -enum class ReturnCode : uint8_t -{ - /** - * Batch exported successfully. - */ - SUCCESS = 0, - - /** - * The collection does not have enough space to receive the export batch. - */ - FAILURE_FULL_COLLECTION = 1, - - /** - * The export has timed out. - */ - FAILURE_TIMEOUT = 2, - - /** - * The export() function was passed an invalid argument. - */ - FAILURE_INVALID_ARGUMENT = 3, - - /** - * The exporter is already shutdown. - */ - FAILURE_ALREADY_SHUTDOWN = 4, -}; -} // namespace metrics -} // namespace sdk -OPENTELEMETRY_END_NAMESPACE \ No newline at end of file From 47b879bf699bdd90d59a346b8dabeedff68df8a6 Mon Sep 17 00:00:00 2001 From: erichsueh3 Date: Thu, 6 Aug 2020 17:17:36 -0700 Subject: [PATCH 4/8] added newline to end of file --- sdk/include/opentelemetry/sdk/metrics/exporter.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/include/opentelemetry/sdk/metrics/exporter.h b/sdk/include/opentelemetry/sdk/metrics/exporter.h index 18551c0914..b0ed3b11ac 100644 --- a/sdk/include/opentelemetry/sdk/metrics/exporter.h +++ b/sdk/include/opentelemetry/sdk/metrics/exporter.h @@ -63,4 +63,4 @@ class MetricsExporter }; } // namespace metrics } // namespace sdk -OPENTELEMETRY_END_NAMESPACE \ No newline at end of file +OPENTELEMETRY_END_NAMESPACE From 70a17f6459593fe8a7acf66bd44c9e0b8bdf756b Mon Sep 17 00:00:00 2001 From: erichsueh3 Date: Fri, 7 Aug 2020 10:34:12 -0700 Subject: [PATCH 5/8] CI formatting, added copyright header --- sdk/include/opentelemetry/sdk/metrics/exporter.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/sdk/include/opentelemetry/sdk/metrics/exporter.h b/sdk/include/opentelemetry/sdk/metrics/exporter.h index b0ed3b11ac..49667fa88f 100644 --- a/sdk/include/opentelemetry/sdk/metrics/exporter.h +++ b/sdk/include/opentelemetry/sdk/metrics/exporter.h @@ -1,3 +1,19 @@ +/* + * 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. + */ + #pragma once #include From dac00d42a11ff53c91af2285abfafcc1a2dbb7dd Mon Sep 17 00:00:00 2001 From: erichsueh3 Date: Wed, 19 Aug 2020 11:21:42 -0700 Subject: [PATCH 6/8] removed unnecessary ExportResult kFailureTimeout --- sdk/include/opentelemetry/sdk/metrics/exporter.h | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/sdk/include/opentelemetry/sdk/metrics/exporter.h b/sdk/include/opentelemetry/sdk/metrics/exporter.h index 49667fa88f..3b9576c69f 100644 --- a/sdk/include/opentelemetry/sdk/metrics/exporter.h +++ b/sdk/include/opentelemetry/sdk/metrics/exporter.h @@ -45,15 +45,10 @@ enum class ExportResult */ kFailureFull = 2, - /** - * The export has timed out. - */ - kFailureTimeout = 3, - /** * The export() function was passed an invalid argument. */ - kFailureInvalidArgument = 4, + kFailureInvalidArgument = 3, }; /** * MetricsExporter defines the interface that protocol-specific span exporters must From 4c32f00cb3aacafdeca31bafc21e99a9731d2544 Mon Sep 17 00:00:00 2001 From: erichsueh3 Date: Thu, 20 Aug 2020 16:40:53 -0700 Subject: [PATCH 7/8] removed comment about shutdown function --- sdk/include/opentelemetry/sdk/metrics/exporter.h | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/sdk/include/opentelemetry/sdk/metrics/exporter.h b/sdk/include/opentelemetry/sdk/metrics/exporter.h index 3b9576c69f..37ae761edd 100644 --- a/sdk/include/opentelemetry/sdk/metrics/exporter.h +++ b/sdk/include/opentelemetry/sdk/metrics/exporter.h @@ -66,11 +66,7 @@ class MetricsExporter */ virtual ExportResult Export(const std::vector &records) noexcept = 0; - /** - * In the Metrics specification, there is no Shutdown function required for exporters - * The Shutdown function can be implemented within exporters that wish to have one, - * but will not be enforced through this header - */ + }; } // namespace metrics } // namespace sdk From 93a8f3f137efcb0274659281d45c72d163174d46 Mon Sep 17 00:00:00 2001 From: erichsueh3 Date: Thu, 20 Aug 2020 17:03:40 -0700 Subject: [PATCH 8/8] ran formatting tool --- sdk/include/opentelemetry/sdk/metrics/exporter.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/sdk/include/opentelemetry/sdk/metrics/exporter.h b/sdk/include/opentelemetry/sdk/metrics/exporter.h index 37ae761edd..5a66f11815 100644 --- a/sdk/include/opentelemetry/sdk/metrics/exporter.h +++ b/sdk/include/opentelemetry/sdk/metrics/exporter.h @@ -65,8 +65,6 @@ class MetricsExporter * @param records a vector of unique pointers to metric records */ virtual ExportResult Export(const std::vector &records) noexcept = 0; - - }; } // namespace metrics } // namespace sdk