Skip to content

Commit c9b2ef6

Browse files
Added documentation for method
1 parent ac11200 commit c9b2ef6

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

semantic-convention-utils/src/main/java/org/hypertrace/semantic/convention/utils/http/HttpSemanticConventionUtils.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -551,6 +551,24 @@ public static Optional<String> getHttpMethod(Event event) {
551551
return Optional.empty();
552552
}
553553

554+
/**
555+
* Returns the HTTP scheme associated with the given {@link Event}. The scheme is determined as
556+
* follows:
557+
* <ol>
558+
* <li>If the event has an attribute like {@code http.url} that contains a full URL, the scheme
559+
* from that URL is returned if it is https.
560+
* <li>If the scheme from the full URL is not 'https', then other attributes like
561+
* {@code x-forwarded-proto}, {@code forwarded}, {@code http.scheme} are checked. If any of
562+
* these has the value 'https', then that is returned.
563+
* <li>If none of the above steps yield a scheme of 'https', then the scheme from the full URL
564+
* (which should be 'http') is returned.
565+
* <li>If the event does not have a full URL attribute, then the other attributes are checked for
566+
* the scheme.
567+
* </ol>
568+
*
569+
* @param event the event to extract the scheme from
570+
* @return an {@link Optional} containing the scheme if it could be determined, empty otherwise
571+
*/
554572
public static Optional<String> getHttpScheme(Event event) {
555573

556574
Optional<String> scheme = Optional.empty();

0 commit comments

Comments
 (0)