|
20 | 20 | import io.opentelemetry.sdk.trace.samplers.SamplingDecision;
|
21 | 21 | import io.opentelemetry.sdk.trace.samplers.SamplingResult;
|
22 | 22 | import io.opentelemetry.semconv.HttpAttributes;
|
| 23 | +import io.opentelemetry.semconv.ServerAttributes; |
23 | 24 | import io.opentelemetry.semconv.UrlAttributes;
|
24 | 25 | import java.time.Duration;
|
25 | 26 | import java.util.Collections;
|
@@ -59,6 +60,9 @@ final class SamplingRuleApplier {
|
59 | 60 |
|
60 | 61 | private static final Map<String, String> XRAY_CLOUD_PLATFORM;
|
61 | 62 |
|
| 63 | + // _OTHER request method: https://github.com/open-telemetry/semantic-conventions/blob/main/docs/registry/attributes/http.md?plain=1#L96 |
| 64 | + private static final String _OTHER_REQUEST_METHOD = "_OTHER"; |
| 65 | + |
62 | 66 | static {
|
63 | 67 | Map<String, String> xrayCloudPlatform = new HashMap<>();
|
64 | 68 | xrayCloudPlatform.put(AWS_EC2, "AWS::EC2::Instance");
|
@@ -190,9 +194,14 @@ boolean matches(Attributes attributes, Resource resource) {
|
190 | 194 | } else if (entry.getKey().equals(HTTP_METHOD)
|
191 | 195 | || entry.getKey().equals(HttpAttributes.HTTP_REQUEST_METHOD)) {
|
192 | 196 | httpMethod = (String) entry.getValue();
|
193 |
| - } else if (entry.getKey().equals(NET_HOST_NAME)) { |
| 197 | + // according to semantic conventions, if the HTTP request method is not known to instrumentation |
| 198 | + // it must be set to _OTHER and the HTTP_REQUEST_METHOD_ORIGINAL should contain the original method |
| 199 | + if (httpMethod.equals(_OTHER_REQUEST_METHOD)) { |
| 200 | + httpMethod = attributes.get(HttpAttributes.HTTP_REQUEST_METHOD_ORIGINAL); |
| 201 | + } |
| 202 | + } else if (entry.getKey().equals(NET_HOST_NAME) || (entry.getKey().equals(ServerAttributes.SERVER_ADDRESS))) { |
194 | 203 | host = (String) entry.getValue();
|
195 |
| - } else if (entry.getKey().equals(HTTP_HOST)) { |
| 204 | + } else if (entry.getKey().equals(HTTP_HOST) || (entry.getKey().equals(ServerAttributes.SERVER_ADDRESS))) { |
196 | 205 | // TODO (trask) remove support for deprecated http.host attribute
|
197 | 206 | host = (String) entry.getValue();
|
198 | 207 | }
|
|
0 commit comments