Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update network.protocol.version 2.0 -> 2 and 3.0 -> 3 #9145

Merged
merged 1 commit into from
Aug 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ String getProtocolName() {

String getProtocolVersion() {
ProtocolVersion protocolVersion = delegate.getProtocolVersion();
if (protocolVersion.getMinor() == 0) {
return Integer.toString(protocolVersion.getMajor());
}
return protocolVersion.getMajor() + "." + protocolVersion.getMinor();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ String getProtocolName() {

String getProtocolVersion() {
ProtocolVersion protocolVersion = delegate.getProtocolVersion();
if (protocolVersion.getMinor() == 0) {
return Integer.toString(protocolVersion.getMajor());
}
return protocolVersion.getMajor() + "." + protocolVersion.getMinor();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ public String getNetworkProtocolVersion(HttpRequest request, @Nullable HttpRespo
if (protocolVersion == null) {
return null;
}
if (protocolVersion.getMinor() == 0) {
return Integer.toString(protocolVersion.getMajor());
}
return protocolVersion.getMajor() + "." + protocolVersion.getMinor();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public String getNetworkProtocolName(RequestContext ctx, @Nullable RequestLog re
@Override
public String getNetworkProtocolVersion(RequestContext ctx, @Nullable RequestLog requestLog) {
SessionProtocol protocol = ctx.sessionProtocol();
return protocol.isMultiplex() ? "2.0" : "1.1";
return protocol.isMultiplex() ? "2" : "1.1";
}

@Nullable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public String getNetworkProtocolName(RequestContext ctx, @Nullable RequestLog re
@Override
public String getNetworkProtocolVersion(RequestContext ctx, @Nullable RequestLog requestLog) {
SessionProtocol protocol = ctx.sessionProtocol();
return protocol.isMultiplex() ? "2.0" : "1.1";
return protocol.isMultiplex() ? "2" : "1.1";
}

@Nullable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ public String getNetworkProtocolVersion(RequestContext request, @Nullable Respon
if (httpVersion == null) {
return null;
}
if (httpVersion.minorVersion() == 0) {
return Integer.toString(httpVersion.majorVersion());
}
return httpVersion.majorVersion() + "." + httpVersion.minorVersion();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ public String getNetworkProtocolVersion(Request<?> request, @Nullable Response<?
if (protocolVersion == null) {
return null;
}
if (protocolVersion.getMinor() == 0) {
return Integer.toString(protocolVersion.getMajor());
}
return protocolVersion.getMajor() + "." + protocolVersion.getMinor();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public String getNetworkProtocolVersion(HttpRequest request, @Nullable HttpRespo
case HTTP_1_1:
return "1.1";
case HTTP_2:
return "2.0";
return "2";
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
package io.opentelemetry.instrumentation.ktor.v2_0.client

import io.ktor.client.request.*
import io.ktor.client.statement.HttpResponse
import io.ktor.client.statement.*
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientAttributesGetter

internal object KtorHttpClientAttributesGetter : HttpClientAttributesGetter<HttpRequestData, HttpResponse> {
Expand All @@ -31,6 +31,9 @@ internal object KtorHttpClientAttributesGetter : HttpClientAttributesGetter<Http

override fun getNetworkProtocolVersion(request: HttpRequestData?, response: HttpResponse?): String? {
val version = response?.version ?: return null
if (version.minor == 0) {
return "${version.major}"
}
return "${version.major}.${version.minor}"
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ public String getNetworkProtocolName(
public String getNetworkProtocolVersion(
HttpRequestAndChannel requestAndChannel, @Nullable HttpResponse httpResponse) {
HttpVersion version = requestAndChannel.request().getProtocolVersion();
if (version.getMinorVersion() == 0) {
return Integer.toString(version.getMajorVersion());
}
return version.getMajorVersion() + "." + version.getMinorVersion();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ public String getNetworkProtocolName(
public String getNetworkProtocolVersion(
HttpRequestAndChannel requestAndChannel, @Nullable HttpResponse response) {
HttpVersion version = requestAndChannel.request().getProtocolVersion();
if (version.getMinorVersion() == 0) {
return Integer.toString(version.getMajorVersion());
}
return version.getMajorVersion() + "." + version.getMinorVersion();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ public String getNetworkProtocolName(
public String getNetworkProtocolVersion(
HttpRequestAndChannel requestAndChannel, @Nullable HttpResponse response) {
HttpVersion version = requestAndChannel.request().getProtocolVersion();
if (version.minorVersion() == 0) {
return Integer.toString(version.majorVersion());
}
return version.majorVersion() + "." + version.minorVersion();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ public String getNetworkProtocolName(
public String getNetworkProtocolVersion(
HttpRequestAndChannel requestAndChannel, @Nullable HttpResponse response) {
HttpVersion version = requestAndChannel.request().getProtocolVersion();
if (version.minorVersion() == 0) {
return Integer.toString(version.majorVersion());
}
return version.majorVersion() + "." + version.minorVersion();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public String getNetworkProtocolVersion(Request request, @Nullable Response resp
case HTTP_1_1:
return "1.1";
case HTTP_2:
return "2.0";
return "2";
case SPDY_3:
return "3.1";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public String getNetworkProtocolVersion(Request request, @Nullable Response resp
case HTTP_1_1:
return "1.1";
case HTTP_2:
return "2.0";
return "2";
case SPDY_3:
return "3.1";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ public String getNetworkProtocolVersion(
return null;
}
HttpVersion version = response.version();
if (version.minorVersion() == 0) {
return Integer.toString(version.majorVersion());
}
return version.majorVersion() + "." + version.minorVersion();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public String getNetworkProtocolVersion(
case HTTP_1_1:
return "1.1";
case HTTP_2:
return "2.0";
return "2";
}
return null;
}
Expand Down