From aab6e8b4e8d2712c2066c04b7bd4afa6776576a5 Mon Sep 17 00:00:00 2001 From: RoyZhang2022 <104782736+RoyZhang2022@users.noreply.github.com> Date: Fri, 21 Jul 2023 16:45:40 -0700 Subject: [PATCH] Pass driver info to Timestream using user agent (#6) * pass driver info to Timestream using user agent * add log for user agent setting --- .../src/odbc/src/connection.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/amazon-timestream-odbc-driver/src/odbc/src/connection.cpp b/amazon-timestream-odbc-driver/src/odbc/src/connection.cpp index d27add26d957e..598c139e4f671 100644 --- a/amazon-timestream-odbc-driver/src/odbc/src/connection.cpp +++ b/amazon-timestream-odbc-driver/src/odbc/src/connection.cpp @@ -685,11 +685,22 @@ bool Connection::TryRestoreConnection(const config::Configuration& cfg, clientCfg.connectTimeoutMs = cfg.GetConnectionTimeout(); clientCfg.requestTimeoutMs = cfg.GetReqTimeout(); clientCfg.maxConnections = cfg.GetMaxConnections(); + +#if defined(_WIN32) + std::string platform("Windows"); +#elif defined(__APPLE__) + std::string platform("macOS"); +#else + std::string platform("Linux"); +#endif + // pass driver info to Timestream as user agent + clientCfg.userAgent = "ts-odbc." + utility::GetFormatedDriverVersion() + " on " + platform; LOG_DEBUG_MSG("region is " << cfg.GetRegion() << ", connection timeout is " << clientCfg.connectTimeoutMs << ", request timeout is " << clientCfg.requestTimeoutMs << ", max connection is " - << clientCfg.maxConnections); + << clientCfg.maxConnections << ", user agent is " + << clientCfg.userAgent); SetClientProxy(clientCfg);