Coder Social home page Coder Social logo

facebook / fb303 Goto Github PK

View Code? Open in 1sVSCode Editor NEW
54.0 9.0 29.0 6.31 MB

fb303 is a core set of thrift functions that provide a common mechanism for querying stats and other information from a service.

License: Apache License 2.0

C++ 55.41% Thrift 0.47% CMake 9.65% Python 33.77% C 0.49% Rust 0.21%

fb303's Introduction


fb303 is a base Thrift service and a common set of functionality for querying stats, options, and other information from a service.


fb303 depends on

And all transitive dependencies of the above.

Using fb303 for your service

You can have your own thrift service interface extend fb303_core.BaseService to utilize the fb303 API. Some of the primary interfaces defined by fb303 are:

  • getStatus() - Query the state of a running service.
  • getCounters() - Get custom statistics about the performance and behavior of a service.
  • getExportedValues() - Get arbitrary string values exported by a service. This can be used to export things such as the build metadata (version info and the source control commit ID it was built from) and other key configuration information.
  • getOptions() / setOption() - Get and set configurable service parameters.

C++ service handler implementations can extend facebook::fb303::BaseService for default implementations of the Thrift methods.

Curious about the name?


The TB-303 makes bass lines.

Bass is what lies underneath any strong tune.

fb303 is the shared root of all Thrift services.

fb303 ⇒ FacebookBase303.

Join the fb303 community

See the CONTRIBUTING file for how to help out.


fb303 is licensed under Apache 2.0 as found in the LICENSE file.


fb303 is a dependency of many other projects at Facebook which expose Thrift interfaces; some which have been open-sourced. Examples include edenfs, proxygen, and fboss.

This project has evolved over many years, and parts of it predate C++11. While it provides useful functionality for service information reporting, it is not representative of modern C++ coding standards.

An early version of fb303 was originally open-sourced in the Apache Thrift project in 2008, and still exists in the Apache Thrift codebase under contrib/fb303/. The fb303 code has since continued evolving at Facebook. This version contained in this repository has significantly expanded functionality with regards to statistics tracking and reporting in C++ services.

fb303's People


chadaustin avatar simpkins avatar ahornby avatar wez avatar lukaspiatkowski avatar fanzeyi avatar yfeldblum avatar shri-khare avatar xavierd avatar lnicco avatar zertosh avatar dgrnbrg-meta avatar pedroerp avatar udippant avatar snarkmaster avatar cooperlees avatar iahs avatar vitaut avatar zhxchen17 avatar jreese avatar bkoray avatar michel-slm avatar mshneer avatar krallin avatar genevievehelsel avatar mzr avatar kmancini avatar carenthomas avatar davide125 avatar shodoco avatar


 avatar Hebert  F. Barros avatar Zhao Xiaohong avatar Shabab Ayub avatar Sylwester Lachiewicz avatar rahe_alawele avatar Zeeshan Ahmad Khalil avatar Pritam Sarkar avatar Sergey Melnychuk avatar Vikram Saraph avatar day253 avatar Trevor Joynson avatar 0xRake avatar Carlo Cabrera avatar  avatar John Ohue avatar Rahul Kharde avatar Reza Eskandari avatar Simplice Fosso C. avatar HC Zhu avatar Allan Feldman avatar Kapil Sharma avatar Sebastian Liu avatar flychen50 avatar Keany Vy KHUN avatar Jon Repp avatar  avatar Nate Woods avatar Yee avatar Alex Hornby avatar chanwai1219 avatar sitch avatar Jeket avatar lilkypimp1 avatar  avatar  avatar  avatar Kim Young avatar  avatar Chrisnrick avatar  avatar Dimitrij Pinneker avatar Victor Zverovich avatar Liam Patterson avatar Gábor Mihálcz avatar Denis Denisov avatar George Kontridze avatar Yixian (May) Jiang avatar Ning Xu avatar Andrew Shin avatar  avatar ideascf avatar Udip Pant avatar theidexisted avatar


Chad Austin avatar Adam Simpkins avatar Jay Feldblum avatar James Cloos avatar Aravind Anbudurai avatar Alex Hornby avatar Arun Sathiya avatar  avatar  avatar

fb303's Issues

Tag releases?

Hi there,

I'm interested in packaging fb303 at Homebrew since it seems like it would enable useful features in our build of Watchman. However, we have a policy of building only from tagged commits.

