Skip to content

Commit

Permalink
Modify MeterSelector and InstrumentSelector to use std::string instea…
Browse files Browse the repository at this point in the history
…d of nostd::string_view

Signed-off-by: Harish Shan <[email protected]>
  • Loading branch information
perhapsmaple committed Oct 31, 2023
1 parent 405e346 commit 1f9ac98
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 39 deletions.
4 changes: 0 additions & 4 deletions ext/src/dll/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ set(OPENTELEMETRY_EXPORT_DEF

add_library(opentelemetry_cpp SHARED dllmain.cc ${OPENTELEMETRY_EXPORT_DEF})

if(OPENTELEMETRY_STL_VERSION)
add_compile_definitions(OPENTELEMETRY_STL_VERSION)
endif()

target_link_libraries(
opentelemetry_cpp PRIVATE opentelemetry_trace
opentelemetry_exporter_ostream_span)
Expand Down
20 changes: 4 additions & 16 deletions ext/src/dll/opentelemetry_cpp.src
Original file line number Diff line number Diff line change
Expand Up @@ -72,29 +72,17 @@ EXPORTS
?Create@ViewFactory@metrics@sdk@v1@opentelemetry@@SA?AV?$unique_ptr@VView@metrics@sdk@v1@opentelemetry@@U?$default_delete@VView@metrics@sdk@v1@opentelemetry@@@std@@@std@@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@7@00W4AggregationType@2345@V?$shared_ptr@VAggregationConfig@metrics@sdk@v1@opentelemetry@@@7@@Z
// public: static class std::unique_ptr<class opentelemetry::v1::sdk::metrics::View,struct std::default_delete<class opentelemetry::v1::sdk::metrics::View> > __cdecl opentelemetry::v1::sdk::metrics::ViewFactory::Create(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,enum opentelemetry::v1::sdk::metrics::AggregationType)
?Create@ViewFactory@metrics@sdk@v1@opentelemetry@@SA?AV?$unique_ptr@VView@metrics@sdk@v1@opentelemetry@@U?$default_delete@VView@metrics@sdk@v1@opentelemetry@@@std@@@std@@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@7@00W4AggregationType@2345@@Z

#if (OPENTELEMETRY_STL_VERSION >= 2017)
// For OPENTELEMETRY_STL_VERSION >= 2017: Use C++ Standard Library's std::string_view for exported function definitions.
// public: static class std::unique_ptr<class opentelemetry::v1::sdk::metrics::MeterSelector,struct std::default_delete<class opentelemetry::v1::sdk::metrics::MeterSelector> > __cdecl opentelemetry::v1::sdk::metrics::MeterSelectorFactory::Create(class std::basic_string_view<char,struct std::char_traits<char> >,class std::basic_string_view<char,struct std::char_traits<char> >,class std::basic_string_view<char,struct std::char_traits<char> >)
?Create@MeterSelectorFactory@metrics@sdk@v1@opentelemetry@@SA?AV?$unique_ptr@VMeterSelector@metrics@sdk@v1@opentelemetry@@U?$default_delete@VMeterSelector@metrics@sdk@v1@opentelemetry@@@std@@@std@@V?$basic_string_view@DU?$char_traits@D@std@@@7@00@Z
// public: static class std::unique_ptr<class opentelemetry::v1::sdk::metrics::InstrumentSelector,struct std::default_delete<class opentelemetry::v1::sdk::metrics::InstrumentSelector> > __cdecl opentelemetry::v1::sdk::metrics::InstrumentSelectorFactory::Create(enum opentelemetry::v1::sdk::metrics::InstrumentType,class std::basic_string_view<char,struct std::char_traits<char> >,class std::basic_string_view<char,struct std::char_traits<char> >)
?Create@InstrumentSelectorFactory@metrics@sdk@v1@opentelemetry@@SA?AV?$unique_ptr@VInstrumentSelector@metrics@sdk@v1@opentelemetry@@U?$default_delete@VInstrumentSelector@metrics@sdk@v1@opentelemetry@@@std@@@std@@W4InstrumentType@2345@V?$basic_string_view@DU?$char_traits@D@std@@@7@1@Z
#else
// For OPENTELEMETRY_STL_VERSION < 2017 or undefined: Use nostd::string_view for exported function definitions.
// public: static class std::unique_ptr<class opentelemetry::v1::sdk::metrics::MeterSelector,struct std::default_delete<class opentelemetry::v1::sdk::metrics::MeterSelector> > __cdecl opentelemetry::v1::sdk::metrics::MeterSelectorFactory::Create(class opentelemetry::v1::nostd::string_view,class opentelemetry::v1::nostd::string_view,class opentelemetry::v1::nostd::string_view)
?Create@MeterSelectorFactory@metrics@sdk@v1@opentelemetry@@SA?AV?$unique_ptr@VMeterSelector@metrics@sdk@v1@opentelemetry@@U?$default_delete@VMeterSelector@metrics@sdk@v1@opentelemetry@@@std@@@std@@Vstring_view@nostd@45@00@Z
// public: static class std::unique_ptr<class opentelemetry::v1::sdk::metrics::InstrumentSelector,struct std::default_delete<class opentelemetry::v1::sdk::metrics::InstrumentSelector> > __cdecl opentelemetry::v1::sdk::metrics::InstrumentSelectorFactory::Create(enum opentelemetry::v1::sdk::metrics::InstrumentType,class opentelemetry::v1::nostd::string_view,class opentelemetry::v1::nostd::string_view)
?Create@InstrumentSelectorFactory@metrics@sdk@v1@opentelemetry@@SA?AV?$unique_ptr@VInstrumentSelector@metrics@sdk@v1@opentelemetry@@U?$default_delete@VInstrumentSelector@metrics@sdk@v1@opentelemetry@@@std@@@std@@W4InstrumentType@2345@Vstring_view@nostd@45@1@Z
#endif // (OPENTELEMETRY_STL_VERSION >= 2017)

// public: static class std::unique_ptr<class opentelemetry::v1::sdk::metrics::MeterSelector,struct std::default_delete<class opentelemetry::v1::sdk::metrics::MeterSelector> > __cdecl opentelemetry::v1::sdk::metrics::MeterSelectorFactory::Create(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)
?Create@MeterSelectorFactory@metrics@sdk@v1@opentelemetry@@SA?AV?$unique_ptr@VMeterSelector@metrics@sdk@v1@opentelemetry@@U?$default_delete@VMeterSelector@metrics@sdk@v1@opentelemetry@@@std@@@std@@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@7@00@Z
// public: static class std::unique_ptr<class opentelemetry::v1::sdk::metrics::InstrumentSelector,struct std::default_delete<class opentelemetry::v1::sdk::metrics::InstrumentSelector> > __cdecl opentelemetry::v1::sdk::metrics::InstrumentSelectorFactory::Create(enum opentelemetry::v1::sdk::metrics::InstrumentType,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)
?Create@InstrumentSelectorFactory@metrics@sdk@v1@opentelemetry@@SA?AV?$unique_ptr@VInstrumentSelector@metrics@sdk@v1@opentelemetry@@U?$default_delete@VInstrumentSelector@metrics@sdk@v1@opentelemetry@@@std@@@std@@W4InstrumentType@2345@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@7@1@Z
// public: void __cdecl opentelemetry::v1::sdk::metrics::MeterContext::AddMetricReader(class std::shared_ptr<class opentelemetry::v1::sdk::metrics::MetricReader>)
?AddMetricReader@MeterContext@metrics@sdk@v1@opentelemetry@@QEAAXV?$shared_ptr@VMetricReader@metrics@sdk@v1@opentelemetry@@@std@@@Z
// public: void __cdecl opentelemetry::v1::sdk::metrics::MeterProvider::AddMetricReader(class std::shared_ptr<class opentelemetry::v1::sdk::metrics::MetricReader>)
?AddMetricReader@MeterProvider@metrics@sdk@v1@opentelemetry@@QEAAXV?$shared_ptr@VMetricReader@metrics@sdk@v1@opentelemetry@@@std@@@Z
// public: void __cdecl opentelemetry::v1::sdk::metrics::MeterProvider::AddView(class std::unique_ptr<class opentelemetry::v1::sdk::metrics::InstrumentSelector,struct std::default_delete<class opentelemetry::v1::sdk::metrics::InstrumentSelector> >,class std::unique_ptr<class opentelemetry::v1::sdk::metrics::MeterSelector,struct std::default_delete<class opentelemetry::v1::sdk::metrics::MeterSelector> >,class std::unique_ptr<class opentelemetry::v1::sdk::metrics::View,struct std::default_delete<class opentelemetry::v1::sdk::metrics::View> >)
?AddView@MeterProvider@metrics@sdk@v1@opentelemetry@@QEAAXV?$unique_ptr@VInstrumentSelector@metrics@sdk@v1@opentelemetry@@U?$default_delete@VInstrumentSelector@metrics@sdk@v1@opentelemetry@@@std@@@std@@V?$unique_ptr@VMeterSelector@metrics@sdk@v1@opentelemetry@@U?$default_delete@VMeterSelector@metrics@sdk@v1@opentelemetry@@@std@@@7@V?$unique_ptr@VView@metrics@sdk@v1@opentelemetry@@U?$default_delete@VView@metrics@sdk@v1@opentelemetry@@@std@@@7@@Z


#if defined(WITH_OTLP_GRPC) || defined(WITH_OTLP_HTTP)
?GetOtlpDefaultTracesTimeout@otlp@exporter@v1@opentelemetry@@YA?AV?$duration@_JU?$ratio@$00$0JIJGIA@@std@@@chrono@std@@XZ
?GetOtlpDefaultTracesHeaders@otlp@exporter@v1@opentelemetry@@YA?AV?$multimap@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@Ucmp_ic@otlp@exporter@v1@opentelemetry@@V?$allocator@U?$pair@$$CBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@@std@@@2@@std@@XZ
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

#include <memory>

#include "opentelemetry/nostd/string_view.h"
#include "opentelemetry/sdk/metrics/instruments.h"
#include "opentelemetry/sdk/metrics/view/predicate_factory.h"
#include "opentelemetry/version.h"
Expand All @@ -19,8 +18,8 @@ class InstrumentSelector
{
public:
InstrumentSelector(opentelemetry::sdk::metrics::InstrumentType instrument_type,
opentelemetry::nostd::string_view name,
opentelemetry::nostd::string_view units)
const std::string& name,
const std::string& units)
: name_filter_{PredicateFactory::GetPredicate(name, PredicateType::kPattern)},
unit_filter_{PredicateFactory::GetPredicate(units, PredicateType::kExact)},
instrument_type_{instrument_type}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

#pragma once

#include "opentelemetry/nostd/string_view.h"
#include "opentelemetry/sdk/metrics/instruments.h"

OPENTELEMETRY_BEGIN_NAMESPACE
Expand All @@ -19,8 +18,8 @@ class OPENTELEMETRY_EXPORT InstrumentSelectorFactory
public:
static std::unique_ptr<InstrumentSelector> Create(
opentelemetry::sdk::metrics::InstrumentType instrument_type,
opentelemetry::nostd::string_view name,
opentelemetry::nostd::string_view unit);
const std::string& name,
const std::string& unit);
};

} // namespace metrics
Expand Down
7 changes: 3 additions & 4 deletions sdk/include/opentelemetry/sdk/metrics/view/meter_selector.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

