From b072406223d49dd943a229cd893221d44151fefc Mon Sep 17 00:00:00 2001 From: Kyle Loveless Date: Sat, 15 Feb 2025 13:28:23 -0500 Subject: [PATCH 1/3] Fix compilation with Regex disabled: * It was missing an include for std::any_of * Avoid declaring unused constants (at least my LLVM errors out) --- sdk/src/metrics/instrument_metadata_validator.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sdk/src/metrics/instrument_metadata_validator.cc b/sdk/src/metrics/instrument_metadata_validator.cc index 59244bfe33..e3d3f9e206 100644 --- a/sdk/src/metrics/instrument_metadata_validator.cc +++ b/sdk/src/metrics/instrument_metadata_validator.cc @@ -1,6 +1,7 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#include #include #include "opentelemetry/nostd/string_view.h" @@ -16,11 +17,13 @@ namespace sdk { namespace metrics { +#if OPENTELEMETRY_HAVE_WORKING_REGEX // instrument-name = ALPHA 0*254 ("_" / "." / "-" / "/" / ALPHA / DIGIT) const std::string kInstrumentNamePattern = "[a-zA-Z][-_./a-zA-Z0-9]{0,254}"; // const std::string kInstrumentUnitPattern = "[\x01-\x7F]{0,63}"; // instrument-unit = It can have a maximum length of 63 ASCII chars +#endif InstrumentMetaDataValidator::InstrumentMetaDataValidator() #if OPENTELEMETRY_HAVE_WORKING_REGEX From 95f834a031322017ecaf0abd94887b3eadf44c0b Mon Sep 17 00:00:00 2001 From: Kyle Loveless Date: Sat, 15 Feb 2025 15:48:49 -0500 Subject: [PATCH 2/3] Only include algorithm if needed. --- sdk/src/metrics/instrument_metadata_validator.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sdk/src/metrics/instrument_metadata_validator.cc b/sdk/src/metrics/instrument_metadata_validator.cc index e3d3f9e206..c6ad6295ce 100644 --- a/sdk/src/metrics/instrument_metadata_validator.cc +++ b/sdk/src/metrics/instrument_metadata_validator.cc @@ -1,7 +1,9 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#if OPENTELEMETRY_HAVE_WORKING_REGEX #include +#endif #include #include "opentelemetry/nostd/string_view.h" From 6857fc7f115244c6bc482c4050e80715e2fabb9a Mon Sep 17 00:00:00 2001 From: Kyle Loveless Date: Sat, 15 Feb 2025 23:05:52 -0500 Subject: [PATCH 3/3] Fix where we reference the WORKING_REGEX. --- sdk/src/metrics/instrument_metadata_validator.cc | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/sdk/src/metrics/instrument_metadata_validator.cc b/sdk/src/metrics/instrument_metadata_validator.cc index c6ad6295ce..482330a682 100644 --- a/sdk/src/metrics/instrument_metadata_validator.cc +++ b/sdk/src/metrics/instrument_metadata_validator.cc @@ -1,9 +1,6 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#if OPENTELEMETRY_HAVE_WORKING_REGEX -#include -#endif #include #include "opentelemetry/nostd/string_view.h" @@ -12,6 +9,8 @@ #if OPENTELEMETRY_HAVE_WORKING_REGEX # include +#else +# include #endif OPENTELEMETRY_BEGIN_NAMESPACE