Would you consider tagging releases in this repository? The same scheme used in other facebook repositories (e.g. folly, wangle, watchman) of weekly tags seems simple enough and works reasonably well for us.


Doesn't configure when fbthrift isn't built with python

-- Configuring done
CMake Error at build/fbcode_builder/CMake/FBPythonBinary.cmake:494 (add_dependencies):
  The dependency target "FBThrift::thrift_py.py_lib" of target
  "fb303_thrift_py.py_sources_built" does not exist.
Call Stack (most recent call first):
  build/fbcode_builder/CMake/FBThriftPyLibrary.cmake:104 (add_fb_python_library)
  build/fbcode_builder/CMake/FBThriftLibrary.cmake:63 (add_fbthrift_py_library)
  fb303/thrift/CMakeLists.txt:15 (add_fbthrift_library)

Could you please add a cmake option to turn the python support on/off?


Cmake build failing

I'm trying to get OpenR running, but I can not get an fb303 build. I hope you can help me to figure it out.

Cmake fails here:

2020-06-17T12:57:20.9023233Z CMake Error at build/fbcode_builder/CMake/FBPythonBinary.cmake:494 (add_dependencies):
2020-06-17T12:57:20.9023619Z   The dependency target "FBThrift::thrift_py.py_lib" of target
2020-06-17T12:57:20.9023761Z   "fb303_thrift_py.py_sources_built" does not exist.
2020-06-17T12:57:20.9023891Z Call Stack (most recent call first):
2020-06-17T12:57:20.9024253Z   build/fbcode_builder/CMake/FBThriftPyLibrary.cmake:104 (add_fb_python_library)
2020-06-17T12:57:20.9024424Z   build/fbcode_builder/CMake/FBThriftLibrary.cmake:63 (add_fbthrift_py_library)
2020-06-17T12:57:20.9024572Z   fb303/thrift/CMakeLists.txt:15 (add_fbthrift_library)

No idea where I can get this library from.

Full log:

