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-exception |
6 | // |
7 | //===----------------------------------------------------------------------===// |
8 | /// |
9 | /// \file |
10 | /// 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 | |
16 | namespace llvm { |
17 | namespace telemetry { |
18 | |
19 | void TelemetryInfo::serialize(Serializer &serializer) const { |
20 | serializer.write(KeyName: "SessionId", Value: SessionId); |
21 | } |
22 | |
23 | Error 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(E1: std::move(AllErrs), E2: Dest->receiveEntry(Entry)); |
32 | } |
33 | return AllErrs; |
34 | } |
35 | |
36 | void Manager::addDestination(std::unique_ptr<Destination> Dest) { |
37 | Destinations.push_back(x: std::move(Dest)); |
38 | } |
39 | |
40 | Error Manager::preDispatch(TelemetryInfo *Entry) { return Error::success(); } |
41 | |
42 | } // namespace telemetry |
43 | } // namespace llvm |
44 |