in sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/CosmosDiagnosticsContext.java [961:1164]
static void initialize() {
ImplementationBridgeHelpers
.CosmosDiagnosticsContextHelper
.setCosmosDiagnosticsContextAccessor(
new ImplementationBridgeHelpers
.CosmosDiagnosticsContextHelper
.CosmosDiagnosticsContextAccessor() {
@Override
public CosmosDiagnosticsContext create(String spanName, String account, String endpoint,
String databaseId,String containerId,
ResourceType resourceType, OperationType operationType,
String operationId,
ConsistencyLevel consistencyLevel, Integer maxItemCount,
CosmosDiagnosticsThresholds thresholds, String trackingId,
String connectionMode, String userAgent,
Integer sequenceNumber,
String queryStatement,
OverridableRequestOptions requestOptions) {
return new CosmosDiagnosticsContext(
spanName,
account,
endpoint,
databaseId,
containerId,
resourceType,
operationType,
operationId,
consistencyLevel,
maxItemCount,
thresholds,
trackingId,
connectionMode,
userAgent,
sequenceNumber,
queryStatement,
requestOptions
);
}
@Override
public OverridableRequestOptions getRequestOptions(CosmosDiagnosticsContext ctx) {
checkNotNull(ctx, "Argument 'ctx' must not be null.");
return ctx.getRequestOptions();
}
@Override
public void setRequestOptions(CosmosDiagnosticsContext ctx, OverridableRequestOptions requestOptions) {
checkNotNull(ctx, "Argument 'ctx' must not be null.");
ctx.setRequestOptions(requestOptions);
}
@Override
public CosmosDiagnosticsSystemUsageSnapshot createSystemUsageSnapshot(String cpu, String used, String available, int cpuCount) {
return new CosmosDiagnosticsSystemUsageSnapshot(cpu, used, available, cpuCount);
}
@Override
public void startOperation(CosmosDiagnosticsContext ctx) {
checkNotNull(ctx, "Argument 'ctx' must not be null.");
ctx.startOperation();
}
@Override
public void recordOperation(CosmosDiagnosticsContext ctx, int statusCode, int subStatusCode,
Integer actualItemCount, Double requestCharge,
CosmosDiagnostics diagnostics, Throwable finalError) {
ctx.recordOperation(statusCode, subStatusCode, actualItemCount, requestCharge, 0L, 0L, 0L, 0, diagnostics, finalError);
}
@Override
public boolean endOperation(CosmosDiagnosticsContext ctx, int statusCode, int subStatusCode, Integer actualItemCount, Double requestCharge, CosmosDiagnostics diagnostics, Throwable finalError) {
return ctx.endOperation(statusCode, subStatusCode, actualItemCount, requestCharge, 0L, 0L, 0L, 0, diagnostics, finalError);
}
@Override
public boolean endOperation(
CosmosDiagnosticsContext ctx,
int statusCode,
int subStatusCode,
Integer actualItemCount,
Double requestCharge,
Long opCountPerEvaluation,
Long opRetriedCountPerEvaluation,
Long globalOpCount,
Integer targetMaxMicroBatchSize,
CosmosDiagnostics diagnostics,
Throwable finalError) {
return ctx.endOperation(statusCode, subStatusCode, actualItemCount, requestCharge, opCountPerEvaluation, opRetriedCountPerEvaluation, globalOpCount, targetMaxMicroBatchSize, diagnostics, finalError);
}
@Override
public void addRequestCharge(CosmosDiagnosticsContext ctx, float requestCharge) {
checkNotNull(ctx, "Argument 'ctx' must not be null.");
ctx.addRequestCharge(requestCharge);
}
@Override
public void addRequestSize(CosmosDiagnosticsContext ctx, int bytes) {
checkNotNull(ctx, "Argument 'ctx' must not be null.");
ctx.addRequestSize(bytes);
}
@Override
public void addResponseSize(CosmosDiagnosticsContext ctx, int bytes) {
checkNotNull(ctx, "Argument 'ctx' must not be null.");
ctx.addResponseSize(bytes);
}
@Override
public void addDiagnostics(CosmosDiagnosticsContext ctx, CosmosDiagnostics diagnostics) {
checkNotNull(ctx, "Argument 'ctx' must not be null.");
checkNotNull(ctx, "Argument 'diagnostics' must not be null.");
ctx.addDiagnostics(diagnostics);
}
@Override
public Collection<CosmosDiagnostics> getDiagnostics(CosmosDiagnosticsContext ctx) {
checkNotNull(ctx, "Argument 'ctx' must not be null.");
return ctx.getDiagnostics();
}
@Override
public ResourceType getResourceType(CosmosDiagnosticsContext ctx) {
checkNotNull(ctx, "Argument 'ctx' must not be null.");
return ctx.getResourceTypeInternal();
}
@Override
public OperationType getOperationType(CosmosDiagnosticsContext ctx) {
checkNotNull(ctx, "Argument 'ctx' must not be null.");
return ctx.getOperationTypeInternal();
}
@Override
public String getEndpoint(CosmosDiagnosticsContext ctx) {
checkNotNull(ctx, "Argument 'ctx' must not be null.");
return ctx.getEndpoint();
}
@Override
public Collection<ClientSideRequestStatistics> getDistinctCombinedClientSideRequestStatistics(CosmosDiagnosticsContext ctx) {
checkNotNull(ctx, "Argument 'ctx' must not be null.");
return ctx.getDistinctCombinedClientSideRequestStatistics();
}
@Override
public String getSpanName(CosmosDiagnosticsContext ctx) {
checkNotNull(ctx, "Argument 'ctx' must not be null.");
return ctx.getSpanName();
}
@Override
public void setSamplingRateSnapshot(CosmosDiagnosticsContext ctx, double samplingRate, boolean isSampledOut) {
checkNotNull(ctx, "Argument 'ctx' must not be null.");
ctx.setSamplingRateSnapshot(samplingRate, isSampledOut);
}
@Override
public Integer getSequenceNumber(CosmosDiagnosticsContext ctx) {
checkNotNull(ctx, "Argument 'ctx' must not be null.");
return ctx.getSequenceNumber();
}
@Override
public boolean isEmptyCompletion(CosmosDiagnosticsContext ctx) {
checkNotNull(ctx, "Argument 'ctx' must not be null.");
Integer sequenceNumber = ctx.getSequenceNumber();
if (sequenceNumber == null || sequenceNumber == 1) {
return false;
}
return true;
}
@Override
public String getQueryStatement(CosmosDiagnosticsContext ctx) {
checkNotNull(ctx, "Argument 'ctx' must not be null.");
return ctx.getQueryStatement();
}
@Override
public Long getOpCountPerEvaluation(CosmosDiagnosticsContext ctx) {
return ctx.opCountPerEvaluation;
}
@Override
public Long getRetriedOpCountPerEvaluation(CosmosDiagnosticsContext ctx) {
return ctx.opRetriedCountPerEvaluation;
}
@Override
public Long getGlobalOpCount(CosmosDiagnosticsContext ctx) {
return ctx.globalOpCount;
}
@Override
public Integer getTargetMaxMicroBatchSize(CosmosDiagnosticsContext ctx) {
return ctx.targetMaxMicroBatchSize;
}
});
}