File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed
semantic-convention-utils/src
main/java/org/hypertrace/semantic/convention/utils/http
test/java/org/hypertrace/semantic/convention/utils/http Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change 28
28
import static org .hypertrace .core .span .constants .v1 .Http .HTTP_REQUEST_X_FORWARDED_FOR_HEADER ;
29
29
import static org .hypertrace .core .span .constants .v1 .Http .HTTP_RESPONSE_BODY_TRUNCATED ;
30
30
import static org .hypertrace .core .span .constants .v1 .Http .HTTP_RESPONSE_CONTENT_LENGTH ;
31
+ import static org .hypertrace .core .span .constants .v1 .Http .HTTP_RESPONSE_CONTENT_TYPE ;
31
32
import static org .hypertrace .core .span .constants .v1 .Http .HTTP_RESPONSE_HEADER ;
32
33
import static org .hypertrace .core .span .constants .v1 .Http .HTTP_RESPONSE_SIZE ;
33
34
import static org .hypertrace .core .span .constants .v1 .Http .HTTP_RESPONSE_STATUS_CODE ;
@@ -816,6 +817,12 @@ public static Optional<String> getHttpRequestContentType(Event event) {
816
817
event , List .of (RawSpanConstants .getValue (HTTP_REQUEST_CONTENT_TYPE ))));
817
818
}
818
819
820
+ public static Optional <String > getHttpResponseContentType (Event event ) {
821
+ return Optional .ofNullable (
822
+ SpanAttributeUtils .getFirstAvailableStringAttribute (
823
+ event , List .of (RawSpanConstants .getValue (HTTP_RESPONSE_CONTENT_TYPE ))));
824
+ }
825
+
819
826
public static boolean isHttpRequestCookie (String requestHeaderAttributeKey ) {
820
827
return requestHeaderAttributeKey .equals (REQUEST_COOKIE_HEADER_KEY );
821
828
}
Original file line number Diff line number Diff line change 28
28
import static org .hypertrace .core .span .constants .v1 .Http .HTTP_REQUEST_X_FORWARDED_FOR_HEADER ;
29
29
import static org .hypertrace .core .span .constants .v1 .Http .HTTP_RESPONSE_BODY_TRUNCATED ;
30
30
import static org .hypertrace .core .span .constants .v1 .Http .HTTP_RESPONSE_CONTENT_LENGTH ;
31
+ import static org .hypertrace .core .span .constants .v1 .Http .HTTP_RESPONSE_CONTENT_TYPE ;
31
32
import static org .hypertrace .core .span .constants .v1 .Http .HTTP_RESPONSE_SIZE ;
32
33
import static org .hypertrace .core .span .constants .v1 .Http .HTTP_USER_AGENT_REQUEST_HEADER ;
33
34
import static org .hypertrace .core .span .constants .v1 .Http .HTTP_USER_AGENT_WITH_DASH ;
@@ -513,6 +514,16 @@ public void testGetHttpRequestContentType() {
513
514
HttpSemanticConventionUtils .getHttpRequestContentType (event ));
514
515
}
515
516
517
+ @ Test
518
+ public void testGetHttpResponseContentType () {
519
+ Event event =
520
+ createMockEventWithAttribute (
521
+ RawSpanConstants .getValue (HTTP_RESPONSE_CONTENT_TYPE ), "application/text" );
522
+ assertEquals (
523
+ Optional .of ("application/text" ),
524
+ HttpSemanticConventionUtils .getHttpResponseContentType (event ));
525
+ }
526
+
516
527
@ Test
517
528
public void testGetHttpRequestSize () {
518
529
Event event = createMockEventWithAttribute (RawSpanConstants .getValue (HTTP_REQUEST_SIZE ), "100" );
You can’t perform that action at this time.
0 commit comments