File tree Expand file tree Collapse file tree
main/java/io/opentelemetry/sdk/metrics
test/java/io/opentelemetry/sdk/metrics Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1919/** Helper to make implementing builders easier. */
2020abstract class AbstractInstrumentBuilder <BuilderT extends AbstractInstrumentBuilder <?>> {
2121
22- static final String DEFAULT_UNIT = "1 " ;
22+ static final String DEFAULT_UNIT = "" ;
2323
2424 private final MeterProviderSharedState meterProviderSharedState ;
2525 private String description ;
@@ -45,7 +45,8 @@ abstract class AbstractInstrumentBuilder<BuilderT extends AbstractInstrumentBuil
4545
4646 public BuilderT setUnit (String unit ) {
4747 if (!ValidationUtil .checkValidInstrumentUnit (
48- unit , " Using " + DEFAULT_UNIT + " for instrument " + this .instrumentName + " instead." )) {
48+ unit ,
49+ " Using \" " + DEFAULT_UNIT + "\" for instrument " + this .instrumentName + " instead." )) {
4950 this .unit = DEFAULT_UNIT ;
5051 } else {
5152 this .unit = unit ;
Original file line number Diff line number Diff line change @@ -290,15 +290,14 @@ void sameMeterConflictingInstrumentUnitNoViews() {
290290 .hasLongSum ()
291291 .points ()
292292 .satisfiesExactly (point -> assertThat (point ).hasValue (10 )),
293- metricData -> {
294- assertThat (metricData )
295- .hasInstrumentationScope (forMeter ("meter1" ))
296- .hasName ("counter1" )
297- .hasLongSum ()
298- .points ()
299- .satisfiesExactly (point -> assertThat (point ).hasValue (10 ));
300- assertThat (metricData .getUnit ()).isEqualTo ("1" );
301- });
293+ metricData ->
294+ assertThat (metricData )
295+ .hasInstrumentationScope (forMeter ("meter1" ))
296+ .hasName ("counter1" )
297+ .hasUnit ("" )
298+ .hasLongSum ()
299+ .points ()
300+ .satisfiesExactly (point -> assertThat (point ).hasValue (10 )));
302301
303302 assertThat (metricStorageRegistryLogs .getEvents ())
304303 .allSatisfy (
Original file line number Diff line number Diff line change @@ -131,7 +131,7 @@ void collectMetrics_WithMultipleCollects() {
131131 .hasInstrumentationScope (INSTRUMENTATION_SCOPE_INFO )
132132 .hasName ("testCounter" )
133133 .hasDescription ("" )
134- .hasUnit ("1 " )
134+ .hasUnit ("" )
135135 .hasDoubleSum ()
136136 .isMonotonic ()
137137 .isCumulative ()
Original file line number Diff line number Diff line change @@ -115,7 +115,7 @@ void collectAllSyncInstruments() {
115115 .hasResource (RESOURCE )
116116 .hasInstrumentationScope (INSTRUMENTATION_SCOPE_INFO )
117117 .hasDescription ("" )
118- .hasUnit ("1 " ))
118+ .hasUnit ("" ))
119119 .satisfiesExactlyInAnyOrder (
120120 metric ->
121121 assertThat (metric )
@@ -284,7 +284,7 @@ void collectAllSyncInstruments_DeltaHistogram() {
284284 .hasResource (RESOURCE )
285285 .hasInstrumentationScope (INSTRUMENTATION_SCOPE_INFO )
286286 .hasDescription ("" )
287- .hasUnit ("1 " )
287+ .hasUnit ("" )
288288 .hasDoubleHistogram ()
289289 .isDelta ()
290290 .points ()
@@ -313,7 +313,7 @@ void collectAllSyncInstruments_DeltaHistogram() {
313313 .hasResource (RESOURCE )
314314 .hasInstrumentationScope (INSTRUMENTATION_SCOPE_INFO )
315315 .hasDescription ("" )
316- .hasUnit ("1 " )
316+ .hasUnit ("" )
317317 .hasDoubleHistogram ()
318318 .isDelta ()
319319 .points ()
@@ -365,7 +365,7 @@ void collectAllAsyncInstruments() {
365365 .hasResource (RESOURCE )
366366 .hasInstrumentationScope (INSTRUMENTATION_SCOPE_INFO )
367367 .hasDescription ("" )
368- .hasUnit ("1 " ))
368+ .hasUnit ("" ))
369369 .satisfiesExactlyInAnyOrder (
370370 metric ->
371371 assertThat (metric )
Original file line number Diff line number Diff line change @@ -135,7 +135,7 @@ void builder_InvalidUnit() {
135135 .allMatch (
136136 log ->
137137 log .equals (
138- "Unit \" 日\" is invalid. Instrument unit must be 63 or less ASCII characters. Using 1 for instrument my-instrument instead." ));
138+ "Unit \" 日\" is invalid. Instrument unit must be 63 or less ASCII characters. Using \" \" for instrument my-instrument instead." ));
139139 }
140140
141141 @ Test
You can’t perform that action at this time.
0 commit comments