-
Notifications
You must be signed in to change notification settings - Fork 334
Expand file tree
/
Copy pathOtelInstrumentationScope.java
More file actions
65 lines (54 loc) · 1.84 KB
/
OtelInstrumentationScope.java
File metadata and controls
65 lines (54 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package datadog.opentelemetry.shim;
import datadog.trace.bootstrap.instrumentation.api.UTF8BytesString;
import java.util.Objects;
import javax.annotation.Nullable;
/** Instrumentation scopes have a mandatory name, optional version, and optional schema URL. */
public final class OtelInstrumentationScope {
private final UTF8BytesString scopeName;
@Nullable private final UTF8BytesString scopeVersion;
@Nullable private final UTF8BytesString schemaUrl;
public OtelInstrumentationScope(
String scopeName, @Nullable String scopeVersion, @Nullable String schemaUrl) {
this.scopeName = UTF8BytesString.create(scopeName);
this.scopeVersion = UTF8BytesString.create(scopeVersion);
this.schemaUrl = UTF8BytesString.create(schemaUrl);
}
public UTF8BytesString getName() {
return scopeName;
}
@Nullable
public UTF8BytesString getVersion() {
return scopeVersion;
}
@Nullable
public UTF8BytesString getSchemaUrl() {
return schemaUrl;
}
@Override
public boolean equals(Object o) {
if (!(o instanceof OtelInstrumentationScope)) {
return false;
}
OtelInstrumentationScope that = (OtelInstrumentationScope) o;
return scopeName.equals(that.scopeName)
&& Objects.equals(scopeVersion, that.scopeVersion)
&& Objects.equals(schemaUrl, that.schemaUrl);
}
@Override
public int hashCode() {
int result = scopeName.hashCode();
result = 31 * result + Objects.hashCode(scopeVersion);
result = 31 * result + Objects.hashCode(schemaUrl);
return result;
}
@Override
public String toString() {
// use same property names as OTel in toString
return "OtelInstrumentationScope{"
+ "name='"
+ scopeName
+ (scopeVersion != null ? "', version='" + scopeVersion : "")
+ (schemaUrl != null ? "', schemaUrl='" + schemaUrl : "")
+ "'}";
}
}