46
46
*/
47
47
public final class AggregateByLabelMetricTimeSeriesBuilder implements MetricTimeSeriesBuilder {
48
48
49
- public static final String LABEL_INSTRUMENTATION_LIBRARY_NAME = "instrumentation_source" ;
50
- public static final String LABEL_INSTRUMENTATION_LIBRARY_VERSION = "instrumentation_version" ;
49
+ public static final String LABEL_INSTRUMENTATION_SOURCE =
50
+ "instrumentation_source" ; // name of the instrumentation source
51
+ public static final String LABEL_INSTRUMENTATION_VERSION =
52
+ "instrumentation_version" ; // version of the instrumentation source
51
53
52
54
private final Map <String , MetricDescriptor > descriptors = new HashMap <>();
53
55
private final Map <MetricWithLabels , TimeSeries .Builder > pendingTimeSeries = new HashMap <>();
@@ -61,7 +63,7 @@ public AggregateByLabelMetricTimeSeriesBuilder(String projectId, String prefix)
61
63
62
64
@ Override
63
65
public void recordPoint (MetricData metricData , LongPointData pointData ) {
64
- recordPoint (
66
+ recordPointInTimeSeries (
65
67
metricData ,
66
68
pointData ,
67
69
Point .newBuilder ()
@@ -72,7 +74,7 @@ public void recordPoint(MetricData metricData, LongPointData pointData) {
72
74
73
75
@ Override
74
76
public void recordPoint (MetricData metricData , DoublePointData pointData ) {
75
- recordPoint (
77
+ recordPointInTimeSeries (
76
78
metricData ,
77
79
pointData ,
78
80
Point .newBuilder ()
@@ -83,7 +85,7 @@ public void recordPoint(MetricData metricData, DoublePointData pointData) {
83
85
84
86
@ Override
85
87
public void recordPoint (MetricData metricData , HistogramPointData pointData ) {
86
- recordPoint (
88
+ recordPointInTimeSeries (
87
89
metricData ,
88
90
pointData ,
89
91
Point .newBuilder ()
@@ -93,7 +95,7 @@ public void recordPoint(MetricData metricData, HistogramPointData pointData) {
93
95
.build ());
94
96
}
95
97
96
- private void recordPoint (MetricData metric , PointData point , Point builtPoint ) {
98
+ private void recordPointInTimeSeries (MetricData metric , PointData point , Point builtPoint ) {
97
99
MetricDescriptor descriptor = mapMetricDescriptor (this .prefix , metric , point );
98
100
if (descriptor == null ) {
99
101
// Unsupported type.
@@ -121,10 +123,10 @@ private Attributes attachInstrumentationLibraryLabels(
121
123
Attributes attributes , InstrumentationScopeInfo instrumentationScopeInfo ) {
122
124
return attributes .toBuilder ()
123
125
.put (
124
- AttributeKey .stringKey (LABEL_INSTRUMENTATION_LIBRARY_NAME ),
126
+ AttributeKey .stringKey (LABEL_INSTRUMENTATION_SOURCE ),
125
127
instrumentationScopeInfo .getName ())
126
128
.put (
127
- AttributeKey .stringKey (LABEL_INSTRUMENTATION_LIBRARY_VERSION ),
129
+ AttributeKey .stringKey (LABEL_INSTRUMENTATION_VERSION ),
128
130
Objects .requireNonNullElse (instrumentationScopeInfo .getVersion (), "" ))
129
131
.build ();
130
132
}
@@ -136,6 +138,8 @@ public Collection<MetricDescriptor> getDescriptors() {
136
138
137
139
@ Override
138
140
public List <TimeSeries > getTimeSeries () {
139
- return pendingTimeSeries .values ().stream ().map (b -> b .build ()).collect (Collectors .toList ());
141
+ return pendingTimeSeries .values ().stream ()
142
+ .map (TimeSeries .Builder ::build )
143
+ .collect (Collectors .toList ());
140
144
}
141
145
}
0 commit comments