11package datadog .opentelemetry .shim .metrics ;
22
3+ import datadog .trace .bootstrap .instrumentation .api .UTF8BytesString ;
34import java .util .Locale ;
45import java .util .Objects ;
56import javax .annotation .Nullable ;
67
78/** Uniquely describes an instrument for the Meter that created it. */
89public final class OtelInstrumentDescriptor {
9- private final String instrumentName ;
10+ private final UTF8BytesString instrumentName ;
1011 private final OtelInstrumentType instrumentType ;
1112 private final boolean longValues ;
12- @ Nullable private final String description ;
13- @ Nullable private final String unit ;
13+ @ Nullable private final UTF8BytesString description ;
14+ @ Nullable private final UTF8BytesString unit ;
1415
1516 OtelInstrumentDescriptor (
1617 String instrumentName ,
1718 OtelInstrumentType instrumentType ,
1819 boolean longValues ,
1920 @ Nullable String description ,
2021 @ Nullable String unit ) {
21- this .instrumentName = instrumentName ;
22+ this .instrumentName = UTF8BytesString . create ( instrumentName ) ;
2223 this .instrumentType = instrumentType ;
2324 this .longValues = longValues ;
24- this .description = description ;
25- this .unit = unit ;
25+ this .description = UTF8BytesString . create ( description ) ;
26+ this .unit = UTF8BytesString . create ( unit ) ;
2627 }
2728
28- public String getName () {
29+ public UTF8BytesString getName () {
2930 return instrumentName ;
3031 }
3132
@@ -38,12 +39,12 @@ public boolean hasLongValues() {
3839 }
3940
4041 @ Nullable
41- public String getDescription () {
42+ public UTF8BytesString getDescription () {
4243 return description ;
4344 }
4445
4546 @ Nullable
46- public String getUnit () {
47+ public UTF8BytesString getUnit () {
4748 return unit ;
4849 }
4950
@@ -54,7 +55,7 @@ public boolean equals(Object o) {
5455 }
5556
5657 OtelInstrumentDescriptor that = (OtelInstrumentDescriptor ) o ;
57- return instrumentName .equalsIgnoreCase (that .instrumentName )
58+ return instrumentName .toString (). equalsIgnoreCase (that .instrumentName . toString () )
5859 && instrumentType == that .instrumentType
5960 && longValues == that .longValues
6061 && Objects .equals (description , that .description )
@@ -63,7 +64,7 @@ public boolean equals(Object o) {
6364
6465 @ Override
6566 public int hashCode () {
66- int result = instrumentName .toLowerCase (Locale .ROOT ).hashCode ();
67+ int result = instrumentName .toString (). toLowerCase (Locale .ROOT ).hashCode ();
6768 result = 31 * result + instrumentType .hashCode ();
6869 result = 31 * result + Boolean .hashCode (longValues );
6970 result = 31 * result + Objects .hashCode (description );
0 commit comments