19
19
package org .apache .synapse .aspects .flow .statistics .opentracing .management .helpers ;
20
20
21
21
import io .opentracing .Span ;
22
- import org .apache .synapse .MessageContext ;
23
- import org .apache .synapse .aspects .flow .statistics .data .raw .BasicStatisticDataUnit ;
24
- import org .apache .synapse .aspects .flow .statistics .data .raw .StatisticDataUnit ;
25
22
import org .apache .synapse .aspects .flow .statistics .data .raw .StatisticsLog ;
26
23
import org .apache .synapse .aspects .flow .statistics .opentracing .OpenTracingManagerHolder ;
27
24
import org .apache .synapse .aspects .flow .statistics .opentracing .models .SpanWrapper ;
@@ -40,37 +37,45 @@ private SpanTagger() {}
40
37
* Sets tags to the span which is contained in the provided span wrapper, from information acquired from the
41
38
* given basic statistic data unit.
42
39
* @param spanWrapper Span wrapper that contains the target span.
43
- * @param basicStatisticDataUnit Basic statistic data unit from which, tag data will be acquired.
44
40
*/
45
- public static void setSpanTags (SpanWrapper spanWrapper , BasicStatisticDataUnit basicStatisticDataUnit ) {
46
- StatisticsLog statisticsLog = new StatisticsLog (spanWrapper .getStatisticDataUnit ());
41
+ public static void setSpanTags (SpanWrapper spanWrapper ) {
42
+ StatisticsLog openStatisticsLog = new StatisticsLog (spanWrapper .getStatisticDataUnit ());
47
43
Span span = spanWrapper .getSpan ();
48
- if (basicStatisticDataUnit instanceof StatisticDataUnit ) {
49
- if (OpenTracingManagerHolder .isCollectingPayloads () || OpenTracingManagerHolder . isCollectingProperties () ) {
50
- StatisticDataUnit endEventDataUnit = ( StatisticDataUnit ) basicStatisticDataUnit ;
51
-
52
- if ( OpenTracingManagerHolder . isCollectingPayloads ()) {
53
- statisticsLog . setAfterPayload ( endEventDataUnit . getPayload ());
54
- span . setTag ( "beforePayload" , statisticsLog . getBeforePayload ());
55
- span .setTag ("afterPayload" , statisticsLog . getAfterPayload ());
44
+ if (OpenTracingManagerHolder . isCollectingPayloads () || OpenTracingManagerHolder . isCollectingProperties () ) {
45
+ if (OpenTracingManagerHolder .isCollectingPayloads ()) {
46
+ span . setTag ( "beforePayload" , openStatisticsLog . getBeforePayload ()) ;
47
+ if ( spanWrapper . getCloseEventStatisticDataUnit () != null ) {
48
+ span . setTag ( "afterPayload" , spanWrapper . getCloseEventStatisticDataUnit (). getPayload ());
49
+ } else {
50
+ //This means a close event hasn't been triggered so payload is equal to before payload
51
+ span .setTag ("afterPayload" , openStatisticsLog . getBeforePayload ());
56
52
}
53
+ }
57
54
58
- if (OpenTracingManagerHolder .isCollectingProperties ()) {
59
- if (spanWrapper .getStatisticDataUnit ().getContextPropertyMap () != null ) {
60
- span .setTag ("beforeContextPropertyMap" ,
61
- spanWrapper .getStatisticDataUnit ().getContextPropertyMap ().toString ());
62
- }
63
- if (statisticsLog .getContextPropertyMap () != null ) {
64
- span .setTag ("afterContextPropertyMap" , statisticsLog .getContextPropertyMap ().toString ());
55
+ if (OpenTracingManagerHolder .isCollectingProperties ()) {
56
+ if (spanWrapper .getStatisticDataUnit ().getContextPropertyMap () != null ) {
57
+ span .setTag ("beforeContextPropertyMap" ,
58
+ spanWrapper .getStatisticDataUnit ().getContextPropertyMap ().toString ());
59
+ }
60
+ if (spanWrapper .getCloseEventStatisticDataUnit () != null ) {
61
+ if (spanWrapper .getCloseEventStatisticDataUnit ().getContextPropertyMap () != null ) {
62
+ span .setTag ("afterContextPropertyMap" ,
63
+ spanWrapper .getCloseEventStatisticDataUnit ().getContextPropertyMap ().toString ());
65
64
}
65
+ } else if (openStatisticsLog .getContextPropertyMap () != null ) {
66
+ span .setTag ("afterContextPropertyMap" , openStatisticsLog .getContextPropertyMap ().toString ());
67
+ }
68
+ if (spanWrapper .getCloseEventStatisticDataUnit () != null &&
69
+ spanWrapper .getCloseEventStatisticDataUnit ().getPropertyValue () != null ) {
70
+ span .setTag ("propertyMediatorValue" ,
71
+ spanWrapper .getCloseEventStatisticDataUnit ().getPropertyValue ());
66
72
}
67
73
}
68
-
69
- span .setTag ("componentName" , statisticsLog .getComponentName ());
70
- span .setTag ("componentType" , statisticsLog .getComponentTypeToString ());
71
- span .setTag ("threadId" , Thread .currentThread ().getId ());
72
- span .setTag ("componentId" , statisticsLog .getComponentId ());
73
- span .setTag ("hashcode" , statisticsLog .getHashCode ());
74
74
}
75
+ span .setTag ("componentName" , openStatisticsLog .getComponentName ());
76
+ span .setTag ("componentType" , openStatisticsLog .getComponentTypeToString ());
77
+ span .setTag ("threadId" , Thread .currentThread ().getId ());
78
+ span .setTag ("componentId" , openStatisticsLog .getComponentId ());
79
+ span .setTag ("hashcode" , openStatisticsLog .getHashCode ());
75
80
}
76
81
}
0 commit comments