Skip to content

Commit

Permalink
Merge pull request #1233 from andreaTP/issue-1232
Browse files Browse the repository at this point in the history
Remove `-alpha` OpenTelemetry dependencies
  • Loading branch information
baywet authored Apr 19, 2024
2 parents 6bed700 + 239065d commit 992e7ef
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 21 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [1.1.6] - 2024-04-18

### Changed

- Remove the OpenTelemetry `-alpha` dependencies to avoid classpath issues.

### Added

### Changed
Expand Down
2 changes: 0 additions & 2 deletions components/http/okHttp/gradle/dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ dependencies {
// This dependency is used internally, and not exposed to consumers on their own compile classpath.
implementation 'io.opentelemetry:opentelemetry-api:1.37.0'
implementation 'io.opentelemetry:opentelemetry-context:1.37.0'
implementation 'io.opentelemetry.semconv:opentelemetry-semconv:1.25.0-alpha'
implementation 'io.opentelemetry.semconv:opentelemetry-semconv-incubating:1.25.0-alpha'
implementation 'jakarta.annotation:jakarta.annotation-api:3.0.0'
api 'com.squareup.okhttp3:okhttp:4.12.0'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.microsoft.kiota.http;

import static com.microsoft.kiota.http.TelemetrySemanticConventions.*;

import com.microsoft.kiota.*;
import com.microsoft.kiota.authentication.AuthenticationProvider;
import com.microsoft.kiota.http.middleware.ParametersNameDecodingHandler;
Expand All @@ -19,11 +21,6 @@
import io.opentelemetry.api.trace.StatusCode;
import io.opentelemetry.context.Context;
import io.opentelemetry.context.Scope;
import io.opentelemetry.semconv.HttpAttributes;
import io.opentelemetry.semconv.NetworkAttributes;
import io.opentelemetry.semconv.ServerAttributes;
import io.opentelemetry.semconv.UrlAttributes;
import io.opentelemetry.semconv.incubating.HttpIncubatingAttributes;

import jakarta.annotation.Nonnull;
import jakarta.annotation.Nullable;
Expand Down Expand Up @@ -723,18 +720,16 @@ private Response getHttpResponseMessage(
final int contentLengthHeaderValueAsInt =
Integer.parseInt(contentLengthHeaderValue);
spanForAttributes.setAttribute(
HttpIncubatingAttributes.HTTP_RESPONSE_BODY_SIZE,
contentLengthHeaderValueAsInt);
EXPERIMENTAL_HTTP_RESPONSE_BODY_SIZE, contentLengthHeaderValueAsInt);
}
final String contentTypeHeaderValue = getHeaderValue(response, "Content-Length");
if (contentTypeHeaderValue != null && !contentTypeHeaderValue.isEmpty()) {
spanForAttributes.setAttribute(
"http.response_content_type", contentTypeHeaderValue);
}
spanForAttributes.setAttribute(HTTP_RESPONSE_STATUS_CODE, response.code());
spanForAttributes.setAttribute(
HttpAttributes.HTTP_RESPONSE_STATUS_CODE, response.code());
spanForAttributes.setAttribute(
NetworkAttributes.NETWORK_PROTOCOL_VERSION,
NETWORK_PROTOCOL_VERSION,
response.protocol().toString().toUpperCase(Locale.ROOT));
return this.retryCAEResponseIfRequired(
response, requestInfo, span, spanForAttributes, claims);
Expand Down Expand Up @@ -790,7 +785,7 @@ private Response retryCAEResponseIfRequired(
}
closeResponse(true, response);
span.addEvent(authenticateChallengedEventKey);
spanForAttributes.setAttribute(HttpAttributes.HTTP_REQUEST_RESEND_COUNT, 1);
spanForAttributes.setAttribute(HTTP_REQUEST_RESEND_COUNT, 1);
return this.getHttpResponseMessage(
requestInfo, span, spanForAttributes, responseClaims);
}
Expand Down Expand Up @@ -874,15 +869,14 @@ private void setBaseUrlForRequestInformation(@Nonnull final RequestInformation r
.setParent(Context.current().with(parentSpan))
.startSpan();
try (final Scope scope = span.makeCurrent()) {
spanForAttributes.setAttribute(
HttpAttributes.HTTP_REQUEST_METHOD, requestInfo.httpMethod.toString());
spanForAttributes.setAttribute(HTTP_REQUEST_METHOD, requestInfo.httpMethod.toString());
final URL requestURL = requestInfo.getUri().toURL();
if (obsOptions.getIncludeEUIIAttributes()) {
spanForAttributes.setAttribute(UrlAttributes.URL_FULL, requestURL.toString());
spanForAttributes.setAttribute(URL_FULL, requestURL.toString());
}
spanForAttributes.setAttribute("http.port", requestURL.getPort());
spanForAttributes.setAttribute(ServerAttributes.SERVER_ADDRESS, requestURL.getHost());
spanForAttributes.setAttribute(UrlAttributes.URL_SCHEME, requestURL.getProtocol());
spanForAttributes.setAttribute(SERVER_PORT, requestURL.getPort());
spanForAttributes.setAttribute(SERVER_ADDRESS, requestURL.getHost());
spanForAttributes.setAttribute(URL_SCHEME, requestURL.getProtocol());

RequestBody body =
requestInfo.content == null
Expand Down Expand Up @@ -966,7 +960,7 @@ public void writeTo(@Nonnull BufferedSink sink) throws IOException {
long contentLength = requestBody.contentLength();
if (contentLength >= 0) {
spanForAttributes.setAttribute(
HttpIncubatingAttributes.HTTP_REQUEST_BODY_SIZE, contentLength);
EXPERIMENTAL_HTTP_REQUEST_BODY_SIZE, contentLength);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.microsoft.kiota.http;

import static io.opentelemetry.api.common.AttributeKey.longKey;
import static io.opentelemetry.api.common.AttributeKey.stringKey;

import io.opentelemetry.api.common.AttributeKey;

public class TelemetrySemanticConventions {

// https://opentelemetry.io/docs/specs/semconv/attributes-registry/
public static final AttributeKey HTTP_RESPONSE_STATUS_CODE =
longKey("http.response.status_code"); // stable
public static final AttributeKey HTTP_REQUEST_RESEND_COUNT =
longKey("http.request.resend_count"); // stable
public static final AttributeKey HTTP_REQUEST_METHOD =
stringKey("http.request.method"); // stable
public static final AttributeKey NETWORK_PROTOCOL_VERSION =
stringKey("network.protocol.version"); // stable
public static final AttributeKey URL_FULL = stringKey("url.full"); // stable
public static final AttributeKey URL_SCHEME = stringKey("url.scheme"); // stable
public static final AttributeKey SERVER_ADDRESS = stringKey("server.address"); // stable
public static final AttributeKey SERVER_PORT = stringKey("server.port"); // stable

public static final AttributeKey EXPERIMENTAL_HTTP_RESPONSE_BODY_SIZE =
longKey("http.response.body.size"); // experimental
public static final AttributeKey EXPERIMENTAL_HTTP_REQUEST_BODY_SIZE =
longKey("http.request.body.size"); // experimental
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ org.gradle.caching=true
mavenGroupId = com.microsoft.kiota
mavenMajorVersion = 1
mavenMinorVersion = 1
mavenPatchVersion = 5
mavenPatchVersion = 6
mavenArtifactSuffix =

#These values are used to run functional tests
Expand Down

0 comments on commit 992e7ef

Please sign in to comment.