Skip to content

Commit

Permalink
code refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
sourabh1007 committed Jun 15, 2022
1 parent 6fd136c commit dc5bad8
Show file tree
Hide file tree
Showing 22 changed files with 35 additions and 177 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ public ChangeFeedEstimatorFeedResponse(

public override string IndexMetrics => null;

public override RequestMessage RequestMessage => null;
internal override RequestMessage RequestMessage => null;

public override IEnumerator<ChangeFeedProcessorState> GetEnumerator()
{
Expand Down Expand Up @@ -407,7 +407,7 @@ public ChangeFeedEstimatorEmptyFeedResponse(ITrace trace)

public override string IndexMetrics => string.Empty;

public override RequestMessage RequestMessage => null;
internal override RequestMessage RequestMessage => null;

public override IEnumerator<ChangeFeedProcessorState> GetEnumerator()
{
Expand Down
2 changes: 1 addition & 1 deletion Microsoft.Azure.Cosmos/src/Query/v3Query/QueryResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ public override IEnumerator<T> GetEnumerator()

public override IEnumerable<T> Resource { get; }

public override RequestMessage RequestMessage { get; }
internal override RequestMessage RequestMessage { get; }

internal static QueryResponse<TInput> CreateResponse<TInput>(
QueryResponse cosmosQueryResponse,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ internal ReadFeedResponse(

public override string IndexMetrics { get; }

public override RequestMessage RequestMessage { get; }
internal override RequestMessage RequestMessage { get; }

public override IEnumerator<T> GetEnumerator()
{
Expand Down
10 changes: 5 additions & 5 deletions Microsoft.Azure.Cosmos/src/Resource/ClientContextCore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ internal override Task<TResult>
string operationName,
RequestOptions requestOptions,
Func<ITrace, Task<TResult>> task,
Func<TResult, OpenTelemetryResponseCore> openTelemetry = null,
Func<TResult, OpenTelemetryAttributes> openTelemetry = null,
TraceComponent traceComponent = TraceComponent.Transport,
Tracing.TraceLevel traceLevel = Tracing.TraceLevel.Info)
{
Expand All @@ -252,7 +252,7 @@ private async Task<TResult> OperationHelperWithRootTraceAsync<TResult>(
string operationName,
RequestOptions requestOptions,
Func<ITrace, Task<TResult>> task,
Func<TResult, OpenTelemetryResponseCore> openTelemetry,
Func<TResult, OpenTelemetryAttributes> openTelemetry,
TraceComponent traceComponent,
Tracing.TraceLevel traceLevel)
{
Expand All @@ -274,7 +274,7 @@ private Task<TResult> OperationHelperWithRootTraceWithSynchronizationContextAsyn
string operationName,
RequestOptions requestOptions,
Func<ITrace, Task<TResult>> task,
Func<TResult, OpenTelemetryResponseCore> openTelemetry,
Func<TResult, OpenTelemetryAttributes> openTelemetry,
TraceComponent traceComponent,
Tracing.TraceLevel traceLevel)
{
Expand Down Expand Up @@ -470,7 +470,7 @@ protected virtual void Dispose(bool disposing)
private async Task<TResult> RunWithDiagnosticsHelperAsync<TResult>(
ITrace trace,
Func<ITrace, Task<TResult>> task,
Func<TResult, OpenTelemetryResponseCore> openTelemetry,
Func<TResult, OpenTelemetryAttributes> openTelemetry,
string operationName)
{
using (OpenTelemetryCoreRecorder recorder = OpenTelemetryRecorderFactory.CreateRecorder(operationName))
Expand All @@ -481,7 +481,7 @@ private async Task<TResult> RunWithDiagnosticsHelperAsync<TResult>(
TResult result = await task(trace).ConfigureAwait(false);
if (openTelemetry != null && recorder.IsEnabled)
{
OpenTelemetryResponseCore response = openTelemetry(result);
OpenTelemetryAttributes response = openTelemetry(result);
recorder.Record(response);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ internal ClientEncryptionKeyResponse(
public override string ETag => this.Headers?.ETag;

/// <inheritdoc/>
public override RequestMessage RequestMessage { get; }
internal override RequestMessage RequestMessage { get; }

/// <summary>
/// Get the client encryption key implicitly from an encryption key response.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ internal ContainerResponse(
public override string ETag => this.Headers?.ETag;

/// <inheritdoc/>
public override RequestMessage RequestMessage { get; }
internal override RequestMessage RequestMessage { get; }

/// <summary>
/// Get <see cref="Cosmos.Container"/> implicitly from <see cref="ContainerResponse"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ internal ItemResponse(
}

/// <inheritdoc/>
public override RequestMessage RequestMessage { get; }
internal override RequestMessage RequestMessage { get; }

/// <inheritdoc/>
public override Headers Headers { get; }
Expand Down
2 changes: 1 addition & 1 deletion Microsoft.Azure.Cosmos/src/Resource/CosmosClientContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ internal abstract Task<TResult> OperationHelperAsync<TResult>(
string operationName,
RequestOptions requestOptions,
Func<ITrace, Task<TResult>> task,
Func<TResult, OpenTelemetryResponseCore> openTelemetry = null,
Func<TResult, OpenTelemetryAttributes> openTelemetry = null,
TraceComponent traceComponent = TraceComponent.Transport,
TraceLevel traceLevel = TraceLevel.Info);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ internal DatabaseResponse(
public override string ETag => this.Headers?.ETag;

/// <inheritdoc/>
public override RequestMessage RequestMessage { get; }
internal override RequestMessage RequestMessage { get; }

/// <summary>
/// Get <see cref="Cosmos.Database"/> implicitly from <see cref="DatabaseResponse"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ internal PermissionResponse(
public override string ETag => this.Headers?.ETag;

/// <inheritdoc/>
public override RequestMessage RequestMessage { get; }
internal override RequestMessage RequestMessage { get; }

/// <summary>
/// Get <see cref="Cosmos.Permission"/> implicitly from <see cref="PermissionResponse"/>
Expand Down
2 changes: 1 addition & 1 deletion Microsoft.Azure.Cosmos/src/Resource/Response.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,6 @@ public static implicit operator T(Response<T> response)
/// <summary>
/// Gets the original request message
/// </summary>
public abstract RequestMessage RequestMessage { get; }
internal abstract RequestMessage RequestMessage { get; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,6 @@ public virtual string ScriptLog
}

/// <inheritdoc/>
public override RequestMessage RequestMessage { get; }
internal override RequestMessage RequestMessage { get; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ internal StoredProcedureResponse(
public virtual string SessionToken => this.Headers?.GetHeaderValue<string>(HttpConstants.HttpHeaders.SessionToken);

/// <inheritdoc/>
public override RequestMessage RequestMessage { get; }
internal override RequestMessage RequestMessage { get; }

/// <summary>
/// Get <see cref="StoredProcedureProperties"/> implicitly from <see cref="StoredProcedureResponse"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ internal TriggerResponse(
public override string ETag => this.Headers?.ETag;

/// <inheritdoc/>
public override RequestMessage RequestMessage { get; }
internal override RequestMessage RequestMessage { get; }

/// <summary>
/// Get <see cref="TriggerProperties"/> implicitly from <see cref="TriggerResponse"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ internal UserDefinedFunctionResponse(
public override string ETag => this.Headers?.ETag;

/// <inheritdoc/>
public override RequestMessage RequestMessage { get; }
internal override RequestMessage RequestMessage { get; }

/// <summary>
/// Get <see cref="UserDefinedFunctionProperties"/> implicitly from <see cref="UserDefinedFunctionResponse"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public bool? IsReplacePending
}

/// <inheritdoc/>
public override RequestMessage RequestMessage { get; }
internal override RequestMessage RequestMessage { get; }

/// <summary>
/// Get <see cref="ThroughputProperties"/> implicitly from <see cref="ThroughputResponse"/>
Expand Down
2 changes: 1 addition & 1 deletion Microsoft.Azure.Cosmos/src/Resource/User/UserResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ internal UserResponse(
public override string ETag => this.Headers?.ETag;

/// <inheritdoc/>
public override RequestMessage RequestMessage { get; }
internal override RequestMessage RequestMessage { get; }

/// <summary>
/// Get <see cref="Cosmos.User"/> implicitly from <see cref="UserResponse"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,41 +9,41 @@ namespace Microsoft.Azure.Cosmos.Telemetry.OpenTelemetry
using System.Net;
using System.Text;

internal class OpenTelemetryResponseCore
internal class OpenTelemetryAttributes
{
/// <summary>
/// StatusCode
/// </summary>
public HttpStatusCode StatusCode { get; set; }
internal HttpStatusCode StatusCode { get; set; }

/// <summary>
/// RequestCharge
/// </summary>
public double? RequestCharge { get; set; }
internal double? RequestCharge { get; set; }

/// <summary>
/// RequestLength
/// </summary>
public string RequestContentLength { get; set; }
internal string RequestContentLength { get; set; }

/// <summary>
/// ResponseLength
/// </summary>
public string ResponseContentLength { get; set; }
internal string ResponseContentLength { get; set; }

/// <summary>
/// ContainerName
/// </summary>
public string ContainerName { get; set; }
internal string ContainerName { get; set; }

/// <summary>
/// ItemCount
/// </summary>
public string ItemCount { get; set; }
internal string ItemCount { get; set; }

/// <summary>
/// ItemCount
/// </summary>
public CosmosDiagnostics Diagnostics { get; set; }
internal CosmosDiagnostics Diagnostics { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public void Record(string key, string value)
this.scope.AddAttribute(key, value);
}

public void Record(OpenTelemetryResponseCore response)
public void Record(OpenTelemetryAttributes response)
{
this.scope.AddAttribute(OpenTelemetryAttributeKeys.StatusCode, response.StatusCode);
this.scope.AddAttribute(OpenTelemetryAttributeKeys.RequestContentLength, response.RequestContentLength);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ namespace Microsoft.Azure.Cosmos
using Microsoft.Azure.Cosmos.Telemetry.OpenTelemetry;
using Microsoft.Azure.Documents;

internal sealed class OpenTelemetryResponse : OpenTelemetryResponseCore
internal sealed class OpenTelemetryResponse : OpenTelemetryAttributes
{
public OpenTelemetryResponse(ResponseMessage message)
internal OpenTelemetryResponse(ResponseMessage message)
{
this.StatusCode = message.StatusCode;
this.RequestCharge = message.Headers?.RequestCharge;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ namespace Microsoft.Azure.Cosmos
using Microsoft.Azure.Cosmos.Telemetry.OpenTelemetry;
using Microsoft.Azure.Documents;

internal sealed class OpenTelemetryResponse<T> : OpenTelemetryResponseCore
internal sealed class OpenTelemetryResponse<T> : OpenTelemetryAttributes
{
public OpenTelemetryResponse(Response<T> message)
internal OpenTelemetryResponse(Response<T> message)
{
this.StatusCode = message.StatusCode;
this.RequestCharge = message.Headers?.RequestCharge;
Expand Down
Loading

0 comments on commit dc5bad8

Please sign in to comment.