diff --git a/eden/common/eden-config.h b/eden/common/eden-config.h new file mode 100644 index 0000000..08d9e16 --- /dev/null +++ b/eden/common/eden-config.h @@ -0,0 +1,12 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +// This configuration file is used by the Buck build. + +#pragma once + +#define LOGGER_FB_SESSION_INFO 1 diff --git a/eden/common/telemetry/SessionInfo.cpp b/eden/common/telemetry/SessionInfo.cpp index 160a8e2..ecb0f5d 100644 --- a/eden/common/telemetry/SessionInfo.cpp +++ b/eden/common/telemetry/SessionInfo.cpp @@ -6,9 +6,9 @@ */ #include "eden/common/telemetry/SessionInfo.h" - #include #include +#include "eden/common/eden-config.h" #if defined(__linux__) || defined(__APPLE__) #include @@ -56,6 +56,7 @@ SessionInfo makeSessionInfo( env.os = getOperatingSystemName(); env.osVersion = getOperatingSystemVersion(); env.appVersion = std::move(appVersion); + env.crossEnvSessionId = getCrossEnvSessionId(); #if defined(__APPLE__) env.systemArchitecture = getOperatingSystemArchitecture(); #endif @@ -113,6 +114,7 @@ std::string getHostname() { } std::optional getCiInstanceId() { +#if defined(LOGGER_FB_SESSION_INFO) auto str = std::getenv("SANDCASTLE_INSTANCE_ID"); if (!str) { return std::nullopt; @@ -123,6 +125,13 @@ std::optional getCiInstanceId() { } catch (const folly::ConversionError&) { return std::nullopt; } +#else + return std::nullopt; +#endif +} + +std::string getCrossEnvSessionId() { + return std::string(); } } // namespace facebook::eden diff --git a/eden/common/telemetry/SessionInfo.h b/eden/common/telemetry/SessionInfo.h index b560d23..1cfc01f 100644 --- a/eden/common/telemetry/SessionInfo.h +++ b/eden/common/telemetry/SessionInfo.h @@ -22,6 +22,7 @@ struct SessionInfo { std::string os; std::string osVersion; std::string appVersion; + std::string crossEnvSessionId; #ifdef __APPLE__ std::string systemArchitecture; #endif @@ -50,4 +51,11 @@ std::string getHostname(); */ std::optional getCiInstanceId(); +/** + * Returns the Cross Environment Session Id, which uniquely identifies the host. + * This function returns an empty string if the Cross Environment Session Id is + * not unknown. + */ +std::string getCrossEnvSessionId(); + } // namespace facebook::eden