mirror of
https://github.com/facebook/sapling.git
synced 2024-10-05 14:28:17 +03:00
add fetch type to data fetch logging
Summary: Having the type of data fetched can help in debugging where these fetches are comming from. In the currently logs figuring out if a data fetch is blob or tree requires some manual work. When looking at a big bunch of fetches this is not super practical. So this includes this info in our logging. Reviewed By: chadaustin Differential Revision: D23243444 fbshipit-source-id: 9abe5180c5d2afc0d02b27ba6a6b76401e86556e
This commit is contained in:
parent
34df768136
commit
3827b9787d
@ -27,7 +27,8 @@ BackingStoreLogger::BackingStoreLogger(
|
||||
|
||||
void BackingStoreLogger::logImport(
|
||||
ObjectFetchContext& context,
|
||||
RelativePathPiece importPath) {
|
||||
RelativePathPiece importPath,
|
||||
ObjectFetchContext::ObjectType fetchedType) {
|
||||
if (!loggingAvailable_) {
|
||||
return;
|
||||
}
|
||||
@ -58,10 +59,27 @@ void BackingStoreLogger::logImport(
|
||||
folly::to<std::string>(cause_string, " - ", causeDetail.value());
|
||||
}
|
||||
|
||||
std::string typeString = "<invalid>";
|
||||
switch (fetchedType) {
|
||||
case ObjectFetchContext::ObjectType::Blob:
|
||||
typeString = "Blob";
|
||||
break;
|
||||
case ObjectFetchContext::ObjectType::BlobMetadata:
|
||||
typeString = "Blob Metadata";
|
||||
break;
|
||||
case ObjectFetchContext::ObjectType::Tree:
|
||||
typeString = "Tree";
|
||||
break;
|
||||
case ObjectFetchContext::ObjectType::kObjectTypeEnumMax:
|
||||
// invalid string prolly good here
|
||||
break;
|
||||
}
|
||||
|
||||
logger_->logEvent(ServerDataFetch{std::move(cause_string),
|
||||
pid,
|
||||
std::move(cmdline),
|
||||
std::move(importPathString)});
|
||||
std::move(importPathString),
|
||||
std::move(typeString)});
|
||||
}
|
||||
|
||||
} // namespace eden
|
||||
|
@ -10,13 +10,13 @@
|
||||
#include <folly/Executor.h>
|
||||
#include <string>
|
||||
|
||||
#include "eden/fs/store/ObjectFetchContext.h"
|
||||
#include "eden/fs/utils/PathFuncs.h"
|
||||
|
||||
namespace facebook {
|
||||
namespace eden {
|
||||
|
||||
class UnboundedQueueExecutor;
|
||||
class ObjectFetchContext;
|
||||
class StructuredLogger;
|
||||
class ProcessNameCache;
|
||||
|
||||
@ -29,7 +29,10 @@ class BackingStoreLogger {
|
||||
// for unit tests so that a no-op logger can be passed into the backing store
|
||||
BackingStoreLogger() = default;
|
||||
|
||||
void logImport(ObjectFetchContext& context, RelativePathPiece importPath);
|
||||
void logImport(
|
||||
ObjectFetchContext& context,
|
||||
RelativePathPiece importPath,
|
||||
ObjectFetchContext::ObjectType fetchedType);
|
||||
|
||||
private:
|
||||
std::shared_ptr<StructuredLogger> logger_;
|
||||
|
@ -186,7 +186,7 @@ void HgQueuedBackingStore::processRequest() {
|
||||
folly::SemiFuture<std::unique_ptr<Tree>> HgQueuedBackingStore::getTree(
|
||||
const Hash& id,
|
||||
ObjectFetchContext& context) {
|
||||
logBackingStoreFetch(context, id);
|
||||
logBackingStoreFetch(context, id, ObjectFetchContext::ObjectType::Tree);
|
||||
|
||||
auto importTracker =
|
||||
std::make_unique<RequestMetricsScope>(&pendingImportTreeWatches_);
|
||||
@ -201,7 +201,8 @@ folly::SemiFuture<std::unique_ptr<Blob>> HgQueuedBackingStore::getBlob(
|
||||
ObjectFetchContext& context) {
|
||||
auto proxyHash = HgProxyHash(localStore_.get(), id, "getBlob");
|
||||
auto path = proxyHash.path();
|
||||
logBackingStoreFetch(context, path);
|
||||
|
||||
logBackingStoreFetch(context, path, ObjectFetchContext::ObjectType::Blob);
|
||||
|
||||
if (auto blob =
|
||||
backingStore_->getDatapackStore().getBlobLocal(id, proxyHash)) {
|
||||
@ -249,7 +250,7 @@ folly::SemiFuture<folly::Unit> HgQueuedBackingStore::prefetchBlobs(
|
||||
}
|
||||
|
||||
for (auto& hash : ids) {
|
||||
logBackingStoreFetch(context, hash);
|
||||
logBackingStoreFetch(context, hash, ObjectFetchContext::ObjectType::Blob);
|
||||
}
|
||||
|
||||
auto importTracker =
|
||||
@ -263,7 +264,8 @@ folly::SemiFuture<folly::Unit> HgQueuedBackingStore::prefetchBlobs(
|
||||
|
||||
void HgQueuedBackingStore::logBackingStoreFetch(
|
||||
ObjectFetchContext& context,
|
||||
std::variant<RelativePathPiece, Hash> identifier) {
|
||||
std::variant<RelativePathPiece, Hash> identifier,
|
||||
ObjectFetchContext::ObjectType type) {
|
||||
if (!config_) {
|
||||
return;
|
||||
}
|
||||
@ -291,7 +293,7 @@ void HgQueuedBackingStore::logBackingStoreFetch(
|
||||
|
||||
if (RelativePathPiece(logFetchPath.value())
|
||||
.isParentDirOf(RelativePathPiece(path))) {
|
||||
logger_->logImport(context, path);
|
||||
logger_->logImport(context, path, type);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -112,7 +112,8 @@ class HgQueuedBackingStore : public BackingStore {
|
||||
*/
|
||||
void logBackingStoreFetch(
|
||||
ObjectFetchContext& context,
|
||||
std::variant<RelativePathPiece, Hash> identifer);
|
||||
std::variant<RelativePathPiece, Hash> identifer,
|
||||
ObjectFetchContext::ObjectType type);
|
||||
|
||||
/**
|
||||
* gets the watches timing `object` imports that are `stage`
|
||||
|
@ -207,6 +207,7 @@ struct ServerDataFetch {
|
||||
std::optional<pid_t> client_pid;
|
||||
std::optional<std::string> client_cmdline;
|
||||
std::string fetched_path;
|
||||
std::string fetched_object_type;
|
||||
|
||||
void populate(DynamicEvent& event) const {
|
||||
event.addString("interface", cause);
|
||||
@ -217,6 +218,7 @@ struct ServerDataFetch {
|
||||
event.addString("client_cmdline", client_cmdline.value());
|
||||
}
|
||||
event.addString("fetched_path", fetched_path);
|
||||
event.addString("fetched_object_type", fetched_object_type);
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user