#include <memory>

#include "opentelemetry/nostd/string_view.h"
#include "opentelemetry/sdk/metrics/view/predicate_factory.h"
#include "opentelemetry/version.h"

Expand All @@ -17,9 +16,9 @@ namespace metrics
class MeterSelector
{
public:
MeterSelector(opentelemetry::nostd::string_view name,
opentelemetry::nostd::string_view version,
opentelemetry::nostd::string_view schema)
MeterSelector(const std::string& name,
const std::string& version,
const std::string& schema)
: name_filter_{PredicateFactory::GetPredicate(name, PredicateType::kExact)},
version_filter_{PredicateFactory::GetPredicate(version, PredicateType::kExact)},
schema_filter_{PredicateFactory::GetPredicate(schema, PredicateType::kExact)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
#pragma once

#include <memory>
#include <string>

#include "opentelemetry/nostd/string_view.h"
#include "opentelemetry/version.h"

OPENTELEMETRY_BEGIN_NAMESPACE
Expand All @@ -19,9 +19,9 @@ class MeterSelector;
class OPENTELEMETRY_EXPORT MeterSelectorFactory
{
public:
static std::unique_ptr<MeterSelector> Create(opentelemetry::nostd::string_view name,
opentelemetry::nostd::string_view version,
opentelemetry::nostd::string_view schema);
static std::unique_ptr<MeterSelector> Create(const std::string& name,
const std::string& version,
const std::string& schema);
};

} // namespace metrics
Expand Down
4 changes: 2 additions & 2 deletions sdk/src/metrics/view/instrument_selector_factory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ namespace metrics

std::unique_ptr<InstrumentSelector> InstrumentSelectorFactory::Create(
opentelemetry::sdk::metrics::InstrumentType instrument_type,
opentelemetry::nostd::string_view name,
opentelemetry::nostd::string_view unit)
const std::string& name,
const std::string& unit)
{
std::unique_ptr<InstrumentSelector> instrument_selector(
new InstrumentSelector(instrument_type, name, unit));
Expand Down
6 changes: 3 additions & 3 deletions sdk/src/metrics/view/meter_selector_factory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ namespace metrics
{

std::unique_ptr<MeterSelector> MeterSelectorFactory::Create(
opentelemetry::nostd::string_view name,
opentelemetry::nostd::string_view version,
opentelemetry::nostd::string_view schema)
const std::string& name,
const std::string& version,
const std::string& schema)
{
std::unique_ptr<MeterSelector> meter_selector(new MeterSelector(name, version, schema));
return meter_selector;
Expand Down

0 comments on commit 1f9ac98

Please sign in to comment.