diff --git a/api/include/opentelemetry/plugin/detail/dynamic_load_windows.h b/api/include/opentelemetry/plugin/detail/dynamic_load_windows.h index 5ed2833756..c74d1b27b9 100644 --- a/api/include/opentelemetry/plugin/detail/dynamic_load_windows.h +++ b/api/include/opentelemetry/plugin/detail/dynamic_load_windows.h @@ -26,11 +26,11 @@ inline void GetLastErrorMessage(std::string &error_message) noexcept { auto error_code = ::GetLastError(); // See https://stackoverflow.com/a/455533/4447365 - LPTSTR error_text = nullptr; - auto size = ::FormatMessage( + LPSTR error_text = nullptr; + auto size = ::FormatMessageA( FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_IGNORE_INSERTS, nullptr, error_code, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), - reinterpret_cast(&error_text), 0, nullptr); + reinterpret_cast(&error_text), 0, nullptr); if (size == 0) { return; @@ -53,7 +53,7 @@ class DynamicLibraryHandleWindows final : public DynamicLibraryHandle inline std::unique_ptr LoadFactory(const char *plugin, std::string &error_message) noexcept { - auto handle = ::LoadLibrary(plugin); + auto handle = ::LoadLibraryA(plugin); if (handle == nullptr) { detail::GetLastErrorMessage(error_message); diff --git a/x/otel.yaml b/x/otel.yaml index 8d45e2cea5..878422ffe8 100644 --- a/x/otel.yaml +++ b/x/otel.yaml @@ -3,12 +3,12 @@ receivers: protocols: grpc: http: - prometheus/collector: - config: - scrape_configs: - - job_name: 'opentelemetry-collector' - static_configs: - - targets: ['localhost:8888'] + # prometheus/collector: + # config: + # scrape_configs: + # - job_name: 'opentelemetry-collector' + # static_configs: + # - targets: ['localhost:8888'] # service: # # https://opentelemetry.io/docs/collector/configuration/#telemetry @@ -62,7 +62,8 @@ service: processors: [batch] exporters: [otlphttp,logging/traces] metrics: - receivers: [otlp,prometheus/collector] + receivers: [otlp] + #,prometheus/collector] processors: [batch] exporters: [prometheusremotewrite,logging/metrics] logs: diff --git a/x/x.cpp b/x/x.cpp index ce5ce7ea30..a5f119b447 100644 --- a/x/x.cpp +++ b/x/x.cpp @@ -276,7 +276,7 @@ static std::map get_random_attr() return { labels[rand() % ( labels.size() - 1 )], labels[rand() % ( labels.size() - 1 )] }; } -static void counter_example( const std::string &name, const opentelemetry::trace::SpanContext &spanContext ) +static void counter_example( const std::string &name, double startValue, const opentelemetry::trace::SpanContext &spanContext ) { get_logger()->Info( "counter_example" ); opentelemetry::trace::StartSpanOptions options; @@ -285,16 +285,17 @@ static void counter_example( const std::string &name, const opentelemetry::trace const auto provider{ opentelemetry::metrics::Provider::GetMeterProvider() }; const auto meter{ provider->GetMeter( name ) }; - const auto double_counter{ meter->CreateDoubleCounter( name + "_counter" ) }; + const auto double_updown_counter{ meter->CreateDoubleUpDownCounter( name + "_updown_counter" ) }; + + double_counter->Add( startValue ); + double_updown_counter->Add( startValue + 500.0 ); for ( auto i = 0; i < 1000; ++i ) { - const double val{ rand() % 7 + 1.1 }; - - double_counter->Add( val ); - - std::this_thread::sleep_for( std::chrono::milliseconds( 10 ) ); + double_counter->Add( 1.0 ); + double_updown_counter->Add( 1.0 ); + std::this_thread::sleep_for( std::chrono::milliseconds( 100 ) ); } } @@ -530,17 +531,23 @@ void demo() get_logger()->Info( "Spawning threads" ); auto context = span->GetContext(); - std::thread counter_example_thread( counter_example, metric_prefix_name, context ); - std::thread observable_counter_example_thread( observable_counter_example, metric_prefix_name, context ); - std::thread histogram_example_thread( histogram_example, metric_prefix_name, context ); + std::thread counter_example_thread1( counter_example, metric_prefix_name + "_0", 100.0, context ); + std::thread counter_example_thread2( counter_example, metric_prefix_name + "_1", 200.0, context ); + std::thread counter_example_thread3( counter_example, metric_prefix_name + "_1", 200.0, context ); + std::thread counter_example_thread4( counter_example, metric_prefix_name + "_1", 300.0, context ); + //std::thread observable_counter_example_thread( observable_counter_example, metric_prefix_name, context ); + //std::thread histogram_example_thread( histogram_example, metric_prefix_name, context ); get_logger()->Info( "Joining threads" ); - ui_main(); + //ui_main(); - counter_example_thread.join(); - observable_counter_example_thread.join(); - histogram_example_thread.join(); + counter_example_thread1.join(); + counter_example_thread2.join(); + counter_example_thread3.join(); + counter_example_thread4.join(); + //observable_counter_example_thread.join(); + //histogram_example_thread.join(); get_logger()->Info( "Joined all threads" ); }