forked from facebookincubator/Glean
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Summary: Pull Request resolved: facebookincubator#440 Traces are written to Scuba glean_glass_server_events and visualised with Chrome (Perfetto) {F1477527085} https://fburl.com/scuba/glean_glass_server_events/gkhqrmoo Right now only the following things are instrumented: * The top level Thrift Handler * documentSymbolsList/Index RFC: * would this be useful to debug Glass performance on individual requests? * any concerns about running it in production? One limitation is tracing inside Haxl computations. Would need a bit more work to instrument the Haxl datasource. Once that's done, it would theoretically be possible to carry the instrumentation through to the Glean server and have whole-system traces. But that's probably overkill. I'll clean up the code and test the OSS build when/if there is consensus to land it Reviewed By: josefs Differential Revision: D55698252 fbshipit-source-id: ccd7c41345fcb2a54e5c3de6ed68912797516e6d
- Loading branch information
1 parent
b3a2b63
commit b6b1b33
Showing
9 changed files
with
128 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
{- | ||
Copyright (c) Meta Platforms, Inc. and affiliates. | ||
All rights reserved. | ||
This source code is licensed under the BSD-style license found in the | ||
LICENSE file in the root directory of this source tree. | ||
-} | ||
|
||
{-# OPTIONS_GHC -Wno-unused-matches #-} | ||
module Glean.Glass.Tracing | ||
( GlassTrace(..) | ||
, GlassTracer | ||
, traceSpan | ||
, glassTraceEvent | ||
) where | ||
|
||
import Data.Text (Text) | ||
|
||
import Control.Trace (traceMsg, Tracer) | ||
|
||
import Glean.Glass.GlassService.Service as Glass | ||
import Glean.Glass.Types | ||
import Data.Aeson ( pairs, fromEncoding, toEncoding, KeyValue((.=)) ) | ||
import Data.Text.Lazy (toStrict) | ||
import Data.Text.Lazy.Encoding (decodeUtf8) | ||
import Data.Binary.Builder ( toLazyByteString ) | ||
|
||
type GlassTracer = Tracer GlassTrace | ||
|
||
traceSpan :: GlassTracer -> Text -> IO a -> IO a | ||
traceSpan tracer span = traceMsg tracer (TraceSpan span Nothing) | ||
|
||
data GlassTrace where | ||
TraceCommand :: forall r . GlassServiceCommand r -> GlassTrace | ||
TraceSpan :: !Text -> Maybe Text -> GlassTrace | ||
|
||
glassTraceEvent :: GlassTrace -> (Text, Maybe Text) | ||
glassTraceEvent (TraceSpan event args) = (event, args) | ||
glassTraceEvent (TraceCommand cmd) = case cmd of | ||
Glass.SuperFacebookService r -> ("SuperFacebookService", Nothing) | ||
Glass.DocumentSymbolListX DocumentSymbolsRequest{..} opts -> | ||
( "DocumentSymbolListX" | ||
, json $ pairs $ | ||
"filepath" .= documentSymbolsRequest_filepath <> | ||
"repository" .= documentSymbolsRequest_repository <> | ||
"revision" .= requestOptions_revision opts | ||
) | ||
Glass.DocumentSymbolIndex DocumentSymbolsRequest{..} opts -> | ||
("DocumentSymbolIndex" | ||
, json $ pairs $ | ||
"filepath" .= documentSymbolsRequest_filepath <> | ||
"repository" .= documentSymbolsRequest_repository <> | ||
"revision" .= requestOptions_revision opts | ||
) | ||
Glass.FindReferences r opts -> | ||
( "FindReferences" , json $ toEncoding r) | ||
Glass.FindReferenceRanges r opts -> | ||
("FindReferenceRanges", json $ toEncoding r) | ||
Glass.ResolveSymbolRange r opts -> | ||
("ResolveSymbolRange", json $ toEncoding r) | ||
Glass.DescribeSymbol r opts -> | ||
("DescribeSymbol", json $ toEncoding r) | ||
Glass.SearchSymbol r opts -> | ||
("SearchSymbol", json $ toEncoding r) | ||
Glass.SearchRelated r opts req -> | ||
("SearchRelated", json $ toEncoding r) | ||
Glass.SearchRelatedNeighborhood r opts req -> | ||
("SearchRelatedNeighborhood", json $ toEncoding r) | ||
Glass.SearchBySymbolId r opts -> | ||
("SearchBySymbolId", json $ toEncoding r) | ||
Glass.Index r -> | ||
("Index", json $ toEncoding r) | ||
Glass.FileIncludeLocations r opts -> | ||
("FileIncludeLocations", json $ toEncoding r) | ||
Glass.ClangUSRToDefinition r opts -> | ||
("ClangUSRToDefinition", json $ toEncoding r) | ||
|
||
where | ||
json = | ||
Just . toStrict . decodeUtf8 . toLazyByteString . fromEncoding |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters