2020
2121#include " cpp2sky/config.h"
2222#include " cpp2sky/propagation.h"
23+ #include " cpp2sky/time.h"
2324#include " language-agent/Tracing.pb.h"
2425
2526namespace cpp2sky {
@@ -33,11 +34,73 @@ class CurrentSegmentSpan {
3334 */
3435 virtual SpanObject createSpanObject () = 0;
3536
37+ /* *
38+ * Get sampling status. If true, spans belongs to this segment will be sent to
39+ * OAP.
40+ */
41+ virtual bool samplingStatus () const = 0;
42+
3643 /* *
3744 * Get span ID.
3845 */
3946 virtual int32_t spanId () const = 0;
4047
48+ /* *
49+ * Get parent span ID.
50+ */
51+ virtual int32_t parentSpanId () const = 0;
52+
53+ /* *
54+ * Get start time.
55+ */
56+ virtual int64_t startTime () const = 0;
57+
58+ /* *
59+ * Get end time.
60+ */
61+ virtual int64_t endTime () const = 0;
62+
63+ /* *
64+ * Get peer address.
65+ */
66+ virtual const std::string& peer () const = 0;
67+
68+ /* *
69+ * Get span type.
70+ */
71+ virtual SpanType spanType () const = 0;
72+
73+ /* *
74+ * Get span layer.
75+ */
76+ virtual SpanLayer spanLayer () const = 0;
77+
78+ /* *
79+ * Get error occurred or not.
80+ */
81+ virtual bool errorStatus () const = 0;
82+
83+ /* *
84+ * Enable to skip analysis or not.
85+ */
86+ virtual bool skipAnalysis () const = 0;
87+
88+ /* *
89+ * Get component ID.
90+ */
91+ virtual int32_t componentId () const = 0;
92+
93+ /* *
94+ * Get tags.
95+ */
96+ virtual const std::vector<std::pair<std::string, std::string>>& tags ()
97+ const = 0;
98+
99+ /* *
100+ * Get logs.
101+ */
102+ virtual const std::vector<Log>& logs () const = 0;
103+
41104 /* *
42105 * Get operation name.
43106 */
@@ -51,17 +114,21 @@ class CurrentSegmentSpan {
51114 /* *
52115 * Set start time to calculate execution time.
53116 */
54- virtual void setStartTime (int64_t start_time) = 0;
117+ virtual void startSpan () = 0;
118+ virtual void startSpan (TimePoint<SystemTime> current_time) = 0;
119+ virtual void startSpan (TimePoint<SteadyTime> current_time) = 0;
55120
56121 /* *
57122 * Set end time to calculate execution time.
58123 */
59- virtual void setEndTime (int64_t end_time) = 0;
124+ virtual void endSpan () = 0;
125+ virtual void endSpan (TimePoint<SystemTime> current_time) = 0;
126+ virtual void endSpan (TimePoint<SteadyTime> current_time) = 0;
60127
61128 /* *
62129 * Set operation name for this span (lvalue)
63130 */
64- virtual void setOperationName (std::string& operation_name) = 0;
131+ virtual void setOperationName (const std::string& operation_name) = 0;
65132
66133 /* *
67134 * Set operation name for this span (rvalue)
@@ -71,7 +138,7 @@ class CurrentSegmentSpan {
71138 /* *
72139 * Set peer address for this span (lvalue)
73140 */
74- virtual void setPeer (std::string& remote_address) = 0;
141+ virtual void setPeer (const std::string& remote_address) = 0;
75142
76143 /* *
77144 * Set peer address for this span (rvalue)
@@ -104,7 +171,7 @@ class CurrentSegmentSpan {
104171 /* *
105172 * Set tag to current span. (lvalue)
106173 */
107- virtual void addTag (std::string& key, std::string& value) = 0;
174+ virtual void addTag (const std::string& key, const std::string& value) = 0;
108175
109176 /* *
110177 * Set tag to current span. (rvalue)
@@ -113,8 +180,26 @@ class CurrentSegmentSpan {
113180
114181 /* *
115182 * Add log related with current span.
183+ * @param set_time To determine whether to set actual time or not.
184+ * This value is introduced for unit-test.
185+ */
186+ virtual void addLog (const std::string& key, const std::string& value,
187+ bool set_time = true ) = 0;
188+
189+ /* *
190+ * Set component ID.
191+ */
192+ virtual void setComponentId (int32_t component_id) = 0;
193+
194+ /* *
195+ * This span had finished or not.
196+ */
197+ virtual bool finished () const = 0;
198+
199+ /* *
200+ * Change sampling status. If true, it will be sampled.
116201 */
117- virtual void addLog ( int64_t time, std::string& key, std::string& value ) = 0;
202+ virtual void setSamplingStatus ( bool do_sample ) = 0;
118203};
119204
120205using CurrentSegmentSpanPtr = std::shared_ptr<CurrentSegmentSpan>;
0 commit comments