Skip to content

Commit

Permalink
[BUILD] Improve the handling of OPENTELEMETRY_HAVE_WORKING_REGEX. (#2430
Browse files Browse the repository at this point in the history
)
  • Loading branch information
kylepl authored Dec 5, 2023
1 parent d1143ab commit a86f8f0
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 8 deletions.
6 changes: 4 additions & 2 deletions api/include/opentelemetry/trace/trace_state.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include "opentelemetry/nostd/unique_ptr.h"
#include "opentelemetry/version.h"

#if defined(OPENTELEMETRY_HAVE_WORKING_REGEX)
#if OPENTELEMETRY_HAVE_WORKING_REGEX
# include <regex>
#endif

Expand Down Expand Up @@ -246,6 +246,7 @@ class OPENTELEMETRY_EXPORT TraceState
return str.substr(left, right - left + 1);
}

#if OPENTELEMETRY_HAVE_WORKING_REGEX
static bool IsValidKeyRegEx(nostd::string_view key)
{
static std::regex reg_key("^[a-z0-9][a-z0-9*_\\-/]{0,255}$");
Expand All @@ -267,7 +268,7 @@ class OPENTELEMETRY_EXPORT TraceState
// Need to benchmark without regex, as a string object is created here.
return std::regex_match(std::string(value.data(), value.size()), reg_value);
}

#else
static bool IsValidKeyNonRegEx(nostd::string_view key)
{
if (key.empty() || key.size() > kKeyMaxSize || !IsLowerCaseAlphaOrDigit(key[0]))
Expand Down Expand Up @@ -307,6 +308,7 @@ class OPENTELEMETRY_EXPORT TraceState
}
return true;
}
#endif

static bool IsLowerCaseAlphaOrDigit(char c) { return isdigit(c) || islower(c); }

Expand Down
2 changes: 1 addition & 1 deletion sdk/include/opentelemetry/sdk/metrics/view/predicate.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include "opentelemetry/nostd/string_view.h"
#include "opentelemetry/sdk/common/global_log_handler.h"

#if defined(OPENTELEMETRY_HAVE_WORKING_REGEX)
#if OPENTELEMETRY_HAVE_WORKING_REGEX
# include <regex>
#endif

Expand Down
2 changes: 1 addition & 1 deletion sdk/src/metrics/instrument_metadata_validator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include <algorithm>
#include <iostream>

#if defined(OPENTELEMETRY_HAVE_WORKING_REGEX)
#if OPENTELEMETRY_HAVE_WORKING_REGEX
# include <regex>
#endif

Expand Down
6 changes: 3 additions & 3 deletions sdk/test/metrics/histogram_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

#include <gtest/gtest.h>

#if defined(OPENTELEMETRY_HAVE_WORKING_REGEX)
#if OPENTELEMETRY_HAVE_WORKING_REGEX
# include <regex>
#endif

Expand Down Expand Up @@ -73,7 +73,7 @@ TEST(Histogram, Double)
actual.counts_);
}

#if (OPENTELEMETRY_HAVE_WORKING_REGEX)
#if OPENTELEMETRY_HAVE_WORKING_REGEX
// FIXME - View Preficate search is only supported through regex
TEST(Histogram, DoubleCustomBuckets)
{
Expand Down Expand Up @@ -188,7 +188,7 @@ TEST(Histogram, UInt64)
actual.counts_);
}

#if (OPENTELEMETRY_HAVE_WORKING_REGEX)
#if OPENTELEMETRY_HAVE_WORKING_REGEX
// FIXME - View Preficate search is only supported through regex
TEST(Histogram, UInt64CustomBuckets)
{
Expand Down
2 changes: 1 addition & 1 deletion sdk/test/metrics/view_registry_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#include <gtest/gtest.h>

#if defined(OPENTELEMETRY_HAVE_WORKING_REGEX)
#if OPENTELEMETRY_HAVE_WORKING_REGEX
# include <regex>
#endif

Expand Down

2 comments on commit a86f8f0

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark 'OpenTelemetry-cpp sdk Benchmark'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 2.

Benchmark suite Current: a86f8f0 Previous: d1143ab Ratio
BM_BaselineBuffer/1 4124135.0173950195 ns/iter 570020.1988220215 ns/iter 7.24

This comment was automatically generated by workflow using github-action-benchmark.

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark 'OpenTelemetry-cpp api Benchmark'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 2.

Benchmark suite Current: a86f8f0 Previous: d1143ab Ratio
BM_SpinLockThrashing/1/process_time/real_time 1.2580876080495007 ms/iter 0.07631538966514545 ms/iter 16.49

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.