Skip to content

Commit 067df6f

Browse files
Kinga Bojarczukmeta-codesync[bot]
authored andcommitted
add client info logging
Summary: set up thrift for client info in glass Reviewed By: jjuliamolin Differential Revision: D90025357 fbshipit-source-id: 15adc971792da1b1d3e0ba67d384d66fb45f9be0
1 parent 8b80866 commit 067df6f

3 files changed

Lines changed: 32 additions & 1 deletion

File tree

glean/github/Logger/GleanGlass.hs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,3 +118,12 @@ setAttributeOptions _ = GleanGlassLogger
118118

119119
setDynamicAttributeStats :: [Text] -> GleanGlassLogger
120120
setDynamicAttributeStats _ = GleanGlassLogger
121+
122+
setClientUnixname :: Text -> GleanGlassLogger
123+
setClientUnixname _ = GleanGlassLogger
124+
125+
setClientApplication :: Text -> GleanGlassLogger
126+
setClientApplication _ = GleanGlassLogger
127+
128+
setClientName :: Text -> GleanGlassLogger
129+
setClientName _ = GleanGlassLogger

glean/glass/Glean/Glass/Logging.hs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,21 @@ instance LogRequest RequestOptions where
6767
Logger.setExactRevision requestOptions_exact_revision <>
6868
Logger.setMatchingRevision requestOptions_matching_revision <>
6969
Logger.setContentCheck requestOptions_content_check <>
70+
logRequest requestOptions_client_info <>
7071
logRequest requestOptions_feature_flags <>
7172
logRequest requestOptions_attribute_opts
7273

74+
instance LogRequest ClientInfo where
75+
logRequest ClientInfo{..} = mconcat
76+
[ maybe mempty Logger.setClientUnixname clientInfo_unixname
77+
, maybe mempty Logger.setClientApplication clientInfo_application
78+
, maybe mempty Logger.setClientName clientInfo_name
79+
]
80+
7381
instance LogRequest AttributeOptions where
7482
logRequest AttributeOptions{..} =
75-
Logger.setAttributeOptions $ textShow $ Thrift.serializeJSON AttributeOptions{..}
83+
Logger.setAttributeOptions $ textShow $
84+
Thrift.serializeJSON AttributeOptions{..}
7685

7786
instance LogRequest FeatureFlags where
7887
logRequest FeatureFlags{} = mempty

glean/glass/if/glass.thrift

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,16 @@ typedef string BinaryName (hs.newtype)
121121

122122
typedef string PackageName (hs.newtype)
123123

124+
// Client information for logging and debugging
125+
struct ClientInfo {
126+
// Client name (e.g. api-python3, api-haskell, vscode)
127+
1: optional string name;
128+
// Unix username of the user making the request
129+
2: optional string unixname;
130+
// Application identifier (e.g. build rule)
131+
3: optional string application;
132+
}
133+
124134
// Generic request options, supported by most calls
125135
struct RequestOptions {
126136
// repo-global preferred revision identifier
@@ -167,6 +177,9 @@ struct RequestOptions {
167177
6: bool matching_revision = false;
168178

169179
8: AttributeOptions attribute_opts;
180+
181+
// Information about who is making the call
182+
9: optional ClientInfo client_info;
170183
}
171184

172185
struct FeatureFlags {

0 commit comments

Comments
 (0)