From 94111f612afc277ba457f4ac153d4770983057d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20Zamora=20Trevi=C3=B1o?= Date: Tue, 10 Sep 2024 14:09:44 -0700 Subject: [PATCH] preps for CESID Summary: # Context We want to experiment on EdenFS using Meta's mature stack of data analysis and experimentation that is QE + Deltoid. To do this, we need an ID we can join against in data land so we can define a population unit. We're using the [CESID](https://fb.workplace.com/groups/301619822315138/permalink/528321876311597/) for this purpose, which uniquely identifies a dev server, sandcastle instance, ondemand, and laptop/PC. # This Diff Adding the new field and function that will be populated later in the stack # Technical Details This code leverages 2 things: - The previously-introduced CESID getter API ported over with cxx.rs - Conditional compilation to obscure away Meta-only logic from the OSS project (using a header file introduced in this stack) Reviewed By: genevievehelsel Differential Revision: D62343641 fbshipit-source-id: 2a70ee00c1a57204c83ffe0c8974dfc92fd3da67 --- eden/common/eden-config.h | 12 ++++++++++++ eden/common/telemetry/SessionInfo.cpp | 11 ++++++++++- eden/common/telemetry/SessionInfo.h | 8 ++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 eden/common/eden-config.h diff --git a/eden/common/eden-config.h b/eden/common/eden-config.h new file mode 100644 index 00000000..08d9e16d --- /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 160a8e27..ecb0f5d4 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 b560d23e..1cfc01f5 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