@@ -30,7 +30,12 @@ libmexclass::proxy::MakeResult ViewProxy::make(const libmexclass::proxy::Functio
3030 auto unit = unit_mda[0 ];
3131
3232 matlab::data::TypedArray<int > aggregation_type_mda = constructor_arguments[9 ];
33- auto aggregation_type = static_cast <metrics_sdk::AggregationType>(static_cast <int >(aggregation_type_mda[0 ]));
33+ metrics_sdk::AggregationType aggregation_type;
34+ if (static_cast <int >(aggregation_type_mda[0 ]) == -1 ){
35+ aggregation_type = metrics_sdk::AggregationType::kDefault ;
36+ }else {
37+ aggregation_type = static_cast <metrics_sdk::AggregationType>(static_cast <int >(aggregation_type_mda[0 ]));
38+ }
3439
3540 std::shared_ptr<metrics_sdk::HistogramAggregationConfig> aggregation_config = std::shared_ptr<metrics_sdk::HistogramAggregationConfig>(new metrics_sdk::HistogramAggregationConfig ());
3641 if (aggregation_type == metrics_sdk::AggregationType::kHistogram ){
@@ -45,58 +50,64 @@ libmexclass::proxy::MakeResult ViewProxy::make(const libmexclass::proxy::Functio
4550 }
4651
4752 std::unique_ptr<metrics_sdk::AttributesProcessor> attributes_processor;
48- matlab::data::StringArray attributes_mda = constructor_arguments[8 ];
49- if (attributes_mda.getNumberOfElements ()==0 ){
53+ matlab::data::TypedArray<matlab::data::MATLABString> attributes_mda = constructor_arguments[8 ];
54+ if (attributes_mda.getNumberOfElements ()==1 ){
5055 attributes_processor = std::unique_ptr<metrics_sdk::AttributesProcessor>(new metrics_sdk::DefaultAttributesProcessor ());
5156 }else {
5257 std::unordered_map<std::string, bool > allowed_attribute_keys;
53- for (auto a : attributes_mda) {
54- allowed_attribute_keys[a ] = true ;
58+ for (int a= 1 ; a< attributes_mda. getNumberOfElements (); a++ ) {
59+ allowed_attribute_keys[attributes_mda[a] ] = true ;
5560 }
5661 attributes_processor = std::unique_ptr<metrics_sdk::AttributesProcessor>(new metrics_sdk::FilteringAttributesProcessor (allowed_attribute_keys));
5762 }
5863
5964 auto view = metrics_sdk::ViewFactory::Create (name, description,
60- unit, aggregation_type, std::move ( aggregation_config) , std::move (attributes_processor));
65+ unit, aggregation_type, aggregation_config, std::move (attributes_processor));
6166
6267 // Create Instrument Selector
6368 matlab::data::TypedArray<int > instrument_type_mda = constructor_arguments[4 ];
64- auto instrument_type = static_cast <metrics_sdk::InstrumentType>(static_cast <int >(instrument_type_mda[0 ]));
69+ metrics_sdk::InstrumentType instrument_type;
70+ if (static_cast <int >(instrument_type_mda[0 ]) == -1 ){
71+ instrument_type = metrics_sdk::InstrumentType::kCounter ;
72+ }else {
73+ instrument_type = static_cast <metrics_sdk::InstrumentType>(static_cast <int >(instrument_type_mda[0 ]));
74+ }
6575
6676 matlab::data::StringArray instrument_name_mda = constructor_arguments[3 ];
67- auto instrument_name = static_cast <std::string>(instrument_name_mda[0 ]);
68- auto instrument_name_view = nostd::string_view (instrument_name);
77+ auto instrument_name_view = static_cast <std::string>(instrument_name_mda[0 ]);
78+ // auto instrument_name_view = nostd::string_view(instrument_name);
6979
70- auto unit_view = nostd::string_view (static_cast <std::string>(unit));
80+ auto unit_view = static_cast <std::string>(unit);
81+ // auto unit_view = nostd::string_view(static_cast<std::string>(unit));
7182
7283 auto instrumentSelector = metrics_sdk::InstrumentSelectorFactory::Create (instrument_type,
73- instrument_name, unit_view);
74-
84+ instrument_name_view, unit_view);
7585
7686 // Create Meter Selector
7787 matlab::data::StringArray meter_name_mda = constructor_arguments[5 ];
78- auto meter_name = static_cast <std::string>(meter_name_mda[0 ]);
79- auto meter_name_view = nostd::string_view (meter_name);
88+ auto meter_name_view = static_cast <std::string>(meter_name_mda[0 ]);
89+ // auto meter_name_view = nostd::string_view(meter_name);
8090
8191 matlab::data::StringArray meter_version_mda = constructor_arguments[6 ];
82- auto meter_version = static_cast <std::string>(meter_version_mda[0 ]);
83- auto meter_version_view = nostd::string_view (meter_version);
92+ auto meter_version_view = static_cast <std::string>(meter_version_mda[0 ]);
93+ // auto meter_version_view = nostd::string_view(meter_version);
8494
8595 matlab::data::StringArray meter_schema_mda = constructor_arguments[7 ];
86- auto meter_schema = static_cast <std::string>(meter_schema_mda[0 ]);
87- auto meter_schema_view = nostd::string_view (meter_schema);
96+ auto meter_schema_view = static_cast <std::string>(meter_schema_mda[0 ]);
97+ // auto meter_schema_view = nostd::string_view(meter_schema);
8898
8999 auto meterSelector = metrics_sdk::MeterSelectorFactory::Create (meter_name_view,
90100 meter_version_view, meter_schema_view);
91101
92-
93-
94- // out = std::make_shared<ViewProxy>(nostd::shared_ptr<metrics_sdk::View>(
95- // std::move(metrics_sdk::ViewFactory::Create(name, description,
96- // unit, aggregation_type, std::move(aggregation_config), std::move(attributes_processor)))));
97-
98-
99- // return out;
102+ // std::unique_ptr<metrics_sdk::InstrumentSelector> instrumentSelector{
103+ // new metrics_sdk::InstrumentSelector(instrument_type,
104+ // instrument_name_view, unit_view)};
105+ // std::unique_ptr<metrics_sdk::MeterSelector> meterSelector{
106+ // new metrics_sdk::MeterSelector(meter_name_view,
107+ // meter_version_view, meter_schema_view)};
108+ // std::unique_ptr<metrics_sdk::View> view{
109+ // new metrics_sdk::View{name, description,
110+ // unit, aggregation_type, aggregation_config, std::move(attributes_processor)}};
100111
101112 return std::make_shared<ViewProxy>(std::move (view), std::move (instrumentSelector), std::move (meterSelector));
102113}
0 commit comments