forked from aws-observability/aws-otel-java-instrumentation
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathopentelemetry-java-contrib.patch
More file actions
237 lines (223 loc) · 9.71 KB
/
opentelemetry-java-contrib.patch
File metadata and controls
237 lines (223 loc) · 9.71 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
diff --git a/aws-xray/src/main/java/io/opentelemetry/contrib/awsxray/SamplingRuleApplier.java b/aws-xray/src/main/java/io/opentelemetry/contrib/awsxray/SamplingRuleApplier.java
index 1ef8abf..ef84f35 100644
--- a/aws-xray/src/main/java/io/opentelemetry/contrib/awsxray/SamplingRuleApplier.java
+++ b/aws-xray/src/main/java/io/opentelemetry/contrib/awsxray/SamplingRuleApplier.java
@@ -35,6 +35,11 @@ final class SamplingRuleApplier {
private static final Map<String, String> XRAY_CLOUD_PLATFORM;
+ private static final AttributeKey<String> URL_PATH = AttributeKey.stringKey("url.path");
+ private static final AttributeKey<String> URL_FULL = AttributeKey.stringKey("url.full");
+ private static final AttributeKey<String> HTTP_REQUEST_METHOD =
+ AttributeKey.stringKey("http.request.method");
+
static {
Map<String, String> xrayCloudPlatform = new HashMap<>();
xrayCloudPlatform.put(ResourceAttributes.CloudPlatformValues.AWS_EC2, "AWS::EC2::Instance");
@@ -162,11 +167,14 @@ final class SamplingRuleApplier {
String host = null;
for (Map.Entry<AttributeKey<?>, Object> entry : attributes.asMap().entrySet()) {
- if (entry.getKey().equals(SemanticAttributes.HTTP_TARGET)) {
+ if (entry.getKey().equals(SemanticAttributes.HTTP_TARGET)
+ || entry.getKey().equals(URL_PATH)) {
httpTarget = (String) entry.getValue();
- } else if (entry.getKey().equals(SemanticAttributes.HTTP_URL)) {
+ } else if (entry.getKey().equals(SemanticAttributes.HTTP_URL)
+ || entry.getKey().equals(URL_FULL)) {
httpUrl = (String) entry.getValue();
- } else if (entry.getKey().equals(SemanticAttributes.HTTP_METHOD)) {
+ } else if (entry.getKey().equals(SemanticAttributes.HTTP_METHOD)
+ || entry.getKey().equals(HTTP_REQUEST_METHOD)) {
httpMethod = (String) entry.getValue();
} else if (entry.getKey().equals(SemanticAttributes.NET_HOST_NAME)) {
host = (String) entry.getValue();
diff --git a/aws-xray/src/test/java/io/opentelemetry/contrib/awsxray/SamplingRuleApplierTest.java b/aws-xray/src/test/java/io/opentelemetry/contrib/awsxray/SamplingRuleApplierTest.java
index 6bb6e82..55dabbd 100644
--- a/aws-xray/src/test/java/io/opentelemetry/contrib/awsxray/SamplingRuleApplierTest.java
+++ b/aws-xray/src/test/java/io/opentelemetry/contrib/awsxray/SamplingRuleApplierTest.java
@@ -42,6 +42,11 @@ class SamplingRuleApplierTest {
private static final String CLIENT_ID = "test-client-id";
+ private static final AttributeKey<String> URL_PATH = AttributeKey.stringKey("url.path");
+ private static final AttributeKey<String> URL_FULL = AttributeKey.stringKey("url.full");
+ private static final AttributeKey<String> HTTP_REQUEST_METHOD =
+ AttributeKey.stringKey("http.request.method");
+
@Nested
@SuppressWarnings("ClassCanBeStatic")
class ExactMatch {
@@ -68,6 +73,15 @@ class SamplingRuleApplierTest {
.put(AttributeKey.longKey("speed"), 10)
.build();
+ private final Attributes newSemCovAttributes =
+ Attributes.builder()
+ .put(HTTP_REQUEST_METHOD, "GET")
+ .put(SemanticAttributes.NET_HOST_NAME, "opentelemetry.io")
+ .put(URL_PATH, "/instrument-me")
+ .put(AttributeKey.stringKey("animal"), "cat")
+ .put(AttributeKey.longKey("speed"), 10)
+ .build();
+
// FixedRate set to 1.0 in rule and no reservoir
@Test
void fixedRateAlwaysSample() {
@@ -116,6 +130,21 @@ class SamplingRuleApplierTest {
.isTrue();
}
+ @Test
+ void matchesURLFullNewSemCov() {
+ assertThat(applier.matches(newSemCovAttributes, resource)).isTrue();
+
+ // http.url works too
+ assertThat(
+ applier.matches(
+ attributes.toBuilder()
+ .remove(URL_FULL)
+ .put(URL_FULL, "scheme://host:port/instrument-me")
+ .build(),
+ resource))
+ .isTrue();
+ }
+
@Test
void serviceNameNotMatch() {
assertThat(
@@ -137,6 +166,13 @@ class SamplingRuleApplierTest {
assertThat(applier.matches(attributes, resource)).isFalse();
}
+ @Test
+ void methodNewSemCovNotMatch() {
+ Attributes attributes =
+ this.newSemCovAttributes.toBuilder().put(HTTP_REQUEST_METHOD, "POST").build();
+ assertThat(applier.matches(attributes, resource)).isFalse();
+ }
+
@Test
void hostNotMatch() {
// Replacing dot with character makes sure we're not accidentally treating dot as regex
@@ -178,6 +214,34 @@ class SamplingRuleApplierTest {
assertThat(applier.matches(attributes, resource)).isFalse();
}
+ @Test
+ void pathNewSemCovNotMatch() {
+ Attributes attributes =
+ this.newSemCovAttributes.toBuilder().put(URL_PATH, "/instrument-you").build();
+ assertThat(applier.matches(attributes, resource)).isFalse();
+ attributes =
+ this.newSemCovAttributes.toBuilder()
+ .remove(URL_PATH)
+ .put(URL_FULL, "scheme://host:port/instrument-you")
+ .build();
+ assertThat(applier.matches(attributes, resource)).isFalse();
+ attributes =
+ this.newSemCovAttributes.toBuilder()
+ .remove(URL_PATH)
+ .put(URL_FULL, "scheme://host:port")
+ .build();
+ assertThat(applier.matches(attributes, resource)).isFalse();
+
+ // Correct path, but we ignore anyways since the URL is malformed per spec, scheme is always
+ // present.
+ attributes =
+ this.newSemCovAttributes.toBuilder()
+ .remove(URL_PATH)
+ .put(URL_FULL, "host:port/instrument-me")
+ .build();
+ assertThat(applier.matches(attributes, resource)).isFalse();
+ }
+
@Test
void attributeNotMatch() {
Attributes attributes =
@@ -243,6 +307,15 @@ class SamplingRuleApplierTest {
.put(AttributeKey.longKey("speed"), 10)
.build();
+ private final Attributes newSemCovAttributes =
+ Attributes.builder()
+ .put(HTTP_REQUEST_METHOD, "GET")
+ .put(SemanticAttributes.NET_HOST_NAME, "opentelemetry.io")
+ .put(URL_PATH, "/instrument-me?foo=bar&cat=meow")
+ .put(AttributeKey.stringKey("animal"), "cat")
+ .put(AttributeKey.longKey("speed"), 10)
+ .build();
+
// FixedRate set to 0.0 in rule and no reservoir
@Test
void fixedRateNeverSample() {
@@ -329,6 +402,26 @@ class SamplingRuleApplierTest {
assertThat(applier.matches(attributes, resource)).isFalse();
}
+ @Test
+ void newSemCovMethodMatches() {
+ Attributes attributes =
+ this.newSemCovAttributes.toBuilder().put(HTTP_REQUEST_METHOD, "BADGETGOOD").build();
+ assertThat(applier.matches(attributes, resource)).isTrue();
+ attributes = newSemCovAttributes.toBuilder().put(HTTP_REQUEST_METHOD, "BADGET").build();
+ assertThat(applier.matches(attributes, resource)).isTrue();
+ attributes = newSemCovAttributes.toBuilder().put(HTTP_REQUEST_METHOD, "GETGET").build();
+ assertThat(applier.matches(attributes, resource)).isTrue();
+ }
+
+ @Test
+ void newSemCovMethodNotMatch() {
+ Attributes attributes =
+ newSemCovAttributes.toBuilder().put(HTTP_REQUEST_METHOD, "POST").build();
+ assertThat(applier.matches(attributes, resource)).isFalse();
+ attributes = removeAttribute(newSemCovAttributes, HTTP_REQUEST_METHOD);
+ assertThat(applier.matches(attributes, resource)).isFalse();
+ }
+
@Test
void hostMatches() {
Attributes attributes =
@@ -410,6 +503,29 @@ class SamplingRuleApplierTest {
assertThat(applier.matches(attributes, resource)).isFalse();
}
+ @Test
+ void pathNewSemCovMatches() {
+ Attributes attributes =
+ newSemCovAttributes.toBuilder().put(URL_PATH, "/instrument-me?foo=bar&cat=").build();
+ assertThat(applier.matches(attributes, resource)).isTrue();
+ // Deceptive question mark, it's actually a wildcard :-)
+ attributes =
+ newSemCovAttributes.toBuilder().put(URL_PATH, "/instrument-meafoo=bar&cat=").build();
+ assertThat(applier.matches(attributes, resource)).isTrue();
+ }
+
+ @Test
+ void pathNewSemCovNotMatch() {
+ Attributes attributes =
+ newSemCovAttributes.toBuilder().put(URL_PATH, "/instrument-mea?foo=bar&cat=").build();
+ assertThat(applier.matches(attributes, resource)).isFalse();
+ attributes =
+ newSemCovAttributes.toBuilder().put(URL_PATH, "foo/instrument-meafoo=bar&cat=").build();
+ assertThat(applier.matches(attributes, resource)).isFalse();
+ attributes = removeAttribute(newSemCovAttributes, URL_PATH);
+ assertThat(applier.matches(attributes, resource)).isFalse();
+ }
+
@Test
void attributeMatches() {
Attributes attributes =
diff --git a/disk-buffering/build.gradle.kts b/disk-buffering/build.gradle.kts
index 041d2e9..e3d60f4 100644
--- a/disk-buffering/build.gradle.kts
+++ b/disk-buffering/build.gradle.kts
@@ -70,6 +70,10 @@ tasks.named<ShadowJar>("shadowJar") {
mustRunAfter("jar")
}
+tasks.withType<Test>().configureEach {
+ dependsOn("shadowJar")
+}
+
// The javadoc from wire's generated classes has errors that make the task that generates the "javadoc" artifact to fail. This
// makes the javadoc task to ignore those generated classes.
tasks.withType(Javadoc::class.java) {
diff --git a/version.gradle.kts b/version.gradle.kts
index acefcee..329b524 100644
--- a/version.gradle.kts
+++ b/version.gradle.kts
@@ -1,5 +1,5 @@
-val stableVersion = "1.39.0"
-val alphaVersion = "1.39.0-alpha"
+val stableVersion = "1.39.0-adot1"
+val alphaVersion = "1.39.0-alpha-adot1"
allprojects {
if (findProperty("otel.stable") != "true") {