44 lines · cpp
1//===----------------------------------------------------------------------===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8///9/// \file10/// This file provides the basic framework for Telemetry.11/// Refer to its documentation at llvm/docs/Telemetry.rst for more details.12//===---------------------------------------------------------------------===//13 14#include "llvm/Telemetry/Telemetry.h"15 16namespace llvm {17namespace telemetry {18 19void TelemetryInfo::serialize(Serializer &serializer) const {20 serializer.write("SessionId", SessionId);21}22 23Error Manager::dispatch(TelemetryInfo *Entry) {24 assert(Config::BuildTimeEnableTelemetry &&25 "Telemetry should have been enabled");26 if (Error Err = preDispatch(Entry))27 return Err;28 29 Error AllErrs = Error::success();30 for (auto &Dest : Destinations) {31 AllErrs = joinErrors(std::move(AllErrs), Dest->receiveEntry(Entry));32 }33 return AllErrs;34}35 36void Manager::addDestination(std::unique_ptr<Destination> Dest) {37 Destinations.push_back(std::move(Dest));38}39 40Error Manager::preDispatch(TelemetryInfo *Entry) { return Error::success(); }41 42} // namespace telemetry43} // namespace llvm44