Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into witemple-msft/rollup2
Browse files Browse the repository at this point in the history
  • Loading branch information
witemple-msft committed Jan 28, 2022
2 parents db7197b + 55ad309 commit 6527b28
Show file tree
Hide file tree
Showing 11 changed files with 49 additions and 9 deletions.
3 changes: 2 additions & 1 deletion eng/CredScanSuppression.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
"SecretPlaceholder",
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjM2MDB9.adM-ddBZZlQ1WlN3pdPBOF5G4Wh9iZpxNP_fSvpF4cWs",
"Resource",
"sanitized.${expiryReplacement}.sanitized"
"sanitized.${expiryReplacement}.sanitized",
"123456789"
],
"_justification": "Secret used by test code, it is fake."
},
Expand Down
7 changes: 6 additions & 1 deletion sdk/core/core-tracing/review/core-tracing.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ export interface OperationTracingOptions {
tracingContext?: TracingContext;
}

// @public
export type Resolved<T> = T extends {
then(onfulfilled: infer F): any;
} ? F extends (value: infer V) => any ? Resolved<V> : never : T;

// @public
export type SpanStatus = SpanStatusSuccess | SpanStatusError;

Expand Down Expand Up @@ -57,7 +62,7 @@ export interface TracingClient {
withContext<CallbackArgs extends unknown[], Callback extends (...args: CallbackArgs) => ReturnType<Callback>>(context: TracingContext, callback: Callback, ...callbackArgs: CallbackArgs): ReturnType<Callback>;
withSpan<Options extends {
tracingOptions?: OperationTracingOptions;
}, Callback extends (updatedOptions: Options, span: Omit<TracingSpan, "end">) => ReturnType<Callback>>(name: string, operationOptions: Options, callback: Callback, spanOptions?: TracingSpanOptions): Promise<ReturnType<Callback>>;
}, Callback extends (updatedOptions: Options, span: Omit<TracingSpan, "end">) => ReturnType<Callback>>(name: string, operationOptions: Options, callback: Callback, spanOptions?: TracingSpanOptions): Promise<Resolved<ReturnType<Callback>>>;
}

// @public
Expand Down
1 change: 1 addition & 0 deletions sdk/core/core-tracing/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export {
Instrumenter,
InstrumenterSpanOptions,
OperationTracingOptions,
Resolved,
SpanStatus,
SpanStatusError,
SpanStatusSuccess,
Expand Down
14 changes: 13 additions & 1 deletion sdk/core/core-tracing/src/interfaces.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

/**
* A narrower version of TypeScript 4.5's Awaited type which Recursively
* unwraps the "awaited type", emulating the behavior of `await`.
*/
export type Resolved<T> = T extends { then(onfulfilled: infer F): any } // `await` only unwraps object types with a callable `then`. Non-object types are not unwrapped
? F extends (value: infer V) => any // if the argument to `then` is callable, extracts the first argument
? Resolved<V> // recursively unwrap the value
: never // the argument to `then` was not callable
: T; // non-object or non-thenable

/**
* Represents a client that can integrate with the currently configured {@link Instrumenter}.
*
Expand All @@ -12,6 +22,8 @@ export interface TracingClient {
*
* This is the primary interface for using Tracing and will handle error recording as well as setting the status on the span.
*
* Both synchronous and asynchronous functions will be awaited in order to reflect the result of the callback on the span.
*
* Example:
*
* ```ts
Expand All @@ -32,7 +44,7 @@ export interface TracingClient {
operationOptions: Options,
callback: Callback,
spanOptions?: TracingSpanOptions
): Promise<ReturnType<Callback>>;
): Promise<Resolved<ReturnType<Callback>>>;
/**
* Starts a given span but does not set it as the active span.
*
Expand Down
5 changes: 3 additions & 2 deletions sdk/core/core-tracing/src/tracingClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import {
OperationTracingOptions,
Resolved,
TracingClient,
TracingClientOptions,
TracingContext,
Expand Down Expand Up @@ -64,14 +65,14 @@ export function createTracingClient(options: TracingClientOptions): TracingClien
operationOptions: Options,
callback: Callback,
spanOptions?: TracingSpanOptions
): Promise<ReturnType<Callback>> {
): Promise<Resolved<ReturnType<Callback>>> {
const { span, updatedOptions } = startSpan(name, operationOptions, spanOptions);
try {
const result = await withContext(updatedOptions.tracingOptions!.tracingContext!, () =>
Promise.resolve(callback(updatedOptions, span))
);
span.setStatus({ status: "success" });
return result;
return result as ReturnType<typeof withSpan>;
} catch (err) {
span.setStatus({ status: "error", error: err });
throw err;
Expand Down
7 changes: 7 additions & 0 deletions sdk/eventhub/eventhubs-checkpointstore-table/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"plugins": ["@azure/azure-sdk"],
"extends": ["plugin:@azure/azure-sdk/azure-sdk-base"],
"rules": {
"sort-imports": "error"
}
}
7 changes: 7 additions & 0 deletions sdk/eventhub/mock-hub/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"plugins": ["@azure/azure-sdk"],
"extends": ["plugin:@azure/azure-sdk/azure-sdk-base"],
"rules": {
"sort-imports": "error"
}
}
1 change: 1 addition & 0 deletions sdk/identity/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ extends:
template: ../../eng/pipelines/templates/stages/archetype-sdk-client.yml
parameters:
ServiceDirectory: identity
TestProxy: true
Artifacts:
- name: azure-identity
safeName: azureidentity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,9 @@ matrix([[true, false]] as const, async (useAad) => {
}
});

it("creates ChangePoint feedback", async function () {
// Skipped due to potential errors on service side
// Issue - https://github.com/Azure/azure-sdk-for-js/issues/19747
it.skip("creates ChangePoint feedback", async function () {
const changePointFeedback: MetricChangePointFeedback = {
metricId: testEnv.METRICS_ADVISOR_AZURE_SQLSERVER_METRIC_ID_1,
feedbackType: "ChangePoint",
Expand All @@ -558,7 +560,9 @@ matrix([[true, false]] as const, async (useAad) => {
}
});

it("creates Period feedback", async function () {
// Skipped due to potential errors on service side
// Issue - https://github.com/Azure/azure-sdk-for-js/issues/19747
it.skip("creates Period feedback", async function () {
const periodFeedback: MetricPeriodFeedback = {
metricId: testEnv.METRICS_ADVISOR_AZURE_SQLSERVER_METRIC_ID_1,
feedbackType: "Period",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -354,8 +354,8 @@ describe("Model unit tests", () => {

it("convertTimespanToInterval", () => {
const res1 = convertTimespanToInterval({
startTime: new Date("2007-11-13T08:00:00"),
endTime: new Date("2007-11-16T08:00:00"),
startTime: new Date("2007-11-13T08:00:00Z"),
endTime: new Date("2007-11-16T08:00:00Z"),
});
assert.equal(res1, "2007-11-13T08:00:00.000Z/2007-11-16T08:00:00.000Z");

Expand Down
1 change: 1 addition & 0 deletions sdk/template/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ extends:
template: ../../eng/pipelines/templates/stages/archetype-sdk-client.yml
parameters:
ServiceDirectory: template
TestProxy: true
Artifacts:
- name: azure-template
safeName: azuretemplate

0 comments on commit 6527b28

Please sign in to comment.