2020-06-17T12:57:17.6175552Z + git clone
2020-06-17T12:57:17.6216775Z Cloning into 'fb303'...
2020-06-17T12:57:19.7658614Z + mkdir -p /usr/local/src/fb303/_build
2020-06-17T12:57:19.7669914Z + cd /usr/local/src/fb303/_build
2020-06-17T12:57:19.7671005Z + CXXFLAGS=' -fPIC'
2020-06-17T12:57:19.7671601Z + CFLAGS=' -fPIC'
2020-06-17T12:57:19.7672055Z + cmake -DBUILD_SHARED_LIBS=ON ..
2020-06-17T12:57:19.8613933Z -- The CXX compiler identification is GNU 7.5.0
2020-06-17T12:57:19.9124339Z -- The C compiler identification is GNU 7.5.0
2020-06-17T12:57:19.9248120Z -- Check for working CXX compiler: /usr/bin/c++
2020-06-17T12:57:19.9922128Z -- Check for working CXX compiler: /usr/bin/c++ - works
2020-06-17T12:57:19.9945782Z -- Detecting CXX compiler ABI info
2020-06-17T12:57:20.0782526Z -- Detecting CXX compiler ABI info - done
2020-06-17T12:57:20.0974588Z -- Detecting CXX compile features
2020-06-17T12:57:20.0982859Z -- Detecting CXX compile features - done
2020-06-17T12:57:20.1011666Z -- Check for working C compiler: /usr/bin/cc
2020-06-17T12:57:20.1592519Z -- Check for working C compiler: /usr/bin/cc - works
2020-06-17T12:57:20.8654076Z CMake Warning (dev) at /usr/local/share/cmake-3.17/Modules/FindPackageHandleStandardArgs.cmake:272 (message):
2020-06-17T12:57:20.8654449Z -- Detecting C compiler ABI info
2020-06-17T12:57:20.8658853Z   The package name passed to `find_package_handle_standard_args` (glog) does
2020-06-17T12:57:20.8659879Z   not match the name of the calling package (Glog).  This can lead to
2020-06-17T12:57:20.8660265Z -- Detecting C compiler ABI info - done
2020-06-17T12:57:20.8661104Z   problems in calling code that expects `find_package` result variables
2020-06-17T12:57:20.8661398Z -- Detecting C compile features
2020-06-17T12:57:20.8662025Z   (e.g., `_FOUND`) to follow a certain pattern.
2020-06-17T12:57:20.8662326Z -- Detecting C compile features - done
2020-06-17T12:57:20.8663394Z Call Stack (most recent call first):
2020-06-17T12:57:20.8663948Z -- Found gflags from package config /usr/lib/x86_64-linux-gnu/cmake/gflags/gflags-config.cmake
2020-06-17T12:57:20.8664798Z   build/fbcode_builder/CMake/FindGlog.cmake:17 (find_package_handle_standard_args)
2020-06-17T12:57:20.8665161Z -- Found glog: /usr/lib/x86_64-linux-gnu/  
2020-06-17T12:57:20.8666164Z   CMakeLists.txt:35 (find_package)
2020-06-17T12:57:20.8666576Z -- Looking for pthread.h
2020-06-17T12:57:20.8667785Z This warning is for project developers.  Use -Wno-dev to suppress it.
2020-06-17T12:57:20.8668021Z -- Looking for pthread.h - found
2020-06-17T12:57:20.8669067Z -- Performing Test CMAKE_HAVE_LIBC_PTHREAD
2020-06-17T12:57:20.8669762Z -- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
2020-06-17T12:57:20.8670314Z -- Looking for pthread_create in pthreads
2020-06-17T12:57:20.8670729Z -- Looking for pthread_create in pthreads - not found
2020-06-17T12:57:20.8671126Z -- Looking for pthread_create in pthread
2020-06-17T12:57:20.8671907Z -- Looking for pthread_create in pthread - found
2020-06-17T12:57:20.8672468Z -- Found Threads: TRUE  
2020-06-17T12:57:20.8673226Z -- Found Boost: /usr/local/include (found suitable version "1.69.0", minimum required is "1.51.0") found components: context filesystem program_options regex system thread chrono date_time atomic 
2020-06-17T12:57:20.8673651Z -- Found folly: /usr/local
2020-06-17T12:57:20.8674057Z -- Check if compiler accepts -pthread
2020-06-17T12:57:20.8674453Z -- Check if compiler accepts -pthread - yes
2020-06-17T12:57:20.8674832Z -- Found FBThrift: /usr/local
2020-06-17T12:57:20.8675466Z -- Found fizz: /usr/local
2020-06-17T12:57:20.8676004Z -- Found wangle: /usr/local
2020-06-17T12:57:20.8676379Z -- Found YARPL: /usr/local
2020-06-17T12:57:20.8676750Z -- Found rsocket: /usr/local
2020-06-17T12:57:20.8896041Z -- Found Python 3: /usr/bin/python3.6
2020-06-17T12:57:20.8984834Z -- Configuring done
2020-06-17T12:57:20.9023233Z CMake Error at build/fbcode_builder/CMake/FBPythonBinary.cmake:494 (add_dependencies):
2020-06-17T12:57:20.9023619Z   The dependency target "FBThrift::thrift_py.py_lib" of target
2020-06-17T12:57:20.9023761Z   "fb303_thrift_py.py_sources_built" does not exist.
2020-06-17T12:57:20.9023891Z Call Stack (most recent call first):
2020-06-17T12:57:20.9024253Z   build/fbcode_builder/CMake/FBThriftPyLibrary.cmake:104 (add_fb_python_library)
2020-06-17T12:57:20.9024424Z   build/fbcode_builder/CMake/FBThriftLibrary.cmake:63 (add_fbthrift_py_library)
2020-06-17T12:57:20.9024572Z   fb303/thrift/CMakeLists.txt:15 (add_fbthrift_library)

Enable automatic tagging

e.g. folly, proxygen, and (formerly) Thrift are given consistent tags weekly by TagIt.

As HHVM depends on the whole lot, these tags are useful for updating first-party dependencies.

Given that Proxygen now depends on fb303, it would be useful for HHVM if fb303 had these tags rather than having to manually find a roughly-corresponding rFBS, then a roughly corresponding github commit for it.

building fails with folly

When compiling fb303 for latest openr build, build fails:

