Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Omondi committed Oct 28, 2024
2 parents 0411dca + 650812d commit db68526
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 14 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.13.1] - 2024-10-10

### Changed

- Updated HTTP span attributes to comply with updated OpenTelemetry semantic conventions. [#344](https://github.com/microsoft/kiota-dotnet/issues/344)

## [1.13.0] - 2024-09-25

### Changed
Expand Down
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project>
<!-- Common default project properties for ALL projects-->
<PropertyGroup>
<VersionPrefix>1.13.0</VersionPrefix>
<VersionPrefix>1.13.1</VersionPrefix>
<VersionSuffix></VersionSuffix>
<!-- This is overidden in test projects by setting to true-->
<IsTestProject>false</IsTestProject>
Expand Down
22 changes: 11 additions & 11 deletions src/http/httpClient/HttpClientRequestAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public string? BaseUrl
var decodedUriTemplate = ParametersNameDecodingHandler.DecodeUriEncodedString(requestInfo.UrlTemplate, charactersToDecodeForUriTemplate);
var telemetryPathValue = string.IsNullOrEmpty(decodedUriTemplate) ? string.Empty : queryParametersCleanupRegex.Replace(decodedUriTemplate, string.Empty);
var span = activitySource?.StartActivity($"{methodName} - {telemetryPathValue}");
span?.SetTag("http.uri_template", decodedUriTemplate);
span?.SetTag("url.uri_template", decodedUriTemplate);
return span;
}
/// <summary>
Expand Down Expand Up @@ -519,19 +519,19 @@ private async Task<HttpResponseMessage> GetHttpResponseMessageAsync(RequestInfor
using var contentLengthEnumerator = contentLengthValues.GetEnumerator();
if(contentLengthEnumerator.MoveNext() && int.TryParse(contentLengthEnumerator.Current, out var contentLength))
{
activityForAttributes?.SetTag("http.response_content_length", contentLength);
activityForAttributes?.SetTag("http.response.body.size", contentLength);
}
}
if(response.Headers.TryGetValues("Content-Type", out var contentTypeValues))
{
using var contentTypeEnumerator = contentTypeValues.GetEnumerator();
if(contentTypeEnumerator.MoveNext())
{
activityForAttributes?.SetTag("http.response_content_type", contentTypeEnumerator.Current);
activityForAttributes?.SetTag("http.response.header.content-type", contentTypeEnumerator.Current);
}
}
activityForAttributes?.SetTag("http.status_code", (int)response.StatusCode);
activityForAttributes?.SetTag("http.flavor", $"{response.Version.Major}.{response.Version.Minor}");
activityForAttributes?.SetTag("http.response.status_code", (int)response.StatusCode);
activityForAttributes?.SetTag("network.protocol.name", $"{response.Version.Major}.{response.Version.Minor}");

return await RetryCAEResponseIfRequiredAsync(response, requestInfo, cancellationToken, claims, activityForAttributes).ConfigureAwait(false);
}
Expand Down Expand Up @@ -612,12 +612,12 @@ private HttpRequestMessage GetRequestMessageFromRequestInformation(RequestInform
{
using var span = activitySource?.StartActivity(nameof(GetRequestMessageFromRequestInformation));
SetBaseUrlForRequestInformation(requestInfo);// this method can also be called from a different context so ensure the baseUrl is added.
activityForAttributes?.SetTag("http.method", requestInfo.HttpMethod.ToString());
activityForAttributes?.SetTag("http.request.method", requestInfo.HttpMethod.ToString());
var requestUri = requestInfo.URI;
activityForAttributes?.SetTag("http.host", requestUri.Host);
activityForAttributes?.SetTag("http.scheme", requestUri.Scheme);
activityForAttributes?.SetTag("url.scheme", requestUri.Host);
activityForAttributes?.SetTag("server.address", requestUri.Scheme);
if(obsOptions.IncludeEUIIAttributes)
activityForAttributes?.SetTag("http.uri", requestUri.ToString());
activityForAttributes?.SetTag("url.full", requestUri.ToString());
var message = new HttpRequestMessage
{
Method = new HttpMethod(requestInfo.HttpMethod.ToString().ToUpperInvariant()),
Expand Down Expand Up @@ -653,13 +653,13 @@ private HttpRequestMessage GetRequestMessageFromRequestInformation(RequestInform
{
var contentLenEnumerator = contentLenValues.GetEnumerator();
if(contentLenEnumerator.MoveNext() && int.TryParse(contentLenEnumerator.Current, out var contentLenValueInt))
activityForAttributes?.SetTag("http.request_content_length", contentLenValueInt);
activityForAttributes?.SetTag("http.request.body.size", contentLenValueInt);
}
if(message.Content.Headers.TryGetValues("Content-Type", out var contentTypeValues))
{
var contentTypeEnumerator = contentTypeValues.GetEnumerator();
if(contentTypeEnumerator.MoveNext())
activityForAttributes?.SetTag("http.request_content_type", contentTypeEnumerator.Current);
activityForAttributes?.SetTag("http.request.header.content-type", contentTypeEnumerator.Current);
}
}
return message;
Expand Down
2 changes: 1 addition & 1 deletion src/http/httpClient/Middleware/RedirectHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage
{
using var redirectActivity = activitySource?.StartActivity($"{nameof(RedirectHandler)}_{nameof(SendAsync)} - redirect {redirectCount}");
redirectActivity?.SetTag("com.microsoft.kiota.handler.redirect.count", redirectCount);
redirectActivity?.SetTag("http.status_code", response.StatusCode);
redirectActivity?.SetTag("http.response.status_code", response.StatusCode);
// Drain response content to free responses.
if(response.Content != null)
{
Expand Down
2 changes: 1 addition & 1 deletion src/http/httpClient/Middleware/RetryHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ private async Task<HttpResponseMessage> SendRetryAsync(HttpResponseMessage respo
exceptions.Add(await GetInnerExceptionAsync(response).ConfigureAwait(false));
using var retryActivity = activitySource?.StartActivity($"{nameof(RetryHandler)}_{nameof(SendAsync)} - attempt {retryCount}");
retryActivity?.SetTag("http.retry_count", retryCount);
retryActivity?.SetTag("http.status_code", response.StatusCode);
retryActivity?.SetTag("http.response.status_code", response.StatusCode);

// Call Delay method to get delay time from response's Retry-After header or by exponential backoff
Task delay = RetryHandler.DelayAsync(response, retryCount, retryOption.Delay, out double delayInSeconds, cancellationToken);
Expand Down

0 comments on commit db68526

Please sign in to comment.