]>
Commit | Line | Data |
---|---|---|
f67539c2 TL |
1 | /* |
2 | * Copyright (c) 2017 Uber Technologies, Inc. | |
3 | * | |
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | * you may not use this file except in compliance with the License. | |
6 | * You may obtain a copy of the License at | |
7 | * | |
8 | * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | * | |
10 | * Unless required by applicable law or agreed to in writing, software | |
11 | * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | * See the License for the specific language governing permissions and | |
14 | * limitations under the License. | |
15 | */ | |
16 | ||
17 | #ifndef JAEGERTRACING_LOGRECORD_H | |
18 | #define JAEGERTRACING_LOGRECORD_H | |
19 | ||
20 | #include "jaegertracing/Compilers.h" | |
21 | #include "jaegertracing/Tag.h" | |
22 | #include <algorithm> | |
23 | #include <chrono> | |
24 | #include <iterator> | |
25 | #include <type_traits> | |
26 | #include <vector> | |
27 | ||
28 | #include <opentracing/span.h> | |
29 | ||
30 | namespace jaegertracing { | |
31 | namespace thrift { | |
32 | class Log; | |
33 | } | |
34 | ||
35 | class LogRecord { | |
36 | public: | |
37 | using Clock = std::chrono::system_clock; | |
38 | ||
39 | LogRecord() | |
40 | : _timestamp(Clock::now()) | |
41 | { | |
42 | } | |
43 | ||
44 | template <typename FieldIterator> | |
45 | LogRecord(const Clock::time_point& timestamp, | |
46 | FieldIterator first, | |
47 | FieldIterator last) | |
48 | : _timestamp(timestamp) | |
49 | , _fields(first, last) | |
50 | { | |
51 | } | |
52 | ||
53 | LogRecord(const opentracing::LogRecord& other) | |
54 | : _timestamp(other.timestamp) | |
55 | , _fields(other.fields.begin(), other.fields.end()) | |
56 | { | |
57 | } | |
58 | ||
59 | const Clock::time_point& timestamp() const { return _timestamp; } | |
60 | ||
61 | const std::vector<Tag>& fields() const { return _fields; } | |
62 | ||
63 | void thrift(thrift::Log& log) const; | |
64 | ||
65 | private: | |
66 | Clock::time_point _timestamp; | |
67 | std::vector<Tag> _fields; | |
68 | }; | |
69 | ||
70 | } // namespace jaegertracing | |
71 | ||
72 | #endif // JAEGERTRACING_LOGRECORD_H |