/usr/bin/ccache /usr/bin/c++  -DFMT_LOCALE -DGFLAGS_IS_A_DLL=0 -I/tmp/fbcode_builder_getdeps-ZhomeZtesterZfbopenrZbuildZfbcode_builder-root/repos/ -I. -isystem /opt/facebook/gflags-pFtnO7FGNohWj2trXxCs1LJfTIHedZ2PK7-kG1OaSXE/include -isystem /opt/facebook/glog-R44LrGPBZ5Ekev3frpigEm9bl9nhgX5MwHVbIcKZDg0/include -isystem /opt/facebook/boost-7LpWNokbp7fffjv2w4hlkWWkwII6NJnUz1J5Mz-Bn6o/include -isystem /opt/facebook/double-conversion-NqKE7AnVid4b3W43A8WK4LjVfw0xFTLqUuHrTl0NFLo/include -isystem /opt/facebook/libevent-44TH0t7Nx1sKPHl68UnriEFhcTq0gOnPP1uj7eAK_Cs/include -isystem /opt/facebook/lz4-uHW3b2jq-6sYkhgHWIC5uOF5J-XvWPpVHKisDg3mybY/include -isystem /opt/facebook/zstd-R8qk54ynfKeMcTBOFbW_88TkyeP8_p31qHsrtS6PbjI/include -isystem /opt/facebook/snappy-RehFr1x9aaDGhVdf2Q0avturNagBDfDfo0XDikBq65U/include -isystem /opt/facebook/folly/include -isystem /opt/facebook/fmt-jbgZWgl9ZeHgzeb9I0aQv1Fl9vV25X4rqSmUr9iebPk/include -isystem /opt/facebook/fbthrift/include -isystem /opt/facebook/wangle/include -isystem /opt/facebook/fizz/include -isystem /opt/facebook/libsodium-dpxdMUeC3ZP7pYLJR5GciWzcq2i0SX9szlzDD0SU2zE/include -O2 -g -DNDEBUG -fPIC   -std=c++17 -MD -MT CMakeFiles/fb303.dir/fb303/detail/QuantileStatWrappers.cpp.o -MF CMakeFiles/fb303.dir/fb303/detail/QuantileStatWrappers.cpp.o.d -o CMakeFiles/fb303.dir/fb303/detail/QuantileStatWrappers.cpp.o -c /tmp/fbcode_builder_getdeps-ZhomeZtesterZfbopenrZbuildZfbcode_builder-root/repos/
In file included from /tmp/fbcode_builder_getdeps-ZhomeZtesterZfbopenrZbuildZfbcode_builder-root/repos/,
                 from /tmp/fbcode_builder_getdeps-ZhomeZtesterZfbopenrZbuildZfbcode_builder-root/repos/
/tmp/fbcode_builder_getdeps-ZhomeZtesterZfbopenrZbuildZfbcode_builder-root/repos/ In member function ‘void facebook::fb303::detail::DynamicQuantileStatWrapper<N>::addValue(double, std::chrono::_V2::steady_clock::time_point, Args&& ...)’:
/tmp/fbcode_builder_getdeps-ZhomeZtesterZfbopenrZbuildZfbcode_builder-root/repos/ error: ‘make_hazard_pointer’ is not a member of ‘folly’
   folly::hazptr_holder<> h = folly::make_hazard_pointer<>();
/tmp/fbcode_builder_getdeps-ZhomeZtesterZfbopenrZbuildZfbcode_builder-root/repos/ error: expected primary-expression before ‘>’ token
   folly::hazptr_holder<> h = folly::make_hazard_pointer<>();

Usage was introduced, but function not declared in open sourced folly

commit 1f2d757b0a9511fe9cf7f8734c0d86e5451c3d52
Author: Maged Michael <[email protected]>
Date:   Thu May 27 19:57:52 2021 -0700

    hazptr: Change hazard pointer construction to be consistent with WG21 P1121

    Change the constructors for hazptr_holder and add the function make_hazard_pointer to be consistent with [WG21 P1121](

diff --git a/fb303/detail/QuantileStatWrappers-inl.h b/fb303/detail/QuantileStatWrappers-inl.h
index 77314b22..bc16cb4e 100644
--- a/fb303/detail/QuantileStatWrappers-inl.h
+++ b/fb303/detail/QuantileStatWrappers-inl.h
@@ -57,7 +57,7 @@ void DynamicQuantileStatWrapper<N>::addValue(
     Args&&... subkeys) {
   const SubkeyArray subkeyArray{{std::forward<Args>(subkeys)...}};

-  folly::hazptr_holder<> h;
+  folly::hazptr_holder<> h = folly::make_hazard_pointer<>();
   auto mapPtr = h.protect(stats_);

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.