Skip to content

Commit

Permalink
preps for CESID
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Francisco Zamora Treviño authored and facebook-github-bot committed Sep 10, 2024
1 parent 01946d0 commit 94111f6
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
12 changes: 12 additions & 0 deletions eden/common/eden-config.h
Original file line number Diff line number Diff line change
@@ -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
11 changes: 10 additions & 1 deletion eden/common/telemetry/SessionInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
*/

#include "eden/common/telemetry/SessionInfo.h"

#include <folly/Conv.h>
#include <folly/Exception.h>
#include "eden/common/eden-config.h"

#if defined(__linux__) || defined(__APPLE__)
#include <folly/portability/Unistd.h>
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -113,6 +114,7 @@ std::string getHostname() {
}

std::optional<uint64_t> getCiInstanceId() {
#if defined(LOGGER_FB_SESSION_INFO)
auto str = std::getenv("SANDCASTLE_INSTANCE_ID");
if (!str) {
return std::nullopt;
Expand All @@ -123,6 +125,13 @@ std::optional<uint64_t> getCiInstanceId() {
} catch (const folly::ConversionError&) {
return std::nullopt;
}
#else
return std::nullopt;
#endif
}

std::string getCrossEnvSessionId() {
return std::string();
}

} // namespace facebook::eden
8 changes: 8 additions & 0 deletions eden/common/telemetry/SessionInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ struct SessionInfo {
std::string os;
std::string osVersion;
std::string appVersion;
std::string crossEnvSessionId;
#ifdef __APPLE__
std::string systemArchitecture;
#endif
Expand Down Expand Up @@ -50,4 +51,11 @@ std::string getHostname();
*/
std::optional<uint64_t> 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

0 comments on commit 94111f6

Please sign in to comment.