From 2ccc04f15ea44ed35a11e7205af5b071402d0ac0 Mon Sep 17 00:00:00 2001 From: Richard Park <51494936+richardpark-msft@users.noreply.github.com> Date: Fri, 19 Feb 2021 21:41:41 +0000 Subject: [PATCH 01/52] Centralize createSpan code into core-tracing, update the minimum needed for core-tracing to compile and test --- sdk/core/core-tracing/package.json | 4 +- .../core-tracing/review/core-tracing.api.md | 15 ++++++ .../src/createSpan.ts | 20 ++++++-- sdk/core/core-tracing/src/index.ts | 1 + .../test/createSpan.spec.ts | 50 ++++++++++++++----- 5 files changed, 71 insertions(+), 19 deletions(-) rename sdk/core/{core-http => core-tracing}/src/createSpan.ts (78%) rename sdk/core/{core-http => core-tracing}/test/createSpan.spec.ts (55%) diff --git a/sdk/core/core-tracing/package.json b/sdk/core/core-tracing/package.json index 8ffaca6f48e2..61e8ac551bf3 100644 --- a/sdk/core/core-tracing/package.json +++ b/sdk/core/core-tracing/package.json @@ -88,6 +88,8 @@ "rollup-plugin-visualizer": "^4.0.4", "typescript": "4.1.2", "util": "^0.12.1", - "typedoc": "0.15.2" + "typedoc": "0.15.2", + "sinon": "^9.0.2", + "@types/sinon": "^9.0.4" } } diff --git a/sdk/core/core-tracing/review/core-tracing.api.md b/sdk/core/core-tracing/review/core-tracing.api.md index e5cd6fcea46e..a5953bee308e 100644 --- a/sdk/core/core-tracing/review/core-tracing.api.md +++ b/sdk/core/core-tracing/review/core-tracing.api.md @@ -16,6 +16,16 @@ import { TimeInput } from '@opentelemetry/api'; import { Tracer } from '@opentelemetry/api'; import { TracerBase } from '@opencensus/web-types'; +// Warning: (ae-forgotten-export) The symbol "SpanConfig" needs to be exported by the entry point index.d.ts +// +// @public +export function createSpanFunction({ packagePrefix, namespace }: SpanConfig): (operationName: string, operationOptions: T) => { + span: Span; + updatedOptions: T; +}; + // @public export function extractSpanContextFromTraceParentHeader(traceParentHeader: string): SpanContext | undefined; @@ -79,6 +89,11 @@ export interface OperationTracingOptions { spanOptions?: SpanOptions; } +// @public +export interface OperationTracingOptionsLike { + spanOptions?: OTSpanOptions; +} + export { OTSpanContext } export { OTSpanOptions } diff --git a/sdk/core/core-http/src/createSpan.ts b/sdk/core/core-tracing/src/createSpan.ts similarity index 78% rename from sdk/core/core-http/src/createSpan.ts rename to sdk/core/core-tracing/src/createSpan.ts index d7029a039e9f..c9dbc223d2c5 100644 --- a/sdk/core/core-http/src/createSpan.ts +++ b/sdk/core/core-tracing/src/createSpan.ts @@ -2,13 +2,22 @@ // Licensed under the MIT license. import { Span, SpanOptions, SpanKind } from "@opentelemetry/api"; -import { getTracer } from "@azure/core-tracing"; -import { OperationOptions } from "./coreHttp"; +import { getTracer } from "../src/tracerProxy"; -type OperationTracingOptions = OperationOptions["tracingOptions"]; +/** + * Tracing options to set on an operation. + * @hidden + */ +export interface OperationTracingOptionsLike { + /** + * OpenTelemetry SpanOptions used to create a span when tracing is enabled. + */ + spanOptions?: SpanOptions; +} /** * Configuration for creating a new Tracing Span + * @hidden */ export interface SpanConfig { /** @@ -28,7 +37,7 @@ export interface SpanConfig { * @param tracingOptions - The options for the underlying http request. */ export function createSpanFunction({ packagePrefix, namespace }: SpanConfig) { - return function( + return function( operationName: string, operationOptions: T ): { span: Span; updatedOptions: T } { @@ -55,9 +64,10 @@ export function createSpanFunction({ packagePrefix, namespace }: SpanConfig) { }; } - const newTracingOptions: OperationTracingOptions = { + const newTracingOptions: OperationTracingOptionsLike = { ...tracingOptions, spanOptions: newSpanOptions + // TODO: .context soon. }; const newOperationOptions: T = { diff --git a/sdk/core/core-tracing/src/index.ts b/sdk/core/core-tracing/src/index.ts index e97ce0e3a238..5fabbb35b210 100644 --- a/sdk/core/core-tracing/src/index.ts +++ b/sdk/core/core-tracing/src/index.ts @@ -10,6 +10,7 @@ export { OpenCensusSpanWrapper } from "./tracers/opencensus/openCensusSpanWrappe export { OpenCensusTracerWrapper } from "./tracers/opencensus/openCensusTracerWrapper"; export { TestTracer, SpanGraph, SpanGraphNode } from "./tracers/test/testTracer"; export { TestSpan } from "./tracers/test/testSpan"; +export { OperationTracingOptionsLike, createSpanFunction } from "./createSpan"; // Shared interfaces export { SpanContext, SpanOptions, TraceFlags } from "./interfaces"; diff --git a/sdk/core/core-http/test/createSpan.spec.ts b/sdk/core/core-tracing/test/createSpan.spec.ts similarity index 55% rename from sdk/core/core-http/test/createSpan.spec.ts rename to sdk/core/core-tracing/test/createSpan.spec.ts index 90ef3d8e26fb..b0b107f0a8b3 100644 --- a/sdk/core/core-http/test/createSpan.spec.ts +++ b/sdk/core/core-tracing/test/createSpan.spec.ts @@ -1,14 +1,15 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -import { assert } from "chai"; -import { SpanKind, TraceFlags } from "@opentelemetry/api"; -import { setTracer, TestSpan, TestTracer } from "@azure/core-tracing"; +import * as assert from "assert"; import sinon from "sinon"; +import { SpanKind, TraceFlags } from "@opentelemetry/api"; -import { OperationOptions } from "../src/coreHttp"; +import { setTracer } from "../src/tracerProxy"; +import { TestTracer } from "../src/tracers/test/testTracer"; +import { TestSpan } from "../src/tracers/test/testSpan"; +import { createSpanFunction, OperationTracingOptionsLike } from "../src/createSpan"; -import { createSpanFunction } from "../src/createSpan"; const createSpan = createSpanFunction({ namespace: "Microsoft.Test", packagePrefix: "Azure.Test" }); describe("createSpan", () => { @@ -24,21 +25,44 @@ describe("createSpan", () => { const startSpanStub = sinon.stub(tracer, "startSpan"); startSpanStub.returns(testSpan); setTracer(tracer); - const { span } = createSpan("testMethod", {}); + const { span, updatedOptions } = createSpan("testMethod", { + tracingOptions: ({ + // validate that we dumbly just copy any fields (this makes future upgrades easier) + someOtherField: "someOtherFieldValue", + context: { someContext: "some Context" } + } as OperationTracingOptionsLike) as any + }); assert.strictEqual(span, testSpan, "Should return mocked span"); - assert.isTrue(startSpanStub.calledOnce); + assert.ok(startSpanStub.calledOnce); const [name, options] = startSpanStub.firstCall.args; assert.strictEqual(name, "Azure.Test.testMethod"); assert.deepEqual(options, { kind: SpanKind.INTERNAL }); - assert.isTrue(setAttributeSpy.calledOnceWithExactly("az.namespace", "Microsoft.Test")); + assert.ok(setAttributeSpy.calledOnceWithExactly("az.namespace", "Microsoft.Test")); + + assert.deepEqual(updatedOptions.tracingOptions, { + someOtherField: "someOtherFieldValue", + // TODO: note, this will be incorrect (and break) when we get to the next opentelemetry + // upgrade (and that'll be a good reminder to fix it) + context: { someContext: "some Context" }, + spanOptions: { + attributes: { + 'az.namespace': 'Microsoft.Test' + }, + parent: { + spanId: '', + traceFlags: 0, + traceId: '' + } + } + }); }); it("returns updated SpanOptions", () => { - const options: OperationOptions = {}; + const options: { tracingOptions?: OperationTracingOptionsLike } = {}; const { span, updatedOptions } = createSpan("testMethod", options); - assert.isEmpty(options, "original options should not be modified"); + assert.deepStrictEqual(options, {}, "original options should not be modified"); assert.notStrictEqual(updatedOptions, options, "should return new object"); - const expected: OperationOptions = { + const expected: { tracingOptions?: OperationTracingOptionsLike } = { tracingOptions: { spanOptions: { parent: span.context(), @@ -52,7 +76,7 @@ describe("createSpan", () => { }); it("preserves existing attributes", () => { - const options: OperationOptions = { + const options: { tracingOptions?: OperationTracingOptionsLike } = { tracingOptions: { spanOptions: { attributes: { @@ -63,7 +87,7 @@ describe("createSpan", () => { }; const { span, updatedOptions } = createSpan("testMethod", options); assert.notStrictEqual(updatedOptions, options, "should return new object"); - const expected: OperationOptions = { + const expected: { tracingOptions?: OperationTracingOptionsLike } = { tracingOptions: { spanOptions: { parent: span.context(), From d00744f00efdb69e1725846270f14f8cc7ad240f Mon Sep 17 00:00:00 2001 From: Richard Park <51494936+richardpark-msft@users.noreply.github.com> Date: Fri, 19 Feb 2021 21:42:06 +0000 Subject: [PATCH 02/52] Formatting --- sdk/core/core-tracing/test/createSpan.spec.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sdk/core/core-tracing/test/createSpan.spec.ts b/sdk/core/core-tracing/test/createSpan.spec.ts index b0b107f0a8b3..c87cbb1e8628 100644 --- a/sdk/core/core-tracing/test/createSpan.spec.ts +++ b/sdk/core/core-tracing/test/createSpan.spec.ts @@ -46,12 +46,12 @@ describe("createSpan", () => { context: { someContext: "some Context" }, spanOptions: { attributes: { - 'az.namespace': 'Microsoft.Test' + "az.namespace": "Microsoft.Test" }, parent: { - spanId: '', + spanId: "", traceFlags: 0, - traceId: '' + traceId: "" } } }); From 96f7c97880304f32d8940c4835055b9dd1cb8f75 Mon Sep 17 00:00:00 2001 From: Richard Park <51494936+richardpark-msft@users.noreply.github.com> Date: Fri, 19 Feb 2021 21:50:29 +0000 Subject: [PATCH 03/52] Updating the package reference to be the new core-tracing version (which will shortly have a new OT) --- sdk/anomalydetector/ai-anomaly-detector/package.json | 4 ++-- sdk/appconfiguration/app-configuration/package.json | 4 ++-- .../communication-administration/package.json | 4 ++-- sdk/communication/communication-chat/package.json | 4 ++-- sdk/communication/communication-identity/package.json | 4 ++-- sdk/communication/communication-sms/package.json | 4 ++-- sdk/core/core-client/package.json | 4 ++-- sdk/core/core-http/package.json | 4 ++-- sdk/core/core-https/package.json | 4 ++-- sdk/core/core-tracing/package.json | 4 ++-- sdk/core/core-tracing/review/core-tracing.api.md | 8 ++++++-- sdk/digitaltwins/digital-twins-core/package.json | 4 ++-- sdk/eventgrid/eventgrid/package.json | 4 ++-- sdk/eventhub/event-hubs/package.json | 4 ++-- sdk/formrecognizer/ai-form-recognizer/package.json | 4 ++-- sdk/identity/identity/package.json | 4 ++-- sdk/keyvault/keyvault-admin/package.json | 4 ++-- sdk/keyvault/keyvault-certificates/package.json | 4 ++-- sdk/keyvault/keyvault-common/package.json | 4 ++-- sdk/keyvault/keyvault-keys/package.json | 4 ++-- sdk/keyvault/keyvault-secrets/package.json | 4 ++-- sdk/metricsadvisor/ai-metrics-advisor/package.json | 4 ++-- sdk/mixedreality/mixedreality-authentication/package.json | 4 ++-- sdk/search/search-documents/package.json | 4 ++-- sdk/servicebus/service-bus/package.json | 4 ++-- sdk/storage/storage-blob-changefeed/package.json | 4 ++-- sdk/storage/storage-blob/package.json | 4 ++-- sdk/storage/storage-file-datalake/package.json | 4 ++-- sdk/storage/storage-file-share/package.json | 4 ++-- sdk/storage/storage-queue/package.json | 4 ++-- sdk/tables/data-tables/package.json | 4 ++-- sdk/template/template/package.json | 4 ++-- sdk/textanalytics/ai-text-analytics/package.json | 4 ++-- 33 files changed, 70 insertions(+), 66 deletions(-) diff --git a/sdk/anomalydetector/ai-anomaly-detector/package.json b/sdk/anomalydetector/ai-anomaly-detector/package.json index 91aecad1c45c..26726f581975 100644 --- a/sdk/anomalydetector/ai-anomaly-detector/package.json +++ b/sdk/anomalydetector/ai-anomaly-detector/package.json @@ -67,7 +67,7 @@ "@azure/logger": "^1.0.0", "@opentelemetry/api": "^0.10.2", "tslib": "^2.0.0", - "@azure/core-tracing": "1.0.0-preview.9" + "@azure/core-tracing": "1.0.0-preview.10" }, "devDependencies": { "@azure/dev-tool": "^1.0.0", @@ -129,4 +129,4 @@ } ] } -} +} \ No newline at end of file diff --git a/sdk/appconfiguration/app-configuration/package.json b/sdk/appconfiguration/app-configuration/package.json index eae92739a4a3..ce8409c10911 100644 --- a/sdk/appconfiguration/app-configuration/package.json +++ b/sdk/appconfiguration/app-configuration/package.json @@ -89,7 +89,7 @@ "@azure/core-asynciterator-polyfill": "^1.0.0", "@azure/core-http": "^1.2.0", "@azure/core-paging": "^1.1.1", - "@azure/core-tracing": "1.0.0-preview.9", + "@azure/core-tracing": "1.0.0-preview.10", "@opentelemetry/api": "^0.10.2", "tslib": "^2.0.0" }, @@ -142,4 +142,4 @@ "cross-env": "^7.0.2", "typedoc": "0.15.2" } -} +} \ No newline at end of file diff --git a/sdk/communication/communication-administration/package.json b/sdk/communication/communication-administration/package.json index 2f6124547e2d..cb4cec11b03f 100644 --- a/sdk/communication/communication-administration/package.json +++ b/sdk/communication/communication-administration/package.json @@ -73,7 +73,7 @@ "@azure/core-lro": "^1.0.2", "@azure/core-paging": "^1.1.1", "@azure/logger": "^1.0.0", - "@azure/core-tracing": "1.0.0-preview.9", + "@azure/core-tracing": "1.0.0-preview.10", "@opentelemetry/api": "^0.10.2", "events": "^3.0.0", "tslib": "^2.0.0" @@ -132,4 +132,4 @@ "purchasePhoneNumber.js" ] } -} +} \ No newline at end of file diff --git a/sdk/communication/communication-chat/package.json b/sdk/communication/communication-chat/package.json index fa3c5044e920..00e29a2c6fab 100644 --- a/sdk/communication/communication-chat/package.json +++ b/sdk/communication/communication-chat/package.json @@ -69,7 +69,7 @@ "@azure/communication-signaling": "1.0.0-beta.2", "@azure/core-auth": "^1.2.0", "@azure/core-http": "^1.2.0", - "@azure/core-tracing": "1.0.0-preview.9", + "@azure/core-tracing": "1.0.0-preview.10", "@azure/logger": "^1.0.0", "@opentelemetry/api": "^0.10.2", "events": "^3.0.0", @@ -124,4 +124,4 @@ "util": "^0.12.1", "typedoc": "0.15.2" } -} +} \ No newline at end of file diff --git a/sdk/communication/communication-identity/package.json b/sdk/communication/communication-identity/package.json index ad770abeb8c1..f7d657e9693b 100644 --- a/sdk/communication/communication-identity/package.json +++ b/sdk/communication/communication-identity/package.json @@ -72,7 +72,7 @@ "@azure/core-lro": "^1.0.2", "@azure/core-paging": "^1.1.1", "@azure/logger": "^1.0.0", - "@azure/core-tracing": "1.0.0-preview.9", + "@azure/core-tracing": "1.0.0-preview.10", "@opentelemetry/api": "^0.10.2", "events": "^3.0.0", "tslib": "^2.0.0" @@ -126,4 +126,4 @@ "typescript": "4.1.2", "typedoc": "0.15.2" } -} +} \ No newline at end of file diff --git a/sdk/communication/communication-sms/package.json b/sdk/communication/communication-sms/package.json index 67e30fd42036..8f6a4045c1f2 100644 --- a/sdk/communication/communication-sms/package.json +++ b/sdk/communication/communication-sms/package.json @@ -71,7 +71,7 @@ "@azure/communication-common": "1.0.0-beta.6", "@azure/core-auth": "^1.2.0", "@azure/core-http": "^1.2.0", - "@azure/core-tracing": "1.0.0-preview.9", + "@azure/core-tracing": "1.0.0-preview.10", "@azure/logger": "^1.0.0", "@opentelemetry/api": "^0.10.2", "events": "^3.0.0", @@ -127,4 +127,4 @@ "//sampleConfiguration": { "skipFolder": true } -} +} \ No newline at end of file diff --git a/sdk/core/core-client/package.json b/sdk/core/core-client/package.json index 55abfaaa2f68..add32d849b13 100644 --- a/sdk/core/core-client/package.json +++ b/sdk/core/core-client/package.json @@ -79,7 +79,7 @@ "@azure/abort-controller": "^1.0.0", "@azure/core-auth": "^1.2.0", "@azure/core-https": "1.0.0-beta.2", - "@azure/core-tracing": "1.0.0-preview.9", + "@azure/core-tracing": "1.0.0-preview.10", "@opentelemetry/api": "^0.10.2", "tslib": "^2.0.0" }, @@ -125,4 +125,4 @@ "util": "^0.12.1", "typedoc": "0.15.2" } -} +} \ No newline at end of file diff --git a/sdk/core/core-http/package.json b/sdk/core/core-http/package.json index 1c4f0d2cd718..fad43391a0fe 100644 --- a/sdk/core/core-http/package.json +++ b/sdk/core/core-http/package.json @@ -132,7 +132,7 @@ "dependencies": { "@azure/abort-controller": "^1.0.0", "@azure/core-auth": "^1.2.0", - "@azure/core-tracing": "1.0.0-preview.9", + "@azure/core-tracing": "1.0.0-preview.10", "@azure/logger": "^1.0.0", "@opentelemetry/api": "^0.10.2", "@types/node-fetch": "^2.5.0", @@ -198,4 +198,4 @@ "xhr-mock": "^2.4.1", "typedoc": "0.15.2" } -} +} \ No newline at end of file diff --git a/sdk/core/core-https/package.json b/sdk/core/core-https/package.json index bcf5ab633ee1..638f26b34efa 100644 --- a/sdk/core/core-https/package.json +++ b/sdk/core/core-https/package.json @@ -90,7 +90,7 @@ "dependencies": { "@azure/abort-controller": "^1.0.0", "@azure/core-auth": "^1.2.0", - "@azure/core-tracing": "1.0.0-preview.9", + "@azure/core-tracing": "1.0.0-preview.10", "@azure/logger": "^1.0.0", "@opentelemetry/api": "^0.10.2", "form-data": "^3.0.0", @@ -141,4 +141,4 @@ "util": "^0.12.1", "typedoc": "0.15.2" } -} +} \ No newline at end of file diff --git a/sdk/core/core-tracing/package.json b/sdk/core/core-tracing/package.json index 61e8ac551bf3..7b48075904d8 100644 --- a/sdk/core/core-tracing/package.json +++ b/sdk/core/core-tracing/package.json @@ -1,6 +1,6 @@ { "name": "@azure/core-tracing", - "version": "1.0.0-beta.1", + "version": "1.0.0-preview.10", "description": "Provides low-level interfaces and helper methods for tracing in Azure SDK", "sdk-type": "client", "main": "dist/index.js", @@ -92,4 +92,4 @@ "sinon": "^9.0.2", "@types/sinon": "^9.0.4" } -} +} \ No newline at end of file diff --git a/sdk/core/core-tracing/review/core-tracing.api.md b/sdk/core/core-tracing/review/core-tracing.api.md index a5953bee308e..154feaf84e61 100644 --- a/sdk/core/core-tracing/review/core-tracing.api.md +++ b/sdk/core/core-tracing/review/core-tracing.api.md @@ -16,8 +16,6 @@ import { TimeInput } from '@opentelemetry/api'; import { Tracer } from '@opentelemetry/api'; import { TracerBase } from '@opencensus/web-types'; -// Warning: (ae-forgotten-export) The symbol "SpanConfig" needs to be exported by the entry point index.d.ts -// // @public export function createSpanFunction({ packagePrefix, namespace }: SpanConfig): Date: Fri, 19 Feb 2021 21:50:45 +0000 Subject: [PATCH 04/52] Formatting --- sdk/anomalydetector/ai-anomaly-detector/package.json | 2 +- sdk/appconfiguration/app-configuration/package.json | 2 +- sdk/communication/communication-administration/package.json | 2 +- sdk/communication/communication-chat/package.json | 2 +- sdk/communication/communication-identity/package.json | 2 +- sdk/communication/communication-sms/package.json | 2 +- sdk/core/core-client/package.json | 2 +- sdk/core/core-http/package.json | 2 +- sdk/core/core-https/package.json | 2 +- sdk/core/core-tracing/package.json | 2 +- sdk/core/core-tracing/src/index.ts | 2 +- sdk/digitaltwins/digital-twins-core/package.json | 2 +- sdk/eventgrid/eventgrid/package.json | 2 +- sdk/eventhub/event-hubs/package.json | 2 +- sdk/formrecognizer/ai-form-recognizer/package.json | 2 +- sdk/identity/identity/package.json | 2 +- sdk/keyvault/keyvault-admin/package.json | 2 +- sdk/keyvault/keyvault-certificates/package.json | 2 +- sdk/keyvault/keyvault-common/package.json | 2 +- sdk/keyvault/keyvault-keys/package.json | 2 +- sdk/keyvault/keyvault-secrets/package.json | 2 +- sdk/metricsadvisor/ai-metrics-advisor/package.json | 2 +- sdk/mixedreality/mixedreality-authentication/package.json | 2 +- sdk/search/search-documents/package.json | 2 +- sdk/servicebus/service-bus/package.json | 2 +- sdk/storage/storage-blob-changefeed/package.json | 2 +- sdk/storage/storage-blob/package.json | 2 +- sdk/storage/storage-file-datalake/package.json | 2 +- sdk/storage/storage-file-share/package.json | 2 +- sdk/storage/storage-queue/package.json | 2 +- sdk/tables/data-tables/package.json | 2 +- sdk/template/template/package.json | 2 +- sdk/textanalytics/ai-text-analytics/package.json | 2 +- 33 files changed, 33 insertions(+), 33 deletions(-) diff --git a/sdk/anomalydetector/ai-anomaly-detector/package.json b/sdk/anomalydetector/ai-anomaly-detector/package.json index 26726f581975..99dc77aff5a0 100644 --- a/sdk/anomalydetector/ai-anomaly-detector/package.json +++ b/sdk/anomalydetector/ai-anomaly-detector/package.json @@ -129,4 +129,4 @@ } ] } -} \ No newline at end of file +} diff --git a/sdk/appconfiguration/app-configuration/package.json b/sdk/appconfiguration/app-configuration/package.json index ce8409c10911..092ea3f5dde8 100644 --- a/sdk/appconfiguration/app-configuration/package.json +++ b/sdk/appconfiguration/app-configuration/package.json @@ -142,4 +142,4 @@ "cross-env": "^7.0.2", "typedoc": "0.15.2" } -} \ No newline at end of file +} diff --git a/sdk/communication/communication-administration/package.json b/sdk/communication/communication-administration/package.json index cb4cec11b03f..caeafaa478a2 100644 --- a/sdk/communication/communication-administration/package.json +++ b/sdk/communication/communication-administration/package.json @@ -132,4 +132,4 @@ "purchasePhoneNumber.js" ] } -} \ No newline at end of file +} diff --git a/sdk/communication/communication-chat/package.json b/sdk/communication/communication-chat/package.json index 00e29a2c6fab..9cfe8688aac1 100644 --- a/sdk/communication/communication-chat/package.json +++ b/sdk/communication/communication-chat/package.json @@ -124,4 +124,4 @@ "util": "^0.12.1", "typedoc": "0.15.2" } -} \ No newline at end of file +} diff --git a/sdk/communication/communication-identity/package.json b/sdk/communication/communication-identity/package.json index f7d657e9693b..ca503398c977 100644 --- a/sdk/communication/communication-identity/package.json +++ b/sdk/communication/communication-identity/package.json @@ -126,4 +126,4 @@ "typescript": "4.1.2", "typedoc": "0.15.2" } -} \ No newline at end of file +} diff --git a/sdk/communication/communication-sms/package.json b/sdk/communication/communication-sms/package.json index 8f6a4045c1f2..0e32a7706727 100644 --- a/sdk/communication/communication-sms/package.json +++ b/sdk/communication/communication-sms/package.json @@ -127,4 +127,4 @@ "//sampleConfiguration": { "skipFolder": true } -} \ No newline at end of file +} diff --git a/sdk/core/core-client/package.json b/sdk/core/core-client/package.json index add32d849b13..cefedf47590c 100644 --- a/sdk/core/core-client/package.json +++ b/sdk/core/core-client/package.json @@ -125,4 +125,4 @@ "util": "^0.12.1", "typedoc": "0.15.2" } -} \ No newline at end of file +} diff --git a/sdk/core/core-http/package.json b/sdk/core/core-http/package.json index fad43391a0fe..6442218547df 100644 --- a/sdk/core/core-http/package.json +++ b/sdk/core/core-http/package.json @@ -198,4 +198,4 @@ "xhr-mock": "^2.4.1", "typedoc": "0.15.2" } -} \ No newline at end of file +} diff --git a/sdk/core/core-https/package.json b/sdk/core/core-https/package.json index 638f26b34efa..6902abfdeaca 100644 --- a/sdk/core/core-https/package.json +++ b/sdk/core/core-https/package.json @@ -141,4 +141,4 @@ "util": "^0.12.1", "typedoc": "0.15.2" } -} \ No newline at end of file +} diff --git a/sdk/core/core-tracing/package.json b/sdk/core/core-tracing/package.json index 7b48075904d8..e00b2c1bece4 100644 --- a/sdk/core/core-tracing/package.json +++ b/sdk/core/core-tracing/package.json @@ -92,4 +92,4 @@ "sinon": "^9.0.2", "@types/sinon": "^9.0.4" } -} \ No newline at end of file +} diff --git a/sdk/core/core-tracing/src/index.ts b/sdk/core/core-tracing/src/index.ts index 5fabbb35b210..b5ea7949fb54 100644 --- a/sdk/core/core-tracing/src/index.ts +++ b/sdk/core/core-tracing/src/index.ts @@ -10,7 +10,7 @@ export { OpenCensusSpanWrapper } from "./tracers/opencensus/openCensusSpanWrappe export { OpenCensusTracerWrapper } from "./tracers/opencensus/openCensusTracerWrapper"; export { TestTracer, SpanGraph, SpanGraphNode } from "./tracers/test/testTracer"; export { TestSpan } from "./tracers/test/testSpan"; -export { OperationTracingOptionsLike, createSpanFunction } from "./createSpan"; +export { OperationTracingOptionsLike, createSpanFunction, SpanConfig } from "./createSpan"; // Shared interfaces export { SpanContext, SpanOptions, TraceFlags } from "./interfaces"; diff --git a/sdk/digitaltwins/digital-twins-core/package.json b/sdk/digitaltwins/digital-twins-core/package.json index d2515afc3dc2..98c76383a736 100644 --- a/sdk/digitaltwins/digital-twins-core/package.json +++ b/sdk/digitaltwins/digital-twins-core/package.json @@ -125,4 +125,4 @@ "//sampleConfiguration": { "skipFolder": true } -} \ No newline at end of file +} diff --git a/sdk/eventgrid/eventgrid/package.json b/sdk/eventgrid/eventgrid/package.json index c8c4361c75f8..acc1adfc5024 100644 --- a/sdk/eventgrid/eventgrid/package.json +++ b/sdk/eventgrid/eventgrid/package.json @@ -139,4 +139,4 @@ "typescript": "4.1.2", "typedoc": "0.15.2" } -} \ No newline at end of file +} diff --git a/sdk/eventhub/event-hubs/package.json b/sdk/eventhub/event-hubs/package.json index a0806359d542..e627fab4ac51 100644 --- a/sdk/eventhub/event-hubs/package.json +++ b/sdk/eventhub/event-hubs/package.json @@ -166,4 +166,4 @@ "ws": "^7.1.1", "typedoc": "0.15.2" } -} \ No newline at end of file +} diff --git a/sdk/formrecognizer/ai-form-recognizer/package.json b/sdk/formrecognizer/ai-form-recognizer/package.json index 14473de33724..327136df4622 100644 --- a/sdk/formrecognizer/ai-form-recognizer/package.json +++ b/sdk/formrecognizer/ai-form-recognizer/package.json @@ -143,4 +143,4 @@ "deleteAllModels.js" ] } -} \ No newline at end of file +} diff --git a/sdk/identity/identity/package.json b/sdk/identity/identity/package.json index b3770457511d..4a83601bcb63 100644 --- a/sdk/identity/identity/package.json +++ b/sdk/identity/identity/package.json @@ -143,4 +143,4 @@ "mock-fs": "^4.10.4", "typedoc": "0.15.2" } -} \ No newline at end of file +} diff --git a/sdk/keyvault/keyvault-admin/package.json b/sdk/keyvault/keyvault-admin/package.json index 0c9f7708aec5..64f0418c94e5 100644 --- a/sdk/keyvault/keyvault-admin/package.json +++ b/sdk/keyvault/keyvault-admin/package.json @@ -128,4 +128,4 @@ "uuid": "^8.3.0", "typedoc": "0.15.2" } -} \ No newline at end of file +} diff --git a/sdk/keyvault/keyvault-certificates/package.json b/sdk/keyvault/keyvault-certificates/package.json index f8685d59a1cd..db693b5098a5 100644 --- a/sdk/keyvault/keyvault-certificates/package.json +++ b/sdk/keyvault/keyvault-certificates/package.json @@ -154,4 +154,4 @@ "url": "^0.11.0", "typedoc": "0.15.2" } -} \ No newline at end of file +} diff --git a/sdk/keyvault/keyvault-common/package.json b/sdk/keyvault/keyvault-common/package.json index 4b89d3aa2d79..998fa6a23b84 100644 --- a/sdk/keyvault/keyvault-common/package.json +++ b/sdk/keyvault/keyvault-common/package.json @@ -69,4 +69,4 @@ "rimraf": "^3.0.0", "typescript": "4.1.2" } -} \ No newline at end of file +} diff --git a/sdk/keyvault/keyvault-keys/package.json b/sdk/keyvault/keyvault-keys/package.json index 368043db18dc..31fc9690720d 100644 --- a/sdk/keyvault/keyvault-keys/package.json +++ b/sdk/keyvault/keyvault-keys/package.json @@ -149,4 +149,4 @@ "url": "^0.11.0", "typedoc": "0.15.2" } -} \ No newline at end of file +} diff --git a/sdk/keyvault/keyvault-secrets/package.json b/sdk/keyvault/keyvault-secrets/package.json index cc2efaec3dca..3be80130695b 100644 --- a/sdk/keyvault/keyvault-secrets/package.json +++ b/sdk/keyvault/keyvault-secrets/package.json @@ -152,4 +152,4 @@ "url": "^0.11.0", "typedoc": "0.15.2" } -} \ No newline at end of file +} diff --git a/sdk/metricsadvisor/ai-metrics-advisor/package.json b/sdk/metricsadvisor/ai-metrics-advisor/package.json index e6f8d590a6d2..81219aec357d 100644 --- a/sdk/metricsadvisor/ai-metrics-advisor/package.json +++ b/sdk/metricsadvisor/ai-metrics-advisor/package.json @@ -140,4 +140,4 @@ "seriesData.js" ] } -} \ No newline at end of file +} diff --git a/sdk/mixedreality/mixedreality-authentication/package.json b/sdk/mixedreality/mixedreality-authentication/package.json index 18484b435fdf..3e8f08a7d555 100644 --- a/sdk/mixedreality/mixedreality-authentication/package.json +++ b/sdk/mixedreality/mixedreality-authentication/package.json @@ -115,4 +115,4 @@ "//smokeTestConfiguration": { "skipFolder": true } -} \ No newline at end of file +} diff --git a/sdk/search/search-documents/package.json b/sdk/search/search-documents/package.json index 7062de1b0def..b6b8c9ca9e11 100644 --- a/sdk/search/search-documents/package.json +++ b/sdk/search/search-documents/package.json @@ -132,4 +132,4 @@ "util": "^0.12.1", "typedoc": "0.15.2" } -} \ No newline at end of file +} diff --git a/sdk/servicebus/service-bus/package.json b/sdk/servicebus/service-bus/package.json index 1658a7e27296..19b0b99512c6 100644 --- a/sdk/servicebus/service-bus/package.json +++ b/sdk/servicebus/service-bus/package.json @@ -177,4 +177,4 @@ "events": "^3.0.0", "typedoc": "0.15.2" } -} \ No newline at end of file +} diff --git a/sdk/storage/storage-blob-changefeed/package.json b/sdk/storage/storage-blob-changefeed/package.json index 180ea7638661..464ae5dcc14a 100644 --- a/sdk/storage/storage-blob-changefeed/package.json +++ b/sdk/storage/storage-blob-changefeed/package.json @@ -160,4 +160,4 @@ "//sampleConfiguration": { "skipFolder": true } -} \ No newline at end of file +} diff --git a/sdk/storage/storage-blob/package.json b/sdk/storage/storage-blob/package.json index 9457372bc4f7..e1cccb6d0ab1 100644 --- a/sdk/storage/storage-blob/package.json +++ b/sdk/storage/storage-blob/package.json @@ -183,4 +183,4 @@ "util": "^0.12.1", "typedoc": "0.15.2" } -} \ No newline at end of file +} diff --git a/sdk/storage/storage-file-datalake/package.json b/sdk/storage/storage-file-datalake/package.json index bfe534ecb3e1..9d704f0ededf 100644 --- a/sdk/storage/storage-file-datalake/package.json +++ b/sdk/storage/storage-file-datalake/package.json @@ -163,4 +163,4 @@ "util": "^0.12.1", "typedoc": "0.15.2" } -} \ No newline at end of file +} diff --git a/sdk/storage/storage-file-share/package.json b/sdk/storage/storage-file-share/package.json index 2bfa500b2900..303255c2ef13 100644 --- a/sdk/storage/storage-file-share/package.json +++ b/sdk/storage/storage-file-share/package.json @@ -169,4 +169,4 @@ "util": "^0.12.1", "typedoc": "0.15.2" } -} \ No newline at end of file +} diff --git a/sdk/storage/storage-queue/package.json b/sdk/storage/storage-queue/package.json index 67fa0f664c94..4031c1ba7f25 100644 --- a/sdk/storage/storage-queue/package.json +++ b/sdk/storage/storage-queue/package.json @@ -163,4 +163,4 @@ "util": "^0.12.1", "typedoc": "0.15.2" } -} \ No newline at end of file +} diff --git a/sdk/tables/data-tables/package.json b/sdk/tables/data-tables/package.json index 723e4ac0f0bd..3f00337ecc8a 100644 --- a/sdk/tables/data-tables/package.json +++ b/sdk/tables/data-tables/package.json @@ -137,4 +137,4 @@ } ] } -} \ No newline at end of file +} diff --git a/sdk/template/template/package.json b/sdk/template/template/package.json index 96a2c4cc0c9a..035e382705c0 100644 --- a/sdk/template/template/package.json +++ b/sdk/template/template/package.json @@ -120,4 +120,4 @@ "//sampleConfiguration": { "skipFolder": false } -} \ No newline at end of file +} diff --git a/sdk/textanalytics/ai-text-analytics/package.json b/sdk/textanalytics/ai-text-analytics/package.json index 3b459b282463..e5debb1ea2e1 100644 --- a/sdk/textanalytics/ai-text-analytics/package.json +++ b/sdk/textanalytics/ai-text-analytics/package.json @@ -133,4 +133,4 @@ "karma-source-map-support": "~1.4.0", "typedoc": "0.15.2" } -} \ No newline at end of file +} From 450e1baf2677165585dd6bd2307362036d735108 Mon Sep 17 00:00:00 2001 From: Richard Park <51494936+richardpark-msft@users.noreply.github.com> Date: Fri, 19 Feb 2021 22:29:12 +0000 Subject: [PATCH 05/52] core-http compatible! --- sdk/core/core-http/review/core-http.api.md | 11 ++++---- sdk/core/core-http/src/createSpan.ts | 27 +++++++++++++++++++ sdk/core/core-http/src/serviceClient.ts | 8 +++--- .../core-tracing/review/core-tracing.api.md | 2 +- sdk/core/core-tracing/src/createSpan.ts | 4 +-- sdk/synapse/synapse-monitoring/package.json | 1 + 6 files changed, 40 insertions(+), 13 deletions(-) create mode 100644 sdk/core/core-http/src/createSpan.ts diff --git a/sdk/core/core-http/review/core-http.api.md b/sdk/core/core-http/review/core-http.api.md index 680dac23462e..979729484ad2 100644 --- a/sdk/core/core-http/review/core-http.api.md +++ b/sdk/core/core-http/review/core-http.api.md @@ -11,6 +11,7 @@ import { GetTokenOptions } from '@azure/core-auth'; import { isTokenCredential } from '@azure/core-auth'; import { OperationTracingOptions } from '@azure/core-tracing'; import { Span } from '@opentelemetry/api'; +import { SpanConfig as SpanConfig_2 } from '@azure/core-tracing'; import { SpanOptions } from '@azure/core-tracing'; import { TokenCredential } from '@azure/core-auth'; @@ -157,8 +158,8 @@ export const Constants: { // @public (undocumented) export function createPipelineFromOptions(pipelineOptions: InternalPipelineOptions, authPolicyFactory?: RequestPolicyFactory): ServiceClientOptions; -// @public -export function createSpanFunction({ packagePrefix, namespace }: SpanConfig): (operationName: string, operationOptions: T) => { +// @public (undocumented) +export function createSpanFunction(spanConfig: SpanConfig): (operationName: string, operationOptions: T) => { span: Span; updatedOptions: T; }; @@ -798,10 +799,8 @@ export interface SimpleMapperType { name: "Base64Url" | "Boolean" | "ByteArray" | "Date" | "DateTime" | "DateTimeRfc1123" | "Object" | "Stream" | "String" | "TimeSpan" | "UnixTime" | "Uuid" | "Number" | "any"; } -// @public -export interface SpanConfig { - namespace: string; - packagePrefix: string; +// @public (undocumented) +export interface SpanConfig extends SpanConfig_2 { } // @public diff --git a/sdk/core/core-http/src/createSpan.ts b/sdk/core/core-http/src/createSpan.ts new file mode 100644 index 000000000000..9eb2de540df0 --- /dev/null +++ b/sdk/core/core-http/src/createSpan.ts @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +import { SpanConfig as coreTracingSpanConfig, createSpanFunction as coreTracingCreateSpanFunction } from "@azure/core-tracing"; +import { Span } from "@opentelemetry/api"; +import { OperationOptions } from "./operationOptions"; + +export interface SpanConfig extends coreTracingSpanConfig { } + +// export function createSpanFunction({ packagePrefix, namespace }: SpanConfig) { +// return function ( +// operationName: string, +// operationOptions: T +// ): { span: Span; updatedOptions: T } { + +export function createSpanFunction(spanConfig: SpanConfig): (operationName: string, operationOptions: T) => { + span: Span; + updatedOptions: T; +} { + return coreTracingCreateSpanFunction(spanConfig); +} + +// export function createSpanFunction({ packagePrefix, namespace }: SpanConfig) { +// return function ( +// operationName: string, +// operationOptions: T +// ): { span: Span; updatedOptions: T } { \ No newline at end of file diff --git a/sdk/core/core-http/src/serviceClient.ts b/sdk/core/core-http/src/serviceClient.ts index 3b68b16f1e08..b1affcb507f5 100644 --- a/sdk/core/core-http/src/serviceClient.ts +++ b/sdk/core/core-http/src/serviceClient.ts @@ -100,8 +100,8 @@ export interface ServiceClientOptions { * the requestPolicyFactories that will be used. */ requestPolicyFactories?: - | RequestPolicyFactory[] - | ((defaultRequestPolicyFactories: RequestPolicyFactory[]) => void | RequestPolicyFactory[]); + | RequestPolicyFactory[] + | ((defaultRequestPolicyFactories: RequestPolicyFactory[]) => void | RequestPolicyFactory[]); /** * The HttpClient that will be used to send HTTP requests. */ @@ -459,7 +459,7 @@ export class ServiceClient { } else { httpRequest.headers.set( headerParameter.mapper.serializedName || - getPathStringFromParameter(headerParameter), + getPathStringFromParameter(headerParameter), headerValue ); } @@ -520,7 +520,7 @@ export class ServiceClient { sendRequestError.details = flattenResponse( sendRequestError.response, operationSpec.responses[sendRequestError.statusCode] || - operationSpec.responses["default"] + operationSpec.responses["default"] ); } result = Promise.reject(sendRequestError); diff --git a/sdk/core/core-tracing/review/core-tracing.api.md b/sdk/core/core-tracing/review/core-tracing.api.md index 154feaf84e61..a0f379428771 100644 --- a/sdk/core/core-tracing/review/core-tracing.api.md +++ b/sdk/core/core-tracing/review/core-tracing.api.md @@ -19,7 +19,7 @@ import { TracerBase } from '@opencensus/web-types'; // @public export function createSpanFunction({ packagePrefix, namespace }: SpanConfig): (operationName: string, operationOptions: T) => { +} | undefined>(operationName: string, operationOptions: T) => { span: Span; updatedOptions: T; }; diff --git a/sdk/core/core-tracing/src/createSpan.ts b/sdk/core/core-tracing/src/createSpan.ts index c9dbc223d2c5..2ebfc3297df3 100644 --- a/sdk/core/core-tracing/src/createSpan.ts +++ b/sdk/core/core-tracing/src/createSpan.ts @@ -37,12 +37,12 @@ export interface SpanConfig { * @param tracingOptions - The options for the underlying http request. */ export function createSpanFunction({ packagePrefix, namespace }: SpanConfig) { - return function( + return function ( operationName: string, operationOptions: T ): { span: Span; updatedOptions: T } { const tracer = getTracer(); - const tracingOptions = operationOptions.tracingOptions || {}; + const tracingOptions = operationOptions?.tracingOptions || {}; const spanOptions: SpanOptions = { ...tracingOptions.spanOptions, kind: SpanKind.INTERNAL diff --git a/sdk/synapse/synapse-monitoring/package.json b/sdk/synapse/synapse-monitoring/package.json index 7715d81dd0b4..1a9f23a9527e 100644 --- a/sdk/synapse/synapse-monitoring/package.json +++ b/sdk/synapse/synapse-monitoring/package.json @@ -8,6 +8,7 @@ "version": "1.0.0-beta.3", "dependencies": { "@azure/core-http": "^1.2.0", + "@azure/core-tracing": "1.0.0-preview.10", "@opentelemetry/api": "^0.10.2", "tslib": "^2.0.0" }, From 88b57833dcf3f0ce98fe15326715485457ffd490 Mon Sep 17 00:00:00 2001 From: Richard Park <51494936+richardpark-msft@users.noreply.github.com> Date: Fri, 19 Feb 2021 22:52:32 +0000 Subject: [PATCH 06/52] Formatting --- sdk/core/core-http/src/createSpan.ts | 16 ++++++++++++---- sdk/core/core-http/src/serviceClient.ts | 8 ++++---- sdk/core/core-tracing/src/createSpan.ts | 2 +- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/sdk/core/core-http/src/createSpan.ts b/sdk/core/core-http/src/createSpan.ts index 9eb2de540df0..2511a11b75e6 100644 --- a/sdk/core/core-http/src/createSpan.ts +++ b/sdk/core/core-http/src/createSpan.ts @@ -1,11 +1,14 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -import { SpanConfig as coreTracingSpanConfig, createSpanFunction as coreTracingCreateSpanFunction } from "@azure/core-tracing"; +import { + SpanConfig as coreTracingSpanConfig, + createSpanFunction as coreTracingCreateSpanFunction +} from "@azure/core-tracing"; import { Span } from "@opentelemetry/api"; import { OperationOptions } from "./operationOptions"; -export interface SpanConfig extends coreTracingSpanConfig { } +export interface SpanConfig extends coreTracingSpanConfig {} // export function createSpanFunction({ packagePrefix, namespace }: SpanConfig) { // return function ( @@ -13,7 +16,12 @@ export interface SpanConfig extends coreTracingSpanConfig { } // operationOptions: T // ): { span: Span; updatedOptions: T } { -export function createSpanFunction(spanConfig: SpanConfig): (operationName: string, operationOptions: T) => { +export function createSpanFunction( + spanConfig: SpanConfig +): ( + operationName: string, + operationOptions: T +) => { span: Span; updatedOptions: T; } { @@ -24,4 +32,4 @@ export function createSpanFunction(spanConfig: SpanConfig): ( // operationName: string, // operationOptions: T -// ): { span: Span; updatedOptions: T } { \ No newline at end of file +// ): { span: Span; updatedOptions: T } { diff --git a/sdk/core/core-http/src/serviceClient.ts b/sdk/core/core-http/src/serviceClient.ts index b1affcb507f5..3b68b16f1e08 100644 --- a/sdk/core/core-http/src/serviceClient.ts +++ b/sdk/core/core-http/src/serviceClient.ts @@ -100,8 +100,8 @@ export interface ServiceClientOptions { * the requestPolicyFactories that will be used. */ requestPolicyFactories?: - | RequestPolicyFactory[] - | ((defaultRequestPolicyFactories: RequestPolicyFactory[]) => void | RequestPolicyFactory[]); + | RequestPolicyFactory[] + | ((defaultRequestPolicyFactories: RequestPolicyFactory[]) => void | RequestPolicyFactory[]); /** * The HttpClient that will be used to send HTTP requests. */ @@ -459,7 +459,7 @@ export class ServiceClient { } else { httpRequest.headers.set( headerParameter.mapper.serializedName || - getPathStringFromParameter(headerParameter), + getPathStringFromParameter(headerParameter), headerValue ); } @@ -520,7 +520,7 @@ export class ServiceClient { sendRequestError.details = flattenResponse( sendRequestError.response, operationSpec.responses[sendRequestError.statusCode] || - operationSpec.responses["default"] + operationSpec.responses["default"] ); } result = Promise.reject(sendRequestError); diff --git a/sdk/core/core-tracing/src/createSpan.ts b/sdk/core/core-tracing/src/createSpan.ts index 2ebfc3297df3..acdb631c7b90 100644 --- a/sdk/core/core-tracing/src/createSpan.ts +++ b/sdk/core/core-tracing/src/createSpan.ts @@ -37,7 +37,7 @@ export interface SpanConfig { * @param tracingOptions - The options for the underlying http request. */ export function createSpanFunction({ packagePrefix, namespace }: SpanConfig) { - return function ( + return function( operationName: string, operationOptions: T ): { span: Span; updatedOptions: T } { From 724092a7c24db5918112457a3cb30b3aa0f126d0 Mon Sep 17 00:00:00 2001 From: Richard Park <51494936+richardpark-msft@users.noreply.github.com> Date: Fri, 19 Feb 2021 23:09:48 +0000 Subject: [PATCH 07/52] Centralize most of the createSpan logic (except for keyvault, which is a bit more complicated) --- .../ai-anomaly-detector/src/tracing.ts | 55 ++------------- .../src/common/tracing.ts | 54 ++------------ .../communication-chat/src/tracing.ts | 54 ++------------ .../src/common/tracing.ts | 53 ++------------ .../communication-sms/src/tracing.ts | 54 ++------------ sdk/core/core-client/src/createSpan.ts | 70 +++++-------------- sdk/core/core-http/src/createSpan.ts | 26 ++----- .../digital-twins-core/src/tracing.ts | 54 ++------------ sdk/eventgrid/eventgrid/src/tracing.ts | 54 ++------------ .../ai-form-recognizer/src/tracing.ts | 55 ++------------- sdk/identity/identity/src/util/tracing.ts | 53 ++------------ .../ai-metrics-advisor/src/tracing.ts | 55 ++------------- .../src/tracing.ts | 58 ++------------- sdk/search/search-documents/src/tracing.ts | 56 ++------------- .../service-bus/src/util/tracing.ts | 47 +++---------- .../src/utils/tracing.ts | 40 ++--------- sdk/storage/storage-blob/src/utils/tracing.ts | 40 ++--------- .../src/utils/tracing.ts | 41 ++--------- .../storage-file-share/src/utils/tracing.ts | 40 ++--------- .../storage-queue/src/utils/tracing.ts | 40 ++--------- sdk/tables/data-tables/src/utils/tracing.ts | 54 ++------------ .../ai-text-analytics/src/tracing.ts | 59 ++-------------- 22 files changed, 138 insertions(+), 974 deletions(-) diff --git a/sdk/anomalydetector/ai-anomaly-detector/src/tracing.ts b/sdk/anomalydetector/ai-anomaly-detector/src/tracing.ts index b088d784b5c5..2c88a5a12c9b 100644 --- a/sdk/anomalydetector/ai-anomaly-detector/src/tracing.ts +++ b/sdk/anomalydetector/ai-anomaly-detector/src/tracing.ts @@ -1,58 +1,13 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -import { getTracer, OperationTracingOptions } from "@azure/core-tracing"; -import { Span, SpanOptions, SpanKind } from "@opentelemetry/api"; -import { OperationOptions } from "@azure/core-http"; +import { createSpanFunction } from "@azure/core-tracing"; /** * Creates a span using the global tracer. * @internal - * @param name - The name of the operation being performed. - * @param tracingOptions - The options for the underlying http request. */ -export function createSpan( - operationName: string, - operationOptions: T -): { span: Span; updatedOptions: T } { - const tracer = getTracer(); - const tracingOptions = operationOptions.tracingOptions || {}; - const spanOptions: SpanOptions = { - ...tracingOptions.spanOptions, - kind: SpanKind.INTERNAL - }; - - const span = tracer.startSpan( - `Azure.CognitiveServices.AnomalyDetector.${operationName}`, - spanOptions - ); - - span.setAttribute("az.namespace", "Microsoft.CognitiveServices"); - - let newSpanOptions = tracingOptions.spanOptions || {}; - if (span.isRecording()) { - newSpanOptions = { - ...tracingOptions.spanOptions, - parent: span.context(), - attributes: { - ...spanOptions.attributes, - "az.namespace": "Microsoft.CognitiveServices" - } - }; - } - - const newTracingOptions: OperationTracingOptions = { - ...tracingOptions, - spanOptions: newSpanOptions - }; - - const newOperationOptions: T = { - ...operationOptions, - tracingOptions: newTracingOptions - }; - - return { - span, - updatedOptions: newOperationOptions - }; -} +export const createSpan = createSpanFunction({ + packagePrefix: "Azure.CognitiveServices.AnomalyDetector", + namespace: "Microsoft.CognitiveServices" +}); diff --git a/sdk/communication/communication-administration/src/common/tracing.ts b/sdk/communication/communication-administration/src/common/tracing.ts index 4407ba845a27..88aa261c1114 100644 --- a/sdk/communication/communication-administration/src/common/tracing.ts +++ b/sdk/communication/communication-administration/src/common/tracing.ts @@ -1,57 +1,13 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -import { OperationOptions } from "@azure/core-http"; -import { getTracer } from "@azure/core-tracing"; -import { Span, SpanOptions, SpanKind } from "@opentelemetry/api"; - -type OperationTracingOptions = OperationOptions["tracingOptions"]; +import { createSpanFunction } from "@azure/core-tracing"; /** * Creates a span using the global tracer. * @internal - * @param name - The name of the operation being performed. - * @param tracingOptions - The options for the underlying http request. */ -export function createSpan( - operationName: string, - operationOptions: T -): { span: Span; updatedOptions: T } { - const tracer = getTracer(); - const tracingOptions = operationOptions.tracingOptions || {}; - const spanOptions: SpanOptions = { - ...tracingOptions.spanOptions, - kind: SpanKind.INTERNAL - }; - - const span = tracer.startSpan(`Azure.Communication.${operationName}`, spanOptions); - - span.setAttribute("az.namespace", "Microsoft.Communication"); - - let newSpanOptions = tracingOptions.spanOptions || {}; - if (span.isRecording()) { - newSpanOptions = { - ...tracingOptions.spanOptions, - parent: span.context(), - attributes: { - ...spanOptions.attributes, - "az.namespace": "Microsoft.Communication" - } - }; - } - - const newTracingOptions: OperationTracingOptions = { - ...tracingOptions, - spanOptions: newSpanOptions - }; - - const newOperationOptions: T = { - ...operationOptions, - tracingOptions: newTracingOptions - }; - - return { - span, - updatedOptions: newOperationOptions - }; -} +export const createSpan = createSpanFunction({ + packagePrefix: "Azure.Communication", + namespace: "Microsoft.Communication" +}); diff --git a/sdk/communication/communication-chat/src/tracing.ts b/sdk/communication/communication-chat/src/tracing.ts index 89f66369a3c2..88aa261c1114 100644 --- a/sdk/communication/communication-chat/src/tracing.ts +++ b/sdk/communication/communication-chat/src/tracing.ts @@ -1,57 +1,13 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -import { getTracer } from "@azure/core-tracing"; -import { Span, SpanOptions, SpanKind } from "@opentelemetry/api"; -import { OperationOptions } from "@azure/core-http"; - -type OperationTracingOptions = OperationOptions["tracingOptions"]; +import { createSpanFunction } from "@azure/core-tracing"; /** * Creates a span using the global tracer. * @internal - * @param name - The name of the operation being performed. - * @param tracingOptions - The options for the underlying http request. */ -export function createSpan( - operationName: string, - operationOptions: T -): { span: Span; updatedOptions: T } { - const tracer = getTracer(); - const tracingOptions = operationOptions.tracingOptions || {}; - const spanOptions: SpanOptions = { - ...tracingOptions.spanOptions, - kind: SpanKind.INTERNAL - }; - - const span = tracer.startSpan(`Azure.Communication.${operationName}`, spanOptions); - - span.setAttribute("az.namespace", "Microsoft.Communication"); - - let newSpanOptions = tracingOptions.spanOptions || {}; - if (span.isRecording()) { - newSpanOptions = { - ...tracingOptions.spanOptions, - parent: span.context(), - attributes: { - ...spanOptions.attributes, - "az.namespace": "Microsoft.Communication" - } - }; - } - - const newTracingOptions: OperationTracingOptions = { - ...tracingOptions, - spanOptions: newSpanOptions - }; - - const newOperationOptions: T = { - ...operationOptions, - tracingOptions: newTracingOptions - }; - - return { - span, - updatedOptions: newOperationOptions - }; -} +export const createSpan = createSpanFunction({ + packagePrefix: "Azure.Communication", + namespace: "Microsoft.Communication" +}); diff --git a/sdk/communication/communication-identity/src/common/tracing.ts b/sdk/communication/communication-identity/src/common/tracing.ts index 4407ba845a27..999aa9f02147 100644 --- a/sdk/communication/communication-identity/src/common/tracing.ts +++ b/sdk/communication/communication-identity/src/common/tracing.ts @@ -1,57 +1,14 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -import { OperationOptions } from "@azure/core-http"; -import { getTracer } from "@azure/core-tracing"; -import { Span, SpanOptions, SpanKind } from "@opentelemetry/api"; - -type OperationTracingOptions = OperationOptions["tracingOptions"]; +import { createSpanFunction } from "@azure/core-tracing"; /** * Creates a span using the global tracer. * @internal - * @param name - The name of the operation being performed. - * @param tracingOptions - The options for the underlying http request. */ -export function createSpan( - operationName: string, - operationOptions: T -): { span: Span; updatedOptions: T } { - const tracer = getTracer(); - const tracingOptions = operationOptions.tracingOptions || {}; - const spanOptions: SpanOptions = { - ...tracingOptions.spanOptions, - kind: SpanKind.INTERNAL - }; - - const span = tracer.startSpan(`Azure.Communication.${operationName}`, spanOptions); - - span.setAttribute("az.namespace", "Microsoft.Communication"); - - let newSpanOptions = tracingOptions.spanOptions || {}; - if (span.isRecording()) { - newSpanOptions = { - ...tracingOptions.spanOptions, - parent: span.context(), - attributes: { - ...spanOptions.attributes, - "az.namespace": "Microsoft.Communication" - } - }; - } - - const newTracingOptions: OperationTracingOptions = { - ...tracingOptions, - spanOptions: newSpanOptions - }; - - const newOperationOptions: T = { - ...operationOptions, - tracingOptions: newTracingOptions - }; +export const createSpan = createSpanFunction({ + packagePrefix: "Azure.Communication", + namespace: "Microsoft.Communication" +}); - return { - span, - updatedOptions: newOperationOptions - }; -} diff --git a/sdk/communication/communication-sms/src/tracing.ts b/sdk/communication/communication-sms/src/tracing.ts index 4407ba845a27..88aa261c1114 100644 --- a/sdk/communication/communication-sms/src/tracing.ts +++ b/sdk/communication/communication-sms/src/tracing.ts @@ -1,57 +1,13 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -import { OperationOptions } from "@azure/core-http"; -import { getTracer } from "@azure/core-tracing"; -import { Span, SpanOptions, SpanKind } from "@opentelemetry/api"; - -type OperationTracingOptions = OperationOptions["tracingOptions"]; +import { createSpanFunction } from "@azure/core-tracing"; /** * Creates a span using the global tracer. * @internal - * @param name - The name of the operation being performed. - * @param tracingOptions - The options for the underlying http request. */ -export function createSpan( - operationName: string, - operationOptions: T -): { span: Span; updatedOptions: T } { - const tracer = getTracer(); - const tracingOptions = operationOptions.tracingOptions || {}; - const spanOptions: SpanOptions = { - ...tracingOptions.spanOptions, - kind: SpanKind.INTERNAL - }; - - const span = tracer.startSpan(`Azure.Communication.${operationName}`, spanOptions); - - span.setAttribute("az.namespace", "Microsoft.Communication"); - - let newSpanOptions = tracingOptions.spanOptions || {}; - if (span.isRecording()) { - newSpanOptions = { - ...tracingOptions.spanOptions, - parent: span.context(), - attributes: { - ...spanOptions.attributes, - "az.namespace": "Microsoft.Communication" - } - }; - } - - const newTracingOptions: OperationTracingOptions = { - ...tracingOptions, - spanOptions: newSpanOptions - }; - - const newOperationOptions: T = { - ...operationOptions, - tracingOptions: newTracingOptions - }; - - return { - span, - updatedOptions: newOperationOptions - }; -} +export const createSpan = createSpanFunction({ + packagePrefix: "Azure.Communication", + namespace: "Microsoft.Communication" +}); diff --git a/sdk/core/core-client/src/createSpan.ts b/sdk/core/core-client/src/createSpan.ts index faaa05f77dd1..98e31f1ecdc8 100644 --- a/sdk/core/core-client/src/createSpan.ts +++ b/sdk/core/core-client/src/createSpan.ts @@ -1,59 +1,23 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -import { Span, SpanOptions, SpanKind } from "@opentelemetry/api"; -import { getTracer } from "@azure/core-tracing"; -import { OperationOptions, SpanConfig } from "./interfaces"; - -type OperationTracingOptions = OperationOptions["tracingOptions"]; - -/** - * Creates a function called createSpan to create spans using the global tracer. - * @hidden - * @param spanConfig - The name of the operation being performed. - * @param tracingOptions - The options for the underlying http request. - */ -export function createSpanFunction({ packagePrefix, namespace }: SpanConfig) { - return function( +import { + SpanConfig as coreTracingSpanConfig, + createSpanFunction as coreTracingCreateSpanFunction +} from "@azure/core-tracing"; +import { Span } from "@opentelemetry/api"; +import { OperationOptions } from "./interfaces"; + +export interface SpanConfig extends coreTracingSpanConfig { } + +export function createSpanFunction( + spanConfig: SpanConfig +): ( operationName: string, operationOptions: T - ): { span: Span; updatedOptions: T } { - const tracer = getTracer(); - const tracingOptions = operationOptions.tracingOptions || {}; - const spanOptions: SpanOptions = { - ...tracingOptions.spanOptions, - kind: SpanKind.INTERNAL - }; - - const span = tracer.startSpan(`${packagePrefix}.${operationName}`, spanOptions); - - span.setAttribute("az.namespace", namespace); - - let newSpanOptions = tracingOptions.spanOptions || {}; - if (span.isRecording()) { - newSpanOptions = { - ...tracingOptions.spanOptions, - parent: span.context(), - attributes: { - ...spanOptions.attributes, - "az.namespace": namespace - } - }; - } - - const newTracingOptions: OperationTracingOptions = { - ...tracingOptions, - spanOptions: newSpanOptions - }; - - const newOperationOptions: T = { - ...operationOptions, - tracingOptions: newTracingOptions - }; - - return { - span, - updatedOptions: newOperationOptions - }; - }; + ) => { + span: Span; + updatedOptions: T; + } { + return coreTracingCreateSpanFunction(spanConfig); } diff --git a/sdk/core/core-http/src/createSpan.ts b/sdk/core/core-http/src/createSpan.ts index 2511a11b75e6..1ecb3c10715e 100644 --- a/sdk/core/core-http/src/createSpan.ts +++ b/sdk/core/core-http/src/createSpan.ts @@ -8,28 +8,16 @@ import { import { Span } from "@opentelemetry/api"; import { OperationOptions } from "./operationOptions"; -export interface SpanConfig extends coreTracingSpanConfig {} - -// export function createSpanFunction({ packagePrefix, namespace }: SpanConfig) { -// return function ( -// operationName: string, -// operationOptions: T -// ): { span: Span; updatedOptions: T } { +export interface SpanConfig extends coreTracingSpanConfig { } export function createSpanFunction( spanConfig: SpanConfig ): ( - operationName: string, - operationOptions: T -) => { - span: Span; - updatedOptions: T; -} { + operationName: string, + operationOptions: T + ) => { + span: Span; + updatedOptions: T; + } { return coreTracingCreateSpanFunction(spanConfig); } - -// export function createSpanFunction({ packagePrefix, namespace }: SpanConfig) { -// return function ( -// operationName: string, -// operationOptions: T -// ): { span: Span; updatedOptions: T } { diff --git a/sdk/digitaltwins/digital-twins-core/src/tracing.ts b/sdk/digitaltwins/digital-twins-core/src/tracing.ts index 24fd5f430249..1d5bf67208d8 100644 --- a/sdk/digitaltwins/digital-twins-core/src/tracing.ts +++ b/sdk/digitaltwins/digital-twins-core/src/tracing.ts @@ -1,57 +1,13 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -import { getTracer } from "@azure/core-tracing"; -import { Span, SpanOptions, SpanKind } from "@opentelemetry/api"; -import { OperationOptions } from "@azure/core-http"; - -type OperationTracingOptions = OperationOptions["tracingOptions"]; +import { createSpanFunction } from "@azure/core-tracing"; /** * Creates a span using the global tracer. * @internal - * @param name - The name of the operation being performed. - * @param tracingOptions - The options for the underlying http request. */ -export function createSpan( - operationName: string, - operationOptions: T -): { span: Span; updatedOptions: T } { - const tracer = getTracer(); - const tracingOptions = operationOptions.tracingOptions || {}; - const spanOptions: SpanOptions = { - ...tracingOptions.spanOptions, - kind: SpanKind.INTERNAL - }; - - const span = tracer.startSpan(`DigitalTwinsClient.${operationName}`, spanOptions); - - span.setAttribute("az.namespace", "Microsoft.DigitalTwins"); - - let newSpanOptions = tracingOptions.spanOptions || {}; - if (span.isRecording()) { - newSpanOptions = { - ...tracingOptions.spanOptions, - parent: span.context(), - attributes: { - ...spanOptions.attributes, - "az.namespace": "Microsoft.DigitalTwins" - } - }; - } - - const newTracingOptions: OperationTracingOptions = { - ...tracingOptions, - spanOptions: newSpanOptions - }; - - const newOperationOptions: T = { - ...operationOptions, - tracingOptions: newTracingOptions - }; - - return { - span, - updatedOptions: newOperationOptions - }; -} +export const createSpan = createSpanFunction({ + packagePrefix: "DigitalTwinsClient", + namespace: "Microsoft.DigitalTwins" +}); diff --git a/sdk/eventgrid/eventgrid/src/tracing.ts b/sdk/eventgrid/eventgrid/src/tracing.ts index b7750fa0d3d5..8b6c476e60ed 100644 --- a/sdk/eventgrid/eventgrid/src/tracing.ts +++ b/sdk/eventgrid/eventgrid/src/tracing.ts @@ -1,57 +1,13 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -import { getTracer } from "@azure/core-tracing"; -import { Span, SpanOptions, SpanKind } from "@opentelemetry/api"; -import { OperationOptions } from "@azure/core-client"; - -type OperationTracingOptions = OperationOptions["tracingOptions"]; +import { createSpanFunction } from "@azure/core-tracing"; /** * Creates a span using the global tracer. * @internal - * @param name - The name of the operation being performed. - * @param tracingOptions - The options for the underlying http request. */ -export function createSpan( - operationName: string, - operationOptions: T -): { span: Span; updatedOptions: T } { - const tracer = getTracer(); - const tracingOptions = operationOptions.tracingOptions || {}; - const spanOptions: SpanOptions = { - ...tracingOptions.spanOptions, - kind: SpanKind.INTERNAL - }; - - const span = tracer.startSpan(`Azure.Data.EventGrid.${operationName}`, spanOptions); - - span.setAttribute("az.namespace", "Microsoft.Messaging.EventGrid"); - - let newSpanOptions = tracingOptions.spanOptions || {}; - if (span.isRecording()) { - newSpanOptions = { - ...tracingOptions.spanOptions, - parent: span.context(), - attributes: { - ...spanOptions.attributes, - "az.namespace": "Microsoft.Data.EventGrid" - } - }; - } - - const newTracingOptions: OperationTracingOptions = { - ...tracingOptions, - spanOptions: newSpanOptions - }; - - const newOperationOptions: T = { - ...operationOptions, - tracingOptions: newTracingOptions - }; - - return { - span, - updatedOptions: newOperationOptions - }; -} +export const createSpan = createSpanFunction({ + packagePrefix: "Azure.Data.EventGrid", + namespace: "Microsoft.Messaging.EventGrid" +}); diff --git a/sdk/formrecognizer/ai-form-recognizer/src/tracing.ts b/sdk/formrecognizer/ai-form-recognizer/src/tracing.ts index ab8a61d1f832..ca9e15799641 100644 --- a/sdk/formrecognizer/ai-form-recognizer/src/tracing.ts +++ b/sdk/formrecognizer/ai-form-recognizer/src/tracing.ts @@ -1,58 +1,13 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -import { getTracer, OperationTracingOptions } from "@azure/core-tracing"; -import { Span, SpanOptions, SpanKind } from "@opentelemetry/api"; -import { OperationOptions } from "@azure/core-http"; +import { createSpanFunction } from "@azure/core-tracing"; /** * Creates a span using the global tracer. * @internal - * @param name - The name of the operation being performed. - * @param tracingOptions - The options for the underlying http request. */ -export function createSpan( - operationName: string, - operationOptions: T -): { span: Span; updatedOptions: T } { - const tracer = getTracer(); - const tracingOptions = operationOptions.tracingOptions || {}; - const spanOptions: SpanOptions = { - ...tracingOptions.spanOptions, - kind: SpanKind.INTERNAL - }; - - const span = tracer.startSpan( - `Azure.CognitiveServices.FormRecognizer.${operationName}`, - spanOptions - ); - - span.setAttribute("az.namespace", "Microsoft.CognitiveServices"); - - let newSpanOptions = tracingOptions.spanOptions || {}; - if (span.isRecording()) { - newSpanOptions = { - ...tracingOptions.spanOptions, - parent: span.context(), - attributes: { - ...spanOptions.attributes, - "az.namespace": "Microsoft.CognitiveServices" - } - }; - } - - const newTracingOptions: OperationTracingOptions = { - ...tracingOptions, - spanOptions: newSpanOptions - }; - - const newOperationOptions: T = { - ...operationOptions, - tracingOptions: newTracingOptions - }; - - return { - span, - updatedOptions: newOperationOptions - }; -} +export const createSpan = createSpanFunction({ + packagePrefix: "Azure.CognitiveServices.FormRecognizer", + namespace: "Microsoft.CognitiveServices" +}); diff --git a/sdk/identity/identity/src/util/tracing.ts b/sdk/identity/identity/src/util/tracing.ts index 173f43f04870..2e2f0a0ce4c4 100644 --- a/sdk/identity/identity/src/util/tracing.ts +++ b/sdk/identity/identity/src/util/tracing.ts @@ -1,54 +1,13 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -import { GetTokenOptions } from "@azure/core-http"; -import { getTracer, OperationTracingOptions } from "@azure/core-tracing"; -import { Span, SpanKind, SpanOptions as OTSpanOptions } from "@opentelemetry/api"; +import { createSpanFunction } from "@azure/core-tracing"; /** * Creates a span using the global tracer. - * @param name - The name of the operation being performed. - * @param options - The options for the underlying http request. + * @internal */ -export function createSpan( - operationName: string, - options: GetTokenOptions = {} -): { span: Span; options: GetTokenOptions } { - const tracer = getTracer(); - - const tracingOptions: OperationTracingOptions = { - spanOptions: {}, - ...options.tracingOptions - }; - - const spanOptions: OTSpanOptions = { - ...tracingOptions.spanOptions, - kind: SpanKind.INTERNAL - }; - - const span = tracer.startSpan(`Azure.Identity.${operationName}`, spanOptions); - span.setAttribute("az.namespace", "Microsoft.AAD"); - - let newOptions = options; - if (span.isRecording()) { - newOptions = { - ...options, - tracingOptions: { - ...tracingOptions, - spanOptions: { - ...tracingOptions.spanOptions, - parent: span.context(), - attributes: { - ...spanOptions.attributes, - "az.namespace": "Microsoft.AAD" - } - } - } - }; - } - - return { - span, - options: newOptions - }; -} +export const createSpan = createSpanFunction({ + packagePrefix: "Azure.Identity", + namespace: "Microsoft.AAD" +}); diff --git a/sdk/metricsadvisor/ai-metrics-advisor/src/tracing.ts b/sdk/metricsadvisor/ai-metrics-advisor/src/tracing.ts index fe6f44d0aa60..3c434d6dbe84 100644 --- a/sdk/metricsadvisor/ai-metrics-advisor/src/tracing.ts +++ b/sdk/metricsadvisor/ai-metrics-advisor/src/tracing.ts @@ -1,58 +1,13 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -import { getTracer, OperationTracingOptions } from "@azure/core-tracing"; -import { Span, SpanOptions, SpanKind } from "@opentelemetry/api"; -import { OperationOptions } from "@azure/core-http"; +import { createSpanFunction } from "@azure/core-tracing"; /** * Creates a span using the global tracer. * @internal - * @param name - The name of the operation being performed. - * @param tracingOptions - The options for the underlying http request. */ -export function createSpan( - operationName: string, - operationOptions: T -): { span: Span; updatedOptions: T } { - const tracer = getTracer(); - const tracingOptions = operationOptions.tracingOptions || {}; - const spanOptions: SpanOptions = { - ...tracingOptions.spanOptions, - kind: SpanKind.INTERNAL - }; - - const span = tracer.startSpan( - `Azure.CognitiveServices.MetricsAdvisor.${operationName}`, - spanOptions - ); - - span.setAttribute("az.namespace", "Microsoft.CognitiveServices"); - - let newSpanOptions = tracingOptions.spanOptions || {}; - if (span.isRecording()) { - newSpanOptions = { - ...tracingOptions.spanOptions, - parent: span.context(), - attributes: { - ...spanOptions.attributes, - "az.namespace": "Microsoft.CognitiveServices" - } - }; - } - - const newTracingOptions: OperationTracingOptions = { - ...tracingOptions, - spanOptions: newSpanOptions - }; - - const newOperationOptions: T = { - ...operationOptions, - tracingOptions: newTracingOptions - }; - - return { - span, - updatedOptions: newOperationOptions - }; -} +export const createSpan = createSpanFunction({ + packagePrefix: "Azure.CognitiveServices.MetricsAdvisor", + namespace: "Microsoft.CognitiveServices" +}); diff --git a/sdk/mixedreality/mixedreality-authentication/src/tracing.ts b/sdk/mixedreality/mixedreality-authentication/src/tracing.ts index d5bd668486f5..6aa773938456 100644 --- a/sdk/mixedreality/mixedreality-authentication/src/tracing.ts +++ b/sdk/mixedreality/mixedreality-authentication/src/tracing.ts @@ -1,59 +1,15 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -import { getTracer } from "@azure/core-tracing"; -import { Span, SpanOptions, SpanKind } from "@opentelemetry/api"; -import { OperationOptions } from "@azure/core-http"; - -type OperationTracingOptions = OperationOptions["tracingOptions"]; +import { createSpanFunction } from "@azure/core-tracing"; /** * Creates a span using the global tracer. * @internal - * @param name The name of the operation being performed. - * @param tracingOptions The options for the underlying http request. */ -export function createSpan( - operationName: string, - operationOptions: T -): { span: Span; updatedOptions: T } { - const tracer = getTracer(); - const tracingOptions = operationOptions.tracingOptions || {}; - const spanOptions: SpanOptions = { - ...tracingOptions.spanOptions, - kind: SpanKind.INTERNAL - }; - - const span = tracer.startSpan(`Azure.MixedReality.${operationName}`, spanOptions); - - // Resource providers are documented here: - // https://docs.microsoft.com/en-us/azure/azure-resource-manager/management/azure-services-resource-providers - span.setAttribute("Microsoft.MixedReality", "Microsoft.MixedReality"); - - let newSpanOptions = tracingOptions.spanOptions || {}; - if (span.isRecording()) { - newSpanOptions = { - ...tracingOptions.spanOptions, - parent: span.context(), - attributes: { - ...spanOptions.attributes, - "Microsoft.MixedReality": "Microsoft.MixedReality" - } - }; - } - - const newTracingOptions: OperationTracingOptions = { - ...tracingOptions, - spanOptions: newSpanOptions - }; - - const newOperationOptions: T = { - ...operationOptions, - tracingOptions: newTracingOptions - }; - - return { - span, - updatedOptions: newOperationOptions - }; -} +export const createSpan = createSpanFunction({ + packagePrefix: "Azure.MixedReality", + // TODO: oddly enough the createSpan here was actually the attribute named + // 'Microsoft.MixedReality', not 'az.namespace'. Might have been a bug. + namespace: "Microsoft.MixedReality" +}); diff --git a/sdk/search/search-documents/src/tracing.ts b/sdk/search/search-documents/src/tracing.ts index 36dde5e51d18..0392b0a03cbe 100644 --- a/sdk/search/search-documents/src/tracing.ts +++ b/sdk/search/search-documents/src/tracing.ts @@ -1,57 +1,13 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -import { getTracer } from "@azure/core-tracing"; -import { Span, SpanOptions, SpanKind } from "@opentelemetry/api"; -import { OperationOptions } from "@azure/core-http"; - -type OperationTracingOptions = OperationOptions["tracingOptions"]; +import { createSpanFunction } from "@azure/core-tracing"; /** * Creates a span using the global tracer. - * @hidden - * @param operationName - The name of the operation being performed. - * @param operationOptions - The options for the underlying http request. + * @internal */ -export function createSpan( - operationName: string, - operationOptions: T -): { span: Span; updatedOptions: T } { - const tracer = getTracer(); - const tracingOptions = operationOptions.tracingOptions || {}; - const spanOptions: SpanOptions = { - ...tracingOptions.spanOptions, - kind: SpanKind.INTERNAL - }; - - const span = tracer.startSpan(`Azure.Search.${operationName}`, spanOptions); - - span.setAttribute("az.namespace", "Microsoft.Search"); - - let newSpanOptions = tracingOptions.spanOptions || {}; - if (span.isRecording()) { - newSpanOptions = { - ...tracingOptions.spanOptions, - parent: span.context(), - attributes: { - ...spanOptions.attributes, - "az.namespace": "Microsoft.Search" - } - }; - } - - const newTracingOptions: OperationTracingOptions = { - ...tracingOptions, - spanOptions: newSpanOptions - }; - - const newOperationOptions: T = { - ...operationOptions, - tracingOptions: newTracingOptions - }; - - return { - span, - updatedOptions: newOperationOptions - }; -} +export const createSpan = createSpanFunction({ + packagePrefix: "Azure.Search", + namespace: "Microsoft.Search" +}); diff --git a/sdk/servicebus/service-bus/src/util/tracing.ts b/sdk/servicebus/service-bus/src/util/tracing.ts index 277db537fdc9..240a5b9b545f 100644 --- a/sdk/servicebus/service-bus/src/util/tracing.ts +++ b/sdk/servicebus/service-bus/src/util/tracing.ts @@ -1,49 +1,18 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -import { OperationOptions, RestError } from "@azure/core-http"; -import { getTracer } from "@azure/core-tracing"; -import { CanonicalCode, Span, SpanKind, SpanOptions as OTSpanOptions } from "@opentelemetry/api"; +import { RestError } from "@azure/core-http"; +import { CanonicalCode } from "@opentelemetry/api"; +import { createSpanFunction } from "@azure/core-tracing"; /** - * @internal * Creates a span using the global tracer. - * @param name - The name of the operation being performed. - * @param operationOptions - The options for the underlying http request. + * @internal */ -export function createSpan( - operationName: string, - operationOptions: OperationOptions = {} -): { span: Span; updatedOperationOptions: OperationOptions } { - const tracer = getTracer(); - const spanOptions: OTSpanOptions = { - ...operationOptions.tracingOptions?.spanOptions, - kind: SpanKind.INTERNAL - }; - - const span = tracer.startSpan(`Azure.ServiceBus.${operationName}`, spanOptions); - span.setAttribute("az.namespace", "Microsoft.ServiceBus"); - - let newSpanOptions = operationOptions.tracingOptions?.spanOptions || {}; - if (span.isRecording()) { - newSpanOptions = { - ...operationOptions.tracingOptions?.spanOptions, - parent: span.context(), - attributes: { - ...spanOptions.attributes, - "az.namespace": "Microsoft.ServiceBus" - } - }; - } - - return { - span, - updatedOperationOptions: { - ...operationOptions, - tracingOptions: { ...operationOptions?.tracingOptions, spanOptions: newSpanOptions } - } - }; -} +export const createSpan = createSpanFunction({ + packagePrefix: "Azure.ServiceBus", + namespace: "Microsoft.ServiceBus" +}); /** * @internal diff --git a/sdk/storage/storage-blob-changefeed/src/utils/tracing.ts b/sdk/storage/storage-blob-changefeed/src/utils/tracing.ts index 881f79f84d93..c1402b5817e4 100644 --- a/sdk/storage/storage-blob-changefeed/src/utils/tracing.ts +++ b/sdk/storage/storage-blob-changefeed/src/utils/tracing.ts @@ -1,41 +1,13 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -import { getTracer, OperationTracingOptions, SpanOptions } from "@azure/core-tracing"; -import { Span, SpanOptions as OTSpanOptions, SpanKind } from "@opentelemetry/api"; +import { createSpanFunction } from "@azure/core-tracing"; /** * Creates a span using the global tracer. - * @param name - The name of the operation being performed. - * @param tracingOptions - The options for the underlying http request. + * @internal */ -export function createSpan( - operationName: string, - tracingOptions: OperationTracingOptions = {} -): { span: Span; spanOptions: SpanOptions } { - const tracer = getTracer(); - const spanOptions: OTSpanOptions = { - ...tracingOptions.spanOptions, - kind: SpanKind.INTERNAL - }; - - const span = tracer.startSpan(`Azure.Storage.Blob.Changefeed.${operationName}`, spanOptions); - span.setAttribute("az.namespace", "Microsoft.Storage"); - - let newOptions = tracingOptions.spanOptions || {}; - if (span.isRecording()) { - newOptions = { - ...tracingOptions.spanOptions, - parent: span.context(), - attributes: { - ...spanOptions.attributes, - "az.namespace": "Microsoft.Storage" - } - }; - } - - return { - span, - spanOptions: newOptions - }; -} +export const createSpan = createSpanFunction({ + packagePrefix: "Azure.Storage.Blob.Changefeed", + namespace: "Microsoft.Storage" +}); diff --git a/sdk/storage/storage-blob/src/utils/tracing.ts b/sdk/storage/storage-blob/src/utils/tracing.ts index b84e961499f0..875c97c66fd3 100644 --- a/sdk/storage/storage-blob/src/utils/tracing.ts +++ b/sdk/storage/storage-blob/src/utils/tracing.ts @@ -1,41 +1,13 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -import { getTracer, OperationTracingOptions, SpanOptions } from "@azure/core-tracing"; -import { Span, SpanOptions as OTSpanOptions, SpanKind } from "@opentelemetry/api"; +import { createSpanFunction } from "@azure/core-tracing"; /** * Creates a span using the global tracer. - * @param name - The name of the operation being performed. - * @param tracingOptions - The options for the underlying http request. + * @internal */ -export function createSpan( - operationName: string, - tracingOptions: OperationTracingOptions = {} -): { span: Span; spanOptions: SpanOptions } { - const tracer = getTracer(); - const spanOptions: OTSpanOptions = { - ...tracingOptions.spanOptions, - kind: SpanKind.INTERNAL - }; - - const span = tracer.startSpan(`Azure.Storage.Blob.${operationName}`, spanOptions); - span.setAttribute("az.namespace", "Microsoft.Storage"); - - let newOptions = tracingOptions.spanOptions || {}; - if (span.isRecording()) { - newOptions = { - ...tracingOptions.spanOptions, - parent: span.context(), - attributes: { - ...spanOptions.attributes, - "az.namespace": "Microsoft.Storage" - } - }; - } - - return { - span, - spanOptions: newOptions - }; -} +export const createSpan = createSpanFunction({ + packagePrefix: "Azure.Storage.Blob", + namespace: "Microsoft.Storage" +}); diff --git a/sdk/storage/storage-file-datalake/src/utils/tracing.ts b/sdk/storage/storage-file-datalake/src/utils/tracing.ts index 138c20f51c86..fab06c3b613b 100644 --- a/sdk/storage/storage-file-datalake/src/utils/tracing.ts +++ b/sdk/storage/storage-file-datalake/src/utils/tracing.ts @@ -1,40 +1,13 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -import { Span, SpanKind, SpanOptions as OTSpanOptions } from "@opentelemetry/api"; -import { getTracer, SpanOptions, OperationTracingOptions } from "@azure/core-tracing"; + +import { createSpanFunction } from "@azure/core-tracing"; /** * Creates a span using the global tracer. - * @param name - The name of the operation being performed. - * @param tracingOptions - The options for the underlying http request. + * @internal */ -export function createSpan( - operationName: string, - tracingOptions: OperationTracingOptions = {} -): { span: Span; spanOptions: SpanOptions } { - const tracer = getTracer(); - const spanOptions: OTSpanOptions = { - ...tracingOptions.spanOptions, - kind: SpanKind.INTERNAL - }; - - const span = tracer.startSpan(`Azure.Storage.DataLake.${operationName}`, spanOptions); - span.setAttribute("az.namespace", "Microsoft.Storage"); - - let newOptions = tracingOptions.spanOptions || {}; - if (span.isRecording()) { - newOptions = { - ...tracingOptions.spanOptions, - parent: span.context(), - attributes: { - ...spanOptions.attributes, - "az.namespace": "Microsoft.Storage" - } - }; - } - - return { - span, - spanOptions: newOptions - }; -} +export const createSpan = createSpanFunction({ + packagePrefix: "Azure.Storage.DataLake", + namespace: "Microsoft.Storage" +}); diff --git a/sdk/storage/storage-file-share/src/utils/tracing.ts b/sdk/storage/storage-file-share/src/utils/tracing.ts index 5f12d9a7d628..f803ba5acffb 100644 --- a/sdk/storage/storage-file-share/src/utils/tracing.ts +++ b/sdk/storage/storage-file-share/src/utils/tracing.ts @@ -1,41 +1,13 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -import { Span, SpanOptions as OTSpanOptions, SpanKind } from "@opentelemetry/api"; -import { getTracer, SpanOptions, OperationTracingOptions } from "@azure/core-tracing"; +import { createSpanFunction } from "@azure/core-tracing"; /** * Creates a span using the global tracer. - * @param name - The name of the operation being performed. - * @param tracingOptions - The tracingOptions for the underlying http request. + * @internal */ -export function createSpan( - operationName: string, - tracingOptions: OperationTracingOptions = {} -): { span: Span; spanOptions: SpanOptions } { - const tracer = getTracer(); - const spanOptions: OTSpanOptions = { - ...tracingOptions.spanOptions, - kind: SpanKind.INTERNAL - }; - - const span = tracer.startSpan(`Azure.Storage.File.${operationName}`, spanOptions); - span.setAttribute("az.namespace", "Microsoft.Storage"); - - let newOptions = tracingOptions.spanOptions || {}; - if (span.isRecording()) { - newOptions = { - ...tracingOptions.spanOptions, - parent: span.context(), - attributes: { - ...spanOptions.attributes, - "az.namespace": "Microsoft.Storage" - } - }; - } - - return { - span, - spanOptions: newOptions - }; -} +export const createSpan = createSpanFunction({ + packagePrefix: "Azure.Storage.File", + namespace: "Microsoft.Storage" +}); diff --git a/sdk/storage/storage-queue/src/utils/tracing.ts b/sdk/storage/storage-queue/src/utils/tracing.ts index 78a05e6170bf..d095a0b6483b 100644 --- a/sdk/storage/storage-queue/src/utils/tracing.ts +++ b/sdk/storage/storage-queue/src/utils/tracing.ts @@ -1,41 +1,13 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -import { Span, SpanOptions as OTSpanOptions, SpanKind } from "@opentelemetry/api"; -import { getTracer, SpanOptions, OperationTracingOptions } from "@azure/core-tracing"; +import { createSpanFunction } from "@azure/core-tracing"; /** * Creates a span using the global tracer. - * @param operationName - The name of the operation being performed. - * @param options - The options for the underlying http request. + * @internal */ -export function createSpan( - operationName: string, - tracingOptions: OperationTracingOptions = {} -): { span: Span; spanOptions: SpanOptions } { - const tracer = getTracer(); - const spanOptions: OTSpanOptions = { - ...tracingOptions.spanOptions, - kind: SpanKind.INTERNAL - }; - - const span = tracer.startSpan(`Azure.Storage.Queue.${operationName}`, spanOptions); - span.setAttribute("az.namespace", "Microsoft.Storage"); - - let newOptions = tracingOptions.spanOptions || {}; - if (span.isRecording()) { - newOptions = { - ...tracingOptions.spanOptions, - parent: span.context(), - attributes: { - ...spanOptions.attributes, - "az.namespace": "Microsoft.Storage" - } - }; - } - - return { - span, - spanOptions: newOptions - }; -} +export const createSpan = createSpanFunction({ + packagePrefix: "Azure.Storage.Queue", + namespace: "Microsoft.Storage" +}); diff --git a/sdk/tables/data-tables/src/utils/tracing.ts b/sdk/tables/data-tables/src/utils/tracing.ts index bb3113ffe0ec..842b41f1d24d 100644 --- a/sdk/tables/data-tables/src/utils/tracing.ts +++ b/sdk/tables/data-tables/src/utils/tracing.ts @@ -1,57 +1,13 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -import { getTracer } from "@azure/core-tracing"; -import { Span, SpanOptions, SpanKind } from "@opentelemetry/api"; -import { OperationOptions } from "@azure/core-client"; - -type OperationTracingOptions = OperationOptions["tracingOptions"]; +import { createSpanFunction } from "@azure/core-tracing"; /** * Creates a span using the global tracer. * @internal - * @param name - The name of the operation being performed. - * @param tracingOptions - The options for the underlying http request. */ -export function createSpan( - operationName: string, - operationOptions: T -): { span: Span; updatedOptions: T } { - const tracer = getTracer(); - const tracingOptions = operationOptions.tracingOptions || {}; - const spanOptions: SpanOptions = { - ...tracingOptions.spanOptions, - kind: SpanKind.INTERNAL - }; - - const span = tracer.startSpan(`Azure.Data.Tables.${operationName}`, spanOptions); - - span.setAttribute("az.namespace", "Microsoft.Data.Tables"); - - let newSpanOptions = tracingOptions.spanOptions || {}; - if (span.isRecording()) { - newSpanOptions = { - ...tracingOptions.spanOptions, - parent: span.context(), - attributes: { - ...spanOptions.attributes, - "az.namespace": "Microsoft.Data.Tables" - } - }; - } - - const newTracingOptions: OperationTracingOptions = { - ...tracingOptions, - spanOptions: newSpanOptions - }; - - const newOperationOptions: T = { - ...operationOptions, - tracingOptions: newTracingOptions - }; - - return { - span, - updatedOptions: newOperationOptions - }; -} +export const createSpan = createSpanFunction({ + packagePrefix: "Azure.Data.Tables", + namespace: "Microsoft.Data.Tables" +}); diff --git a/sdk/textanalytics/ai-text-analytics/src/tracing.ts b/sdk/textanalytics/ai-text-analytics/src/tracing.ts index 8ed4b7e36505..9f785fd9deb9 100644 --- a/sdk/textanalytics/ai-text-analytics/src/tracing.ts +++ b/sdk/textanalytics/ai-text-analytics/src/tracing.ts @@ -1,60 +1,13 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -import { getTracer } from "@azure/core-tracing"; -import { Span, SpanOptions, SpanKind } from "@opentelemetry/api"; -import { OperationOptions } from "@azure/core-http"; - -type OperationTracingOptions = OperationOptions["tracingOptions"]; +import { createSpanFunction } from "@azure/core-tracing"; /** - * @internal * Creates a span using the global tracer. - * @param name - The name of the operation being performed. - * @param tracingOptions - The options for the underlying http request. + * @internal */ -export function createSpan( - operationName: string, - operationOptions: T -): { span: Span; updatedOptions: T } { - const tracer = getTracer(); - const tracingOptions = operationOptions.tracingOptions || {}; - const spanOptions: SpanOptions = { - ...tracingOptions.spanOptions, - kind: SpanKind.INTERNAL - }; - - const span = tracer.startSpan( - `Azure.CognitiveServices.TextAnalytics.${operationName}`, - spanOptions - ); - - span.setAttribute("az.namespace", "Microsoft.CognitiveServices"); - - let newSpanOptions = tracingOptions.spanOptions || {}; - if (span.isRecording()) { - newSpanOptions = { - ...tracingOptions.spanOptions, - parent: span.context(), - attributes: { - ...spanOptions.attributes, - "az.namespace": "Microsoft.CognitiveServices" - } - }; - } - - const newTracingOptions: OperationTracingOptions = { - ...tracingOptions, - spanOptions: newSpanOptions - }; - - const newOperationOptions: T = { - ...operationOptions, - tracingOptions: newTracingOptions - }; - - return { - span, - updatedOptions: newOperationOptions - }; -} +export const createSpan = createSpanFunction({ + packagePrefix: "Azure.CognitiveServices.TextAnalytics", + namespace: "Microsoft.CognitiveServices" +}); From 7092a579934657a4e1adf496caecf29f0715f475 Mon Sep 17 00:00:00 2001 From: Richard Park <51494936+richardpark-msft@users.noreply.github.com> Date: Fri, 19 Feb 2021 23:10:58 +0000 Subject: [PATCH 08/52] Formatting --- .../communication-identity/src/common/tracing.ts | 1 - sdk/core/core-client/src/createSpan.ts | 14 +++++++------- sdk/core/core-http/src/createSpan.ts | 14 +++++++------- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/sdk/communication/communication-identity/src/common/tracing.ts b/sdk/communication/communication-identity/src/common/tracing.ts index 999aa9f02147..88aa261c1114 100644 --- a/sdk/communication/communication-identity/src/common/tracing.ts +++ b/sdk/communication/communication-identity/src/common/tracing.ts @@ -11,4 +11,3 @@ export const createSpan = createSpanFunction({ packagePrefix: "Azure.Communication", namespace: "Microsoft.Communication" }); - diff --git a/sdk/core/core-client/src/createSpan.ts b/sdk/core/core-client/src/createSpan.ts index 98e31f1ecdc8..3bae5e190a4a 100644 --- a/sdk/core/core-client/src/createSpan.ts +++ b/sdk/core/core-client/src/createSpan.ts @@ -8,16 +8,16 @@ import { import { Span } from "@opentelemetry/api"; import { OperationOptions } from "./interfaces"; -export interface SpanConfig extends coreTracingSpanConfig { } +export interface SpanConfig extends coreTracingSpanConfig {} export function createSpanFunction( spanConfig: SpanConfig ): ( - operationName: string, - operationOptions: T - ) => { - span: Span; - updatedOptions: T; - } { + operationName: string, + operationOptions: T +) => { + span: Span; + updatedOptions: T; +} { return coreTracingCreateSpanFunction(spanConfig); } diff --git a/sdk/core/core-http/src/createSpan.ts b/sdk/core/core-http/src/createSpan.ts index 1ecb3c10715e..6587deab716a 100644 --- a/sdk/core/core-http/src/createSpan.ts +++ b/sdk/core/core-http/src/createSpan.ts @@ -8,16 +8,16 @@ import { import { Span } from "@opentelemetry/api"; import { OperationOptions } from "./operationOptions"; -export interface SpanConfig extends coreTracingSpanConfig { } +export interface SpanConfig extends coreTracingSpanConfig {} export function createSpanFunction( spanConfig: SpanConfig ): ( - operationName: string, - operationOptions: T - ) => { - span: Span; - updatedOptions: T; - } { + operationName: string, + operationOptions: T +) => { + span: Span; + updatedOptions: T; +} { return coreTracingCreateSpanFunction(spanConfig); } From df7f0e1eaf76aa6e3b3ed048387920aa7a0f8e78 Mon Sep 17 00:00:00 2001 From: Richard Park <51494936+richardpark-msft@users.noreply.github.com> Date: Fri, 19 Feb 2021 23:31:54 +0000 Subject: [PATCH 09/52] Service Bus was using the properties from createSpan() with a different name. Not sure why I didn't see this earlier. --- .../src/serviceBusAtomManagementClient.ts | 142 +++++++++--------- 1 file changed, 71 insertions(+), 71 deletions(-) diff --git a/sdk/servicebus/service-bus/src/serviceBusAtomManagementClient.ts b/sdk/servicebus/service-bus/src/serviceBusAtomManagementClient.ts index 045345546d93..25dd7dc25071 100644 --- a/sdk/servicebus/service-bus/src/serviceBusAtomManagementClient.ts +++ b/sdk/servicebus/service-bus/src/serviceBusAtomManagementClient.ts @@ -224,7 +224,7 @@ export class ServiceBusAdministrationClient extends ServiceClient { operationOptions?: OperationOptions ): Promise> { logger.verbose(`Performing management operation - getNamespaceProperties()`); - const { span, updatedOperationOptions } = createSpan( + const { span, updatedOptions } = createSpan( "ServiceBusAdministrationClient-getNamespaceProperties", operationOptions ); @@ -232,7 +232,7 @@ export class ServiceBusAdministrationClient extends ServiceClient { const response: HttpOperationResponse = await this.getResource( "$namespaceinfo", this.namespaceResourceSerializer, - updatedOperationOptions + updatedOptions ); return this.buildNamespacePropertiesResponse(response); @@ -266,7 +266,7 @@ export class ServiceBusAdministrationClient extends ServiceClient { queueName: string, options?: CreateQueueOptions ): Promise> { - const { span, updatedOperationOptions } = createSpan( + const { span, updatedOptions } = createSpan( "ServiceBusAdministrationClient-createQueue", options ); @@ -280,7 +280,7 @@ export class ServiceBusAdministrationClient extends ServiceClient { buildQueueOptions(options || {}), this.queueResourceSerializer, false, - updatedOperationOptions + updatedOptions ); return this.buildQueueResponse(response); @@ -313,7 +313,7 @@ export class ServiceBusAdministrationClient extends ServiceClient { queueName: string, operationOptions?: OperationOptions ): Promise> { - const { span, updatedOperationOptions } = createSpan( + const { span, updatedOptions } = createSpan( "ServiceBusAdministrationClient-getQueue", operationOptions ); @@ -322,7 +322,7 @@ export class ServiceBusAdministrationClient extends ServiceClient { const response: HttpOperationResponse = await this.getResource( queueName, this.queueResourceSerializer, - updatedOperationOptions + updatedOptions ); return this.buildQueueResponse(response); @@ -354,7 +354,7 @@ export class ServiceBusAdministrationClient extends ServiceClient { queueName: string, operationOptions?: OperationOptions ): Promise> { - const { span, updatedOperationOptions } = createSpan( + const { span, updatedOptions } = createSpan( "ServiceBusAdministrationClient-getQueueRuntimeProperties", operationOptions ); @@ -365,7 +365,7 @@ export class ServiceBusAdministrationClient extends ServiceClient { const response: HttpOperationResponse = await this.getResource( queueName, this.queueResourceSerializer, - updatedOperationOptions + updatedOptions ); return this.buildQueueRuntimePropertiesResponse(response); @@ -396,7 +396,7 @@ export class ServiceBusAdministrationClient extends ServiceClient { private async getQueues( options?: ListRequestOptions & OperationOptions ): Promise> { - const { span, updatedOperationOptions } = createSpan( + const { span, updatedOptions } = createSpan( "ServiceBusAdministrationClient-getQueues", options ); @@ -404,7 +404,7 @@ export class ServiceBusAdministrationClient extends ServiceClient { logger.verbose(`Performing management operation - getQueues() with options: %j`, options); const response: HttpOperationResponse = await this.listResources( "$Resources/Queues", - updatedOperationOptions, + updatedOptions, this.queueResourceSerializer ); @@ -495,7 +495,7 @@ export class ServiceBusAdministrationClient extends ServiceClient { private async getQueuesRuntimeProperties( options?: ListRequestOptions & OperationOptions ): Promise> { - const { span, updatedOperationOptions } = createSpan( + const { span, updatedOptions } = createSpan( "ServiceBusAdministrationClient-getQueuesRuntimeProperties", options ); @@ -506,7 +506,7 @@ export class ServiceBusAdministrationClient extends ServiceClient { ); const response: HttpOperationResponse = await this.listResources( "$Resources/Queues", - updatedOperationOptions, + updatedOptions, this.queueResourceSerializer ); @@ -610,7 +610,7 @@ export class ServiceBusAdministrationClient extends ServiceClient { queue: WithResponse, operationOptions?: OperationOptions ): Promise> { - const { span, updatedOperationOptions } = createSpan( + const { span, updatedOptions } = createSpan( "ServiceBusAdministrationClient-updateQueue", operationOptions ); @@ -635,7 +635,7 @@ export class ServiceBusAdministrationClient extends ServiceClient { buildQueueOptions(queue), this.queueResourceSerializer, true, - updatedOperationOptions + updatedOptions ); return this.buildQueueResponse(response); @@ -667,7 +667,7 @@ export class ServiceBusAdministrationClient extends ServiceClient { queueName: string, operationOptions?: OperationOptions ): Promise> { - const { span, updatedOperationOptions } = createSpan( + const { span, updatedOptions } = createSpan( "ServiceBusAdministrationClient-deleteQueue", operationOptions ); @@ -676,7 +676,7 @@ export class ServiceBusAdministrationClient extends ServiceClient { const response: HttpOperationResponse = await this.deleteResource( queueName, this.queueResourceSerializer, - updatedOperationOptions + updatedOptions ); return { _response: getHttpResponseOnly(response) }; @@ -696,14 +696,14 @@ export class ServiceBusAdministrationClient extends ServiceClient { * @param operationOptions - The options that can be used to abort, trace and control other configurations on the HTTP request. */ async queueExists(queueName: string, operationOptions?: OperationOptions): Promise { - const { span, updatedOperationOptions } = createSpan( + const { span, updatedOptions } = createSpan( "ServiceBusAdministrationClient-queueExists", operationOptions ); try { logger.verbose(`Performing management operation - queueExists() for "${queueName}"`); try { - await this.getQueue(queueName, updatedOperationOptions); + await this.getQueue(queueName, updatedOptions); } catch (error) { if (error.code == "MessageEntityNotFoundError") { return false; @@ -741,7 +741,7 @@ export class ServiceBusAdministrationClient extends ServiceClient { topicName: string, options?: CreateTopicOptions ): Promise> { - const { span, updatedOperationOptions } = createSpan( + const { span, updatedOptions } = createSpan( "ServiceBusAdministrationClient-createTopic", options ); @@ -755,7 +755,7 @@ export class ServiceBusAdministrationClient extends ServiceClient { buildTopicOptions(options || {}), this.topicResourceSerializer, false, - updatedOperationOptions + updatedOptions ); return this.buildTopicResponse(response); @@ -788,7 +788,7 @@ export class ServiceBusAdministrationClient extends ServiceClient { topicName: string, operationOptions?: OperationOptions ): Promise> { - const { span, updatedOperationOptions } = createSpan( + const { span, updatedOptions } = createSpan( "ServiceBusAdministrationClient-getTopic", operationOptions ); @@ -797,7 +797,7 @@ export class ServiceBusAdministrationClient extends ServiceClient { const response: HttpOperationResponse = await this.getResource( topicName, this.topicResourceSerializer, - updatedOperationOptions + updatedOptions ); return this.buildTopicResponse(response); @@ -829,7 +829,7 @@ export class ServiceBusAdministrationClient extends ServiceClient { topicName: string, operationOptions?: OperationOptions ): Promise> { - const { span, updatedOperationOptions } = createSpan( + const { span, updatedOptions } = createSpan( "ServiceBusAdministrationClient-getTopicRuntimeProperties", operationOptions ); @@ -840,7 +840,7 @@ export class ServiceBusAdministrationClient extends ServiceClient { const response: HttpOperationResponse = await this.getResource( topicName, this.topicResourceSerializer, - updatedOperationOptions + updatedOptions ); return this.buildTopicRuntimePropertiesResponse(response); @@ -871,7 +871,7 @@ export class ServiceBusAdministrationClient extends ServiceClient { private async getTopics( options?: ListRequestOptions & OperationOptions ): Promise> { - const { span, updatedOperationOptions } = createSpan( + const { span, updatedOptions } = createSpan( "ServiceBusAdministrationClient-getTopics", options ); @@ -879,7 +879,7 @@ export class ServiceBusAdministrationClient extends ServiceClient { logger.verbose(`Performing management operation - getTopics() with options: %j`, options); const response: HttpOperationResponse = await this.listResources( "$Resources/Topics", - updatedOperationOptions, + updatedOptions, this.topicResourceSerializer ); @@ -971,7 +971,7 @@ export class ServiceBusAdministrationClient extends ServiceClient { private async getTopicsRuntimeProperties( options?: ListRequestOptions & OperationOptions ): Promise> { - const { span, updatedOperationOptions } = createSpan( + const { span, updatedOptions } = createSpan( "ServiceBusAdministrationClient-getTopicsRuntimeProperties", options ); @@ -982,7 +982,7 @@ export class ServiceBusAdministrationClient extends ServiceClient { ); const response: HttpOperationResponse = await this.listResources( "$Resources/Topics", - updatedOperationOptions, + updatedOptions, this.topicResourceSerializer ); @@ -1089,7 +1089,7 @@ export class ServiceBusAdministrationClient extends ServiceClient { topic: WithResponse, operationOptions?: OperationOptions ): Promise> { - const { span, updatedOperationOptions } = createSpan( + const { span, updatedOptions } = createSpan( "ServiceBusAdministrationClient-updateTopic", operationOptions ); @@ -1114,7 +1114,7 @@ export class ServiceBusAdministrationClient extends ServiceClient { buildTopicOptions(topic), this.topicResourceSerializer, true, - updatedOperationOptions + updatedOptions ); return this.buildTopicResponse(response); @@ -1146,7 +1146,7 @@ export class ServiceBusAdministrationClient extends ServiceClient { topicName: string, operationOptions?: OperationOptions ): Promise> { - const { span, updatedOperationOptions } = createSpan( + const { span, updatedOptions } = createSpan( "ServiceBusAdministrationClient-deleteTopic", operationOptions ); @@ -1155,7 +1155,7 @@ export class ServiceBusAdministrationClient extends ServiceClient { const response: HttpOperationResponse = await this.deleteResource( topicName, this.topicResourceSerializer, - updatedOperationOptions + updatedOptions ); return { _response: getHttpResponseOnly(response) }; @@ -1175,14 +1175,14 @@ export class ServiceBusAdministrationClient extends ServiceClient { * @param operationOptions - The options that can be used to abort, trace and control other configurations on the HTTP request. */ async topicExists(topicName: string, operationOptions?: OperationOptions): Promise { - const { span, updatedOperationOptions } = createSpan( + const { span, updatedOptions } = createSpan( "ServiceBusAdministrationClient-topicExists", operationOptions ); try { logger.verbose(`Performing management operation - topicExists() for "${topicName}"`); try { - await this.getTopic(topicName, updatedOperationOptions); + await this.getTopic(topicName, updatedOptions); } catch (error) { if (error.code == "MessageEntityNotFoundError") { return false; @@ -1221,7 +1221,7 @@ export class ServiceBusAdministrationClient extends ServiceClient { subscriptionName: string, options?: CreateSubscriptionOptions ): Promise> { - const { span, updatedOperationOptions } = createSpan( + const { span, updatedOptions } = createSpan( "ServiceBusAdministrationClient-createSubscription", options ); @@ -1236,7 +1236,7 @@ export class ServiceBusAdministrationClient extends ServiceClient { buildSubscriptionOptions(options || {}), this.subscriptionResourceSerializer, false, - updatedOperationOptions + updatedOptions ); return this.buildSubscriptionResponse(response); @@ -1270,7 +1270,7 @@ export class ServiceBusAdministrationClient extends ServiceClient { subscriptionName: string, operationOptions?: OperationOptions ): Promise> { - const { span, updatedOperationOptions } = createSpan( + const { span, updatedOptions } = createSpan( "ServiceBusAdministrationClient-getSubscription", operationOptions ); @@ -1282,7 +1282,7 @@ export class ServiceBusAdministrationClient extends ServiceClient { const response: HttpOperationResponse = await this.getResource( fullPath, this.subscriptionResourceSerializer, - updatedOperationOptions + updatedOptions ); return this.buildSubscriptionResponse(response); @@ -1315,7 +1315,7 @@ export class ServiceBusAdministrationClient extends ServiceClient { subscriptionName: string, operationOptions?: OperationOptions ): Promise> { - const { span, updatedOperationOptions } = createSpan( + const { span, updatedOptions } = createSpan( "ServiceBusAdministrationClient-getSubscriptionRuntimeProperties", operationOptions ); @@ -1327,7 +1327,7 @@ export class ServiceBusAdministrationClient extends ServiceClient { const response: HttpOperationResponse = await this.getResource( fullPath, this.subscriptionResourceSerializer, - updatedOperationOptions + updatedOptions ); return this.buildSubscriptionRuntimePropertiesResponse(response); @@ -1359,7 +1359,7 @@ export class ServiceBusAdministrationClient extends ServiceClient { topicName: string, options?: ListRequestOptions & OperationOptions ): Promise> { - const { span, updatedOperationOptions } = createSpan( + const { span, updatedOptions } = createSpan( "ServiceBusAdministrationClient-getSubscriptions", options ); @@ -1370,7 +1370,7 @@ export class ServiceBusAdministrationClient extends ServiceClient { ); const response: HttpOperationResponse = await this.listResources( topicName + "/Subscriptions/", - updatedOperationOptions, + updatedOptions, this.subscriptionResourceSerializer ); @@ -1470,7 +1470,7 @@ export class ServiceBusAdministrationClient extends ServiceClient { topicName: string, options?: ListRequestOptions & OperationOptions ): Promise> { - const { span, updatedOperationOptions } = createSpan( + const { span, updatedOptions } = createSpan( "ServiceBusAdministrationClient-getSubscriptionsRuntimeProperties", options ); @@ -1481,7 +1481,7 @@ export class ServiceBusAdministrationClient extends ServiceClient { ); const response: HttpOperationResponse = await this.listResources( topicName + "/Subscriptions/", - updatedOperationOptions, + updatedOptions, this.subscriptionResourceSerializer ); @@ -1593,7 +1593,7 @@ export class ServiceBusAdministrationClient extends ServiceClient { subscription: WithResponse, operationOptions?: OperationOptions ): Promise> { - const { span, updatedOperationOptions } = createSpan( + const { span, updatedOptions } = createSpan( "ServiceBusAdministrationClient-updateSubscription", operationOptions ); @@ -1625,7 +1625,7 @@ export class ServiceBusAdministrationClient extends ServiceClient { buildSubscriptionOptions(subscription), this.subscriptionResourceSerializer, true, - updatedOperationOptions + updatedOptions ); return this.buildSubscriptionResponse(response); @@ -1658,7 +1658,7 @@ export class ServiceBusAdministrationClient extends ServiceClient { subscriptionName: string, operationOptions?: OperationOptions ): Promise> { - const { span, updatedOperationOptions } = createSpan( + const { span, updatedOptions } = createSpan( "ServiceBusAdministrationClient-deleteSubscription", operationOptions ); @@ -1670,7 +1670,7 @@ export class ServiceBusAdministrationClient extends ServiceClient { const response: HttpOperationResponse = await this.deleteResource( fullPath, this.subscriptionResourceSerializer, - updatedOperationOptions + updatedOptions ); return { _response: getHttpResponseOnly(response) }; @@ -1694,7 +1694,7 @@ export class ServiceBusAdministrationClient extends ServiceClient { subscriptionName: string, operationOptions?: OperationOptions ): Promise { - const { span, updatedOperationOptions } = createSpan( + const { span, updatedOptions } = createSpan( "ServiceBusAdministrationClient-subscriptionExists", operationOptions ); @@ -1703,7 +1703,7 @@ export class ServiceBusAdministrationClient extends ServiceClient { `Performing management operation - subscriptionExists() for "${topicName}" and "${subscriptionName}"` ); try { - await this.getSubscription(topicName, subscriptionName, updatedOperationOptions); + await this.getSubscription(topicName, subscriptionName, updatedOptions); } catch (error) { if (error.code == "MessageEntityNotFoundError") { return false; @@ -1789,7 +1789,7 @@ export class ServiceBusAdministrationClient extends ServiceClient { operOptions = { ...ruleActionOrOperationOptions, ...operationOptions }; } } - const { span, updatedOperationOptions } = createSpan( + const { span, updatedOptions } = createSpan( "ServiceBusAdministrationClient-createRule", operOptions ); @@ -1804,7 +1804,7 @@ export class ServiceBusAdministrationClient extends ServiceClient { { name: ruleName, filter: ruleFilter, action: ruleAction }, this.ruleResourceSerializer, false, - updatedOperationOptions + updatedOptions ); return this.buildRuleResponse(response); } catch (e) { @@ -1837,7 +1837,7 @@ export class ServiceBusAdministrationClient extends ServiceClient { ruleName: string, operationOptions?: OperationOptions ): Promise> { - const { span, updatedOperationOptions } = createSpan( + const { span, updatedOptions } = createSpan( "ServiceBusAdministrationClient-getRule", operationOptions ); @@ -1847,7 +1847,7 @@ export class ServiceBusAdministrationClient extends ServiceClient { const response: HttpOperationResponse = await this.getResource( fullPath, this.ruleResourceSerializer, - updatedOperationOptions + updatedOptions ); return this.buildRuleResponse(response); @@ -1879,7 +1879,7 @@ export class ServiceBusAdministrationClient extends ServiceClient { subscriptionName: string, options?: ListRequestOptions & OperationOptions ): Promise> { - const { span, updatedOperationOptions } = createSpan( + const { span, updatedOptions } = createSpan( "ServiceBusAdministrationClient-getRules", options ); @@ -1888,7 +1888,7 @@ export class ServiceBusAdministrationClient extends ServiceClient { const fullPath = this.getSubscriptionPath(topicName, subscriptionName) + "/Rules/"; const response: HttpOperationResponse = await this.listResources( fullPath, - updatedOperationOptions, + updatedOptions, this.ruleResourceSerializer ); @@ -1995,7 +1995,7 @@ export class ServiceBusAdministrationClient extends ServiceClient { rule: WithResponse, operationOptions?: OperationOptions ): Promise> { - const { span, updatedOperationOptions } = createSpan( + const { span, updatedOptions } = createSpan( "ServiceBusAdministrationClient-updateRule", operationOptions ); @@ -2021,7 +2021,7 @@ export class ServiceBusAdministrationClient extends ServiceClient { rule, this.ruleResourceSerializer, true, - updatedOperationOptions + updatedOptions ); return this.buildRuleResponse(response); @@ -2055,7 +2055,7 @@ export class ServiceBusAdministrationClient extends ServiceClient { ruleName: string, operationOptions?: OperationOptions ): Promise> { - const { span, updatedOperationOptions } = createSpan( + const { span, updatedOptions } = createSpan( "ServiceBusAdministrationClient-deleteRule", operationOptions ); @@ -2065,7 +2065,7 @@ export class ServiceBusAdministrationClient extends ServiceClient { const response: HttpOperationResponse = await this.deleteResource( fullPath, this.ruleResourceSerializer, - updatedOperationOptions + updatedOptions ); return { _response: getHttpResponseOnly(response) }; @@ -2090,14 +2090,14 @@ export class ServiceBusAdministrationClient extends ServiceClient { ruleName: string, operationOptions?: OperationOptions ): Promise { - const { span, updatedOperationOptions } = createSpan( + const { span, updatedOptions } = createSpan( "ServiceBusAdministrationClient-ruleExists", operationOptions ); try { logger.verbose(`Performing management operation - ruleExists() for "${ruleName}"`); try { - await this.getRule(topicName, subscriptionName, ruleName, updatedOperationOptions); + await this.getRule(topicName, subscriptionName, ruleName, updatedOptions); } catch (error) { if (error.code == "MessageEntityNotFoundError") { return false; @@ -2130,7 +2130,7 @@ export class ServiceBusAdministrationClient extends ServiceClient { isUpdate: boolean = false, operationOptions: OperationOptions = {} ): Promise { - const { span, updatedOperationOptions } = createSpan( + const { span, updatedOptions } = createSpan( "ServiceBusAdministrationClient-putResource", operationOptions ); @@ -2173,7 +2173,7 @@ export class ServiceBusAdministrationClient extends ServiceClient { webResource.headers.set("content-type", "application/atom+xml;type=entry;charset=utf-8"); - return executeAtomXmlOperation(this, webResource, serializer, updatedOperationOptions); + return executeAtomXmlOperation(this, webResource, serializer, updatedOptions); } catch (e) { span.setStatus({ code: getCanonicalCode(e), @@ -2193,7 +2193,7 @@ export class ServiceBusAdministrationClient extends ServiceClient { serializer: AtomXmlSerializer, operationOptions: OperationOptions = {} ): Promise { - const { span, updatedOperationOptions } = createSpan( + const { span, updatedOptions } = createSpan( "ServiceBusAdministrationClient-getResource", operationOptions ); @@ -2204,7 +2204,7 @@ export class ServiceBusAdministrationClient extends ServiceClient { this, webResource, serializer, - updatedOperationOptions + updatedOptions ); if ( response.parsedBody == undefined || @@ -2239,7 +2239,7 @@ export class ServiceBusAdministrationClient extends ServiceClient { options: ListRequestOptions & OperationOptions = {}, serializer: AtomXmlSerializer ): Promise { - const { span, updatedOperationOptions } = createSpan( + const { span, updatedOptions } = createSpan( "ServiceBusAdministrationClient-listResources", options ); @@ -2256,7 +2256,7 @@ export class ServiceBusAdministrationClient extends ServiceClient { const webResource: WebResource = new WebResource(this.getUrl(name, queryParams), "GET"); - return executeAtomXmlOperation(this, webResource, serializer, updatedOperationOptions); + return executeAtomXmlOperation(this, webResource, serializer, updatedOptions); } catch (e) { span.setStatus({ code: getCanonicalCode(e), @@ -2276,14 +2276,14 @@ export class ServiceBusAdministrationClient extends ServiceClient { serializer: AtomXmlSerializer, operationOptions: OperationOptions = {} ): Promise { - const { span, updatedOperationOptions } = createSpan( + const { span, updatedOptions } = createSpan( "ServiceBusAdministrationClient-deleteResource", operationOptions ); try { const webResource: WebResource = new WebResource(this.getUrl(name), "DELETE"); - return executeAtomXmlOperation(this, webResource, serializer, updatedOperationOptions); + return executeAtomXmlOperation(this, webResource, serializer, updatedOptions); } catch (e) { span.setStatus({ code: getCanonicalCode(e), @@ -2327,7 +2327,7 @@ export class ServiceBusAdministrationClient extends ServiceClient { } catch (error) { throw new Error( `Unable to parse the '${Constants.XML_METADATA_MARKER}skip' from the next-link in the response ` + - error + error ); } } From cca332542e49bfbbe34fea2f34535060c4cda1ac Mon Sep 17 00:00:00 2001 From: Richard Park <51494936+richardpark-msft@users.noreply.github.com> Date: Fri, 19 Feb 2021 23:32:10 +0000 Subject: [PATCH 10/52] Formatting --- .../src/serviceBusAtomManagementClient.ts | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/sdk/servicebus/service-bus/src/serviceBusAtomManagementClient.ts b/sdk/servicebus/service-bus/src/serviceBusAtomManagementClient.ts index 25dd7dc25071..8f74c1b5064a 100644 --- a/sdk/servicebus/service-bus/src/serviceBusAtomManagementClient.ts +++ b/sdk/servicebus/service-bus/src/serviceBusAtomManagementClient.ts @@ -1879,10 +1879,7 @@ export class ServiceBusAdministrationClient extends ServiceClient { subscriptionName: string, options?: ListRequestOptions & OperationOptions ): Promise> { - const { span, updatedOptions } = createSpan( - "ServiceBusAdministrationClient-getRules", - options - ); + const { span, updatedOptions } = createSpan("ServiceBusAdministrationClient-getRules", options); try { logger.verbose(`Performing management operation - getRules() with options: %j`, options); const fullPath = this.getSubscriptionPath(topicName, subscriptionName) + "/Rules/"; @@ -2200,12 +2197,7 @@ export class ServiceBusAdministrationClient extends ServiceClient { try { const webResource: WebResource = new WebResource(this.getUrl(name), "GET"); - const response = await executeAtomXmlOperation( - this, - webResource, - serializer, - updatedOptions - ); + const response = await executeAtomXmlOperation(this, webResource, serializer, updatedOptions); if ( response.parsedBody == undefined || (Array.isArray(response.parsedBody) && response.parsedBody.length == 0) @@ -2327,7 +2319,7 @@ export class ServiceBusAdministrationClient extends ServiceClient { } catch (error) { throw new Error( `Unable to parse the '${Constants.XML_METADATA_MARKER}skip' from the next-link in the response ` + - error + error ); } } From 89da87e7e14bfa8a56b453cec4d438bf3ab5afbc Mon Sep 17 00:00:00 2001 From: Richard Park <51494936+richardpark-msft@users.noreply.github.com> Date: Sat, 20 Feb 2021 00:47:04 +0000 Subject: [PATCH 11/52] Remove unneeded OperationTracingOptionsLike (the same package already had OperationTracingOptions!) --- sdk/core/core-client/review/core-client.api.md | 7 +++++-- sdk/core/core-tracing/review/core-tracing.api.md | 7 +------ sdk/core/core-tracing/src/createSpan.ts | 16 +++------------- sdk/core/core-tracing/src/index.ts | 2 +- sdk/core/core-tracing/test/createSpan.spec.ts | 13 +++++++------ 5 files changed, 17 insertions(+), 28 deletions(-) diff --git a/sdk/core/core-client/review/core-client.api.md b/sdk/core/core-client/review/core-client.api.md index 1fe1ee02f061..4c798606ea94 100644 --- a/sdk/core/core-client/review/core-client.api.md +++ b/sdk/core/core-client/review/core-client.api.md @@ -14,6 +14,7 @@ import { PipelinePolicy } from '@azure/core-https'; import { PipelineRequest } from '@azure/core-https'; import { PipelineResponse } from '@azure/core-https'; import { Span } from '@opentelemetry/api'; +import { SpanConfig as SpanConfig_3 } from '@azure/core-tracing'; import { TokenCredential } from '@azure/core-auth'; import { TransferProgressEvent } from '@azure/core-https'; @@ -77,8 +78,10 @@ export function createSerializer(modelMappers?: { [key: string]: any; }, isXML?: boolean): Serializer; -// @public -export function createSpanFunction({ packagePrefix, namespace }: SpanConfig): (operationName: string, operationOptions: T) => { +// Warning: (ae-forgotten-export) The symbol "SpanConfig" needs to be exported by the entry point index.d.ts +// +// @public (undocumented) +export function createSpanFunction(spanConfig: SpanConfig_2): (operationName: string, operationOptions: T) => { span: Span; updatedOptions: T; }; diff --git a/sdk/core/core-tracing/review/core-tracing.api.md b/sdk/core/core-tracing/review/core-tracing.api.md index a0f379428771..f93e4e42cfd7 100644 --- a/sdk/core/core-tracing/review/core-tracing.api.md +++ b/sdk/core/core-tracing/review/core-tracing.api.md @@ -18,7 +18,7 @@ import { TracerBase } from '@opencensus/web-types'; // @public export function createSpanFunction({ packagePrefix, namespace }: SpanConfig): (operationName: string, operationOptions: T) => { span: Span; updatedOptions: T; @@ -87,11 +87,6 @@ export interface OperationTracingOptions { spanOptions?: SpanOptions; } -// @public -export interface OperationTracingOptionsLike { - spanOptions?: OTSpanOptions; -} - export { OTSpanContext } export { OTSpanOptions } diff --git a/sdk/core/core-tracing/src/createSpan.ts b/sdk/core/core-tracing/src/createSpan.ts index acdb631c7b90..545ed7da4810 100644 --- a/sdk/core/core-tracing/src/createSpan.ts +++ b/sdk/core/core-tracing/src/createSpan.ts @@ -3,17 +3,7 @@ import { Span, SpanOptions, SpanKind } from "@opentelemetry/api"; import { getTracer } from "../src/tracerProxy"; - -/** - * Tracing options to set on an operation. - * @hidden - */ -export interface OperationTracingOptionsLike { - /** - * OpenTelemetry SpanOptions used to create a span when tracing is enabled. - */ - spanOptions?: SpanOptions; -} +import { OperationTracingOptions } from "./interfaces"; /** * Configuration for creating a new Tracing Span @@ -37,7 +27,7 @@ export interface SpanConfig { * @param tracingOptions - The options for the underlying http request. */ export function createSpanFunction({ packagePrefix, namespace }: SpanConfig) { - return function( + return function ( operationName: string, operationOptions: T ): { span: Span; updatedOptions: T } { @@ -64,7 +54,7 @@ export function createSpanFunction({ packagePrefix, namespace }: SpanConfig) { }; } - const newTracingOptions: OperationTracingOptionsLike = { + const newTracingOptions: OperationTracingOptions = { ...tracingOptions, spanOptions: newSpanOptions // TODO: .context soon. diff --git a/sdk/core/core-tracing/src/index.ts b/sdk/core/core-tracing/src/index.ts index b5ea7949fb54..eb2615991c89 100644 --- a/sdk/core/core-tracing/src/index.ts +++ b/sdk/core/core-tracing/src/index.ts @@ -10,7 +10,7 @@ export { OpenCensusSpanWrapper } from "./tracers/opencensus/openCensusSpanWrappe export { OpenCensusTracerWrapper } from "./tracers/opencensus/openCensusTracerWrapper"; export { TestTracer, SpanGraph, SpanGraphNode } from "./tracers/test/testTracer"; export { TestSpan } from "./tracers/test/testSpan"; -export { OperationTracingOptionsLike, createSpanFunction, SpanConfig } from "./createSpan"; +export { createSpanFunction, SpanConfig } from "./createSpan"; // Shared interfaces export { SpanContext, SpanOptions, TraceFlags } from "./interfaces"; diff --git a/sdk/core/core-tracing/test/createSpan.spec.ts b/sdk/core/core-tracing/test/createSpan.spec.ts index c87cbb1e8628..c48b070eda1e 100644 --- a/sdk/core/core-tracing/test/createSpan.spec.ts +++ b/sdk/core/core-tracing/test/createSpan.spec.ts @@ -8,7 +8,8 @@ import { SpanKind, TraceFlags } from "@opentelemetry/api"; import { setTracer } from "../src/tracerProxy"; import { TestTracer } from "../src/tracers/test/testTracer"; import { TestSpan } from "../src/tracers/test/testSpan"; -import { createSpanFunction, OperationTracingOptionsLike } from "../src/createSpan"; +import { createSpanFunction } from "../src/createSpan"; +import { OperationTracingOptions } from "../src/interfaces"; const createSpan = createSpanFunction({ namespace: "Microsoft.Test", packagePrefix: "Azure.Test" }); @@ -30,7 +31,7 @@ describe("createSpan", () => { // validate that we dumbly just copy any fields (this makes future upgrades easier) someOtherField: "someOtherFieldValue", context: { someContext: "some Context" } - } as OperationTracingOptionsLike) as any + } as OperationTracingOptions) as any }); assert.strictEqual(span, testSpan, "Should return mocked span"); assert.ok(startSpanStub.calledOnce); @@ -58,11 +59,11 @@ describe("createSpan", () => { }); it("returns updated SpanOptions", () => { - const options: { tracingOptions?: OperationTracingOptionsLike } = {}; + const options: { tracingOptions?: OperationTracingOptions } = {}; const { span, updatedOptions } = createSpan("testMethod", options); assert.deepStrictEqual(options, {}, "original options should not be modified"); assert.notStrictEqual(updatedOptions, options, "should return new object"); - const expected: { tracingOptions?: OperationTracingOptionsLike } = { + const expected: { tracingOptions?: OperationTracingOptions } = { tracingOptions: { spanOptions: { parent: span.context(), @@ -76,7 +77,7 @@ describe("createSpan", () => { }); it("preserves existing attributes", () => { - const options: { tracingOptions?: OperationTracingOptionsLike } = { + const options: { tracingOptions?: OperationTracingOptions } = { tracingOptions: { spanOptions: { attributes: { @@ -87,7 +88,7 @@ describe("createSpan", () => { }; const { span, updatedOptions } = createSpan("testMethod", options); assert.notStrictEqual(updatedOptions, options, "should return new object"); - const expected: { tracingOptions?: OperationTracingOptionsLike } = { + const expected: { tracingOptions?: OperationTracingOptions } = { tracingOptions: { spanOptions: { parent: span.context(), From fd10725685878a9c5b0c80b1cb588999c5ca9176 Mon Sep 17 00:00:00 2001 From: Richard Park <51494936+richardpark-msft@users.noreply.github.com> Date: Sat, 20 Feb 2021 00:47:42 +0000 Subject: [PATCH 12/52] Formatting --- sdk/core/core-tracing/src/createSpan.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/core/core-tracing/src/createSpan.ts b/sdk/core/core-tracing/src/createSpan.ts index 545ed7da4810..6dae79c2d16c 100644 --- a/sdk/core/core-tracing/src/createSpan.ts +++ b/sdk/core/core-tracing/src/createSpan.ts @@ -27,7 +27,7 @@ export interface SpanConfig { * @param tracingOptions - The options for the underlying http request. */ export function createSpanFunction({ packagePrefix, namespace }: SpanConfig) { - return function ( + return function( operationName: string, operationOptions: T ): { span: Span; updatedOptions: T } { From b00a41372206baff4649a09caa9ff4adfcdceecb Mon Sep 17 00:00:00 2001 From: Richard Park <51494936+richardpark-msft@users.noreply.github.com> Date: Sat, 20 Feb 2021 00:56:56 +0000 Subject: [PATCH 13/52] identity: the deconstructed names are different (and null checks need to be propagated) --- sdk/identity/identity/src/client/identityClient.ts | 4 ++-- .../src/credentials/authorizationCodeCredential.ts | 6 +++--- .../identity/src/credentials/chainedTokenCredential.ts | 4 ++-- .../src/credentials/clientCertificateCredential.ts | 4 ++-- .../identity/src/credentials/clientSecretCredential.ts | 4 ++-- .../identity/src/credentials/environmentCredential.ts | 4 ++-- .../credentials/managedIdentityCredential/imdsMsi.ts | 6 +++--- .../src/credentials/managedIdentityCredential/index.ts | 10 +++++----- .../src/credentials/usernamePasswordCredential.ts | 4 ++-- 9 files changed, 23 insertions(+), 23 deletions(-) diff --git a/sdk/identity/identity/src/client/identityClient.ts b/sdk/identity/identity/src/client/identityClient.ts index 7fd8a0a21ab8..8e7075359224 100644 --- a/sdk/identity/identity/src/client/identityClient.ts +++ b/sdk/identity/identity/src/client/identityClient.ts @@ -126,7 +126,7 @@ export class IdentityClient extends ServiceClient implements INetworkModule { `IdentityClient: refreshing access token with client ID: ${clientId}, scopes: ${scopes} started` ); - const { span, options: newOptions } = createSpan("IdentityClient-refreshAccessToken", options); + const { span, updatedOptions } = createSpan("IdentityClient-refreshAccessToken", options); const refreshParams = { grant_type: "refresh_token", @@ -151,7 +151,7 @@ export class IdentityClient extends ServiceClient implements INetworkModule { Accept: "application/json", "Content-Type": "application/x-www-form-urlencoded" }, - spanOptions: newOptions.tracingOptions && newOptions.tracingOptions.spanOptions, + spanOptions: updatedOptions?.tracingOptions?.spanOptions, abortSignal: options && options.abortSignal }); diff --git a/sdk/identity/identity/src/credentials/authorizationCodeCredential.ts b/sdk/identity/identity/src/credentials/authorizationCodeCredential.ts index 2aa38086e470..ba0e3ae552b0 100644 --- a/sdk/identity/identity/src/credentials/authorizationCodeCredential.ts +++ b/sdk/identity/identity/src/credentials/authorizationCodeCredential.ts @@ -135,7 +135,7 @@ export class AuthorizationCodeCredential implements TokenCredential { scopes: string | string[], options?: GetTokenOptions ): Promise { - const { span, options: newOptions } = createSpan( + const { span, updatedOptions } = createSpan( "AuthorizationCodeCredential-getToken", options ); @@ -155,7 +155,7 @@ export class AuthorizationCodeCredential implements TokenCredential { this.lastTokenResponse.refreshToken, this.clientSecret, undefined, - newOptions + updatedOptions ); } @@ -179,7 +179,7 @@ export class AuthorizationCodeCredential implements TokenCredential { "Content-Type": "application/x-www-form-urlencoded" }, abortSignal: options && options.abortSignal, - spanOptions: newOptions.tracingOptions && newOptions.tracingOptions.spanOptions + spanOptions: updatedOptions?.tracingOptions?.spanOptions }); tokenResponse = await this.identityClient.sendTokenRequest(webResource); diff --git a/sdk/identity/identity/src/credentials/chainedTokenCredential.ts b/sdk/identity/identity/src/credentials/chainedTokenCredential.ts index 092946f2ab55..1f7330248678 100644 --- a/sdk/identity/identity/src/credentials/chainedTokenCredential.ts +++ b/sdk/identity/identity/src/credentials/chainedTokenCredential.ts @@ -58,11 +58,11 @@ export class ChainedTokenCredential implements TokenCredential { let token = null; const errors = []; - const { span, options: newOptions } = createSpan("ChainedTokenCredential-getToken", options); + const { span, updatedOptions } = createSpan("ChainedTokenCredential-getToken", options); for (let i = 0; i < this._sources.length && token === null; i++) { try { - token = await this._sources[i].getToken(scopes, newOptions); + token = await this._sources[i].getToken(scopes, updatedOptions); } catch (err) { if (err instanceof CredentialUnavailable) { errors.push(err); diff --git a/sdk/identity/identity/src/credentials/clientCertificateCredential.ts b/sdk/identity/identity/src/credentials/clientCertificateCredential.ts index 38c1b1f43ffa..c968061c9955 100644 --- a/sdk/identity/identity/src/credentials/clientCertificateCredential.ts +++ b/sdk/identity/identity/src/credentials/clientCertificateCredential.ts @@ -114,7 +114,7 @@ export class ClientCertificateCredential implements TokenCredential { scopes: string | string[], options?: GetTokenOptions ): Promise { - const { span, options: newOptions } = createSpan( + const { span, updatedOptions } = createSpan( "ClientCertificateCredential-getToken", options ); @@ -172,7 +172,7 @@ export class ClientCertificateCredential implements TokenCredential { "Content-Type": "application/x-www-form-urlencoded" }, abortSignal: options && options.abortSignal, - spanOptions: newOptions.tracingOptions && newOptions.tracingOptions.spanOptions + spanOptions: updatedOptions?.tracingOptions?.spanOptions }); const tokenResponse = await this.identityClient.sendTokenRequest(webResource); diff --git a/sdk/identity/identity/src/credentials/clientSecretCredential.ts b/sdk/identity/identity/src/credentials/clientSecretCredential.ts index a7d1382d9b7f..4024515025e8 100644 --- a/sdk/identity/identity/src/credentials/clientSecretCredential.ts +++ b/sdk/identity/identity/src/credentials/clientSecretCredential.ts @@ -62,7 +62,7 @@ export class ClientSecretCredential implements TokenCredential { scopes: string | string[], options?: GetTokenOptions ): Promise { - const { span, options: newOptions } = createSpan("ClientSecretCredential-getToken", options); + const { span, updatedOptions } = createSpan("ClientSecretCredential-getToken", options); try { const urlSuffix = getIdentityTokenEndpointSuffix(this.tenantId); const webResource = this.identityClient.createWebResource({ @@ -82,7 +82,7 @@ export class ClientSecretCredential implements TokenCredential { "Content-Type": "application/x-www-form-urlencoded" }, abortSignal: options && options.abortSignal, - spanOptions: newOptions.tracingOptions && newOptions.tracingOptions.spanOptions + spanOptions: updatedOptions?.tracingOptions?.spanOptions }); const tokenResponse = await this.identityClient.sendTokenRequest(webResource); diff --git a/sdk/identity/identity/src/credentials/environmentCredential.ts b/sdk/identity/identity/src/credentials/environmentCredential.ts index 7ce0b6230ef8..537e852b1214 100644 --- a/sdk/identity/identity/src/credentials/environmentCredential.ts +++ b/sdk/identity/identity/src/credentials/environmentCredential.ts @@ -122,10 +122,10 @@ export class EnvironmentCredential implements TokenCredential { scopes: string | string[], options?: GetTokenOptions ): Promise { - const { span, options: newOptions } = createSpan("EnvironmentCredential-getToken", options); + const { span, updatedOptions } = createSpan("EnvironmentCredential-getToken", options); if (this._credential) { try { - const result = await this._credential.getToken(scopes, newOptions); + const result = await this._credential.getToken(scopes, updatedOptions); logger.getToken.info(formatSuccess(scopes)); return result; } catch (err) { diff --git a/sdk/identity/identity/src/credentials/managedIdentityCredential/imdsMsi.ts b/sdk/identity/identity/src/credentials/managedIdentityCredential/imdsMsi.ts index 45bfe8261209..11bcbd3f22ef 100644 --- a/sdk/identity/identity/src/credentials/managedIdentityCredential/imdsMsi.ts +++ b/sdk/identity/identity/src/credentials/managedIdentityCredential/imdsMsi.ts @@ -54,7 +54,7 @@ export const imdsMsi: MSI = { clientId?: string, getTokenOptions?: GetTokenOptions ): Promise { - const { span, options } = createSpan( + const { span, updatedOptions } = createSpan( "ManagedIdentityCredential-pingImdsEndpoint", getTokenOptions ); @@ -68,14 +68,14 @@ export const imdsMsi: MSI = { delete request.headers.Metadata; } - request.spanOptions = options.tracingOptions && options.tracingOptions.spanOptions; + request.spanOptions = updatedOptions?.tracingOptions?.spanOptions; try { // Create a request with a timeout since we expect that // not having a "Metadata" header should cause an error to be // returned quickly from the endpoint, proving its availability. const webResource = identityClient.createWebResource(request); - webResource.timeout = (options.requestOptions && options.requestOptions.timeout) || 500; + webResource.timeout = (updatedOptions?.requestOptions?.timeout) || 500; try { logger.info(`Pinging IMDS endpoint`); diff --git a/sdk/identity/identity/src/credentials/managedIdentityCredential/index.ts b/sdk/identity/identity/src/credentials/managedIdentityCredential/index.ts index 58ecfef907a4..193884c6e50a 100644 --- a/sdk/identity/identity/src/credentials/managedIdentityCredential/index.ts +++ b/sdk/identity/identity/src/credentials/managedIdentityCredential/index.ts @@ -97,16 +97,16 @@ export class ManagedIdentityCredential implements TokenCredential { getTokenOptions?: GetTokenOptions ): Promise { const resource = mapScopesToResource(scopes); - const { span, options } = createSpan( + const { span, updatedOptions } = createSpan( "ManagedIdentityCredential-authenticateManagedIdentity", getTokenOptions ); try { // Determining the available MSI, and avoiding checking for other MSIs while the program is running. - const availableMSI = await this.cachedAvailableMSI(resource, clientId, options); + const availableMSI = await this.cachedAvailableMSI(resource, clientId, updatedOptions); - return availableMSI.getToken(this.identityClient, resource, clientId, options); + return availableMSI.getToken(this.identityClient, resource, clientId, updatedOptions); } catch (err) { const code = err.name === AuthenticationErrorName @@ -138,14 +138,14 @@ export class ManagedIdentityCredential implements TokenCredential { ): Promise { let result: AccessToken | null = null; - const { span, options: newOptions } = createSpan("ManagedIdentityCredential-getToken", options); + const { span, updatedOptions } = createSpan("ManagedIdentityCredential-getToken", options); try { // isEndpointAvailable can be true, false, or null, // If it's null, it means we don't yet know whether // the endpoint is available and need to check for it. if (this.isEndpointUnavailable !== true) { - result = await this.authenticateManagedIdentity(scopes, this.clientId, newOptions); + result = await this.authenticateManagedIdentity(scopes, this.clientId, updatedOptions); if (result === null) { // If authenticateManagedIdentity returns null, diff --git a/sdk/identity/identity/src/credentials/usernamePasswordCredential.ts b/sdk/identity/identity/src/credentials/usernamePasswordCredential.ts index 7bf1ac2bdacd..c557282fea8f 100644 --- a/sdk/identity/identity/src/credentials/usernamePasswordCredential.ts +++ b/sdk/identity/identity/src/credentials/usernamePasswordCredential.ts @@ -67,7 +67,7 @@ export class UsernamePasswordCredential implements TokenCredential { scopes: string | string[], options?: GetTokenOptions ): Promise { - const { span, options: newOptions } = createSpan( + const { span, updatedOptions } = createSpan( "UsernamePasswordCredential-getToken", options ); @@ -91,7 +91,7 @@ export class UsernamePasswordCredential implements TokenCredential { "Content-Type": "application/x-www-form-urlencoded" }, abortSignal: options && options.abortSignal, - spanOptions: newOptions.tracingOptions && newOptions.tracingOptions.spanOptions + spanOptions: updatedOptions?.tracingOptions?.spanOptions }); const tokenResponse = await this.identityClient.sendTokenRequest(webResource); From ee2b382a7bf4000bb41426deec6357764f669be8 Mon Sep 17 00:00:00 2001 From: Richard Park <51494936+richardpark-msft@users.noreply.github.com> Date: Sat, 20 Feb 2021 00:57:20 +0000 Subject: [PATCH 14/52] Formatting --- .../identity/src/credentials/authorizationCodeCredential.ts | 5 +---- .../identity/src/credentials/clientCertificateCredential.ts | 5 +---- .../src/credentials/managedIdentityCredential/imdsMsi.ts | 2 +- .../identity/src/credentials/usernamePasswordCredential.ts | 5 +---- 4 files changed, 4 insertions(+), 13 deletions(-) diff --git a/sdk/identity/identity/src/credentials/authorizationCodeCredential.ts b/sdk/identity/identity/src/credentials/authorizationCodeCredential.ts index ba0e3ae552b0..880bd25a9335 100644 --- a/sdk/identity/identity/src/credentials/authorizationCodeCredential.ts +++ b/sdk/identity/identity/src/credentials/authorizationCodeCredential.ts @@ -135,10 +135,7 @@ export class AuthorizationCodeCredential implements TokenCredential { scopes: string | string[], options?: GetTokenOptions ): Promise { - const { span, updatedOptions } = createSpan( - "AuthorizationCodeCredential-getToken", - options - ); + const { span, updatedOptions } = createSpan("AuthorizationCodeCredential-getToken", options); try { let tokenResponse: TokenResponse | null = null; let scopeString = typeof scopes === "string" ? scopes : scopes.join(" "); diff --git a/sdk/identity/identity/src/credentials/clientCertificateCredential.ts b/sdk/identity/identity/src/credentials/clientCertificateCredential.ts index c968061c9955..03efcfe5e5de 100644 --- a/sdk/identity/identity/src/credentials/clientCertificateCredential.ts +++ b/sdk/identity/identity/src/credentials/clientCertificateCredential.ts @@ -114,10 +114,7 @@ export class ClientCertificateCredential implements TokenCredential { scopes: string | string[], options?: GetTokenOptions ): Promise { - const { span, updatedOptions } = createSpan( - "ClientCertificateCredential-getToken", - options - ); + const { span, updatedOptions } = createSpan("ClientCertificateCredential-getToken", options); try { const tokenId = uuidV4(); const urlSuffix = getIdentityTokenEndpointSuffix(this.tenantId); diff --git a/sdk/identity/identity/src/credentials/managedIdentityCredential/imdsMsi.ts b/sdk/identity/identity/src/credentials/managedIdentityCredential/imdsMsi.ts index 11bcbd3f22ef..ac781276960c 100644 --- a/sdk/identity/identity/src/credentials/managedIdentityCredential/imdsMsi.ts +++ b/sdk/identity/identity/src/credentials/managedIdentityCredential/imdsMsi.ts @@ -75,7 +75,7 @@ export const imdsMsi: MSI = { // not having a "Metadata" header should cause an error to be // returned quickly from the endpoint, proving its availability. const webResource = identityClient.createWebResource(request); - webResource.timeout = (updatedOptions?.requestOptions?.timeout) || 500; + webResource.timeout = updatedOptions?.requestOptions?.timeout || 500; try { logger.info(`Pinging IMDS endpoint`); diff --git a/sdk/identity/identity/src/credentials/usernamePasswordCredential.ts b/sdk/identity/identity/src/credentials/usernamePasswordCredential.ts index c557282fea8f..3040b3493683 100644 --- a/sdk/identity/identity/src/credentials/usernamePasswordCredential.ts +++ b/sdk/identity/identity/src/credentials/usernamePasswordCredential.ts @@ -67,10 +67,7 @@ export class UsernamePasswordCredential implements TokenCredential { scopes: string | string[], options?: GetTokenOptions ): Promise { - const { span, updatedOptions } = createSpan( - "UsernamePasswordCredential-getToken", - options - ); + const { span, updatedOptions } = createSpan("UsernamePasswordCredential-getToken", options); try { const urlSuffix = getIdentityTokenEndpointSuffix(this.tenantId); const webResource = this.identityClient.createWebResource({ From 2aea35c734f5602ea79d598b94374bac37b39b29 Mon Sep 17 00:00:00 2001 From: Richard Park <51494936+richardpark-msft@users.noreply.github.com> Date: Sat, 20 Feb 2021 02:04:02 +0000 Subject: [PATCH 15/52] Update storage-blob for the pending update to the latest OpenTelemetry. Prior to this change `createSpan` would create a new SpanOptions, out of a OperationTracingOptions (basically). This works today but will break when we move to a later version of opentelemetry, where the necessary information to track is actually two separate fields. To make this simpler we have a createSpanFunction that can handle doing the proper updating of the `tracingOptions ` property of an OperationOptions compatible type. Converting any code over to this style should future proof us a bit. In storage-blob the changes I've made here are: - If the call takes an OperationOptions, try to pass the updatedOptions directly, or if extensive copying/mutation was occuring - just pass operationOptions.tracingOptions instead. So this code: ``` { ...options, tracingOptions: { ...options!.tracingOptions, spanOptions } } ``` Becomes ``` updatedOptions (which came back from core-tracing's createSpan function) ``` - If the underlying call takes RequestOptionsBase then we call ...convertTracingToRequestOptionsBase(updatedOptions) which should allow me room to just change _that_ function when the number of fields to copy over changes. --- sdk/storage/storage-blob/src/BlobBatch.ts | 26 +- .../storage-blob/src/BlobBatchClient.ts | 8 +- .../storage-blob/src/BlobLeaseClient.ts | 26 +- .../storage-blob/src/BlobServiceClient.ts | 76 +++-- sdk/storage/storage-blob/src/Clients.ts | 288 +++++++++--------- .../storage-blob/src/ContainerClient.ts | 124 ++++---- sdk/storage/storage-blob/src/utils/tracing.ts | 14 + 7 files changed, 268 insertions(+), 294 deletions(-) diff --git a/sdk/storage/storage-blob/src/BlobBatch.ts b/sdk/storage/storage-blob/src/BlobBatch.ts index 58bb53b0d437..1c2ac4c1f2ad 100644 --- a/sdk/storage/storage-blob/src/BlobBatch.ts +++ b/sdk/storage/storage-blob/src/BlobBatch.ts @@ -184,9 +184,9 @@ export class BlobBatch { options = {}; } - const { span, spanOptions } = createSpan( + const { span, updatedOptions } = createSpan( "BatchDeleteRequest-addSubRequest", - options.tracingOptions + options ); try { @@ -197,10 +197,7 @@ export class BlobBatch { credential: credential }, async () => { - await new BlobClient(url, this.batchRequest.createPipeline(credential)).delete({ - ...options, - tracingOptions: { ...options!.tracingOptions, spanOptions } - }); + await new BlobClient(url, this.batchRequest.createPipeline(credential)).delete(updatedOptions); } ); } catch (e) { @@ -303,9 +300,9 @@ export class BlobBatch { options = {}; } - const { span, spanOptions } = createSpan( + const { span, updatedOptions } = createSpan( "BatchSetTierRequest-addSubRequest", - options.tracingOptions + options ); try { @@ -318,10 +315,7 @@ export class BlobBatch { async () => { await new BlobClient(url, this.batchRequest.createPipeline(credential)).setAccessTier( tier, - { - ...options, - tracingOptions: { ...options!.tracingOptions, spanOptions } - } + updatedOptions ); } ); @@ -389,9 +383,9 @@ class InnerBatchRequest { if (!isAnonymousCreds) { factories[2] = isTokenCredential(credential) ? attachCredential( - bearerTokenAuthenticationPolicy(credential, StorageOAuthScopes), - credential - ) + bearerTokenAuthenticationPolicy(credential, StorageOAuthScopes), + credential + ) : credential; } factories[policyFactoryLength - 1] = new BatchRequestAssemblePolicyFactory(this); // Use batch assemble policy to assemble request and intercept request from going to wire @@ -513,7 +507,7 @@ class BatchHeaderFilterPolicy extends BaseRequestPolicy { } class BatchHeaderFilterPolicyFactory implements RequestPolicyFactory { - constructor() {} + constructor() { } public create(nextPolicy: RequestPolicy, options: RequestPolicyOptions): BatchHeaderFilterPolicy { return new BatchHeaderFilterPolicy(nextPolicy, options); diff --git a/sdk/storage/storage-blob/src/BlobBatchClient.ts b/sdk/storage/storage-blob/src/BlobBatchClient.ts index f07644c6e7b6..faee348a36cc 100644 --- a/sdk/storage/storage-blob/src/BlobBatchClient.ts +++ b/sdk/storage/storage-blob/src/BlobBatchClient.ts @@ -13,7 +13,7 @@ import { utf8ByteLength } from "./BatchUtils"; import { BlobBatch } from "./BlobBatch"; import { AbortSignalLike } from "@azure/abort-controller"; import { CanonicalCode } from "@opentelemetry/api"; -import { createSpan } from "./utils/tracing"; +import { convertTracingToRequestOptionsBase, createSpan } from "./utils/tracing"; import { HttpResponse, TokenCredential } from "@azure/core-http"; import { Service, Container } from "./generated/src/operations"; import { StorageSharedKeyCredential } from "./credentials/StorageSharedKeyCredential"; @@ -29,7 +29,7 @@ import { getURLPath } from "./utils/utils.common"; */ export interface BlobBatchSubmitBatchOptionalParams extends ServiceSubmitBatchOptionalParamsModel, - CommonOptions { + CommonOptions { /** * An implementation of the `AbortSignalLike` interface to signal the request to cancel the operation. * For example, use the @azure/abort-controller to create an `AbortSignal`. @@ -303,7 +303,7 @@ export class BlobBatchClient { throw new RangeError("Batch request should contain one or more sub requests."); } - const { span, spanOptions } = createSpan("BlobBatchClient-submitBatch", options.tracingOptions); + const { span, updatedOptions } = createSpan("BlobBatchClient-submitBatch", options); try { const batchRequestBody = batchRequest.getHttpRequestBody(); @@ -314,7 +314,7 @@ export class BlobBatchClient { batchRequest.getMultiPartContentType(), { ...options, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) } ); diff --git a/sdk/storage/storage-blob/src/BlobLeaseClient.ts b/sdk/storage/storage-blob/src/BlobLeaseClient.ts index 586c4a6defd5..62426f818cea 100644 --- a/sdk/storage/storage-blob/src/BlobLeaseClient.ts +++ b/sdk/storage/storage-blob/src/BlobLeaseClient.ts @@ -9,7 +9,7 @@ import { Blob as StorageBlob, Container } from "./generated/src/operations"; import { ModifiedAccessConditions } from "./models"; import { CommonOptions } from "./StorageClient"; import { ETagNone } from "./utils/constants"; -import { createSpan } from "./utils/tracing"; +import { convertTracingToRequestOptionsBase, createSpan } from "./utils/tracing"; import { BlobClient } from "./Clients"; import { ContainerClient } from "./ContainerClient"; @@ -163,9 +163,9 @@ export class BlobLeaseClient { duration: number, options: LeaseOperationOptions = {} ): Promise { - const { span, spanOptions } = createSpan( + const { span, updatedOptions } = createSpan( "BlobLeaseClient-acquireLease", - options.tracingOptions + options ); if ( @@ -188,7 +188,7 @@ export class BlobLeaseClient { ifTags: options.conditions?.tagConditions }, proposedLeaseId: this._leaseId, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) }); } catch (e) { span.setStatus({ @@ -215,7 +215,7 @@ export class BlobLeaseClient { proposedLeaseId: string, options: LeaseOperationOptions = {} ): Promise { - const { span, spanOptions } = createSpan("BlobLeaseClient-changeLease", options.tracingOptions); + const { span, updatedOptions } = createSpan("BlobLeaseClient-changeLease", options); if ( this._isContainer && @@ -238,7 +238,7 @@ export class BlobLeaseClient { ...options.conditions, ifTags: options.conditions?.tagConditions }, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) } ); this._leaseId = proposedLeaseId; @@ -265,9 +265,9 @@ export class BlobLeaseClient { * @returns Response data for release lease operation. */ public async releaseLease(options: LeaseOperationOptions = {}): Promise { - const { span, spanOptions } = createSpan( + const { span, updatedOptions } = createSpan( "BlobLeaseClient-releaseLease", - options.tracingOptions + options ); if ( @@ -288,7 +288,7 @@ export class BlobLeaseClient { ...options.conditions, ifTags: options.conditions?.tagConditions }, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) }); } catch (e) { span.setStatus({ @@ -311,7 +311,7 @@ export class BlobLeaseClient { * @returns Response data for renew lease operation. */ public async renewLease(options: LeaseOperationOptions = {}): Promise { - const { span, spanOptions } = createSpan("BlobLeaseClient-renewLease", options.tracingOptions); + const { span, updatedOptions } = createSpan("BlobLeaseClient-renewLease", options); if ( this._isContainer && @@ -331,7 +331,7 @@ export class BlobLeaseClient { ...options.conditions, ifTags: options.conditions?.tagConditions }, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) }); } catch (e) { span.setStatus({ @@ -359,7 +359,7 @@ export class BlobLeaseClient { breakPeriod: number, options: LeaseOperationOptions = {} ): Promise { - const { span, spanOptions } = createSpan("BlobLeaseClient-breakLease", options.tracingOptions); + const { span, updatedOptions } = createSpan("BlobLeaseClient-breakLease", options); if ( this._isContainer && @@ -380,7 +380,7 @@ export class BlobLeaseClient { ...options.conditions, ifTags: options.conditions?.tagConditions }, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) }; return await this._containerOrBlobOperation.breakLease(operationOptions); } catch (e) { diff --git a/sdk/storage/storage-blob/src/BlobServiceClient.ts b/sdk/storage/storage-blob/src/BlobServiceClient.ts index cfce2b6622b2..9bb8787fbd13 100644 --- a/sdk/storage/storage-blob/src/BlobServiceClient.ts +++ b/sdk/storage/storage-blob/src/BlobServiceClient.ts @@ -46,7 +46,7 @@ import { AnonymousCredential } from "./credentials/AnonymousCredential"; import "@azure/core-paging"; import { PageSettings, PagedAsyncIterableIterator } from "@azure/core-paging"; import { truncatedISO8061Date } from "./utils/utils.common"; -import { createSpan } from "./utils/tracing"; +import { convertTracingToRequestOptionsBase, createSpan } from "./utils/tracing"; import { BlobBatchClient } from "./BlobBatchClient"; import { CommonOptions, StorageClient } from "./StorageClient"; import { Tags } from "./models"; @@ -536,16 +536,13 @@ export class BlobServiceClient extends StorageClient { containerClient: ContainerClient; containerCreateResponse: ContainerCreateResponse; }> { - const { span, spanOptions } = createSpan( + const { span, updatedOptions } = createSpan( "BlobServiceClient-createContainer", - options.tracingOptions + options ); try { const containerClient = this.getContainerClient(containerName); - const containerCreateResponse = await containerClient.create({ - ...options, - tracingOptions: { ...options!.tracingOptions, spanOptions } - }); + const containerCreateResponse = await containerClient.create(updatedOptions); return { containerClient, containerCreateResponse @@ -572,16 +569,13 @@ export class BlobServiceClient extends StorageClient { containerName: string, options: ContainerDeleteMethodOptions = {} ): Promise { - const { span, spanOptions } = createSpan( + const { span, updatedOptions } = createSpan( "BlobServiceClient-deleteContainer", - options.tracingOptions + options ); try { const containerClient = this.getContainerClient(containerName); - return await containerClient.delete({ - ...options, - tracingOptions: { ...options!.tracingOptions, spanOptions } - }); + return await containerClient.delete(updatedOptions); } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, @@ -610,9 +604,9 @@ export class BlobServiceClient extends StorageClient { containerClient: ContainerClient; containerUndeleteResponse: ContainerUndeleteResponse; }> { - const { span, spanOptions } = createSpan( + const { span, updatedOptions } = createSpan( "BlobServiceClient-undeleteContainer", - options.tracingOptions + options ); try { const containerClient = this.getContainerClient( @@ -623,8 +617,7 @@ export class BlobServiceClient extends StorageClient { const containerUndeleteResponse = await containerContext.restore({ deletedContainerName, deletedContainerVersion, - ...options, - tracingOptions: { ...options!.tracingOptions, spanOptions } + ...updatedOptions, }); return { containerClient, containerUndeleteResponse }; } catch (e) { @@ -654,18 +647,17 @@ export class BlobServiceClient extends StorageClient { containerClient: ContainerClient; containerRenameResponse: ContainerRenameResponse; }> { - const { span, spanOptions } = createSpan( + const { span, updatedOptions } = createSpan( "BlobServiceClient-renameContainer", - options.tracingOptions + options ); try { const containerClient = this.getContainerClient(destinationContainerName); // Hack to access a protected member. const containerContext = new Container(containerClient["storageClientContext"]); const containerRenameResponse = await containerContext.rename(sourceContainerName, { - ...options, + ...updatedOptions, sourceLeaseId: options.sourceCondition?.leaseId, - tracingOptions: { ...options.tracingOptions, spanOptions } }); return { containerClient, containerRenameResponse }; } catch (e) { @@ -690,14 +682,14 @@ export class BlobServiceClient extends StorageClient { public async getProperties( options: ServiceGetPropertiesOptions = {} ): Promise { - const { span, spanOptions } = createSpan( + const { span, updatedOptions } = createSpan( "BlobServiceClient-getProperties", - options.tracingOptions + options ); try { return await this.serviceContext.getProperties({ abortSignal: options.abortSignal, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) }); } catch (e) { span.setStatus({ @@ -723,14 +715,14 @@ export class BlobServiceClient extends StorageClient { properties: BlobServiceProperties, options: ServiceSetPropertiesOptions = {} ): Promise { - const { span, spanOptions } = createSpan( + const { span, updatedOptions } = createSpan( "BlobServiceClient-setProperties", - options.tracingOptions + options ); try { return await this.serviceContext.setProperties(properties, { abortSignal: options.abortSignal, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) }); } catch (e) { span.setStatus({ @@ -755,14 +747,14 @@ export class BlobServiceClient extends StorageClient { public async getStatistics( options: ServiceGetStatisticsOptions = {} ): Promise { - const { span, spanOptions } = createSpan( + const { span, updatedOptions } = createSpan( "BlobServiceClient-getStatistics", - options.tracingOptions + options ); try { return await this.serviceContext.getStatistics({ abortSignal: options.abortSignal, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) }); } catch (e) { span.setStatus({ @@ -788,14 +780,14 @@ export class BlobServiceClient extends StorageClient { public async getAccountInfo( options: ServiceGetAccountInfoOptions = {} ): Promise { - const { span, spanOptions } = createSpan( + const { span, updatedOptions } = createSpan( "BlobServiceClient-getAccountInfo", - options.tracingOptions + options ); try { return await this.serviceContext.getAccountInfo({ abortSignal: options.abortSignal, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) }); } catch (e) { span.setStatus({ @@ -826,9 +818,9 @@ export class BlobServiceClient extends StorageClient { marker?: string, options: ServiceListContainersSegmentOptions = {} ): Promise { - const { span, spanOptions } = createSpan( + const { span, updatedOptions } = createSpan( "BlobServiceClient-listContainersSegment", - options.tracingOptions + options ); try { @@ -837,7 +829,7 @@ export class BlobServiceClient extends StorageClient { marker, ...options, include: typeof options.include === "string" ? [options.include] : options.include, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) }); } catch (e) { span.setStatus({ @@ -873,9 +865,9 @@ export class BlobServiceClient extends StorageClient { marker?: string, options: ServiceFindBlobsByTagsSegmentOptions = {} ): Promise { - const { span, spanOptions } = createSpan( + const { span, updatedOptions } = createSpan( "BlobServiceClient-findBlobsByTagsSegment", - options.tracingOptions + options ); try { @@ -884,7 +876,7 @@ export class BlobServiceClient extends StorageClient { where: tagFilterSqlExpression, marker, maxPageSize: options.maxPageSize, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) }); const wrappedResponse: ServiceFindBlobsByTagsSegmentResponse = { @@ -1258,9 +1250,9 @@ export class BlobServiceClient extends StorageClient { expiresOn: Date, options: ServiceGetUserDelegationKeyOptions = {} ): Promise { - const { span, spanOptions } = createSpan( + const { span, updatedOptions } = createSpan( "BlobServiceClient-getUserDelegationKey", - options.tracingOptions + options ); try { const response = await this.serviceContext.getUserDelegationKey( @@ -1270,7 +1262,7 @@ export class BlobServiceClient extends StorageClient { }, { abortSignal: options.abortSignal, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) } ); diff --git a/sdk/storage/storage-blob/src/Clients.ts b/sdk/storage/storage-blob/src/Clients.ts index 2db09f8bf579..cbffeff63c2e 100644 --- a/sdk/storage/storage-blob/src/Clients.ts +++ b/sdk/storage/storage-blob/src/Clients.ts @@ -105,7 +105,7 @@ import { ETagAny, URLConstants } from "./utils/constants"; -import { createSpan } from "./utils/tracing"; +import { createSpan, convertTracingToRequestOptionsBase } from "./utils/tracing"; import { appendToURLPath, appendToURLQuery, @@ -160,7 +160,7 @@ export interface BlobBeginCopyFromURLOptions extends BlobStartCopyFromURLOptions /** * Contains response data for the {@link BlobClient.beginCopyFromURL} operation. */ -export interface BlobBeginCopyFromURLResponse extends BlobStartCopyFromURLResponse {} +export interface BlobBeginCopyFromURLResponse extends BlobStartCopyFromURLResponse { } /** * Options to configure the {@link BlobClient.download} operation. @@ -374,26 +374,26 @@ export interface BlobGetTagsOptions extends CommonOptions { * Contains response data for the {@link BlobClient.getTags} operation. */ export type BlobGetTagsResponse = { tags: Tags } & BlobGetTagsHeaders & { + /** + * The underlying HTTP response. + */ + _response: HttpResponse & { /** - * The underlying HTTP response. + * The parsed HTTP response headers. */ - _response: HttpResponse & { - /** - * The parsed HTTP response headers. - */ - parsedHeaders: BlobGetTagsHeaders; - - /** - * The response body as text (string format) - */ - bodyAsText: string; - - /** - * The response body as parsed JSON or XML - */ - parsedBody: BlobTags; - }; + parsedHeaders: BlobGetTagsHeaders; + + /** + * The response body as text (string format) + */ + bodyAsText: string; + + /** + * The response body as parsed JSON or XML + */ + parsedBody: BlobTags; }; +}; /** * Options to configure Blob - Acquire Lease operation. @@ -1063,7 +1063,7 @@ export class BlobClient extends StorageClient { options.conditions = options.conditions || {}; ensureCpkIfSpecified(options.customerProvidedKey, this.isHttps); - const { span, spanOptions } = createSpan("BlobClient-download", options.tracingOptions); + const { span, updatedOptions } = createSpan("BlobClient-download", options); try { const res = await this.blobContext.download({ @@ -1079,7 +1079,7 @@ export class BlobClient extends StorageClient { rangeGetContentCRC64: options.rangeGetContentCrc64, snapshot: options.snapshot, cpkInfo: options.customerProvidedKey, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) }); const wrappedRes = { @@ -1175,17 +1175,14 @@ export class BlobClient extends StorageClient { * @param options - options to Exists operation. */ public async exists(options: BlobExistsOptions = {}): Promise { - const { span, spanOptions } = createSpan("BlobClient-exists", options.tracingOptions); + const { span, updatedOptions } = createSpan("BlobClient-exists", options); try { ensureCpkIfSpecified(options.customerProvidedKey, this.isHttps); await this.getProperties({ abortSignal: options.abortSignal, customerProvidedKey: options.customerProvidedKey, conditions: options.conditions, - tracingOptions: { - ...options.tracingOptions, - spanOptions - } + tracingOptions: updatedOptions.tracingOptions }); return true; } catch (e) { @@ -1221,7 +1218,7 @@ export class BlobClient extends StorageClient { public async getProperties( options: BlobGetPropertiesOptions = {} ): Promise { - const { span, spanOptions } = createSpan("BlobClient-getProperties", options.tracingOptions); + const { span, updatedOptions } = createSpan("BlobClient-getProperties", options); try { options.conditions = options.conditions || {}; ensureCpkIfSpecified(options.customerProvidedKey, this.isHttps); @@ -1233,7 +1230,7 @@ export class BlobClient extends StorageClient { ifTags: options.conditions?.tagConditions }, cpkInfo: options.customerProvidedKey, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) }); return { @@ -1263,7 +1260,7 @@ export class BlobClient extends StorageClient { * @param options - Optional options to Blob Delete operation. */ public async delete(options: BlobDeleteOptions = {}): Promise { - const { span, spanOptions } = createSpan("BlobClient-delete", options.tracingOptions); + const { span, updatedOptions } = createSpan("BlobClient-delete", options); options.conditions = options.conditions || {}; try { return await this.blobContext.deleteMethod({ @@ -1274,7 +1271,7 @@ export class BlobClient extends StorageClient { ...options.conditions, ifTags: options.conditions?.tagConditions }, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) }); } catch (e) { span.setStatus({ @@ -1299,12 +1296,9 @@ export class BlobClient extends StorageClient { public async deleteIfExists( options: BlobDeleteOptions = {} ): Promise { - const { span, spanOptions } = createSpan("BlobClient-deleteIfExists", options.tracingOptions); + const { span, updatedOptions } = createSpan("BlobClient-deleteIfExists", options); try { - const res = await this.delete({ - ...options, - tracingOptions: { ...options!.tracingOptions, spanOptions } - }); + const res = await this.delete(updatedOptions); return { succeeded: true, ...res, @@ -1341,11 +1335,11 @@ export class BlobClient extends StorageClient { * @param options - Optional options to Blob Undelete operation. */ public async undelete(options: BlobUndeleteOptions = {}): Promise { - const { span, spanOptions } = createSpan("BlobClient-undelete", options.tracingOptions); + const { span, updatedOptions } = createSpan("BlobClient-undelete", options); try { return await this.blobContext.undelete({ abortSignal: options.abortSignal, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) }); } catch (e) { span.setStatus({ @@ -1374,7 +1368,7 @@ export class BlobClient extends StorageClient { blobHTTPHeaders?: BlobHTTPHeaders, options: BlobSetHTTPHeadersOptions = {} ): Promise { - const { span, spanOptions } = createSpan("BlobClient-setHTTPHeaders", options.tracingOptions); + const { span, updatedOptions } = createSpan("BlobClient-setHTTPHeaders", options); options.conditions = options.conditions || {}; try { ensureCpkIfSpecified(options.customerProvidedKey, this.isHttps); @@ -1387,7 +1381,7 @@ export class BlobClient extends StorageClient { ifTags: options.conditions?.tagConditions }, cpkInfo: options.customerProvidedKey, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) }); } catch (e) { span.setStatus({ @@ -1415,7 +1409,7 @@ export class BlobClient extends StorageClient { metadata?: Metadata, options: BlobSetMetadataOptions = {} ): Promise { - const { span, spanOptions } = createSpan("BlobClient-setMetadata", options.tracingOptions); + const { span, updatedOptions } = createSpan("BlobClient-setMetadata", options); options.conditions = options.conditions || {}; try { ensureCpkIfSpecified(options.customerProvidedKey, this.isHttps); @@ -1429,7 +1423,7 @@ export class BlobClient extends StorageClient { }, cpkInfo: options.customerProvidedKey, encryptionScope: options.encryptionScope, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) }); } catch (e) { span.setStatus({ @@ -1452,7 +1446,7 @@ export class BlobClient extends StorageClient { * @param options - */ public async setTags(tags: Tags, options: BlobSetTagsOptions = {}): Promise { - const { span, spanOptions } = createSpan("BlobClient-setTags", options.tracingOptions); + const { span, updatedOptions } = createSpan("BlobClient-setTags", options); try { return await this.blobContext.setTags({ abortSignal: options.abortSignal, @@ -1461,7 +1455,7 @@ export class BlobClient extends StorageClient { ...options.conditions, ifTags: options.conditions?.tagConditions }, - spanOptions, + ...convertTracingToRequestOptionsBase(updatedOptions), tags: toBlobTags(tags) }); } catch (e) { @@ -1481,7 +1475,7 @@ export class BlobClient extends StorageClient { * @param options - */ public async getTags(options: BlobGetTagsOptions = {}): Promise { - const { span, spanOptions } = createSpan("BlobClient-getTags", options.tracingOptions); + const { span, updatedOptions } = createSpan("BlobClient-getTags", options); try { const response = await this.blobContext.getTags({ abortSignal: options.abortSignal, @@ -1490,7 +1484,7 @@ export class BlobClient extends StorageClient { ...options.conditions, ifTags: options.conditions?.tagConditions }, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) }); const wrappedResponse: BlobGetTagsResponse = { ...response, @@ -1528,7 +1522,7 @@ export class BlobClient extends StorageClient { public async createSnapshot( options: BlobCreateSnapshotOptions = {} ): Promise { - const { span, spanOptions } = createSpan("BlobClient-createSnapshot", options.tracingOptions); + const { span, updatedOptions } = createSpan("BlobClient-createSnapshot", options); options.conditions = options.conditions || {}; try { ensureCpkIfSpecified(options.customerProvidedKey, this.isHttps); @@ -1542,7 +1536,7 @@ export class BlobClient extends StorageClient { }, cpkInfo: options.customerProvidedKey, encryptionScope: options.encryptionScope, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) }); } catch (e) { span.setStatus({ @@ -1666,12 +1660,12 @@ export class BlobClient extends StorageClient { copyId: string, options: BlobAbortCopyFromURLOptions = {} ): Promise { - const { span, spanOptions } = createSpan("BlobClient-abortCopyFromURL", options.tracingOptions); + const { span, updatedOptions } = createSpan("BlobClient-abortCopyFromURL", options); try { return await this.blobContext.abortCopyFromURL(copyId, { abortSignal: options.abortSignal, leaseAccessConditions: options.conditions, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) }); } catch (e) { span.setStatus({ @@ -1696,7 +1690,7 @@ export class BlobClient extends StorageClient { copySource: string, options: BlobSyncCopyFromURLOptions = {} ): Promise { - const { span, spanOptions } = createSpan("BlobClient-syncCopyFromURL", options.tracingOptions); + const { span, updatedOptions } = createSpan("BlobClient-syncCopyFromURL", options); options.conditions = options.conditions || {}; options.sourceConditions = options.sourceConditions || {}; @@ -1717,7 +1711,7 @@ export class BlobClient extends StorageClient { }, sourceContentMD5: options.sourceContentMD5, blobTagsString: toBlobTagsString(options.tags), - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) }); } catch (e) { span.setStatus({ @@ -1745,7 +1739,7 @@ export class BlobClient extends StorageClient { tier: BlockBlobTier | PremiumPageBlobTier | string, options: BlobSetTierOptions = {} ): Promise { - const { span, spanOptions } = createSpan("BlobClient-setAccessTier", options.tracingOptions); + const { span, updatedOptions } = createSpan("BlobClient-setAccessTier", options); try { return await this.blobContext.setTier(toAccessTier(tier)!, { abortSignal: options.abortSignal, @@ -1755,7 +1749,7 @@ export class BlobClient extends StorageClient { ifTags: options.conditions?.tagConditions }, rehydratePriority: options.rehydratePriority, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) }); } catch (e) { span.setStatus({ @@ -1831,7 +1825,7 @@ export class BlobClient extends StorageClient { count = typeof param2 === "number" ? param2 : 0; options = (param3 as BlobDownloadToBufferOptions) || {}; } - const { span, spanOptions } = createSpan("BlobClient-downloadToBuffer", options.tracingOptions); + const { span, updatedOptions } = createSpan("BlobClient-downloadToBuffer", options); try { if (!options.blockSize) { @@ -1862,7 +1856,7 @@ export class BlobClient extends StorageClient { ...options, tracingOptions: { ...options.tracingOptions, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) } }); count = response.contentLength! - offset; @@ -1906,7 +1900,7 @@ export class BlobClient extends StorageClient { customerProvidedKey: options.customerProvidedKey, tracingOptions: { ...options.tracingOptions, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) } }); const stream = response.readableStreamBody!; @@ -1955,13 +1949,13 @@ export class BlobClient extends StorageClient { count?: number, options: BlobDownloadOptions = {} ): Promise { - const { span, spanOptions } = createSpan("BlobClient-downloadToFile", options.tracingOptions); + const { span, updatedOptions } = createSpan("BlobClient-downloadToFile", options); try { const response = await this.download(offset, count, { ...options, tracingOptions: { ...options.tracingOptions, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) } }); if (response.readableStreamBody) { @@ -2052,7 +2046,7 @@ export class BlobClient extends StorageClient { copySource: string, options: BlobStartCopyFromURLOptions = {} ): Promise { - const { span, spanOptions } = createSpan("BlobClient-startCopyFromURL", options.tracingOptions); + const { span, updatedOptions } = createSpan("BlobClient-startCopyFromURL", options); options.conditions = options.conditions || {}; options.sourceConditions = options.sourceConditions || {}; @@ -2076,7 +2070,7 @@ export class BlobClient extends StorageClient { tier: toAccessTier(options.tier), blobTagsString: toBlobTagsString(options.tags), sealBlob: options.sealBlob, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) }); } catch (e) { span.setStatus({ @@ -2495,7 +2489,7 @@ export class AppendBlobClient extends BlobClient { * ``` */ public async create(options: AppendBlobCreateOptions = {}): Promise { - const { span, spanOptions } = createSpan("AppendBlobClient-create", options.tracingOptions); + const { span, updatedOptions } = createSpan("AppendBlobClient-create", options); options.conditions = options.conditions || {}; try { ensureCpkIfSpecified(options.customerProvidedKey, this.isHttps); @@ -2512,7 +2506,7 @@ export class AppendBlobClient extends BlobClient { cpkInfo: options.customerProvidedKey, encryptionScope: options.encryptionScope, blobTagsString: toBlobTagsString(options.tags), - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) }); } catch (e) { span.setStatus({ @@ -2535,16 +2529,15 @@ export class AppendBlobClient extends BlobClient { public async createIfNotExists( options: AppendBlobCreateIfNotExistsOptions = {} ): Promise { - const { span, spanOptions } = createSpan( + const { span, updatedOptions } = createSpan( "AppendBlobClient-createIfNotExists", - options.tracingOptions + options ); const conditions = { ifNoneMatch: ETagAny }; try { const res = await this.create({ - ...options, - conditions, - tracingOptions: { ...options!.tracingOptions, spanOptions } + ...updatedOptions, + conditions }); return { succeeded: true, @@ -2580,7 +2573,7 @@ export class AppendBlobClient extends BlobClient { * @param options - */ public async seal(options: AppendBlobSealOptions = {}): Promise { - const { span, spanOptions } = createSpan("AppendBlobClient-seal", options.tracingOptions); + const { span, updatedOptions } = createSpan("AppendBlobClient-seal", options); options.conditions = options.conditions || {}; try { return await this.appendBlobContext.seal({ @@ -2591,7 +2584,7 @@ export class AppendBlobClient extends BlobClient { ...options.conditions, ifTags: options.conditions?.tagConditions }, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) }); } catch (e) { span.setStatus({ @@ -2633,9 +2626,9 @@ export class AppendBlobClient extends BlobClient { contentLength: number, options: AppendBlobAppendBlockOptions = {} ): Promise { - const { span, spanOptions } = createSpan( + const { span, updatedOptions } = createSpan( "AppendBlobClient-appendBlock", - options.tracingOptions + options ); options.conditions = options.conditions || {}; try { @@ -2654,7 +2647,7 @@ export class AppendBlobClient extends BlobClient { transactionalContentCrc64: options.transactionalContentCrc64, cpkInfo: options.customerProvidedKey, encryptionScope: options.encryptionScope, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) }); } catch (e) { span.setStatus({ @@ -2687,9 +2680,9 @@ export class AppendBlobClient extends BlobClient { count: number, options: AppendBlobAppendBlockFromURLOptions = {} ): Promise { - const { span, spanOptions } = createSpan( + const { span, updatedOptions } = createSpan( "AppendBlobClient-appendBlockFromURL", - options.tracingOptions + options ); options.conditions = options.conditions || {}; options.sourceConditions = options.sourceConditions || {}; @@ -2715,7 +2708,7 @@ export class AppendBlobClient extends BlobClient { }, cpkInfo: options.customerProvidedKey, encryptionScope: options.encryptionScope, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) }); } catch (e) { span.setStatus({ @@ -2940,9 +2933,9 @@ export interface BlockBlobQueryOptions extends CommonOptions { * Configurations for the query output. */ outputTextConfiguration?: - | BlobQueryJsonTextConfiguration - | BlobQueryCsvTextConfiguration - | BlobQueryArrowConfiguration; + | BlobQueryJsonTextConfiguration + | BlobQueryCsvTextConfiguration + | BlobQueryArrowConfiguration; /** * Callback to receive events on the progress of query operation. */ @@ -3460,7 +3453,7 @@ export class BlockBlobClient extends BlobClient { ): Promise { ensureCpkIfSpecified(options.customerProvidedKey, this.isHttps); - const { span, spanOptions } = createSpan("BlockBlobClient-query", options.tracingOptions); + const { span, updatedOptions } = createSpan("BlockBlobClient-query", options); try { if (!isNode) { @@ -3479,7 +3472,7 @@ export class BlockBlobClient extends BlobClient { ...options.conditions, ifTags: options.conditions?.tagConditions }, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) }); return new BlobQueryResponse(response, { abortSignal: options.abortSignal, @@ -3530,7 +3523,7 @@ export class BlockBlobClient extends BlobClient { options: BlockBlobUploadOptions = {} ): Promise { options.conditions = options.conditions || {}; - const { span, spanOptions } = createSpan("BlockBlobClient-upload", options.tracingOptions); + const { span, updatedOptions } = createSpan("BlockBlobClient-upload", options); try { ensureCpkIfSpecified(options.customerProvidedKey, this.isHttps); return await this.blockBlobContext.upload(body, contentLength, { @@ -3547,7 +3540,7 @@ export class BlockBlobClient extends BlobClient { encryptionScope: options.encryptionScope, tier: toAccessTier(options.tier), blobTagsString: toBlobTagsString(options.tags), - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) }); } catch (e) { span.setStatus({ @@ -3584,9 +3577,9 @@ export class BlockBlobClient extends BlobClient { options: BlockBlobSyncUploadFromURLOptions = {} ): Promise { options.conditions = options.conditions || {}; - const { span, spanOptions } = createSpan( + const { span, updatedOptions } = createSpan( "BlockBlobClient-syncUploadFromURL", - options.tracingOptions + options ); try { ensureCpkIfSpecified(options.customerProvidedKey, this.isHttps); @@ -3607,7 +3600,7 @@ export class BlockBlobClient extends BlobClient { cpkInfo: options.customerProvidedKey, tier: toAccessTier(options.tier), blobTagsString: toBlobTagsString(options.tags), - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) }); } catch (e) { span.setStatus({ @@ -3637,7 +3630,7 @@ export class BlockBlobClient extends BlobClient { contentLength: number, options: BlockBlobStageBlockOptions = {} ): Promise { - const { span, spanOptions } = createSpan("BlockBlobClient-stageBlock", options.tracingOptions); + const { span, updatedOptions } = createSpan("BlockBlobClient-stageBlock", options); try { ensureCpkIfSpecified(options.customerProvidedKey, this.isHttps); return await this.blockBlobContext.stageBlock(blockId, contentLength, body, { @@ -3648,7 +3641,7 @@ export class BlockBlobClient extends BlobClient { transactionalContentCrc64: options.transactionalContentCrc64, cpkInfo: options.customerProvidedKey, encryptionScope: options.encryptionScope, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) }); } catch (e) { span.setStatus({ @@ -3689,9 +3682,9 @@ export class BlockBlobClient extends BlobClient { count?: number, options: BlockBlobStageBlockFromURLOptions = {} ): Promise { - const { span, spanOptions } = createSpan( + const { span, updatedOptions } = createSpan( "BlockBlobClient-stageBlockFromURL", - options.tracingOptions + options ); try { ensureCpkIfSpecified(options.customerProvidedKey, this.isHttps); @@ -3703,7 +3696,7 @@ export class BlockBlobClient extends BlobClient { sourceRange: offset === 0 && !count ? undefined : rangeToString({ offset, count }), cpkInfo: options.customerProvidedKey, encryptionScope: options.encryptionScope, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) }); } catch (e) { span.setStatus({ @@ -3733,9 +3726,9 @@ export class BlockBlobClient extends BlobClient { options: BlockBlobCommitBlockListOptions = {} ): Promise { options.conditions = options.conditions || {}; - const { span, spanOptions } = createSpan( + const { span, updatedOptions } = createSpan( "BlockBlobClient-commitBlockList", - options.tracingOptions + options ); try { ensureCpkIfSpecified(options.customerProvidedKey, this.isHttps); @@ -3754,7 +3747,7 @@ export class BlockBlobClient extends BlobClient { encryptionScope: options.encryptionScope, tier: toAccessTier(options.tier), blobTagsString: toBlobTagsString(options.tags), - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) } ); } catch (e) { @@ -3782,9 +3775,9 @@ export class BlockBlobClient extends BlobClient { listType: BlockListType, options: BlockBlobGetBlockListOptions = {} ): Promise { - const { span, spanOptions } = createSpan( + const { span, updatedOptions } = createSpan( "BlockBlobClient-getBlockList", - options.tracingOptions + options ); try { const res = await this.blockBlobContext.getBlockList(listType, { @@ -3794,7 +3787,7 @@ export class BlockBlobClient extends BlobClient { ...options.conditions, ifTags: options.conditions?.tagConditions }, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) }); if (!res.committedBlocks) { @@ -3834,7 +3827,7 @@ export class BlockBlobClient extends BlobClient { data: Buffer | Blob | ArrayBuffer | ArrayBufferView, options: BlockBlobParallelUploadOptions = {} ): Promise { - const { span, spanOptions } = createSpan("BlockBlobClient-uploadData", options.tracingOptions); + const { span, updatedOptions } = createSpan("BlockBlobClient-uploadData", options); try { if (isNode) { let buffer: Buffer; @@ -3850,17 +3843,14 @@ export class BlockBlobClient extends BlobClient { return this.uploadSeekableInternal( (offset: number, size: number): Buffer => buffer.slice(offset, offset + size), buffer.byteLength, - { - ...options, - tracingOptions: { ...options!.tracingOptions, spanOptions } - } + updatedOptions ); } else { const browserBlob = new Blob([data]); return this.uploadSeekableInternal( (offset: number, size: number): Blob => browserBlob.slice(offset, offset + size), browserBlob.size, - { ...options, tracingOptions: { ...options!.tracingOptions, spanOptions } } + updatedOptions ); } } catch (e) { @@ -3893,16 +3883,16 @@ export class BlockBlobClient extends BlobClient { browserData: Blob | ArrayBuffer | ArrayBufferView, options: BlockBlobParallelUploadOptions = {} ): Promise { - const { span, spanOptions } = createSpan( + const { span, updatedOptions } = createSpan( "BlockBlobClient-uploadBrowserData", - options.tracingOptions + options ); try { const browserBlob = new Blob([browserData]); return await this.uploadSeekableInternal( (offset: number, size: number): Blob => browserBlob.slice(offset, offset + size), browserBlob.size, - { ...options, tracingOptions: { ...options!.tracingOptions, spanOptions } } + updatedOptions ); } catch (e) { span.setStatus({ @@ -3974,24 +3964,21 @@ export class BlockBlobClient extends BlobClient { options.conditions = {}; } - const { span, spanOptions } = createSpan( + const { span, updatedOptions } = createSpan( "BlockBlobClient-uploadSeekableInternal", - options.tracingOptions + options ); try { if (size <= options.maxSingleShotSize) { - return await this.upload(bodyFactory(0, size), size, { - ...options, - tracingOptions: { ...options!.tracingOptions, spanOptions } - }); + return await this.upload(bodyFactory(0, size), size, updatedOptions); } const numBlocks: number = Math.floor((size - 1) / options.blockSize) + 1; if (numBlocks > BLOCK_BLOB_MAX_BLOCKS) { throw new RangeError( `The buffer's size is too big or the BlockSize is too small;` + - `the number of blocks must be <= ${BLOCK_BLOB_MAX_BLOCKS}` + `the number of blocks must be <= ${BLOCK_BLOB_MAX_BLOCKS}` ); } @@ -4012,7 +3999,7 @@ export class BlockBlobClient extends BlobClient { abortSignal: options.abortSignal, conditions: options.conditions, encryptionScope: options.encryptionScope, - tracingOptions: { ...options!.tracingOptions, spanOptions } + tracingOptions: updatedOptions.tracingOptions }); // Update progress after block is successfully uploaded to server, in case of block trying // TODO: Hook with convenience layer progress event in finer level @@ -4027,10 +4014,7 @@ export class BlockBlobClient extends BlobClient { } await batch.do(); - return this.commitBlockList(blockList, { - ...options, - tracingOptions: { ...options!.tracingOptions, spanOptions } - }); + return this.commitBlockList(blockList, updatedOptions); } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, @@ -4059,7 +4043,7 @@ export class BlockBlobClient extends BlobClient { filePath: string, options: BlockBlobParallelUploadOptions = {} ): Promise { - const { span, spanOptions } = createSpan("BlockBlobClient-uploadFile", options.tracingOptions); + const { span, updatedOptions } = createSpan("BlockBlobClient-uploadFile", options); try { const size = (await fsStat(filePath)).size; return await this.uploadSeekableInternal( @@ -4072,7 +4056,7 @@ export class BlockBlobClient extends BlobClient { }); }, size, - { ...options, tracingOptions: { ...options!.tracingOptions, spanOptions } } + { ...options, tracingOptions: { ...options!.tracingOptions, ...convertTracingToRequestOptionsBase(updatedOptions) } } ); } catch (e) { span.setStatus({ @@ -4114,9 +4098,9 @@ export class BlockBlobClient extends BlobClient { options.conditions = {}; } - const { span, spanOptions } = createSpan( + const { span, updatedOptions } = createSpan( "BlockBlobClient-uploadStream", - options.tracingOptions + options ); try { @@ -4137,7 +4121,7 @@ export class BlockBlobClient extends BlobClient { await this.stageBlock(blockID, body, length, { conditions: options.conditions, encryptionScope: options.encryptionScope, - tracingOptions: { ...options!.tracingOptions, spanOptions } + tracingOptions: updatedOptions.tracingOptions }); // Update progress after block is successfully uploaded to server, in case of block trying @@ -4156,7 +4140,7 @@ export class BlockBlobClient extends BlobClient { return await this.commitBlockList(blockList, { ...options, - tracingOptions: { ...options!.tracingOptions, spanOptions } + tracingOptions: { ...options!.tracingOptions, ...convertTracingToRequestOptionsBase(updatedOptions) } }); } catch (e) { span.setStatus({ @@ -4648,7 +4632,7 @@ export class PageBlobClient extends BlobClient { options: PageBlobCreateOptions = {} ): Promise { options.conditions = options.conditions || {}; - const { span, spanOptions } = createSpan("PageBlobClient-create", options.tracingOptions); + const { span, updatedOptions } = createSpan("PageBlobClient-create", options); try { ensureCpkIfSpecified(options.customerProvidedKey, this.isHttps); return await this.pageBlobContext.create(0, size, { @@ -4665,7 +4649,7 @@ export class PageBlobClient extends BlobClient { encryptionScope: options.encryptionScope, tier: toAccessTier(options.tier), blobTagsString: toBlobTagsString(options.tags), - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) }); } catch (e) { span.setStatus({ @@ -4691,16 +4675,16 @@ export class PageBlobClient extends BlobClient { size: number, options: PageBlobCreateIfNotExistsOptions = {} ): Promise { - const { span, spanOptions } = createSpan( + const { span, updatedOptions } = createSpan( "PageBlobClient-createIfNotExists", - options.tracingOptions + options ); try { const conditions = { ifNoneMatch: ETagAny }; const res = await this.create(size, { ...options, conditions, - tracingOptions: { ...options!.tracingOptions, spanOptions } + tracingOptions: updatedOptions.tracingOptions }); return { succeeded: true, @@ -4747,7 +4731,7 @@ export class PageBlobClient extends BlobClient { options: PageBlobUploadPagesOptions = {} ): Promise { options.conditions = options.conditions || {}; - const { span, spanOptions } = createSpan("PageBlobClient-uploadPages", options.tracingOptions); + const { span, updatedOptions } = createSpan("PageBlobClient-uploadPages", options); try { ensureCpkIfSpecified(options.customerProvidedKey, this.isHttps); return await this.pageBlobContext.uploadPages(body, count, { @@ -4764,7 +4748,7 @@ export class PageBlobClient extends BlobClient { transactionalContentCrc64: options.transactionalContentCrc64, cpkInfo: options.customerProvidedKey, encryptionScope: options.encryptionScope, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) }); } catch (e) { span.setStatus({ @@ -4797,9 +4781,9 @@ export class PageBlobClient extends BlobClient { ): Promise { options.conditions = options.conditions || {}; options.sourceConditions = options.sourceConditions || {}; - const { span, spanOptions } = createSpan( + const { span, updatedOptions } = createSpan( "PageBlobClient-uploadPagesFromURL", - options.tracingOptions + options ); try { ensureCpkIfSpecified(options.customerProvidedKey, this.isHttps); @@ -4826,7 +4810,7 @@ export class PageBlobClient extends BlobClient { }, cpkInfo: options.customerProvidedKey, encryptionScope: options.encryptionScope, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) } ); } catch (e) { @@ -4855,7 +4839,7 @@ export class PageBlobClient extends BlobClient { options: PageBlobClearPagesOptions = {} ): Promise { options.conditions = options.conditions || {}; - const { span, spanOptions } = createSpan("PageBlobClient-clearPages", options.tracingOptions); + const { span, updatedOptions } = createSpan("PageBlobClient-clearPages", options); try { return await this.pageBlobContext.clearPages(0, { abortSignal: options.abortSignal, @@ -4868,7 +4852,7 @@ export class PageBlobClient extends BlobClient { sequenceNumberAccessConditions: options.conditions, cpkInfo: options.customerProvidedKey, encryptionScope: options.encryptionScope, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) }); } catch (e) { span.setStatus({ @@ -4896,9 +4880,9 @@ export class PageBlobClient extends BlobClient { options: PageBlobGetPageRangesOptions = {} ): Promise { options.conditions = options.conditions || {}; - const { span, spanOptions } = createSpan( + const { span, updatedOptions } = createSpan( "PageBlobClient-getPageRanges", - options.tracingOptions + options ); try { return await this.pageBlobContext @@ -4910,7 +4894,7 @@ export class PageBlobClient extends BlobClient { ifTags: options.conditions?.tagConditions }, range: rangeToString({ offset, count }), - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) }) .then(rangeResponseFromModel); } catch (e) { @@ -4941,9 +4925,9 @@ export class PageBlobClient extends BlobClient { options: PageBlobGetPageRangesDiffOptions = {} ): Promise { options.conditions = options.conditions || {}; - const { span, spanOptions } = createSpan( + const { span, updatedOptions } = createSpan( "PageBlobClient-getPageRangesDiff", - options.tracingOptions + options ); try { @@ -4957,7 +4941,7 @@ export class PageBlobClient extends BlobClient { }, prevsnapshot: prevSnapshot, range: rangeToString({ offset, count }), - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) }) .then(rangeResponseFromModel); } catch (e) { @@ -4988,9 +4972,9 @@ export class PageBlobClient extends BlobClient { options: PageBlobGetPageRangesDiffOptions = {} ): Promise { options.conditions = options.conditions || {}; - const { span, spanOptions } = createSpan( + const { span, updatedOptions } = createSpan( "PageBlobClient-GetPageRangesDiffForManagedDisks", - options.tracingOptions + options ); try { @@ -5004,7 +4988,7 @@ export class PageBlobClient extends BlobClient { }, prevSnapshotUrl, range: rangeToString({ offset, count }), - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) }) .then(rangeResponseFromModel); } catch (e) { @@ -5031,7 +5015,7 @@ export class PageBlobClient extends BlobClient { options: PageBlobResizeOptions = {} ): Promise { options.conditions = options.conditions || {}; - const { span, spanOptions } = createSpan("PageBlobClient-resize", options.tracingOptions); + const { span, updatedOptions } = createSpan("PageBlobClient-resize", options); try { return await this.pageBlobContext.resize(size, { abortSignal: options.abortSignal, @@ -5041,7 +5025,7 @@ export class PageBlobClient extends BlobClient { ifTags: options.conditions?.tagConditions }, encryptionScope: options.encryptionScope, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) }); } catch (e) { span.setStatus({ @@ -5069,9 +5053,9 @@ export class PageBlobClient extends BlobClient { options: PageBlobUpdateSequenceNumberOptions = {} ): Promise { options.conditions = options.conditions || {}; - const { span, spanOptions } = createSpan( + const { span, updatedOptions } = createSpan( "PageBlobClient-updateSequenceNumber", - options.tracingOptions + options ); try { return await this.pageBlobContext.updateSequenceNumber(sequenceNumberAction, { @@ -5082,7 +5066,7 @@ export class PageBlobClient extends BlobClient { ...options.conditions, ifTags: options.conditions?.tagConditions }, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) }); } catch (e) { span.setStatus({ @@ -5112,9 +5096,9 @@ export class PageBlobClient extends BlobClient { copySource: string, options: PageBlobStartCopyIncrementalOptions = {} ): Promise { - const { span, spanOptions } = createSpan( + const { span, updatedOptions } = createSpan( "PageBlobClient-startCopyIncremental", - options.tracingOptions + options ); try { return await this.pageBlobContext.copyIncremental(copySource, { @@ -5123,7 +5107,7 @@ export class PageBlobClient extends BlobClient { ...options.conditions, ifTags: options.conditions?.tagConditions }, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) }); } catch (e) { span.setStatus({ diff --git a/sdk/storage/storage-blob/src/ContainerClient.ts b/sdk/storage/storage-blob/src/ContainerClient.ts index 85ac00b3b96c..e474c567fd57 100644 --- a/sdk/storage/storage-blob/src/ContainerClient.ts +++ b/sdk/storage/storage-blob/src/ContainerClient.ts @@ -45,7 +45,7 @@ import { } from "./models"; import { newPipeline, Pipeline, StoragePipelineOptions } from "./Pipeline"; import { CommonOptions, StorageClient } from "./StorageClient"; -import { createSpan } from "./utils/tracing"; +import { convertTracingToRequestOptionsBase, createSpan } from "./utils/tracing"; import { appendToURLPath, appendToURLQuery, @@ -202,24 +202,24 @@ export interface SignedIdentifier { export declare type ContainerGetAccessPolicyResponse = { signedIdentifiers: SignedIdentifier[]; } & ContainerGetAccessPolicyHeaders & { + /** + * The underlying HTTP response. + */ + _response: HttpResponse & { /** - * The underlying HTTP response. + * The parsed HTTP response headers. */ - _response: HttpResponse & { - /** - * The parsed HTTP response headers. - */ - parsedHeaders: ContainerGetAccessPolicyHeaders; - /** - * The response body as text (string format) - */ - bodyAsText: string; - /** - * The response body as parsed JSON or XML - */ - parsedBody: SignedIdentifierModel[]; - }; + parsedHeaders: ContainerGetAccessPolicyHeaders; + /** + * The response body as text (string format) + */ + bodyAsText: string; + /** + * The response body as parsed JSON or XML + */ + parsedBody: SignedIdentifierModel[]; }; +}; /** * Options to configure {@link ContainerClient.setAccessPolicy} operation. @@ -700,13 +700,13 @@ export class ContainerClient extends StorageClient { * ``` */ public async create(options: ContainerCreateOptions = {}): Promise { - const { span, spanOptions } = createSpan("ContainerClient-create", options.tracingOptions); + const { span, updatedOptions } = createSpan("ContainerClient-create", options); try { // Spread operator in destructuring assignments, // this will filter out unwanted properties from the response object into result object return await this.containerContext.create({ ...options, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) }); } catch (e) { span.setStatus({ @@ -729,15 +729,12 @@ export class ContainerClient extends StorageClient { public async createIfNotExists( options: ContainerCreateOptions = {} ): Promise { - const { span, spanOptions } = createSpan( + const { span, updatedOptions } = createSpan( "ContainerClient-createIfNotExists", - options.tracingOptions + options ); try { - const res = await this.create({ - ...options, - tracingOptions: { ...options!.tracingOptions, spanOptions } - }); + const res = await this.create(updatedOptions); return { succeeded: true, ...res, @@ -776,11 +773,11 @@ export class ContainerClient extends StorageClient { * @param options - */ public async exists(options: ContainerExistsOptions = {}): Promise { - const { span, spanOptions } = createSpan("ContainerClient-exists", options.tracingOptions); + const { span, updatedOptions } = createSpan("ContainerClient-exists", options); try { await this.getProperties({ abortSignal: options.abortSignal, - tracingOptions: { ...options!.tracingOptions, spanOptions } + tracingOptions: updatedOptions.tracingOptions }); return true; } catch (e) { @@ -876,15 +873,15 @@ export class ContainerClient extends StorageClient { options.conditions = {}; } - const { span, spanOptions } = createSpan( + const { span, updatedOptions } = createSpan( "ContainerClient-getProperties", - options.tracingOptions + options ); try { return await this.containerContext.getProperties({ abortSignal: options.abortSignal, ...options.conditions, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) }); } catch (e) { span.setStatus({ @@ -911,13 +908,13 @@ export class ContainerClient extends StorageClient { options.conditions = {}; } - const { span, spanOptions } = createSpan("ContainerClient-delete", options.tracingOptions); + const { span, updatedOptions } = createSpan("ContainerClient-delete", options); try { return await this.containerContext.deleteMethod({ abortSignal: options.abortSignal, leaseAccessConditions: options.conditions, modifiedAccessConditions: options.conditions, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) }); } catch (e) { span.setStatus({ @@ -940,16 +937,13 @@ export class ContainerClient extends StorageClient { public async deleteIfExists( options: ContainerDeleteMethodOptions = {} ): Promise { - const { span, spanOptions } = createSpan( + const { span, updatedOptions } = createSpan( "ContainerClient-deleteIfExists", - options.tracingOptions + options ); try { - const res = await this.delete({ - ...options, - tracingOptions: { ...options!.tracingOptions, spanOptions } - }); + const res = await this.delete(updatedOptions); return { succeeded: true, ...res, @@ -1003,7 +997,7 @@ export class ContainerClient extends StorageClient { ); } - const { span, spanOptions } = createSpan("ContainerClient-setMetadata", options.tracingOptions); + const { span, updatedOptions } = createSpan("ContainerClient-setMetadata", options); try { return await this.containerContext.setMetadata({ @@ -1011,7 +1005,7 @@ export class ContainerClient extends StorageClient { leaseAccessConditions: options.conditions, metadata, modifiedAccessConditions: options.conditions, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) }); } catch (e) { span.setStatus({ @@ -1042,16 +1036,16 @@ export class ContainerClient extends StorageClient { options.conditions = {}; } - const { span, spanOptions } = createSpan( + const { span, updatedOptions } = createSpan( "ContainerClient-getAccessPolicy", - options.tracingOptions + options ); try { const response = await this.containerContext.getAccessPolicy({ abortSignal: options.abortSignal, leaseAccessConditions: options.conditions, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) }); const res: ContainerGetAccessPolicyResponse = { @@ -1124,9 +1118,9 @@ export class ContainerClient extends StorageClient { options: ContainerSetAccessPolicyOptions = {} ): Promise { options.conditions = options.conditions || {}; - const { span, spanOptions } = createSpan( + const { span, updatedOptions } = createSpan( "ContainerClient-setAccessPolicy", - options.tracingOptions + options ); try { const acl: SignedIdentifierModel[] = []; @@ -1151,7 +1145,7 @@ export class ContainerClient extends StorageClient { containerAcl: acl, leaseAccessConditions: options.conditions, modifiedAccessConditions: options.conditions, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) }); } catch (e) { span.setStatus({ @@ -1202,16 +1196,13 @@ export class ContainerClient extends StorageClient { contentLength: number, options: BlockBlobUploadOptions = {} ): Promise<{ blockBlobClient: BlockBlobClient; response: BlockBlobUploadResponse }> { - const { span, spanOptions } = createSpan( + const { span, updatedOptions } = createSpan( "ContainerClient-uploadBlockBlob", - options.tracingOptions + options ); try { const blockBlobClient = this.getBlockBlobClient(blobName); - const response = await blockBlobClient.upload(body, contentLength, { - ...options, - tracingOptions: { ...options!.tracingOptions, spanOptions } - }); + const response = await blockBlobClient.upload(body, contentLength, updatedOptions); return { blockBlobClient, response @@ -1242,16 +1233,13 @@ export class ContainerClient extends StorageClient { blobName: string, options: ContainerDeleteBlobOptions = {} ): Promise { - const { span, spanOptions } = createSpan("ContainerClient-deleteBlob", options.tracingOptions); + const { span, updatedOptions } = createSpan("ContainerClient-deleteBlob", options); try { let blobClient = this.getBlobClient(blobName); if (options.versionId) { blobClient = blobClient.withVersion(options.versionId); } - return await blobClient.delete({ - ...options, - tracingOptions: { ...options!.tracingOptions, spanOptions } - }); + return await blobClient.delete(updatedOptions); } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, @@ -1277,15 +1265,15 @@ export class ContainerClient extends StorageClient { marker?: string, options: ContainerListBlobsSegmentOptions = {} ): Promise { - const { span, spanOptions } = createSpan( + const { span, updatedOptions } = createSpan( "ContainerClient-listBlobFlatSegment", - options.tracingOptions + options ); try { const response = await this.containerContext.listBlobFlatSegment({ marker, ...options, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) }); const wrappedResponse: ContainerListBlobFlatSegmentResponse = { ...response, @@ -1332,15 +1320,15 @@ export class ContainerClient extends StorageClient { marker?: string, options: ContainerListBlobsSegmentOptions = {} ): Promise { - const { span, spanOptions } = createSpan( + const { span, updatedOptions } = createSpan( "ContainerClient-listBlobHierarchySegment", - options.tracingOptions + options ); try { const response = await this.containerContext.listBlobHierarchySegment(delimiter, { marker, ...options, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) }); const wrappedResponse: ContainerListBlobHierarchySegmentResponse = { ...response, @@ -1383,7 +1371,7 @@ export class ContainerClient extends StorageClient { * items. The marker value is opaque to the client. * @param options - Options to list blobs operation. */ - private async *listSegments( + private async * listSegments( marker?: string, options: ContainerListBlobsSegmentOptions = {} ): AsyncIterableIterator { @@ -1402,7 +1390,7 @@ export class ContainerClient extends StorageClient { * * @param options - Options to list blobs operation. */ - private async *listItems( + private async * listItems( options: ContainerListBlobsSegmentOptions = {} ): AsyncIterableIterator { let marker: string | undefined; @@ -1555,7 +1543,7 @@ export class ContainerClient extends StorageClient { * items. The marker value is opaque to the client. * @param options - Options to list blobs operation. */ - private async *listHierarchySegments( + private async * listHierarchySegments( delimiter: string, marker?: string, options: ContainerListBlobsSegmentOptions = {} @@ -1580,7 +1568,7 @@ export class ContainerClient extends StorageClient { * @param delimiter - The character or string used to define the virtual hierarchy * @param options - Options to list blobs operation. */ - private async *listItemsByHierarchy( + private async * listItemsByHierarchy( delimiter: string, options: ContainerListBlobsSegmentOptions = {} ): AsyncIterableIterator<({ kind: "prefix" } & BlobPrefix) | ({ kind: "blob" } & BlobItem)> { @@ -1593,7 +1581,9 @@ export class ContainerClient extends StorageClient { const segment = listBlobsHierarchySegmentResponse.segment; if (segment.blobPrefixes) { for (const prefix of segment.blobPrefixes) { - yield { kind: "prefix", ...prefix }; + yield { + kind: "prefix", ...prefix + }; } } for (const blob of segment.blobItems) { diff --git a/sdk/storage/storage-blob/src/utils/tracing.ts b/sdk/storage/storage-blob/src/utils/tracing.ts index 875c97c66fd3..2d71b0d467b0 100644 --- a/sdk/storage/storage-blob/src/utils/tracing.ts +++ b/sdk/storage/storage-blob/src/utils/tracing.ts @@ -1,6 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. +import { OperationOptions, RequestOptionsBase } from "@azure/core-http"; import { createSpanFunction } from "@azure/core-tracing"; /** @@ -11,3 +12,16 @@ export const createSpan = createSpanFunction({ packagePrefix: "Azure.Storage.Blob", namespace: "Microsoft.Storage" }); + +/** + * @internal + * + * Adapt the tracing options from OperationOptions to what they need to be for + * RequestOptionsBase (when we update to later OpenTelemetry versions this is now + * two separate fields, not just one). + */ +export function convertTracingToRequestOptionsBase(options?: OperationOptions): Pick { + return { + spanOptions: options?.tracingOptions?.spanOptions + }; +} \ No newline at end of file From 4dc72d8e65159a524b2ea7d019075aa543d145e6 Mon Sep 17 00:00:00 2001 From: Richard Park <51494936+richardpark-msft@users.noreply.github.com> Date: Sat, 20 Feb 2021 02:04:18 +0000 Subject: [PATCH 16/52] Formatting --- sdk/storage/storage-blob/src/BlobBatch.ts | 22 ++- .../storage-blob/src/BlobBatchClient.ts | 2 +- .../storage-blob/src/BlobLeaseClient.ts | 10 +- .../storage-blob/src/BlobServiceClient.ts | 54 ++----- sdk/storage/storage-blob/src/Clients.ts | 137 +++++++----------- .../storage-blob/src/ContainerClient.ts | 76 ++++------ sdk/storage/storage-blob/src/utils/tracing.ts | 8 +- 7 files changed, 106 insertions(+), 203 deletions(-) diff --git a/sdk/storage/storage-blob/src/BlobBatch.ts b/sdk/storage/storage-blob/src/BlobBatch.ts index 1c2ac4c1f2ad..38a6817cc2db 100644 --- a/sdk/storage/storage-blob/src/BlobBatch.ts +++ b/sdk/storage/storage-blob/src/BlobBatch.ts @@ -184,10 +184,7 @@ export class BlobBatch { options = {}; } - const { span, updatedOptions } = createSpan( - "BatchDeleteRequest-addSubRequest", - options - ); + const { span, updatedOptions } = createSpan("BatchDeleteRequest-addSubRequest", options); try { this.setBatchType("delete"); @@ -197,7 +194,9 @@ export class BlobBatch { credential: credential }, async () => { - await new BlobClient(url, this.batchRequest.createPipeline(credential)).delete(updatedOptions); + await new BlobClient(url, this.batchRequest.createPipeline(credential)).delete( + updatedOptions + ); } ); } catch (e) { @@ -300,10 +299,7 @@ export class BlobBatch { options = {}; } - const { span, updatedOptions } = createSpan( - "BatchSetTierRequest-addSubRequest", - options - ); + const { span, updatedOptions } = createSpan("BatchSetTierRequest-addSubRequest", options); try { this.setBatchType("setAccessTier"); @@ -383,9 +379,9 @@ class InnerBatchRequest { if (!isAnonymousCreds) { factories[2] = isTokenCredential(credential) ? attachCredential( - bearerTokenAuthenticationPolicy(credential, StorageOAuthScopes), - credential - ) + bearerTokenAuthenticationPolicy(credential, StorageOAuthScopes), + credential + ) : credential; } factories[policyFactoryLength - 1] = new BatchRequestAssemblePolicyFactory(this); // Use batch assemble policy to assemble request and intercept request from going to wire @@ -507,7 +503,7 @@ class BatchHeaderFilterPolicy extends BaseRequestPolicy { } class BatchHeaderFilterPolicyFactory implements RequestPolicyFactory { - constructor() { } + constructor() {} public create(nextPolicy: RequestPolicy, options: RequestPolicyOptions): BatchHeaderFilterPolicy { return new BatchHeaderFilterPolicy(nextPolicy, options); diff --git a/sdk/storage/storage-blob/src/BlobBatchClient.ts b/sdk/storage/storage-blob/src/BlobBatchClient.ts index faee348a36cc..1c88fb78f8c4 100644 --- a/sdk/storage/storage-blob/src/BlobBatchClient.ts +++ b/sdk/storage/storage-blob/src/BlobBatchClient.ts @@ -29,7 +29,7 @@ import { getURLPath } from "./utils/utils.common"; */ export interface BlobBatchSubmitBatchOptionalParams extends ServiceSubmitBatchOptionalParamsModel, - CommonOptions { + CommonOptions { /** * An implementation of the `AbortSignalLike` interface to signal the request to cancel the operation. * For example, use the @azure/abort-controller to create an `AbortSignal`. diff --git a/sdk/storage/storage-blob/src/BlobLeaseClient.ts b/sdk/storage/storage-blob/src/BlobLeaseClient.ts index 62426f818cea..7202a2f96ff0 100644 --- a/sdk/storage/storage-blob/src/BlobLeaseClient.ts +++ b/sdk/storage/storage-blob/src/BlobLeaseClient.ts @@ -163,10 +163,7 @@ export class BlobLeaseClient { duration: number, options: LeaseOperationOptions = {} ): Promise { - const { span, updatedOptions } = createSpan( - "BlobLeaseClient-acquireLease", - options - ); + const { span, updatedOptions } = createSpan("BlobLeaseClient-acquireLease", options); if ( this._isContainer && @@ -265,10 +262,7 @@ export class BlobLeaseClient { * @returns Response data for release lease operation. */ public async releaseLease(options: LeaseOperationOptions = {}): Promise { - const { span, updatedOptions } = createSpan( - "BlobLeaseClient-releaseLease", - options - ); + const { span, updatedOptions } = createSpan("BlobLeaseClient-releaseLease", options); if ( this._isContainer && diff --git a/sdk/storage/storage-blob/src/BlobServiceClient.ts b/sdk/storage/storage-blob/src/BlobServiceClient.ts index 9bb8787fbd13..0e847e6ac2f9 100644 --- a/sdk/storage/storage-blob/src/BlobServiceClient.ts +++ b/sdk/storage/storage-blob/src/BlobServiceClient.ts @@ -536,10 +536,7 @@ export class BlobServiceClient extends StorageClient { containerClient: ContainerClient; containerCreateResponse: ContainerCreateResponse; }> { - const { span, updatedOptions } = createSpan( - "BlobServiceClient-createContainer", - options - ); + const { span, updatedOptions } = createSpan("BlobServiceClient-createContainer", options); try { const containerClient = this.getContainerClient(containerName); const containerCreateResponse = await containerClient.create(updatedOptions); @@ -569,10 +566,7 @@ export class BlobServiceClient extends StorageClient { containerName: string, options: ContainerDeleteMethodOptions = {} ): Promise { - const { span, updatedOptions } = createSpan( - "BlobServiceClient-deleteContainer", - options - ); + const { span, updatedOptions } = createSpan("BlobServiceClient-deleteContainer", options); try { const containerClient = this.getContainerClient(containerName); return await containerClient.delete(updatedOptions); @@ -604,10 +598,7 @@ export class BlobServiceClient extends StorageClient { containerClient: ContainerClient; containerUndeleteResponse: ContainerUndeleteResponse; }> { - const { span, updatedOptions } = createSpan( - "BlobServiceClient-undeleteContainer", - options - ); + const { span, updatedOptions } = createSpan("BlobServiceClient-undeleteContainer", options); try { const containerClient = this.getContainerClient( options.destinationContainerName || deletedContainerName @@ -617,7 +608,7 @@ export class BlobServiceClient extends StorageClient { const containerUndeleteResponse = await containerContext.restore({ deletedContainerName, deletedContainerVersion, - ...updatedOptions, + ...updatedOptions }); return { containerClient, containerUndeleteResponse }; } catch (e) { @@ -647,17 +638,14 @@ export class BlobServiceClient extends StorageClient { containerClient: ContainerClient; containerRenameResponse: ContainerRenameResponse; }> { - const { span, updatedOptions } = createSpan( - "BlobServiceClient-renameContainer", - options - ); + const { span, updatedOptions } = createSpan("BlobServiceClient-renameContainer", options); try { const containerClient = this.getContainerClient(destinationContainerName); // Hack to access a protected member. const containerContext = new Container(containerClient["storageClientContext"]); const containerRenameResponse = await containerContext.rename(sourceContainerName, { ...updatedOptions, - sourceLeaseId: options.sourceCondition?.leaseId, + sourceLeaseId: options.sourceCondition?.leaseId }); return { containerClient, containerRenameResponse }; } catch (e) { @@ -682,10 +670,7 @@ export class BlobServiceClient extends StorageClient { public async getProperties( options: ServiceGetPropertiesOptions = {} ): Promise { - const { span, updatedOptions } = createSpan( - "BlobServiceClient-getProperties", - options - ); + const { span, updatedOptions } = createSpan("BlobServiceClient-getProperties", options); try { return await this.serviceContext.getProperties({ abortSignal: options.abortSignal, @@ -715,10 +700,7 @@ export class BlobServiceClient extends StorageClient { properties: BlobServiceProperties, options: ServiceSetPropertiesOptions = {} ): Promise { - const { span, updatedOptions } = createSpan( - "BlobServiceClient-setProperties", - options - ); + const { span, updatedOptions } = createSpan("BlobServiceClient-setProperties", options); try { return await this.serviceContext.setProperties(properties, { abortSignal: options.abortSignal, @@ -747,10 +729,7 @@ export class BlobServiceClient extends StorageClient { public async getStatistics( options: ServiceGetStatisticsOptions = {} ): Promise { - const { span, updatedOptions } = createSpan( - "BlobServiceClient-getStatistics", - options - ); + const { span, updatedOptions } = createSpan("BlobServiceClient-getStatistics", options); try { return await this.serviceContext.getStatistics({ abortSignal: options.abortSignal, @@ -780,10 +759,7 @@ export class BlobServiceClient extends StorageClient { public async getAccountInfo( options: ServiceGetAccountInfoOptions = {} ): Promise { - const { span, updatedOptions } = createSpan( - "BlobServiceClient-getAccountInfo", - options - ); + const { span, updatedOptions } = createSpan("BlobServiceClient-getAccountInfo", options); try { return await this.serviceContext.getAccountInfo({ abortSignal: options.abortSignal, @@ -818,10 +794,7 @@ export class BlobServiceClient extends StorageClient { marker?: string, options: ServiceListContainersSegmentOptions = {} ): Promise { - const { span, updatedOptions } = createSpan( - "BlobServiceClient-listContainersSegment", - options - ); + const { span, updatedOptions } = createSpan("BlobServiceClient-listContainersSegment", options); try { return await this.serviceContext.listContainersSegment({ @@ -1250,10 +1223,7 @@ export class BlobServiceClient extends StorageClient { expiresOn: Date, options: ServiceGetUserDelegationKeyOptions = {} ): Promise { - const { span, updatedOptions } = createSpan( - "BlobServiceClient-getUserDelegationKey", - options - ); + const { span, updatedOptions } = createSpan("BlobServiceClient-getUserDelegationKey", options); try { const response = await this.serviceContext.getUserDelegationKey( { diff --git a/sdk/storage/storage-blob/src/Clients.ts b/sdk/storage/storage-blob/src/Clients.ts index cbffeff63c2e..ad3889fbc646 100644 --- a/sdk/storage/storage-blob/src/Clients.ts +++ b/sdk/storage/storage-blob/src/Clients.ts @@ -160,7 +160,7 @@ export interface BlobBeginCopyFromURLOptions extends BlobStartCopyFromURLOptions /** * Contains response data for the {@link BlobClient.beginCopyFromURL} operation. */ -export interface BlobBeginCopyFromURLResponse extends BlobStartCopyFromURLResponse { } +export interface BlobBeginCopyFromURLResponse extends BlobStartCopyFromURLResponse {} /** * Options to configure the {@link BlobClient.download} operation. @@ -374,26 +374,26 @@ export interface BlobGetTagsOptions extends CommonOptions { * Contains response data for the {@link BlobClient.getTags} operation. */ export type BlobGetTagsResponse = { tags: Tags } & BlobGetTagsHeaders & { - /** - * The underlying HTTP response. - */ - _response: HttpResponse & { - /** - * The parsed HTTP response headers. - */ - parsedHeaders: BlobGetTagsHeaders; - - /** - * The response body as text (string format) - */ - bodyAsText: string; - /** - * The response body as parsed JSON or XML + * The underlying HTTP response. */ - parsedBody: BlobTags; + _response: HttpResponse & { + /** + * The parsed HTTP response headers. + */ + parsedHeaders: BlobGetTagsHeaders; + + /** + * The response body as text (string format) + */ + bodyAsText: string; + + /** + * The response body as parsed JSON or XML + */ + parsedBody: BlobTags; + }; }; -}; /** * Options to configure Blob - Acquire Lease operation. @@ -2529,10 +2529,7 @@ export class AppendBlobClient extends BlobClient { public async createIfNotExists( options: AppendBlobCreateIfNotExistsOptions = {} ): Promise { - const { span, updatedOptions } = createSpan( - "AppendBlobClient-createIfNotExists", - options - ); + const { span, updatedOptions } = createSpan("AppendBlobClient-createIfNotExists", options); const conditions = { ifNoneMatch: ETagAny }; try { const res = await this.create({ @@ -2626,10 +2623,7 @@ export class AppendBlobClient extends BlobClient { contentLength: number, options: AppendBlobAppendBlockOptions = {} ): Promise { - const { span, updatedOptions } = createSpan( - "AppendBlobClient-appendBlock", - options - ); + const { span, updatedOptions } = createSpan("AppendBlobClient-appendBlock", options); options.conditions = options.conditions || {}; try { ensureCpkIfSpecified(options.customerProvidedKey, this.isHttps); @@ -2680,10 +2674,7 @@ export class AppendBlobClient extends BlobClient { count: number, options: AppendBlobAppendBlockFromURLOptions = {} ): Promise { - const { span, updatedOptions } = createSpan( - "AppendBlobClient-appendBlockFromURL", - options - ); + const { span, updatedOptions } = createSpan("AppendBlobClient-appendBlockFromURL", options); options.conditions = options.conditions || {}; options.sourceConditions = options.sourceConditions || {}; try { @@ -2933,9 +2924,9 @@ export interface BlockBlobQueryOptions extends CommonOptions { * Configurations for the query output. */ outputTextConfiguration?: - | BlobQueryJsonTextConfiguration - | BlobQueryCsvTextConfiguration - | BlobQueryArrowConfiguration; + | BlobQueryJsonTextConfiguration + | BlobQueryCsvTextConfiguration + | BlobQueryArrowConfiguration; /** * Callback to receive events on the progress of query operation. */ @@ -3577,10 +3568,7 @@ export class BlockBlobClient extends BlobClient { options: BlockBlobSyncUploadFromURLOptions = {} ): Promise { options.conditions = options.conditions || {}; - const { span, updatedOptions } = createSpan( - "BlockBlobClient-syncUploadFromURL", - options - ); + const { span, updatedOptions } = createSpan("BlockBlobClient-syncUploadFromURL", options); try { ensureCpkIfSpecified(options.customerProvidedKey, this.isHttps); return await this.blockBlobContext.putBlobFromUrl(0, sourceURL, { @@ -3682,10 +3670,7 @@ export class BlockBlobClient extends BlobClient { count?: number, options: BlockBlobStageBlockFromURLOptions = {} ): Promise { - const { span, updatedOptions } = createSpan( - "BlockBlobClient-stageBlockFromURL", - options - ); + const { span, updatedOptions } = createSpan("BlockBlobClient-stageBlockFromURL", options); try { ensureCpkIfSpecified(options.customerProvidedKey, this.isHttps); return await this.blockBlobContext.stageBlockFromURL(blockId, 0, sourceURL, { @@ -3726,10 +3711,7 @@ export class BlockBlobClient extends BlobClient { options: BlockBlobCommitBlockListOptions = {} ): Promise { options.conditions = options.conditions || {}; - const { span, updatedOptions } = createSpan( - "BlockBlobClient-commitBlockList", - options - ); + const { span, updatedOptions } = createSpan("BlockBlobClient-commitBlockList", options); try { ensureCpkIfSpecified(options.customerProvidedKey, this.isHttps); return await this.blockBlobContext.commitBlockList( @@ -3775,10 +3757,7 @@ export class BlockBlobClient extends BlobClient { listType: BlockListType, options: BlockBlobGetBlockListOptions = {} ): Promise { - const { span, updatedOptions } = createSpan( - "BlockBlobClient-getBlockList", - options - ); + const { span, updatedOptions } = createSpan("BlockBlobClient-getBlockList", options); try { const res = await this.blockBlobContext.getBlockList(listType, { abortSignal: options.abortSignal, @@ -3883,10 +3862,7 @@ export class BlockBlobClient extends BlobClient { browserData: Blob | ArrayBuffer | ArrayBufferView, options: BlockBlobParallelUploadOptions = {} ): Promise { - const { span, updatedOptions } = createSpan( - "BlockBlobClient-uploadBrowserData", - options - ); + const { span, updatedOptions } = createSpan("BlockBlobClient-uploadBrowserData", options); try { const browserBlob = new Blob([browserData]); return await this.uploadSeekableInternal( @@ -3964,10 +3940,7 @@ export class BlockBlobClient extends BlobClient { options.conditions = {}; } - const { span, updatedOptions } = createSpan( - "BlockBlobClient-uploadSeekableInternal", - options - ); + const { span, updatedOptions } = createSpan("BlockBlobClient-uploadSeekableInternal", options); try { if (size <= options.maxSingleShotSize) { @@ -3978,7 +3951,7 @@ export class BlockBlobClient extends BlobClient { if (numBlocks > BLOCK_BLOB_MAX_BLOCKS) { throw new RangeError( `The buffer's size is too big or the BlockSize is too small;` + - `the number of blocks must be <= ${BLOCK_BLOB_MAX_BLOCKS}` + `the number of blocks must be <= ${BLOCK_BLOB_MAX_BLOCKS}` ); } @@ -4056,7 +4029,13 @@ export class BlockBlobClient extends BlobClient { }); }, size, - { ...options, tracingOptions: { ...options!.tracingOptions, ...convertTracingToRequestOptionsBase(updatedOptions) } } + { + ...options, + tracingOptions: { + ...options!.tracingOptions, + ...convertTracingToRequestOptionsBase(updatedOptions) + } + } ); } catch (e) { span.setStatus({ @@ -4098,10 +4077,7 @@ export class BlockBlobClient extends BlobClient { options.conditions = {}; } - const { span, updatedOptions } = createSpan( - "BlockBlobClient-uploadStream", - options - ); + const { span, updatedOptions } = createSpan("BlockBlobClient-uploadStream", options); try { let blockNum = 0; @@ -4140,7 +4116,10 @@ export class BlockBlobClient extends BlobClient { return await this.commitBlockList(blockList, { ...options, - tracingOptions: { ...options!.tracingOptions, ...convertTracingToRequestOptionsBase(updatedOptions) } + tracingOptions: { + ...options!.tracingOptions, + ...convertTracingToRequestOptionsBase(updatedOptions) + } }); } catch (e) { span.setStatus({ @@ -4675,10 +4654,7 @@ export class PageBlobClient extends BlobClient { size: number, options: PageBlobCreateIfNotExistsOptions = {} ): Promise { - const { span, updatedOptions } = createSpan( - "PageBlobClient-createIfNotExists", - options - ); + const { span, updatedOptions } = createSpan("PageBlobClient-createIfNotExists", options); try { const conditions = { ifNoneMatch: ETagAny }; const res = await this.create(size, { @@ -4781,10 +4757,7 @@ export class PageBlobClient extends BlobClient { ): Promise { options.conditions = options.conditions || {}; options.sourceConditions = options.sourceConditions || {}; - const { span, updatedOptions } = createSpan( - "PageBlobClient-uploadPagesFromURL", - options - ); + const { span, updatedOptions } = createSpan("PageBlobClient-uploadPagesFromURL", options); try { ensureCpkIfSpecified(options.customerProvidedKey, this.isHttps); return await this.pageBlobContext.uploadPagesFromURL( @@ -4880,10 +4853,7 @@ export class PageBlobClient extends BlobClient { options: PageBlobGetPageRangesOptions = {} ): Promise { options.conditions = options.conditions || {}; - const { span, updatedOptions } = createSpan( - "PageBlobClient-getPageRanges", - options - ); + const { span, updatedOptions } = createSpan("PageBlobClient-getPageRanges", options); try { return await this.pageBlobContext .getPageRanges({ @@ -4925,10 +4895,7 @@ export class PageBlobClient extends BlobClient { options: PageBlobGetPageRangesDiffOptions = {} ): Promise { options.conditions = options.conditions || {}; - const { span, updatedOptions } = createSpan( - "PageBlobClient-getPageRangesDiff", - options - ); + const { span, updatedOptions } = createSpan("PageBlobClient-getPageRangesDiff", options); try { return await this.pageBlobContext @@ -5053,10 +5020,7 @@ export class PageBlobClient extends BlobClient { options: PageBlobUpdateSequenceNumberOptions = {} ): Promise { options.conditions = options.conditions || {}; - const { span, updatedOptions } = createSpan( - "PageBlobClient-updateSequenceNumber", - options - ); + const { span, updatedOptions } = createSpan("PageBlobClient-updateSequenceNumber", options); try { return await this.pageBlobContext.updateSequenceNumber(sequenceNumberAction, { abortSignal: options.abortSignal, @@ -5096,10 +5060,7 @@ export class PageBlobClient extends BlobClient { copySource: string, options: PageBlobStartCopyIncrementalOptions = {} ): Promise { - const { span, updatedOptions } = createSpan( - "PageBlobClient-startCopyIncremental", - options - ); + const { span, updatedOptions } = createSpan("PageBlobClient-startCopyIncremental", options); try { return await this.pageBlobContext.copyIncremental(copySource, { abortSignal: options.abortSignal, diff --git a/sdk/storage/storage-blob/src/ContainerClient.ts b/sdk/storage/storage-blob/src/ContainerClient.ts index e474c567fd57..1af3ec080018 100644 --- a/sdk/storage/storage-blob/src/ContainerClient.ts +++ b/sdk/storage/storage-blob/src/ContainerClient.ts @@ -202,24 +202,24 @@ export interface SignedIdentifier { export declare type ContainerGetAccessPolicyResponse = { signedIdentifiers: SignedIdentifier[]; } & ContainerGetAccessPolicyHeaders & { - /** - * The underlying HTTP response. - */ - _response: HttpResponse & { - /** - * The parsed HTTP response headers. - */ - parsedHeaders: ContainerGetAccessPolicyHeaders; - /** - * The response body as text (string format) - */ - bodyAsText: string; /** - * The response body as parsed JSON or XML + * The underlying HTTP response. */ - parsedBody: SignedIdentifierModel[]; + _response: HttpResponse & { + /** + * The parsed HTTP response headers. + */ + parsedHeaders: ContainerGetAccessPolicyHeaders; + /** + * The response body as text (string format) + */ + bodyAsText: string; + /** + * The response body as parsed JSON or XML + */ + parsedBody: SignedIdentifierModel[]; + }; }; -}; /** * Options to configure {@link ContainerClient.setAccessPolicy} operation. @@ -729,10 +729,7 @@ export class ContainerClient extends StorageClient { public async createIfNotExists( options: ContainerCreateOptions = {} ): Promise { - const { span, updatedOptions } = createSpan( - "ContainerClient-createIfNotExists", - options - ); + const { span, updatedOptions } = createSpan("ContainerClient-createIfNotExists", options); try { const res = await this.create(updatedOptions); return { @@ -873,10 +870,7 @@ export class ContainerClient extends StorageClient { options.conditions = {}; } - const { span, updatedOptions } = createSpan( - "ContainerClient-getProperties", - options - ); + const { span, updatedOptions } = createSpan("ContainerClient-getProperties", options); try { return await this.containerContext.getProperties({ abortSignal: options.abortSignal, @@ -937,10 +931,7 @@ export class ContainerClient extends StorageClient { public async deleteIfExists( options: ContainerDeleteMethodOptions = {} ): Promise { - const { span, updatedOptions } = createSpan( - "ContainerClient-deleteIfExists", - options - ); + const { span, updatedOptions } = createSpan("ContainerClient-deleteIfExists", options); try { const res = await this.delete(updatedOptions); @@ -1036,10 +1027,7 @@ export class ContainerClient extends StorageClient { options.conditions = {}; } - const { span, updatedOptions } = createSpan( - "ContainerClient-getAccessPolicy", - options - ); + const { span, updatedOptions } = createSpan("ContainerClient-getAccessPolicy", options); try { const response = await this.containerContext.getAccessPolicy({ @@ -1118,10 +1106,7 @@ export class ContainerClient extends StorageClient { options: ContainerSetAccessPolicyOptions = {} ): Promise { options.conditions = options.conditions || {}; - const { span, updatedOptions } = createSpan( - "ContainerClient-setAccessPolicy", - options - ); + const { span, updatedOptions } = createSpan("ContainerClient-setAccessPolicy", options); try { const acl: SignedIdentifierModel[] = []; for (const identifier of containerAcl || []) { @@ -1196,10 +1181,7 @@ export class ContainerClient extends StorageClient { contentLength: number, options: BlockBlobUploadOptions = {} ): Promise<{ blockBlobClient: BlockBlobClient; response: BlockBlobUploadResponse }> { - const { span, updatedOptions } = createSpan( - "ContainerClient-uploadBlockBlob", - options - ); + const { span, updatedOptions } = createSpan("ContainerClient-uploadBlockBlob", options); try { const blockBlobClient = this.getBlockBlobClient(blobName); const response = await blockBlobClient.upload(body, contentLength, updatedOptions); @@ -1265,10 +1247,7 @@ export class ContainerClient extends StorageClient { marker?: string, options: ContainerListBlobsSegmentOptions = {} ): Promise { - const { span, updatedOptions } = createSpan( - "ContainerClient-listBlobFlatSegment", - options - ); + const { span, updatedOptions } = createSpan("ContainerClient-listBlobFlatSegment", options); try { const response = await this.containerContext.listBlobFlatSegment({ marker, @@ -1371,7 +1350,7 @@ export class ContainerClient extends StorageClient { * items. The marker value is opaque to the client. * @param options - Options to list blobs operation. */ - private async * listSegments( + private async *listSegments( marker?: string, options: ContainerListBlobsSegmentOptions = {} ): AsyncIterableIterator { @@ -1390,7 +1369,7 @@ export class ContainerClient extends StorageClient { * * @param options - Options to list blobs operation. */ - private async * listItems( + private async *listItems( options: ContainerListBlobsSegmentOptions = {} ): AsyncIterableIterator { let marker: string | undefined; @@ -1543,7 +1522,7 @@ export class ContainerClient extends StorageClient { * items. The marker value is opaque to the client. * @param options - Options to list blobs operation. */ - private async * listHierarchySegments( + private async *listHierarchySegments( delimiter: string, marker?: string, options: ContainerListBlobsSegmentOptions = {} @@ -1568,7 +1547,7 @@ export class ContainerClient extends StorageClient { * @param delimiter - The character or string used to define the virtual hierarchy * @param options - Options to list blobs operation. */ - private async * listItemsByHierarchy( + private async *listItemsByHierarchy( delimiter: string, options: ContainerListBlobsSegmentOptions = {} ): AsyncIterableIterator<({ kind: "prefix" } & BlobPrefix) | ({ kind: "blob" } & BlobItem)> { @@ -1582,7 +1561,8 @@ export class ContainerClient extends StorageClient { if (segment.blobPrefixes) { for (const prefix of segment.blobPrefixes) { yield { - kind: "prefix", ...prefix + kind: "prefix", + ...prefix }; } } diff --git a/sdk/storage/storage-blob/src/utils/tracing.ts b/sdk/storage/storage-blob/src/utils/tracing.ts index 2d71b0d467b0..ff06164466aa 100644 --- a/sdk/storage/storage-blob/src/utils/tracing.ts +++ b/sdk/storage/storage-blob/src/utils/tracing.ts @@ -15,13 +15,15 @@ export const createSpan = createSpanFunction({ /** * @internal - * + * * Adapt the tracing options from OperationOptions to what they need to be for * RequestOptionsBase (when we update to later OpenTelemetry versions this is now * two separate fields, not just one). */ -export function convertTracingToRequestOptionsBase(options?: OperationOptions): Pick { +export function convertTracingToRequestOptionsBase( + options?: OperationOptions +): Pick { return { spanOptions: options?.tracingOptions?.spanOptions }; -} \ No newline at end of file +} From 42ff0587b507abb72fa2fb3145c615753259b4fb Mon Sep 17 00:00:00 2001 From: Richard Park <51494936+richardpark-msft@users.noreply.github.com> Date: Sat, 20 Feb 2021 03:50:56 +0000 Subject: [PATCH 17/52] Update to use the core-tracing version of createSpan --- .../storage-blob-changefeed/src/ChangeFeed.ts | 16 ++++++++-------- .../src/ChangeFeedFactory.ts | 4 ++-- .../src/LazyLoadingBlobStream.ts | 14 +++++++------- .../storage-blob-changefeed/src/Segment.ts | 4 ++-- .../src/SegmentFactory.ts | 6 +++--- sdk/storage/storage-blob-changefeed/src/Shard.ts | 12 ++++++------ .../storage-blob-changefeed/src/ShardFactory.ts | 6 +++--- .../storage-blob-changefeed/src/utils/tracing.ts | 1 + 8 files changed, 32 insertions(+), 31 deletions(-) diff --git a/sdk/storage/storage-blob-changefeed/src/ChangeFeed.ts b/sdk/storage/storage-blob-changefeed/src/ChangeFeed.ts index 85cfe3fd6208..b7fde36bdda9 100644 --- a/sdk/storage/storage-blob-changefeed/src/ChangeFeed.ts +++ b/sdk/storage/storage-blob-changefeed/src/ChangeFeed.ts @@ -80,9 +80,9 @@ export class ChangeFeed { } private async advanceSegmentIfNecessary(options: ChangeFeedGetChangeOptions = {}): Promise { - const { span, spanOptions } = createSpan( + const { span, updatedOptions } = createSpan( "ChangeFeed-advanceSegmentIfNecessary", - options.tracingOptions + options ); try { if (!this.currentSegment) { @@ -102,7 +102,7 @@ export class ChangeFeed { undefined, { abortSignal: options.abortSignal, - tracingOptions: { ...options.tracingOptions, spanOptions } + tracingOptions: updatedOptions.tracingOptions } ); } @@ -116,7 +116,7 @@ export class ChangeFeed { this.end, { abortSignal: options.abortSignal, - tracingOptions: { ...options.tracingOptions, spanOptions } + tracingOptions: updatedOptions.tracingOptions } ); @@ -127,7 +127,7 @@ export class ChangeFeed { undefined, { abortSignal: options.abortSignal, - tracingOptions: { ...options.tracingOptions, spanOptions } + tracingOptions: updatedOptions.tracingOptions } ); } else { @@ -161,17 +161,17 @@ export class ChangeFeed { public async getChange( options: ChangeFeedGetChangeOptions = {} ): Promise { - const { span, spanOptions } = createSpan("ChangeFeed-getChange", options.tracingOptions); + const { span, updatedOptions } = createSpan("ChangeFeed-getChange", options); try { let event: BlobChangeFeedEvent | undefined = undefined; while (event === undefined && this.hasNext()) { event = await this.currentSegment!.getChange({ abortSignal: options.abortSignal, - tracingOptions: { ...options.tracingOptions, spanOptions } + tracingOptions: updatedOptions.tracingOptions }); await this.advanceSegmentIfNecessary({ abortSignal: options.abortSignal, - tracingOptions: { ...options.tracingOptions, spanOptions } + tracingOptions: updatedOptions.tracingOptions }); } return event; diff --git a/sdk/storage/storage-blob-changefeed/src/ChangeFeedFactory.ts b/sdk/storage/storage-blob-changefeed/src/ChangeFeedFactory.ts index e1ba7256c8b9..38173c4bdc2b 100644 --- a/sdk/storage/storage-blob-changefeed/src/ChangeFeedFactory.ts +++ b/sdk/storage/storage-blob-changefeed/src/ChangeFeedFactory.ts @@ -61,7 +61,7 @@ export class ChangeFeedFactory { continuationToken?: string, options: BlobChangeFeedListChangesOptions = {} ): Promise { - const { span, spanOptions } = createSpan("ChangeFeedFactory-create", options.tracingOptions); + const { span, updatedOptions } = createSpan("ChangeFeedFactory-create", options); try { const containerClient = blobServiceClient.getContainerClient(CHANGE_FEED_CONTAINER_NAME); @@ -82,7 +82,7 @@ export class ChangeFeedFactory { // Check if Change Feed has been enabled for this account. const changeFeedContainerExists = await containerClient.exists({ abortSignal: options.abortSignal, - tracingOptions: { ...options.tracingOptions, spanOptions } + tracingOptions: updatedOptions.tracingOptions }); if (!changeFeedContainerExists) { throw new Error( diff --git a/sdk/storage/storage-blob-changefeed/src/LazyLoadingBlobStream.ts b/sdk/storage/storage-blob-changefeed/src/LazyLoadingBlobStream.ts index 2d854c35f3ed..8dd6fecb296f 100644 --- a/sdk/storage/storage-blob-changefeed/src/LazyLoadingBlobStream.ts +++ b/sdk/storage/storage-blob-changefeed/src/LazyLoadingBlobStream.ts @@ -71,14 +71,14 @@ export class LazyLoadingBlobStream extends Readable { } private async downloadBlock(options: LazyLoadingBlobStreamDownloadBlockOptions = {}) { - const { span, spanOptions } = createSpan( + const { span, updatedOptions } = createSpan( "LazyLoadingBlobStream-downloadBlock", - options.tracingOptions + options ); try { const properties = await this.blobClient.getProperties({ abortSignal: options.abortSignal, - tracingOptions: { ...options.tracingOptions, spanOptions } + tracingOptions: updatedOptions.tracingOptions }); this.blobLength = properties.contentLength!; @@ -93,7 +93,7 @@ export class LazyLoadingBlobStream extends Readable { this.lastDownloadBytes, { abortSignal: options.abortSignal, - tracingOptions: { ...options.tracingOptions, spanOptions } + tracingOptions: updatedOptions.tracingOptions } ); this.offset += this.lastDownloadBytes; @@ -114,9 +114,9 @@ export class LazyLoadingBlobStream extends Readable { * @param size - Optional. The size of data to be read */ public async _read(size?: number) { - const { span, spanOptions } = createSpan( + const { span, updatedOptions } = createSpan( "LazyLoadingBlobStream-read", - this.options?.tracingOptions + this.options ); try { @@ -130,7 +130,7 @@ export class LazyLoadingBlobStream extends Readable { if (this.lastDownloadData === undefined || this.lastDownloadData?.byteLength === 0) { await this.downloadBlock({ abortSignal: this.options?.abortSignal, - tracingOptions: { ...this.options?.tracingOptions, spanOptions } + tracingOptions: updatedOptions?.tracingOptions }); } if (this.lastDownloadData?.byteLength) { diff --git a/sdk/storage/storage-blob-changefeed/src/Segment.ts b/sdk/storage/storage-blob-changefeed/src/Segment.ts index f27c8a947590..b16d60beace9 100644 --- a/sdk/storage/storage-blob-changefeed/src/Segment.ts +++ b/sdk/storage/storage-blob-changefeed/src/Segment.ts @@ -58,7 +58,7 @@ export class Segment { public async getChange( options: SegmentGetChangeOptions = {} ): Promise { - const { span, spanOptions } = createSpan("Segment-getChange", options.tracingOptions); + const { span, updatedOptions } = createSpan("Segment-getChange", options); try { if (this.shardIndex >= this.shards.length || this.shardIndex < 0) { @@ -75,7 +75,7 @@ export class Segment { const currentShard = this.shards[this.shardIndex]; event = await currentShard.getChange({ abortSignal: options.abortSignal, - tracingOptions: { ...options.tracingOptions, spanOptions } + tracingOptions: updatedOptions.tracingOptions }); if (!currentShard.hasNext()) { diff --git a/sdk/storage/storage-blob-changefeed/src/SegmentFactory.ts b/sdk/storage/storage-blob-changefeed/src/SegmentFactory.ts index 737c761fac0d..daedcc7dcc59 100644 --- a/sdk/storage/storage-blob-changefeed/src/SegmentFactory.ts +++ b/sdk/storage/storage-blob-changefeed/src/SegmentFactory.ts @@ -46,7 +46,7 @@ export class SegmentFactory { cursor?: SegmentCursor, options: CreateSegmentOptions = {} ): Promise { - const { span, spanOptions } = createSpan("SegmentFactory-create", options.tracingOptions); + const { span, updatedOptions } = createSpan("SegmentFactory-create", options); try { const shards: Shard[] = []; @@ -55,7 +55,7 @@ export class SegmentFactory { const blobClient = containerClient.getBlobClient(manifestPath); const blobDownloadRes = await blobClient.download(undefined, undefined, { abortSignal: options.abortSignal, - tracingOptions: { ...options.tracingOptions, spanOptions } + tracingOptions: updatedOptions.tracingOptions }); const blobContent: string = await bodyToString(blobDownloadRes); @@ -73,7 +73,7 @@ export class SegmentFactory { shardCursor, { abortSignal: options.abortSignal, - tracingOptions: { ...options.tracingOptions, spanOptions } + tracingOptions: updatedOptions.tracingOptions } ); if (shard.hasNext()) { diff --git a/sdk/storage/storage-blob-changefeed/src/Shard.ts b/sdk/storage/storage-blob-changefeed/src/Shard.ts index 15360b672a7c..aaebc87200d2 100644 --- a/sdk/storage/storage-blob-changefeed/src/Shard.ts +++ b/sdk/storage/storage-blob-changefeed/src/Shard.ts @@ -52,7 +52,7 @@ export class Shard { public async getChange( options: ShardGetChangeOptions = {} ): Promise { - const { span, spanOptions } = createSpan("Shard-getChange", options.tracingOptions); + const { span, updatedOptions } = createSpan("Shard-getChange", options); try { let event: BlobChangeFeedEvent | undefined = undefined; while (event === undefined && this.hasNext()) { @@ -67,7 +67,7 @@ export class Shard { undefined, { abortSignal: options.abortSignal, - tracingOptions: { ...options.tracingOptions, spanOptions } + tracingOptions: updatedOptions.tracingOptions } ); } @@ -88,9 +88,9 @@ export class Shard { return this.currentChunk === undefined ? undefined : { - CurrentChunkPath: this.currentChunk.chunkPath, - BlockOffset: this.currentChunk.blockOffset, - EventIndex: this.currentChunk.eventIndex - }; + CurrentChunkPath: this.currentChunk.chunkPath, + BlockOffset: this.currentChunk.blockOffset, + EventIndex: this.currentChunk.eventIndex + }; } } diff --git a/sdk/storage/storage-blob-changefeed/src/ShardFactory.ts b/sdk/storage/storage-blob-changefeed/src/ShardFactory.ts index 691ed1fc19bd..72d2ea59dbde 100644 --- a/sdk/storage/storage-blob-changefeed/src/ShardFactory.ts +++ b/sdk/storage/storage-blob-changefeed/src/ShardFactory.ts @@ -34,7 +34,7 @@ export class ShardFactory { shardCursor?: ShardCursor, options: CreateShardOptions = {} ): Promise { - const { span, spanOptions } = createSpan("ShardFactory-create", options.tracingOptions); + const { span, updatedOptions } = createSpan("ShardFactory-create", options); try { const chunks: string[] = []; const blockOffset: number = shardCursor?.BlockOffset || 0; @@ -43,7 +43,7 @@ export class ShardFactory { for await (const blobItem of containerClient.listBlobsFlat({ prefix: shardPath, abortSignal: options.abortSignal, - tracingOptions: { ...options.tracingOptions, spanOptions } + tracingOptions: updatedOptions.tracingOptions })) { chunks.push(blobItem.name); } @@ -80,7 +80,7 @@ export class ShardFactory { eventIndex, { abortSignal: options.abortSignal, - tracingOptions: { ...options.tracingOptions, spanOptions } + tracingOptions: updatedOptions.tracingOptions } ); } diff --git a/sdk/storage/storage-blob-changefeed/src/utils/tracing.ts b/sdk/storage/storage-blob-changefeed/src/utils/tracing.ts index c1402b5817e4..e07664ef3d7e 100644 --- a/sdk/storage/storage-blob-changefeed/src/utils/tracing.ts +++ b/sdk/storage/storage-blob-changefeed/src/utils/tracing.ts @@ -1,6 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. +import { OperationOptions, RequestOptionsBase } from "@azure/core-http"; import { createSpanFunction } from "@azure/core-tracing"; /** From 6f994881c96680b5a3d224ed5ac080e568f45803 Mon Sep 17 00:00:00 2001 From: Richard Park <51494936+richardpark-msft@users.noreply.github.com> Date: Sat, 20 Feb 2021 03:51:23 +0000 Subject: [PATCH 18/52] Formatting --- sdk/storage/storage-blob-changefeed/src/ChangeFeed.ts | 5 +---- .../src/LazyLoadingBlobStream.ts | 10 ++-------- sdk/storage/storage-blob-changefeed/src/Shard.ts | 8 ++++---- 3 files changed, 7 insertions(+), 16 deletions(-) diff --git a/sdk/storage/storage-blob-changefeed/src/ChangeFeed.ts b/sdk/storage/storage-blob-changefeed/src/ChangeFeed.ts index b7fde36bdda9..91b6dacf13d6 100644 --- a/sdk/storage/storage-blob-changefeed/src/ChangeFeed.ts +++ b/sdk/storage/storage-blob-changefeed/src/ChangeFeed.ts @@ -80,10 +80,7 @@ export class ChangeFeed { } private async advanceSegmentIfNecessary(options: ChangeFeedGetChangeOptions = {}): Promise { - const { span, updatedOptions } = createSpan( - "ChangeFeed-advanceSegmentIfNecessary", - options - ); + const { span, updatedOptions } = createSpan("ChangeFeed-advanceSegmentIfNecessary", options); try { if (!this.currentSegment) { throw new Error("Empty Change Feed shouldn't call this function."); diff --git a/sdk/storage/storage-blob-changefeed/src/LazyLoadingBlobStream.ts b/sdk/storage/storage-blob-changefeed/src/LazyLoadingBlobStream.ts index 8dd6fecb296f..a197865bde2a 100644 --- a/sdk/storage/storage-blob-changefeed/src/LazyLoadingBlobStream.ts +++ b/sdk/storage/storage-blob-changefeed/src/LazyLoadingBlobStream.ts @@ -71,10 +71,7 @@ export class LazyLoadingBlobStream extends Readable { } private async downloadBlock(options: LazyLoadingBlobStreamDownloadBlockOptions = {}) { - const { span, updatedOptions } = createSpan( - "LazyLoadingBlobStream-downloadBlock", - options - ); + const { span, updatedOptions } = createSpan("LazyLoadingBlobStream-downloadBlock", options); try { const properties = await this.blobClient.getProperties({ abortSignal: options.abortSignal, @@ -114,10 +111,7 @@ export class LazyLoadingBlobStream extends Readable { * @param size - Optional. The size of data to be read */ public async _read(size?: number) { - const { span, updatedOptions } = createSpan( - "LazyLoadingBlobStream-read", - this.options - ); + const { span, updatedOptions } = createSpan("LazyLoadingBlobStream-read", this.options); try { if (!size) { diff --git a/sdk/storage/storage-blob-changefeed/src/Shard.ts b/sdk/storage/storage-blob-changefeed/src/Shard.ts index aaebc87200d2..46a96d7060cd 100644 --- a/sdk/storage/storage-blob-changefeed/src/Shard.ts +++ b/sdk/storage/storage-blob-changefeed/src/Shard.ts @@ -88,9 +88,9 @@ export class Shard { return this.currentChunk === undefined ? undefined : { - CurrentChunkPath: this.currentChunk.chunkPath, - BlockOffset: this.currentChunk.blockOffset, - EventIndex: this.currentChunk.eventIndex - }; + CurrentChunkPath: this.currentChunk.chunkPath, + BlockOffset: this.currentChunk.blockOffset, + EventIndex: this.currentChunk.eventIndex + }; } } From ee8c6f031cba744d445b5ebe92789459f168658d Mon Sep 17 00:00:00 2001 From: Richard Park <51494936+richardpark-msft@users.noreply.github.com> Date: Sat, 20 Feb 2021 03:54:32 +0000 Subject: [PATCH 19/52] Formatting --- .../storage-blob-changefeed/src/ChangeFeedFactory.ts | 8 ++++---- sdk/storage/storage-blob-changefeed/src/utils/tracing.ts | 1 - .../storage-blob-changefeed/src/utils/utils.common.ts | 8 ++++---- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/sdk/storage/storage-blob-changefeed/src/ChangeFeedFactory.ts b/sdk/storage/storage-blob-changefeed/src/ChangeFeedFactory.ts index 38173c4bdc2b..263073a09c05 100644 --- a/sdk/storage/storage-blob-changefeed/src/ChangeFeedFactory.ts +++ b/sdk/storage/storage-blob-changefeed/src/ChangeFeedFactory.ts @@ -98,7 +98,7 @@ export class ChangeFeedFactory { const blobClient = containerClient.getBlobClient(CHANGE_FEED_META_SEGMENT_PATH); const blobDownloadRes = await blobClient.download(undefined, undefined, { abortSignal: options.abortSignal, - tracingOptions: { ...options.tracingOptions, spanOptions } + tracingOptions: updatedOptions.tracingOptions }); const lastConsumable = new Date( (JSON.parse(await bodyToString(blobDownloadRes)) as MetaSegments).lastConsumable @@ -107,7 +107,7 @@ export class ChangeFeedFactory { // Get year paths const years: number[] = await getYearsPaths(containerClient, { abortSignal: options.abortSignal, - tracingOptions: { ...options.tracingOptions, spanOptions } + tracingOptions: updatedOptions.tracingOptions }); // Dequeue any years that occur before start time. @@ -130,7 +130,7 @@ export class ChangeFeedFactory { minDate(lastConsumable, options.end), { abortSignal: options.abortSignal, - tracingOptions: { ...options.tracingOptions, spanOptions } + tracingOptions: updatedOptions.tracingOptions } ); } @@ -143,7 +143,7 @@ export class ChangeFeedFactory { cursor?.CurrentSegmentCursor, { abortSignal: options.abortSignal, - tracingOptions: { ...options.tracingOptions, spanOptions } + tracingOptions: updatedOptions.tracingOptions } ); diff --git a/sdk/storage/storage-blob-changefeed/src/utils/tracing.ts b/sdk/storage/storage-blob-changefeed/src/utils/tracing.ts index e07664ef3d7e..c1402b5817e4 100644 --- a/sdk/storage/storage-blob-changefeed/src/utils/tracing.ts +++ b/sdk/storage/storage-blob-changefeed/src/utils/tracing.ts @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -import { OperationOptions, RequestOptionsBase } from "@azure/core-http"; import { createSpanFunction } from "@azure/core-tracing"; /** diff --git a/sdk/storage/storage-blob-changefeed/src/utils/utils.common.ts b/sdk/storage/storage-blob-changefeed/src/utils/utils.common.ts index 576c6a4aa645..a03dd7a0543a 100644 --- a/sdk/storage/storage-blob-changefeed/src/utils/utils.common.ts +++ b/sdk/storage/storage-blob-changefeed/src/utils/utils.common.ts @@ -67,12 +67,12 @@ export async function getYearsPaths( containerClient: ContainerClient, options: GetYearsPathsOptions = {} ): Promise { - const { span, spanOptions } = createSpan("getYearsPaths", options.tracingOptions); + const { span, updatedOptions } = createSpan("getYearsPaths", options); try { const years: number[] = []; for await (const item of containerClient.listBlobsByHierarchy("/", { abortSignal: options.abortSignal, - tracingOptions: { ...options.tracingOptions, spanOptions }, + tracingOptions: updatedOptions.tracingOptions, prefix: CHANGE_FEED_SEGMENT_PREFIX })) { // TODO: add String.prototype.includes polyfill for IE11 @@ -111,7 +111,7 @@ export async function getSegmentsInYear( endTime?: Date, options: GetSegmentsInYearOptions = {} ): Promise { - const { span, spanOptions } = createSpan("getSegmentsInYear", options.tracingOptions); + const { span, updatedOptions } = createSpan("getSegmentsInYear", options); try { const segments: string[] = []; @@ -124,7 +124,7 @@ export async function getSegmentsInYear( for await (const item of containerClient.listBlobsFlat({ prefix, abortSignal: options.abortSignal, - tracingOptions: { ...options.tracingOptions, spanOptions } + tracingOptions: updatedOptions.tracingOptions })) { const segmentTime = parseDateFromSegmentPath(item.name); if ((startTime && segmentTime < startTime) || (endTime && segmentTime >= endTime)) { From 7edc5dd4450cea746e7ed535a8c525ddf1de4341 Mon Sep 17 00:00:00 2001 From: Richard Park <51494936+richardpark-msft@users.noreply.github.com> Date: Sat, 20 Feb 2021 04:02:23 +0000 Subject: [PATCH 20/52] storage-queue: same story, just swapping to core-tracing's versions. --- sdk/storage/storage-queue/src/QueueClient.ts | 71 ++++++++----------- .../storage-queue/src/QueueServiceClient.ts | 50 ++++--------- .../storage-queue/src/utils/tracing.ts | 16 +++++ 3 files changed, 60 insertions(+), 77 deletions(-) diff --git a/sdk/storage/storage-queue/src/QueueClient.ts b/sdk/storage/storage-queue/src/QueueClient.ts index ec10be438a36..6c46cf1d9dbc 100644 --- a/sdk/storage/storage-queue/src/QueueClient.ts +++ b/sdk/storage/storage-queue/src/QueueClient.ts @@ -45,7 +45,7 @@ import { } from "./utils/utils.common"; import { StorageSharedKeyCredential } from "./credentials/StorageSharedKeyCredential"; import { AnonymousCredential } from "./credentials/AnonymousCredential"; -import { createSpan } from "./utils/tracing"; +import { convertTracingToRequestOptionsBase, createSpan } from "./utils/tracing"; import { Metadata } from "./models"; import { generateQueueSASQueryParameters } from "./QueueSASSignatureValues"; import { SasIPRange } from "./SasIPRange"; @@ -584,12 +584,12 @@ export class QueueClient extends StorageClient { * ``` */ public async create(options: QueueCreateOptions = {}): Promise { - const { span, spanOptions } = createSpan("QueueClient-create", options.tracingOptions); + const { span, updatedOptions } = createSpan("QueueClient-create", options); try { return await this.queueContext.create({ ...options, abortSignal: options.abortSignal, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) }); } catch (e) { span.setStatus({ @@ -612,15 +612,9 @@ export class QueueClient extends StorageClient { public async createIfNotExists( options: QueueCreateOptions = {} ): Promise { - const { span, spanOptions } = createSpan( - "QueueClient-createIfNotExists", - options.tracingOptions - ); + const { span, updatedOptions } = createSpan("QueueClient-createIfNotExists", options); try { - const response = await this.create({ - ...options, - tracingOptions: { ...options!.tracingOptions, spanOptions } - }); + const response = await this.create(updatedOptions); // When a queue with the specified name already exists, the Queue service checks the metadata associated with the existing queue. // If the existing metadata is identical to the metadata specified on the Create Queue request, status code 204 (No Content) is returned. @@ -667,12 +661,9 @@ export class QueueClient extends StorageClient { public async deleteIfExists( options: QueueDeleteOptions = {} ): Promise { - const { span, spanOptions } = createSpan("QueueClient-deleteIfExists", options.tracingOptions); + const { span, updatedOptions } = createSpan("QueueClient-deleteIfExists", options); try { - const res = await this.delete({ - ...options, - tracingOptions: { ...options!.tracingOptions, spanOptions } - }); + const res = await this.delete(updatedOptions); return { succeeded: true, ...res @@ -716,11 +707,11 @@ export class QueueClient extends StorageClient { * ``` */ public async delete(options: QueueDeleteOptions = {}): Promise { - const { span, spanOptions } = createSpan("QueueClient-delete", options.tracingOptions); + const { span, updatedOptions } = createSpan("QueueClient-delete", options); try { return await this.queueContext.deleteMethod({ abortSignal: options.abortSignal, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) }); } catch (e) { span.setStatus({ @@ -743,11 +734,11 @@ export class QueueClient extends StorageClient { * @param options - options to Exists operation. */ public async exists(options: QueueExistsOptions = {}): Promise { - const { span, spanOptions } = createSpan("QueueClient-exists", options.tracingOptions); + const { span, updatedOptions } = createSpan("QueueClient-exists", options); try { await this.getProperties({ abortSignal: options.abortSignal, - tracingOptions: { ...options.tracingOptions, spanOptions } + tracingOptions: updatedOptions.tracingOptions }); return true; } catch (e) { @@ -784,11 +775,11 @@ export class QueueClient extends StorageClient { public async getProperties( options: QueueGetPropertiesOptions = {} ): Promise { - const { span, spanOptions } = createSpan("QueueClient-getProperties", options.tracingOptions); + const { span, updatedOptions } = createSpan("QueueClient-getProperties", options); try { return await this.queueContext.getProperties({ abortSignal: options.abortSignal, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) }); } catch (e) { span.setStatus({ @@ -816,12 +807,12 @@ export class QueueClient extends StorageClient { metadata?: Metadata, options: QueueSetMetadataOptions = {} ): Promise { - const { span, spanOptions } = createSpan("QueueClient-setMetadata", options.tracingOptions); + const { span, updatedOptions } = createSpan("QueueClient-setMetadata", options); try { return await this.queueContext.setMetadata({ abortSignal: options.abortSignal, metadata, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) }); } catch (e) { span.setStatus({ @@ -848,11 +839,11 @@ export class QueueClient extends StorageClient { public async getAccessPolicy( options: QueueGetAccessPolicyOptions = {} ): Promise { - const { span, spanOptions } = createSpan("QueueClient-getAccessPolicy", options.tracingOptions); + const { span, updatedOptions } = createSpan("QueueClient-getAccessPolicy", options); try { const response = await this.queueContext.getAccessPolicy({ abortSignal: options.abortSignal, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) }); const res: QueueGetAccessPolicyResponse = { @@ -911,7 +902,7 @@ export class QueueClient extends StorageClient { queueAcl?: SignedIdentifier[], options: QueueSetAccessPolicyOptions = {} ): Promise { - const { span, spanOptions } = createSpan("QueueClient-setAccessPolicy", options.tracingOptions); + const { span, updatedOptions } = createSpan("QueueClient-setAccessPolicy", options); try { const acl: SignedIdentifierModel[] = []; for (const identifier of queueAcl || []) { @@ -932,7 +923,7 @@ export class QueueClient extends StorageClient { return await this.queueContext.setAccessPolicy({ abortSignal: options.abortSignal, queueAcl: acl, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) }); } catch (e) { span.setStatus({ @@ -955,11 +946,11 @@ export class QueueClient extends StorageClient { public async clearMessages( options: QueueClearMessagesOptions = {} ): Promise { - const { span, spanOptions } = createSpan("QueueClient-clearMessages", options.tracingOptions); + const { span, updatedOptions } = createSpan("QueueClient-clearMessages", options); try { return await this.messagesContext.clear({ abortSignal: options.abortSignal, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) }); } catch (e) { span.setStatus({ @@ -997,7 +988,7 @@ export class QueueClient extends StorageClient { messageText: string, options: QueueSendMessageOptions = {} ): Promise { - const { span, spanOptions } = createSpan("QueueClient-sendMessage", options.tracingOptions); + const { span, updatedOptions } = createSpan("QueueClient-sendMessage", options); try { const response = await this.messagesContext.enqueue( { @@ -1006,7 +997,7 @@ export class QueueClient extends StorageClient { { abortSignal: options.abortSignal, ...options, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) } ); const item = response[0]; @@ -1062,12 +1053,12 @@ export class QueueClient extends StorageClient { public async receiveMessages( options: QueueReceiveMessageOptions = {} ): Promise { - const { span, spanOptions } = createSpan("QueueClient-receiveMessages", options.tracingOptions); + const { span, updatedOptions } = createSpan("QueueClient-receiveMessages", options); try { const response = await this.messagesContext.dequeue({ abortSignal: options.abortSignal, ...options, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) }); const res: QueueReceiveMessageResponse = { @@ -1113,12 +1104,12 @@ export class QueueClient extends StorageClient { public async peekMessages( options: QueuePeekMessagesOptions = {} ): Promise { - const { span, spanOptions } = createSpan("QueueClient-peekMessages", options.tracingOptions); + const { span, updatedOptions } = createSpan("QueueClient-peekMessages", options); try { const response = await this.messagesContext.peek({ abortSignal: options.abortSignal, ...options, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) }); const res: QueuePeekMessagesResponse = { @@ -1161,11 +1152,11 @@ export class QueueClient extends StorageClient { popReceipt: string, options: QueueDeleteMessageOptions = {} ): Promise { - const { span, spanOptions } = createSpan("QueueClient-deleteMessage", options.tracingOptions); + const { span, updatedOptions } = createSpan("QueueClient-deleteMessage", options); try { return await this.getMessageIdContext(messageId).deleteMethod(popReceipt, { abortSignal: options.abortSignal, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) }); } catch (e) { span.setStatus({ @@ -1202,7 +1193,7 @@ export class QueueClient extends StorageClient { visibilityTimeout?: number, options: QueueUpdateMessageOptions = {} ): Promise { - const { span, spanOptions } = createSpan("QueueClient-updateMessage", options.tracingOptions); + const { span, updatedOptions } = createSpan("QueueClient-updateMessage", options); let queueMessage = undefined; if (message !== undefined) { queueMessage = { messageText: message }; @@ -1211,7 +1202,7 @@ export class QueueClient extends StorageClient { try { return await this.getMessageIdContext(messageId).update(popReceipt, visibilityTimeout || 0, { abortSignal: options.abortSignal, - spanOptions, + ...convertTracingToRequestOptionsBase(updatedOptions), queueMessage }); } catch (e) { diff --git a/sdk/storage/storage-queue/src/QueueServiceClient.ts b/sdk/storage/storage-queue/src/QueueServiceClient.ts index 418a40a46ba7..1a833496dcb1 100644 --- a/sdk/storage/storage-queue/src/QueueServiceClient.ts +++ b/sdk/storage/storage-queue/src/QueueServiceClient.ts @@ -32,7 +32,7 @@ import { } from "./utils/utils.common"; import { StorageSharedKeyCredential } from "./credentials/StorageSharedKeyCredential"; import { AnonymousCredential } from "./credentials/AnonymousCredential"; -import { createSpan } from "./utils/tracing"; +import { convertTracingToRequestOptionsBase, createSpan } from "./utils/tracing"; import { QueueClient, QueueCreateOptions, QueueDeleteOptions } from "./QueueClient"; import { AccountSASPermissions } from "./AccountSASPermissions"; import { generateAccountSASQueryParameters } from "./AccountSASSignatureValues"; @@ -321,10 +321,7 @@ export class QueueServiceClient extends StorageClient { marker?: string, options: ServiceListQueuesSegmentOptions = {} ): Promise { - const { span, spanOptions } = createSpan( - "QueueServiceClient-listQueuesSegment", - options.tracingOptions - ); + const { span, updatedOptions } = createSpan("QueueServiceClient-listQueuesSegment", options); if (options.prefix === "") { options.prefix = undefined; @@ -337,7 +334,7 @@ export class QueueServiceClient extends StorageClient { maxPageSize: options.maxPageSize, prefix: options.prefix, include: options.include === undefined ? undefined : [options.include], - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) }); } catch (e) { span.setStatus({ @@ -525,14 +522,11 @@ export class QueueServiceClient extends StorageClient { public async getProperties( options: ServiceGetPropertiesOptions = {} ): Promise { - const { span, spanOptions } = createSpan( - "QueueServiceClient-getProperties", - options.tracingOptions - ); + const { span, updatedOptions } = createSpan("QueueServiceClient-getProperties", options); try { return await this.serviceContext.getProperties({ abortSignal: options.abortSignal, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) }); } catch (e) { span.setStatus({ @@ -558,14 +552,11 @@ export class QueueServiceClient extends StorageClient { properties: QueueServiceProperties, options: ServiceGetPropertiesOptions = {} ): Promise { - const { span, spanOptions } = createSpan( - "QueueServiceClient-setProperties", - options.tracingOptions - ); + const { span, updatedOptions } = createSpan("QueueServiceClient-setProperties", options); try { return await this.serviceContext.setProperties(properties, { abortSignal: options.abortSignal, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) }); } catch (e) { span.setStatus({ @@ -590,14 +581,11 @@ export class QueueServiceClient extends StorageClient { public async getStatistics( options: ServiceGetStatisticsOptions = {} ): Promise { - const { span, spanOptions } = createSpan( - "QueueServiceClient-getStatistics", - options.tracingOptions - ); + const { span, updatedOptions } = createSpan("QueueServiceClient-getStatistics", options); try { return await this.serviceContext.getStatistics({ abortSignal: options.abortSignal, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) }); } catch (e) { span.setStatus({ @@ -622,15 +610,9 @@ export class QueueServiceClient extends StorageClient { queueName: string, options: QueueCreateOptions = {} ): Promise { - const { span, spanOptions } = createSpan( - "QueueServiceClient-createQueue", - options.tracingOptions - ); + const { span, updatedOptions } = createSpan("QueueServiceClient-createQueue", options); try { - return await this.getQueueClient(queueName).create({ - ...options, - tracingOptions: { ...options!.tracingOptions, spanOptions } - }); + return await this.getQueueClient(queueName).create(updatedOptions); } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, @@ -654,15 +636,9 @@ export class QueueServiceClient extends StorageClient { queueName: string, options: QueueDeleteOptions = {} ): Promise { - const { span, spanOptions } = createSpan( - "QueueServiceClient-deleteQueue", - options.tracingOptions - ); + const { span, updatedOptions } = createSpan("QueueServiceClient-deleteQueue", options); try { - return await this.getQueueClient(queueName).delete({ - ...options, - tracingOptions: { ...options!.tracingOptions, spanOptions } - }); + return await this.getQueueClient(queueName).delete(updatedOptions); } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, diff --git a/sdk/storage/storage-queue/src/utils/tracing.ts b/sdk/storage/storage-queue/src/utils/tracing.ts index d095a0b6483b..7de33fd48a31 100644 --- a/sdk/storage/storage-queue/src/utils/tracing.ts +++ b/sdk/storage/storage-queue/src/utils/tracing.ts @@ -1,6 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. +import { OperationOptions, RequestOptionsBase } from "@azure/core-http"; import { createSpanFunction } from "@azure/core-tracing"; /** @@ -11,3 +12,18 @@ export const createSpan = createSpanFunction({ packagePrefix: "Azure.Storage.Queue", namespace: "Microsoft.Storage" }); + +/** + * @internal + * + * Adapt the tracing options from OperationOptions to what they need to be for + * RequestOptionsBase (when we update to later OpenTelemetry versions this is now + * two separate fields, not just one). + */ +export function convertTracingToRequestOptionsBase( + options?: OperationOptions +): Pick { + return { + spanOptions: options?.tracingOptions?.spanOptions + }; +} From 63b013d5355a8f41cdeb35d6132d0c7410c1ab74 Mon Sep 17 00:00:00 2001 From: Richard Park <51494936+richardpark-msft@users.noreply.github.com> Date: Sat, 20 Feb 2021 05:51:24 +0000 Subject: [PATCH 21/52] storage-file-datalike now using the core-tracing functions --- .../src/DataLakeFileSystemClient.ts | 74 ++---- .../src/DataLakeLeaseClient.ts | 65 +---- .../src/DataLakeServiceClient.ts | 28 +-- .../storage-file-datalake/src/clients.ts | 237 ++++++------------ .../src/utils/tracing.ts | 16 ++ 5 files changed, 141 insertions(+), 279 deletions(-) diff --git a/sdk/storage/storage-file-datalake/src/DataLakeFileSystemClient.ts b/sdk/storage/storage-file-datalake/src/DataLakeFileSystemClient.ts index 5220acfb6546..5b475d87ce48 100644 --- a/sdk/storage/storage-file-datalake/src/DataLakeFileSystemClient.ts +++ b/sdk/storage/storage-file-datalake/src/DataLakeFileSystemClient.ts @@ -38,7 +38,7 @@ import { import { newPipeline, Pipeline, StoragePipelineOptions } from "./Pipeline"; import { StorageClient } from "./StorageClient"; import { toContainerPublicAccessType, toPublicAccessType, toPermissions } from "./transforms"; -import { createSpan } from "./utils/tracing"; +import { convertTracingToRequestOptionsBase, createSpan } from "./utils/tracing"; import { appendToURLPath, appendToURLQuery } from "./utils/utils.common"; import { DataLakeFileClient, DataLakeDirectoryClient } from "./clients"; import { generateDataLakeSASQueryParameters } from "./sas/DataLakeSASSignatureValues"; @@ -162,15 +162,12 @@ export class DataLakeFileSystemClient extends StorageClient { * @param options - Optional. Options when creating file system. */ public async create(options: FileSystemCreateOptions = {}): Promise { - const { span, spanOptions } = createSpan( - "DataLakeFileSystemClient-create", - options.tracingOptions - ); + const { span, updatedOptions } = createSpan("DataLakeFileSystemClient-create", options); try { return await this.blobContainerClient.create({ ...options, access: toContainerPublicAccessType(options.access), - tracingOptions: { ...options.tracingOptions, spanOptions } + tracingOptions: updatedOptions.tracingOptions }); } catch (e) { span.setStatus({ @@ -194,15 +191,15 @@ export class DataLakeFileSystemClient extends StorageClient { public async createIfNotExists( options: FileSystemCreateOptions = {} ): Promise { - const { span, spanOptions } = createSpan( + const { span, updatedOptions } = createSpan( "DataLakeFileSystemClient-createIfNotExists", - options.tracingOptions + options ); try { return await this.blobContainerClient.createIfNotExists({ ...options, access: toContainerPublicAccessType(options.access), - tracingOptions: { ...options.tracingOptions, spanOptions } + tracingOptions: updatedOptions.tracingOptions }); } catch (e) { span.setStatus({ @@ -225,15 +222,9 @@ export class DataLakeFileSystemClient extends StorageClient { * @param options - */ public async exists(options: FileSystemExistsOptions = {}): Promise { - const { span, spanOptions } = createSpan( - "DataLakeFileSystemClient-exists", - options.tracingOptions - ); + const { span, updatedOptions } = createSpan("DataLakeFileSystemClient-exists", options); try { - return await this.blobContainerClient.exists({ - ...options, - tracingOptions: { ...options!.tracingOptions, spanOptions } - }); + return await this.blobContainerClient.exists(updatedOptions); } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, @@ -253,14 +244,11 @@ export class DataLakeFileSystemClient extends StorageClient { * @param options - Optional. Options when deleting file system. */ public async delete(options: FileSystemDeleteOptions = {}): Promise { - const { span, spanOptions } = createSpan( - "DataLakeFileSystemClient-delete", - options.tracingOptions - ); + const { span, updatedOptions } = createSpan("DataLakeFileSystemClient-delete", options); try { return await this.blobContainerClient.delete({ ...options, - tracingOptions: { ...options.tracingOptions, spanOptions } + tracingOptions: updatedOptions.tracingOptions }); } catch (e) { span.setStatus({ @@ -283,15 +271,9 @@ export class DataLakeFileSystemClient extends StorageClient { public async deleteIfExists( options: FileSystemDeleteOptions = {} ): Promise { - const { span, spanOptions } = createSpan( - "DataLakeFileSystemClient-deleteIfExists", - options.tracingOptions - ); + const { span, updatedOptions } = createSpan("DataLakeFileSystemClient-deleteIfExists", options); try { - return await this.blobContainerClient.deleteIfExists({ - ...options, - tracingOptions: { ...options.tracingOptions, spanOptions } - }); + return await this.blobContainerClient.deleteIfExists(updatedOptions); } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, @@ -319,14 +301,11 @@ export class DataLakeFileSystemClient extends StorageClient { public async getProperties( options: FileSystemGetPropertiesOptions = {} ): Promise { - const { span, spanOptions } = createSpan( - "DataLakeFileSystemClient-getProperties", - options.tracingOptions - ); + const { span, updatedOptions } = createSpan("DataLakeFileSystemClient-getProperties", options); try { const rawResponse = await this.blobContainerClient.getProperties({ ...options, - tracingOptions: { ...options.tracingOptions, spanOptions } + tracingOptions: updatedOptions.tracingOptions }); // Transfer and rename blobPublicAccess to publicAccess @@ -366,14 +345,11 @@ export class DataLakeFileSystemClient extends StorageClient { metadata?: Metadata, options: FileSystemSetMetadataOptions = {} ): Promise { - const { span, spanOptions } = createSpan( - "DataLakeFileSystemClient-setMetadata", - options.tracingOptions - ); + const { span, updatedOptions } = createSpan("DataLakeFileSystemClient-setMetadata", options); try { return await this.blobContainerClient.setMetadata(metadata, { ...options, - tracingOptions: { ...options.tracingOptions, spanOptions } + tracingOptions: updatedOptions.tracingOptions }); } catch (e) { span.setStatus({ @@ -400,14 +376,14 @@ export class DataLakeFileSystemClient extends StorageClient { public async getAccessPolicy( options: FileSystemGetAccessPolicyOptions = {} ): Promise { - const { span, spanOptions } = createSpan( + const { span, updatedOptions } = createSpan( "DataLakeFileSystemClient-getAccessPolicy", - options.tracingOptions + options ); try { const rawResponse = await this.blobContainerClient.getAccessPolicy({ ...options, - tracingOptions: { ...options.tracingOptions, spanOptions } + tracingOptions: updatedOptions.tracingOptions }); // Transfer and rename blobPublicAccess to publicAccess @@ -450,9 +426,9 @@ export class DataLakeFileSystemClient extends StorageClient { fileSystemAcl?: SignedIdentifier[], options: FileSystemSetAccessPolicyOptions = {} ): Promise { - const { span, spanOptions } = createSpan( + const { span, updatedOptions } = createSpan( "DataLakeFileSystemClient-setAccessPolicy", - options.tracingOptions + options ); try { return await this.blobContainerClient.setAccessPolicy( @@ -460,7 +436,7 @@ export class DataLakeFileSystemClient extends StorageClient { fileSystemAcl, { ...options, - tracingOptions: { ...options.tracingOptions, spanOptions } + tracingOptions: updatedOptions.tracingOptions } ); } catch (e) { @@ -591,16 +567,16 @@ export class DataLakeFileSystemClient extends StorageClient { continuation?: string, options: ListPathsSegmentOptions = {} ): Promise { - const { span, spanOptions } = createSpan( + const { span, updatedOptions } = createSpan( "DataLakeFileSystemClient-listPathsSegment", - options.tracingOptions + options ); try { const rawResponse = await this.fileSystemContext.listPaths(options.recursive || false, { continuation, ...options, upn: options.userPrincipalName, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) }); const response = rawResponse as FileSystemListPathsResponse; diff --git a/sdk/storage/storage-file-datalake/src/DataLakeLeaseClient.ts b/sdk/storage/storage-file-datalake/src/DataLakeLeaseClient.ts index 2d025e078c94..1df0646b1cb1 100644 --- a/sdk/storage/storage-file-datalake/src/DataLakeLeaseClient.ts +++ b/sdk/storage/storage-file-datalake/src/DataLakeLeaseClient.ts @@ -22,18 +22,9 @@ export class DataLakeLeaseClient { options: LeaseOperationOptions = {} ): Promise { options.conditions = options.conditions || {}; - const { span, spanOptions } = createSpan( - "DataLakeLeaseClient-acquireLease", - options.tracingOptions - ); + const { span, updatedOptions } = createSpan("DataLakeLeaseClient-acquireLease", options); try { - return await this.client.acquireLease(duration, { - ...options, - tracingOptions: { - ...options.tracingOptions, - spanOptions - } - }); + return await this.client.acquireLease(duration, updatedOptions); } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, @@ -50,18 +41,9 @@ export class DataLakeLeaseClient { options: LeaseOperationOptions = {} ): Promise { options.conditions = options.conditions || {}; - const { span, spanOptions } = createSpan( - "DataLakeLeaseClient-changeLease", - options.tracingOptions - ); + const { span, updatedOptions } = createSpan("DataLakeLeaseClient-changeLease", options); try { - return await this.client.changeLease(proposedLeaseId, { - ...options, - tracingOptions: { - ...options.tracingOptions, - spanOptions - } - }); + return await this.client.changeLease(proposedLeaseId, updatedOptions); } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, @@ -75,18 +57,9 @@ export class DataLakeLeaseClient { public async releaseLease(options: LeaseOperationOptions = {}): Promise { options.conditions = options.conditions || {}; - const { span, spanOptions } = createSpan( - "DataLakeLeaseClient-releaseLease", - options.tracingOptions - ); + const { span, updatedOptions } = createSpan("DataLakeLeaseClient-releaseLease", options); try { - return await this.client.releaseLease({ - ...options, - tracingOptions: { - ...options.tracingOptions, - spanOptions - } - }); + return await this.client.releaseLease(updatedOptions); } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, @@ -100,18 +73,9 @@ export class DataLakeLeaseClient { public async renewLease(options: LeaseOperationOptions = {}): Promise { options.conditions = options.conditions || {}; - const { span, spanOptions } = createSpan( - "DataLakeLeaseClient-renewLease", - options.tracingOptions - ); + const { span, updatedOptions } = createSpan("DataLakeLeaseClient-renewLease", options); try { - return await this.client.renewLease({ - ...options, - tracingOptions: { - ...options.tracingOptions, - spanOptions - } - }); + return await this.client.renewLease(updatedOptions); } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, @@ -128,18 +92,9 @@ export class DataLakeLeaseClient { options: LeaseOperationOptions = {} ): Promise { options.conditions = options.conditions || {}; - const { span, spanOptions } = createSpan( - "DataLakeLeaseClient-renewLease", - options.tracingOptions - ); + const { span, updatedOptions } = createSpan("DataLakeLeaseClient-renewLease", options); try { - return await this.client.breakLease(breakPeriod, { - ...options, - tracingOptions: { - ...options.tracingOptions, - spanOptions - } - }); + return await this.client.breakLease(breakPeriod, updatedOptions); } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, diff --git a/sdk/storage/storage-file-datalake/src/DataLakeServiceClient.ts b/sdk/storage/storage-file-datalake/src/DataLakeServiceClient.ts index 4473a042cb0e..3e7b88ebd39a 100644 --- a/sdk/storage/storage-file-datalake/src/DataLakeServiceClient.ts +++ b/sdk/storage/storage-file-datalake/src/DataLakeServiceClient.ts @@ -187,18 +187,12 @@ export class DataLakeServiceClient extends StorageClient { expiresOn: Date, options: ServiceGetUserDelegationKeyOptions = {} ): Promise { - const { span, spanOptions } = createSpan( + const { span, updatedOptions } = createSpan( "DataLakeServiceClient-getUserDelegationKey", - options.tracingOptions + options ); try { - return await this.blobServiceClient.getUserDelegationKey(startsOn, expiresOn, { - ...options, - tracingOptions: { - ...options.tracingOptions, - spanOptions - } - }); + return await this.blobServiceClient.getUserDelegationKey(startsOn, expiresOn, updatedOptions); } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, @@ -360,19 +354,13 @@ export class DataLakeServiceClient extends StorageClient { fileSystemClient: DataLakeFileSystemClient; fileSystemRenameResponse: FileSystemRenameResponse; }> { - const { span, spanOptions } = createSpan( - "DataLakeServiceClient-renameFileSystem", - options.tracingOptions - ); + const { span, updatedOptions } = createSpan("DataLakeServiceClient-renameFileSystem", options); try { // const res = await this.blobServiceClient.renameContainer( const res = await this.blobServiceClient["renameContainer"]( sourceFileSystemName, destinationFileSystemName, - { - ...options, - tracingOptions: { ...options.tracingOptions, spanOptions } - } + updatedOptions ); const fileSystemClient = this.getFileSystemClient(destinationFileSystemName); @@ -407,9 +395,9 @@ export class DataLakeServiceClient extends StorageClient { fileSystemClient: DataLakeFileSystemClient; fileSystemUndeleteResponse: FileSystemUndeleteResponse; }> { - const { span, spanOptions } = createSpan( + const { span, updatedOptions } = createSpan( "DataLakeServiceClient-undeleteFileSystem", - options.tracingOptions + options ); try { const res = await this.blobServiceClient.undeleteContainer( @@ -418,7 +406,7 @@ export class DataLakeServiceClient extends StorageClient { { ...options, destinationContainerName: options.destinationFileSystemName, - tracingOptions: { ...options.tracingOptions, spanOptions } + tracingOptions: updatedOptions.tracingOptions } ); diff --git a/sdk/storage/storage-file-datalake/src/clients.ts b/sdk/storage/storage-file-datalake/src/clients.ts index e9ff8b5fb3b5..51a3e572e1a6 100644 --- a/sdk/storage/storage-file-datalake/src/clients.ts +++ b/sdk/storage/storage-file-datalake/src/clients.ts @@ -88,7 +88,7 @@ import { FILE_UPLOAD_MAX_CHUNK_SIZE } from "./utils/constants"; import { DataLakeAclChangeFailedError } from "./utils/DataLakeAclChangeFailedError"; -import { createSpan } from "./utils/tracing"; +import { convertTracingToRequestOptionsBase, createSpan } from "./utils/tracing"; import { appendToURLPath, appendToURLQuery, @@ -134,9 +134,9 @@ export class DataLakePathClient extends StorageClient { throw RangeError(`Options batchSize must be larger than 0.`); } - const { span, spanOptions } = createSpan( + const { span, updatedOptions } = createSpan( `DataLakePathClient-setAccessControlRecursiveInternal`, - options.tracingOptions + options ); const result: PathChangeAccessControlRecursiveResponse = { @@ -161,7 +161,7 @@ export class DataLakePathClient extends StorageClient { maxRecords: options.batchSize, continuation: continuationToken, forceFlag: options.continueOnFailure, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) }); } catch (e) { throw new DataLakeAclChangeFailedError(e, continuationToken); @@ -316,7 +316,7 @@ export class DataLakePathClient extends StorageClient { options: PathCreateOptions = {} ): Promise { options.conditions = options.conditions || {}; - const { span, spanOptions } = createSpan("DataLakePathClient-create", options.tracingOptions); + const { span, updatedOptions } = createSpan("DataLakePathClient-create", options); try { return await this.pathContext.create({ ...options, @@ -324,7 +324,7 @@ export class DataLakePathClient extends StorageClient { leaseAccessConditions: options.conditions, modifiedAccessConditions: options.conditions, properties: toProperties(options.metadata), - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) }); } catch (e) { span.setStatus({ @@ -349,16 +349,13 @@ export class DataLakePathClient extends StorageClient { resourceType: PathResourceTypeModel, options: PathCreateIfNotExistsOptions = {} ): Promise { - const { span, spanOptions } = createSpan( - "DataLakePathClient-createIfNotExists", - options.tracingOptions - ); + const { span, updatedOptions } = createSpan("DataLakePathClient-createIfNotExists", options); try { const conditions = { ifNoneMatch: ETagAny }; const res = await this.create(resourceType, { ...options, conditions, - tracingOptions: { ...options!.tracingOptions, spanOptions } + tracingOptions: updatedOptions.tracingOptions }); return { succeeded: true, @@ -396,12 +393,9 @@ export class DataLakePathClient extends StorageClient { * @param options - options to Exists operation. */ public async exists(options: PathExistsOptions = {}): Promise { - const { span, spanOptions } = createSpan("DataLakeFileClient-exists", options.tracingOptions); + const { span, updatedOptions } = createSpan("DataLakeFileClient-exists", options); try { - return await this.blobClient.exists({ - ...options, - tracingOptions: { ...options!.tracingOptions, spanOptions } - }); + return await this.blobClient.exists(updatedOptions); } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, @@ -426,7 +420,7 @@ export class DataLakePathClient extends StorageClient { options: PathDeleteOptions = {} ): Promise { options.conditions = options.conditions || {}; - const { span, spanOptions } = createSpan("DataLakePathClient-delete", options.tracingOptions); + const { span, updatedOptions } = createSpan("DataLakePathClient-delete", options); try { let continuation; let response; @@ -438,7 +432,7 @@ export class DataLakePathClient extends StorageClient { recursive, leaseAccessConditions: options.conditions, modifiedAccessConditions: options.conditions, - spanOptions, + ...convertTracingToRequestOptionsBase(updatedOptions), abortSignal: options.abortSignal }); continuation = response.continuation; @@ -469,15 +463,9 @@ export class DataLakePathClient extends StorageClient { options: PathDeleteOptions = {} ): Promise { options.conditions = options.conditions || {}; - const { span, spanOptions } = createSpan( - "DataLakePathClient-deleteIfExists", - options.tracingOptions - ); + const { span, updatedOptions } = createSpan("DataLakePathClient-deleteIfExists", options); try { - const res = await this.delete(recursive, { - ...options, - tracingOptions: { ...options!.tracingOptions, spanOptions } - }); + const res = await this.delete(recursive, updatedOptions); return { succeeded: true, ...res @@ -515,17 +503,14 @@ export class DataLakePathClient extends StorageClient { options: PathGetAccessControlOptions = {} ): Promise { options.conditions = options.conditions || {}; - const { span, spanOptions } = createSpan( - "DataLakePathClient-getAccessControl", - options.tracingOptions - ); + const { span, updatedOptions } = createSpan("DataLakePathClient-getAccessControl", options); try { const response = await this.pathContext.getProperties({ action: "getAccessControl", upn: options.userPrincipalName, leaseAccessConditions: options.conditions, modifiedAccessConditions: options.conditions, - spanOptions, + ...convertTracingToRequestOptionsBase(updatedOptions), abortSignal: options.abortSignal }); return toPathGetAccessControlResponse(response); @@ -553,17 +538,14 @@ export class DataLakePathClient extends StorageClient { options: PathSetAccessControlOptions = {} ): Promise { options.conditions = options.conditions || {}; - const { span, spanOptions } = createSpan( - "DataLakePathClient-setAccessControl", - options.tracingOptions - ); + const { span, updatedOptions } = createSpan("DataLakePathClient-setAccessControl", options); try { return await this.pathContext.setAccessControl({ ...options, acl: toAclString(acl), leaseAccessConditions: options.conditions, modifiedAccessConditions: options.conditions, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) }); } catch (e) { span.setStatus({ @@ -588,15 +570,12 @@ export class DataLakePathClient extends StorageClient { acl: PathAccessControlItem[], options: PathChangeAccessControlRecursiveOptions = {} ): Promise { - const { span, spanOptions } = createSpan( + const { span, updatedOptions } = createSpan( "DataLakePathClient-setAccessControlRecursive", - options.tracingOptions + options ); try { - return this.setAccessControlRecursiveInternal("set", acl, { - ...options, - tracingOptions: { ...options.tracingOptions, spanOptions } - }); + return this.setAccessControlRecursiveInternal("set", acl, updatedOptions); } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, @@ -620,15 +599,12 @@ export class DataLakePathClient extends StorageClient { acl: PathAccessControlItem[], options: PathChangeAccessControlRecursiveOptions = {} ): Promise { - const { span, spanOptions } = createSpan( + const { span, updatedOptions } = createSpan( "DataLakePathClient-updateAccessControlRecursive", - options.tracingOptions + options ); try { - return this.setAccessControlRecursiveInternal("modify", acl, { - ...options, - tracingOptions: { ...options.tracingOptions, spanOptions } - }); + return this.setAccessControlRecursiveInternal("modify", acl, updatedOptions); } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, @@ -652,15 +628,12 @@ export class DataLakePathClient extends StorageClient { acl: RemovePathAccessControlItem[], options: PathChangeAccessControlRecursiveOptions = {} ): Promise { - const { span, spanOptions } = createSpan( + const { span, updatedOptions } = createSpan( "DataLakePathClient-removeAccessControlRecursive", - options.tracingOptions + options ); try { - return this.setAccessControlRecursiveInternal("remove", acl, { - ...options, - tracingOptions: { ...options.tracingOptions, spanOptions } - }); + return this.setAccessControlRecursiveInternal("remove", acl, updatedOptions); } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, @@ -685,17 +658,14 @@ export class DataLakePathClient extends StorageClient { options: PathSetPermissionsOptions = {} ): Promise { options.conditions = options.conditions || {}; - const { span, spanOptions } = createSpan( - "DataLakePathClient-setPermissions", - options.tracingOptions - ); + const { span, updatedOptions } = createSpan("DataLakePathClient-setPermissions", options); try { return await this.pathContext.setAccessControl({ ...options, permissions: toPermissionsString(permissions), leaseAccessConditions: options.conditions, modifiedAccessConditions: options.conditions, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) }); } catch (e) { span.setStatus({ @@ -724,15 +694,12 @@ export class DataLakePathClient extends StorageClient { public async getProperties( options: PathGetPropertiesOptions = {} ): Promise { - const { span, spanOptions } = createSpan( - "DataLakePathClient-getProperties", - options.tracingOptions - ); + const { span, updatedOptions } = createSpan("DataLakePathClient-getProperties", options); try { return await this.blobClient.getProperties({ ...options, customerProvidedKey: undefined, // Doesn't support customer provided key in data lake package yet - tracingOptions: { ...options.tracingOptions, spanOptions } + tracingOptions: updatedOptions.tracingOptions }); } catch (e) { span.setStatus({ @@ -759,10 +726,7 @@ export class DataLakePathClient extends StorageClient { httpHeaders: PathHttpHeaders, options: PathSetHttpHeadersOptions = {} ): Promise { - const { span, spanOptions } = createSpan( - "DataLakePathClient-setHttpHeaders", - options.tracingOptions - ); + const { span, updatedOptions } = createSpan("DataLakePathClient-setHttpHeaders", options); try { return await this.blobClient.setHTTPHeaders( { @@ -773,10 +737,7 @@ export class DataLakePathClient extends StorageClient { blobContentLanguage: httpHeaders.contentLanguage, blobContentDisposition: httpHeaders.contentDisposition }, - { - ...options, - tracingOptions: { ...options.tracingOptions, spanOptions } - } + updatedOptions ); } catch (e) { span.setStatus({ @@ -805,15 +766,12 @@ export class DataLakePathClient extends StorageClient { metadata?: Metadata, options: PathSetMetadataOptions = {} ): Promise { - const { span, spanOptions } = createSpan( - "DataLakePathClient-setMetadata", - options.tracingOptions - ); + const { span, updatedOptions } = createSpan("DataLakePathClient-setMetadata", options); try { return await this.blobClient.setMetadata(metadata, { ...options, customerProvidedKey: undefined, // Doesn't support customer provided key in data lake package yet - tracingOptions: { ...options.tracingOptions, spanOptions } + tracingOptions: updatedOptions.tracingOptions }); } catch (e) { span.setStatus({ @@ -872,7 +830,7 @@ export class DataLakePathClient extends StorageClient { options.conditions = options.conditions || {}; options.destinationConditions = options.destinationConditions || {}; - const { span, spanOptions } = createSpan("DataLakePathClient-move", options.tracingOptions); + const { span, updatedOptions } = createSpan("DataLakePathClient-move", options); const renameSource = getURLPathAndQuery(this.dfsEndpointUrl); @@ -904,7 +862,7 @@ export class DataLakePathClient extends StorageClient { sourceIfUnmodifiedSince: options.conditions.ifUnmodifiedSince }, modifiedAccessConditions: options.destinationConditions, - spanOptions, + ...convertTracingToRequestOptionsBase(updatedOptions), abortSignal: options.abortSignal }); } catch (e) { @@ -962,16 +920,13 @@ export class DataLakeDirectoryClient extends DataLakePathClient { options = resourceTypeOrOptions || {}; options.conditions = options.conditions || {}; - const { span, spanOptions } = createSpan( - "DataLakeDirectoryClient-create", - options.tracingOptions - ); + const { span, updatedOptions } = createSpan("DataLakeDirectoryClient-create", options); try { return await super.create("directory", { ...options, tracingOptions: { ...options.tracingOptions, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) } }); } catch (e) { @@ -1023,16 +978,16 @@ export class DataLakeDirectoryClient extends DataLakePathClient { options = resourceTypeOrOptions || {}; } - const { span, spanOptions } = createSpan( + const { span, updatedOptions } = createSpan( "DataLakeDirectoryClient-createIfNotExists", - options.tracingOptions + options ); try { return await super.createIfNotExists("directory", { ...options, tracingOptions: { ...options.tracingOptions, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) } }); } catch (e) { @@ -1217,13 +1172,13 @@ export class DataLakeFileClient extends DataLakePathClient { options = resourceTypeOrOptions || {}; options.conditions = options.conditions || {}; - const { span, spanOptions } = createSpan("DataLakeFileClient-create", options.tracingOptions); + const { span, updatedOptions } = createSpan("DataLakeFileClient-create", options); try { return await super.create("file", { ...options, tracingOptions: { ...options.tracingOptions, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) } }); } catch (e) { @@ -1275,16 +1230,13 @@ export class DataLakeFileClient extends DataLakePathClient { options = resourceTypeOrOptions || {}; } - const { span, spanOptions } = createSpan( - "DataLakeFileClient-createIfNotExists", - options.tracingOptions - ); + const { span, updatedOptions } = createSpan("DataLakeFileClient-createIfNotExists", options); try { return await super.createIfNotExists("file", { ...options, tracingOptions: { ...options.tracingOptions, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) } }); } catch (e) { @@ -1357,12 +1309,9 @@ export class DataLakeFileClient extends DataLakePathClient { count?: number, options: FileReadOptions = {} ): Promise { - const { span, spanOptions } = createSpan("DataLakeFileClient-read", options.tracingOptions); + const { span, updatedOptions } = createSpan("DataLakeFileClient-read", options); try { - const rawResponse = await this.blockBlobClientInternal.download(offset, count, { - ...options, - tracingOptions: { ...options.tracingOptions, spanOptions } - }); + const rawResponse = await this.blockBlobClientInternal.download(offset, count, updatedOptions); const response = rawResponse as FileReadResponse; if (!isNode && !response.contentAsBlob) { @@ -1404,7 +1353,7 @@ export class DataLakeFileClient extends DataLakePathClient { options: FileAppendOptions = {} ): Promise { options.conditions = options.conditions || {}; - const { span, spanOptions } = createSpan("DataLakeFileClient-append", options.tracingOptions); + const { span, updatedOptions } = createSpan("DataLakeFileClient-append", options); try { return await this.pathContextInternal.appendData(body, { pathHttpHeaders: { @@ -1415,7 +1364,7 @@ export class DataLakeFileClient extends DataLakePathClient { contentLength: length, leaseAccessConditions: options.conditions, onUploadProgress: options.onProgress, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) }); } catch (e) { span.setStatus({ @@ -1442,7 +1391,7 @@ export class DataLakeFileClient extends DataLakePathClient { */ public async flush(position: number, options: FileFlushOptions = {}): Promise { options.conditions = options.conditions || {}; - const { span, spanOptions } = createSpan("DataLakeFileClient-flush", options.tracingOptions); + const { span, updatedOptions } = createSpan("DataLakeFileClient-flush", options); try { return await this.pathContextInternal.flushData({ ...options, @@ -1450,7 +1399,7 @@ export class DataLakeFileClient extends DataLakePathClient { contentLength: 0, leaseAccessConditions: options.conditions, modifiedAccessConditions: options.conditions, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) }); } catch (e) { span.setStatus({ @@ -1477,10 +1426,7 @@ export class DataLakeFileClient extends DataLakePathClient { filePath: string, options: FileParallelUploadOptions = {} ): Promise { - const { span, spanOptions } = createSpan( - "DataLakeFileClient-uploadFile", - options.tracingOptions - ); + const { span, updatedOptions } = createSpan("DataLakeFileClient-uploadFile", options); try { const size = (await fsStat(filePath)).size; return await this.uploadSeekableInternal( @@ -1493,7 +1439,7 @@ export class DataLakeFileClient extends DataLakePathClient { }); }, size, - { ...options, tracingOptions: { ...options!.tracingOptions, spanOptions } } + updatedOptions ); } catch (e) { span.setStatus({ @@ -1516,7 +1462,7 @@ export class DataLakeFileClient extends DataLakePathClient { data: Buffer | Blob | ArrayBuffer | ArrayBufferView, options: FileParallelUploadOptions = {} ): Promise { - const { span, spanOptions } = createSpan("DataLakeFileClient-upload", options.tracingOptions); + const { span, updatedOptions } = createSpan("DataLakeFileClient-upload", options); try { if (isNode) { let buffer: Buffer; @@ -1532,17 +1478,14 @@ export class DataLakeFileClient extends DataLakePathClient { return this.uploadSeekableInternal( (offset: number, size: number): Buffer => buffer.slice(offset, offset + size), buffer.length, - { - ...options, - tracingOptions: { ...options!.tracingOptions, spanOptions } - } + updatedOptions ); } else { const browserBlob = new Blob([data]); return this.uploadSeekableInternal( (offset: number, size: number): Blob => browserBlob.slice(offset, offset + size), browserBlob.size, - { ...options, tracingOptions: { ...options!.tracingOptions, spanOptions } } + updatedOptions ); } } catch (e) { @@ -1561,10 +1504,7 @@ export class DataLakeFileClient extends DataLakePathClient { size: number, options: FileParallelUploadOptions = {} ): Promise { - const { span, spanOptions } = createSpan( - "DataLakeFileClient-uploadData", - options.tracingOptions - ); + const { span, updatedOptions } = createSpan("DataLakeFileClient-uploadData", options); try { if (size > FILE_MAX_SIZE_BYTES) { throw new RangeError(`size must be <= ${FILE_MAX_SIZE_BYTES}.`); @@ -1578,7 +1518,7 @@ export class DataLakeFileClient extends DataLakePathClient { umask: options.umask, conditions: options.conditions, pathHttpHeaders: options.pathHttpHeaders, - tracingOptions: { ...options!.tracingOptions, spanOptions } + tracingOptions: updatedOptions.tracingOptions }); // append() with empty data would return error, so do not continue if (size === 0) { @@ -1625,7 +1565,7 @@ export class DataLakeFileClient extends DataLakePathClient { abortSignal: options.abortSignal, conditions: options.conditions, onProgress: options.onProgress, - tracingOptions: { ...options!.tracingOptions, spanOptions } + tracingOptions: updatedOptions.tracingOptions }); return await this.flush(size, { @@ -1633,7 +1573,7 @@ export class DataLakeFileClient extends DataLakePathClient { conditions: options.conditions, close: options.close, pathHttpHeaders: options.pathHttpHeaders, - tracingOptions: { ...options!.tracingOptions, spanOptions } + tracingOptions: updatedOptions.tracingOptions }); } @@ -1641,7 +1581,7 @@ export class DataLakeFileClient extends DataLakePathClient { if (numBlocks > BLOCK_BLOB_MAX_BLOCKS) { throw new RangeError( `The data's size is too big or the chunkSize is too small;` + - `the number of chunks must be <= ${BLOCK_BLOB_MAX_BLOCKS}` + `the number of chunks must be <= ${BLOCK_BLOB_MAX_BLOCKS}` ); } @@ -1657,7 +1597,7 @@ export class DataLakeFileClient extends DataLakePathClient { await this.append(bodyFactory(start, contentLength), start, contentLength, { abortSignal: options.abortSignal, conditions: options.conditions, - tracingOptions: { ...options!.tracingOptions, spanOptions } + tracingOptions: updatedOptions.tracingOptions }); transferProgress += contentLength; @@ -1674,7 +1614,7 @@ export class DataLakeFileClient extends DataLakePathClient { conditions: options.conditions, close: options.close, pathHttpHeaders: options.pathHttpHeaders, - tracingOptions: { ...options!.tracingOptions, spanOptions } + tracingOptions: updatedOptions.tracingOptions }); } catch (e) { span.setStatus({ @@ -1706,10 +1646,7 @@ export class DataLakeFileClient extends DataLakePathClient { stream: Readable, options: FileParallelUploadOptions = {} ): Promise { - const { span, spanOptions } = createSpan( - "DataLakeFileClient-uploadStream", - options.tracingOptions - ); + const { span, updatedOptions } = createSpan("DataLakeFileClient-uploadStream", options); try { // Create the file await this.create({ @@ -1719,7 +1656,7 @@ export class DataLakeFileClient extends DataLakePathClient { umask: options.umask, conditions: options.conditions, pathHttpHeaders: options.pathHttpHeaders, - tracingOptions: { ...options!.tracingOptions, spanOptions } + tracingOptions: updatedOptions.tracingOptions }); // After the File is Create, Lease ID is the only valid request parameter. @@ -1747,7 +1684,7 @@ export class DataLakeFileClient extends DataLakePathClient { await this.append(body, offset!, length, { abortSignal: options.abortSignal, conditions: options.conditions, - tracingOptions: { ...options!.tracingOptions, spanOptions } + tracingOptions: updatedOptions.tracingOptions }); // Update progress after block is successfully uploaded to server, in case of block trying @@ -1769,7 +1706,7 @@ export class DataLakeFileClient extends DataLakePathClient { conditions: options.conditions, close: options.close, pathHttpHeaders: options.pathHttpHeaders, - tracingOptions: { ...options!.tracingOptions, spanOptions } + tracingOptions: updatedOptions.tracingOptions }); } catch (e) { span.setStatus({ @@ -1843,24 +1780,21 @@ export class DataLakeFileClient extends DataLakePathClient { count = typeof offsetOrCount === "number" ? offsetOrCount : 0; options = (countOrOptions as FileReadToBufferOptions) || {}; } - const { span, spanOptions } = createSpan( - "DataLakeFileClient-readToBuffer", - options.tracingOptions - ); + const { span, updatedOptions } = createSpan("DataLakeFileClient-readToBuffer", options); try { if (buffer) { return await this.blockBlobClientInternal.downloadToBuffer(buffer, offset, count, { ...options, maxRetryRequestsPerBlock: options.maxRetryRequestsPerChunk, blockSize: options.chunkSize, - tracingOptions: { ...options!.tracingOptions, spanOptions } + tracingOptions: updatedOptions.tracingOptions }); } else { return await this.blockBlobClientInternal.downloadToBuffer(offset, count, { ...options, maxRetryRequestsPerBlock: options.maxRetryRequestsPerChunk, blockSize: options.chunkSize, - tracingOptions: { ...options!.tracingOptions, spanOptions } + tracingOptions: updatedOptions.tracingOptions }); } } catch (e) { @@ -1896,15 +1830,14 @@ export class DataLakeFileClient extends DataLakePathClient { count?: number, options: FileReadOptions = {} ): Promise { - const { span, spanOptions } = createSpan( - "DataLakeFileClient-readToFile", - options.tracingOptions - ); + const { span, updatedOptions } = createSpan("DataLakeFileClient-readToFile", options); try { - return await this.blockBlobClientInternal.downloadToFile(filePath, offset, count, { - ...options, - tracingOptions: { ...options!.tracingOptions, spanOptions } - }); + return await this.blockBlobClientInternal.downloadToFile( + filePath, + offset, + count, + updatedOptions + ); } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, @@ -1945,13 +1878,10 @@ export class DataLakeFileClient extends DataLakePathClient { * @param options - */ public async query(query: string, options: FileQueryOptions = {}): Promise { - const { span, spanOptions } = createSpan("DataLakeFileClient-query", options.tracingOptions); + const { span, updatedOptions } = createSpan("DataLakeFileClient-query", options); try { - const rawResponse = await this.blockBlobClientInternal.query(query, { - ...options, - tracingOptions: { ...options.tracingOptions, spanOptions } - }); + const rawResponse = await this.blockBlobClientInternal.query(query, updatedOptions); const response = rawResponse as FileReadResponse; if (!isNode && !response.contentAsBlob) { response.contentAsBlob = rawResponse.blobBody; @@ -1983,10 +1913,7 @@ export class DataLakeFileClient extends DataLakePathClient { mode: FileExpiryMode, options: FileSetExpiryOptions = {} ): Promise { - const { span, spanOptions } = createSpan( - "DataLakeFileClient-setExpiry", - options.tracingOptions - ); + const { span, updatedOptions } = createSpan("DataLakeFileClient-setExpiry", options); try { let expiresOn: string | undefined = undefined; if (mode === "RelativeToNow" || mode === "RelativeToCreation") { @@ -2013,7 +1940,7 @@ export class DataLakeFileClient extends DataLakePathClient { const adaptedOptions = { ...options, expiresOn }; return await this.pathContextInternalToBlobEndpoint.setExpiry(mode, { ...adaptedOptions, - tracingOptions: { ...options.tracingOptions, spanOptions } + tracingOptions: updatedOptions.tracingOptions }); } catch (e) { span.setStatus({ diff --git a/sdk/storage/storage-file-datalake/src/utils/tracing.ts b/sdk/storage/storage-file-datalake/src/utils/tracing.ts index fab06c3b613b..19f15498e6ca 100644 --- a/sdk/storage/storage-file-datalake/src/utils/tracing.ts +++ b/sdk/storage/storage-file-datalake/src/utils/tracing.ts @@ -1,6 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. +import { OperationOptions, RequestOptionsBase } from "@azure/core-http"; import { createSpanFunction } from "@azure/core-tracing"; /** @@ -11,3 +12,18 @@ export const createSpan = createSpanFunction({ packagePrefix: "Azure.Storage.DataLake", namespace: "Microsoft.Storage" }); + +/** + * @internal + * + * Adapt the tracing options from OperationOptions to what they need to be for + * RequestOptionsBase (when we update to later OpenTelemetry versions this is now + * two separate fields, not just one). + */ +export function convertTracingToRequestOptionsBase( + options?: OperationOptions +): Pick { + return { + spanOptions: options?.tracingOptions?.spanOptions + }; +} From 68c5ce059df7d678251dd4be4a0f8897b7135f80 Mon Sep 17 00:00:00 2001 From: Richard Park <51494936+richardpark-msft@users.noreply.github.com> Date: Sat, 20 Feb 2021 05:57:26 +0000 Subject: [PATCH 22/52] Formatting --- sdk/storage/storage-file-datalake/src/clients.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/sdk/storage/storage-file-datalake/src/clients.ts b/sdk/storage/storage-file-datalake/src/clients.ts index 51a3e572e1a6..2aa1e92c62b9 100644 --- a/sdk/storage/storage-file-datalake/src/clients.ts +++ b/sdk/storage/storage-file-datalake/src/clients.ts @@ -1311,7 +1311,11 @@ export class DataLakeFileClient extends DataLakePathClient { ): Promise { const { span, updatedOptions } = createSpan("DataLakeFileClient-read", options); try { - const rawResponse = await this.blockBlobClientInternal.download(offset, count, updatedOptions); + const rawResponse = await this.blockBlobClientInternal.download( + offset, + count, + updatedOptions + ); const response = rawResponse as FileReadResponse; if (!isNode && !response.contentAsBlob) { @@ -1581,7 +1585,7 @@ export class DataLakeFileClient extends DataLakePathClient { if (numBlocks > BLOCK_BLOB_MAX_BLOCKS) { throw new RangeError( `The data's size is too big or the chunkSize is too small;` + - `the number of chunks must be <= ${BLOCK_BLOB_MAX_BLOCKS}` + `the number of chunks must be <= ${BLOCK_BLOB_MAX_BLOCKS}` ); } From 7031b790e05770068df18c47cd0de8468a08208b Mon Sep 17 00:00:00 2001 From: Richard Park <51494936+richardpark-msft@users.noreply.github.com> Date: Sat, 20 Feb 2021 06:13:25 +0000 Subject: [PATCH 23/52] storage-file-share: ported to using core-tracing --- sdk/storage/storage-file-share/src/Clients.ts | 463 ++++++++---------- .../src/ShareServiceClient.ts | 44 +- .../storage-file-share/src/utils/tracing.ts | 16 + 3 files changed, 241 insertions(+), 282 deletions(-) diff --git a/sdk/storage/storage-file-share/src/Clients.ts b/sdk/storage/storage-file-share/src/Clients.ts index 07944212b84b..901310387384 100644 --- a/sdk/storage/storage-file-share/src/Clients.ts +++ b/sdk/storage/storage-file-share/src/Clients.ts @@ -72,7 +72,7 @@ import { import { Credential } from "./credentials/Credential"; import { StorageSharedKeyCredential } from "./credentials/StorageSharedKeyCredential"; import { AnonymousCredential } from "./credentials/AnonymousCredential"; -import { createSpan } from "./utils/tracing"; +import { convertTracingToRequestOptionsBase, createSpan } from "./utils/tracing"; import { StorageClient, CommonOptions } from "./StorageClient"; import "@azure/core-paging"; import { PageSettings, PagedAsyncIterableIterator } from "@azure/core-paging"; @@ -338,24 +338,24 @@ export interface SignedIdentifier { export declare type ShareGetAccessPolicyResponse = { signedIdentifiers: SignedIdentifier[]; } & ShareGetAccessPolicyHeaders & { + /** + * The underlying HTTP response. + */ + _response: HttpResponse & { /** - * The underlying HTTP response. + * The parsed HTTP response headers. */ - _response: HttpResponse & { - /** - * The parsed HTTP response headers. - */ - parsedHeaders: ShareGetAccessPolicyHeaders; - /** - * The response body as text (string format) - */ - bodyAsText: string; - /** - * The response body as parsed JSON or XML - */ - parsedBody: SignedIdentifierModel[]; - }; + parsedHeaders: ShareGetAccessPolicyHeaders; + /** + * The response body as text (string format) + */ + bodyAsText: string; + /** + * The response body as parsed JSON or XML + */ + parsedBody: SignedIdentifierModel[]; }; +}; /** * Options to configure the {@link ShareClient.createSnapshot} operation. @@ -645,12 +645,12 @@ export class ShareClient extends StorageClient { * @returns Response data for the Share Create operation. */ public async create(options: ShareCreateOptions = {}): Promise { - const { span, spanOptions } = createSpan("ShareClient-create", options.tracingOptions); + const { span, updatedOptions } = createSpan("ShareClient-create", options); try { return await this.context.create({ ...options, enabledProtocols: toShareProtocolsString(options.protocols), - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) }); } catch (e) { span.setStatus({ @@ -673,15 +673,12 @@ export class ShareClient extends StorageClient { public async createIfNotExists( options: ShareCreateOptions = {} ): Promise { - const { span, spanOptions } = createSpan( + const { span, updatedOptions } = createSpan( "ShareClient-createIfNotExists", - options.tracingOptions + options ); try { - const res = await this.create({ - ...options, - tracingOptions: { ...options!.tracingOptions, spanOptions } - }); + const res = await this.create(updatedOptions); return { succeeded: true, ...res @@ -746,13 +743,10 @@ export class ShareClient extends StorageClient { directoryClient: ShareDirectoryClient; directoryCreateResponse: DirectoryCreateResponse; }> { - const { span, spanOptions } = createSpan("ShareClient-createDirectory", options.tracingOptions); + const { span, updatedOptions } = createSpan("ShareClient-createDirectory", options); try { const directoryClient = this.getDirectoryClient(directoryName); - const directoryCreateResponse = await directoryClient.create({ - ...options, - tracingOptions: { ...options.tracingOptions, spanOptions } - }); + const directoryCreateResponse = await directoryClient.create(updatedOptions); return { directoryClient, directoryCreateResponse @@ -781,13 +775,10 @@ export class ShareClient extends StorageClient { directoryName: string, options: DirectoryDeleteOptions = {} ): Promise { - const { span, spanOptions } = createSpan("ShareClient-deleteDirectory", options.tracingOptions); + const { span, updatedOptions } = createSpan("ShareClient-deleteDirectory", options); try { const directoryClient = this.getDirectoryClient(directoryName); - return await directoryClient.delete({ - ...options, - tracingOptions: { ...options.tracingOptions, spanOptions } - }); + return await directoryClient.delete(updatedOptions); } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, @@ -814,14 +805,11 @@ export class ShareClient extends StorageClient { size: number, options: FileCreateOptions = {} ): Promise<{ fileClient: ShareFileClient; fileCreateResponse: FileCreateResponse }> { - const { span, spanOptions } = createSpan("ShareClient-createFile", options.tracingOptions); + const { span, updatedOptions } = createSpan("ShareClient-createFile", options); try { const directoryClient = this.rootDirectoryClient; const fileClient = directoryClient.getFileClient(fileName); - const fileCreateResponse = await fileClient.create(size, { - ...options, - tracingOptions: { ...options.tracingOptions, spanOptions } - }); + const fileCreateResponse = await fileClient.create(size, updatedOptions); return { fileClient, fileCreateResponse @@ -861,14 +849,11 @@ export class ShareClient extends StorageClient { fileName: string, options: FileDeleteOptions = {} ): Promise { - const { span, spanOptions } = createSpan("ShareClient-deleteFile", options.tracingOptions); + const { span, updatedOptions } = createSpan("ShareClient-deleteFile", options); try { const directoryClient = this.rootDirectoryClient; const fileClient = directoryClient.getFileClient(fileName); - return await fileClient.delete({ - ...options, - tracingOptions: { ...options.tracingOptions, spanOptions } - }); + return await fileClient.delete(updatedOptions); } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, @@ -890,12 +875,9 @@ export class ShareClient extends StorageClient { * @param options - options to Exists operation. */ public async exists(options: ShareExistsOptions = {}): Promise { - const { span, spanOptions } = createSpan("ShareClient-exists", options.tracingOptions); + const { span, updatedOptions } = createSpan("ShareClient-exists", options); try { - await this.getProperties({ - ...options, - tracingOptions: { ...options.tracingOptions, spanOptions } - }); + await this.getProperties(updatedOptions); return true; } catch (e) { if (e.statusCode === 404) { @@ -930,11 +912,11 @@ export class ShareClient extends StorageClient { public async getProperties( options: ShareGetPropertiesOptions = {} ): Promise { - const { span, spanOptions } = createSpan("ShareClient-getProperties", options.tracingOptions); + const { span, updatedOptions } = createSpan("ShareClient-getProperties", options); try { const res = await this.context.getProperties({ ...options, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) }); // parse protocols @@ -961,11 +943,11 @@ export class ShareClient extends StorageClient { * @returns Response data for the Share Delete operation. */ public async delete(options: ShareDeleteMethodOptions = {}): Promise { - const { span, spanOptions } = createSpan("ShareClient-delete", options.tracingOptions); + const { span, updatedOptions } = createSpan("ShareClient-delete", options); try { return await this.context.deleteMethod({ ...options, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) }); } catch (e) { span.setStatus({ @@ -988,12 +970,9 @@ export class ShareClient extends StorageClient { public async deleteIfExists( options: ShareDeleteMethodOptions = {} ): Promise { - const { span, spanOptions } = createSpan("ShareClient-deleteIfExists", options.tracingOptions); + const { span, updatedOptions } = createSpan("ShareClient-deleteIfExists", options); try { - const res = await this.delete({ - ...options, - tracingOptions: { ...options!.tracingOptions, spanOptions } - }); + const res = await this.delete(updatedOptions); return { succeeded: true, ...res @@ -1035,12 +1014,12 @@ export class ShareClient extends StorageClient { metadata?: Metadata, options: ShareSetMetadataOptions = {} ): Promise { - const { span, spanOptions } = createSpan("ShareClient-setMetadata", options.tracingOptions); + const { span, updatedOptions } = createSpan("ShareClient-setMetadata", options); try { return await this.context.setMetadata({ ...options, metadata, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) }); } catch (e) { span.setStatus({ @@ -1068,11 +1047,11 @@ export class ShareClient extends StorageClient { public async getAccessPolicy( options: ShareGetAccessPolicyOptions = {} ): Promise { - const { span, spanOptions } = createSpan("ShareClient-getAccessPolicy", options.tracingOptions); + const { span, updatedOptions } = createSpan("ShareClient-getAccessPolicy", options); try { const response = await this.context.getAccessPolicy({ ...options, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) }); const res: ShareGetAccessPolicyResponse = { @@ -1140,7 +1119,7 @@ export class ShareClient extends StorageClient { shareAcl?: SignedIdentifier[], options: ShareSetAccessPolicyOptions = {} ): Promise { - const { span, spanOptions } = createSpan("ShareClient-setAccessPolicy", options.tracingOptions); + const { span, updatedOptions } = createSpan("ShareClient-setAccessPolicy", options); try { const acl: SignedIdentifierModel[] = []; for (const identifier of shareAcl || []) { @@ -1161,7 +1140,7 @@ export class ShareClient extends StorageClient { return await this.context.setAccessPolicy({ ...options, shareAcl: acl, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) }); } catch (e) { span.setStatus({ @@ -1183,12 +1162,12 @@ export class ShareClient extends StorageClient { public async createSnapshot( options: ShareCreateSnapshotOptions = {} ): Promise { - const { span, spanOptions } = createSpan("ShareClient-createSnapshot", options.tracingOptions); + const { span, updatedOptions } = createSpan("ShareClient-createSnapshot", options); try { return await this.context.createSnapshot({ abortSignal: options.abortSignal, ...options, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) }); } catch (e) { span.setStatus({ @@ -1214,12 +1193,12 @@ export class ShareClient extends StorageClient { quotaInGB: number, options: ShareSetQuotaOptions = {} ): Promise { - const { span, spanOptions } = createSpan("ShareClient-setQuota", options.tracingOptions); + const { span, updatedOptions } = createSpan("ShareClient-setQuota", options); try { return await this.context.setProperties({ ...options, quota: quotaInGB, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) }); } catch (e) { span.setStatus({ @@ -1241,12 +1220,12 @@ export class ShareClient extends StorageClient { public async setProperties( options: ShareSetPropertiesOptions = {} ): Promise { - const { span, spanOptions } = createSpan("ShareClient-setProperties", options.tracingOptions); + const { span, updatedOptions } = createSpan("ShareClient-setProperties", options); try { return await this.context.setProperties({ ...options, quota: options.quotaInGB, - tracingOptions: { ...options!.tracingOptions, spanOptions } + tracingOptions: updatedOptions.tracingOptions }); } catch (e) { span.setStatus({ @@ -1268,11 +1247,11 @@ export class ShareClient extends StorageClient { public async getStatistics( options: ShareGetStatisticsOptions = {} ): Promise { - const { span, spanOptions } = createSpan("ShareClient-getStatistics", options.tracingOptions); + const { span, updatedOptions } = createSpan("ShareClient-getStatistics", options); try { const response = await this.context.getStatistics({ ...options, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) }); const GBBytes = 1024 * 1024 * 1024; @@ -1300,9 +1279,9 @@ export class ShareClient extends StorageClient { filePermission: string, options: ShareCreatePermissionOptions = {} ): Promise { - const { span, spanOptions } = createSpan( + const { span, updatedOptions } = createSpan( "ShareClient-createPermission", - options.tracingOptions + options ); try { return await this.context.createPermission( @@ -1311,7 +1290,7 @@ export class ShareClient extends StorageClient { }, { abortSignal: options.abortSignal, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) } ); } catch (e) { @@ -1337,11 +1316,11 @@ export class ShareClient extends StorageClient { filePermissionKey: string, options: ShareGetPermissionOptions = {} ): Promise { - const { span, spanOptions } = createSpan("ShareClient-getPermission", options.tracingOptions); + const { span, updatedOptions } = createSpan("ShareClient-getPermission", options); try { return await this.context.getPermission(filePermissionKey, { aborterSignal: options.abortSignal, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) }); } catch (e) { span.setStatus({ @@ -1401,7 +1380,7 @@ export interface DirectoryCreateOptions extends FileAndDirectoryCreateCommonOpti export interface DirectoryProperties extends FileAndDirectorySetPropertiesCommonOptions, - CommonOptions { + CommonOptions { /** * An implementation of the `AbortSignalLike` interface to signal the request to cancel the operation. * For example, use the @azure/abort-controller to create an `AbortSignal`. @@ -1729,7 +1708,7 @@ export class ShareDirectoryClient extends StorageClient { * @returns Response data for the Directory operation. */ public async create(options: DirectoryCreateOptions = {}): Promise { - const { span, spanOptions } = createSpan("ShareDirectoryClient-create", options.tracingOptions); + const { span, updatedOptions } = createSpan("ShareDirectoryClient-create", options); try { if (!options.fileAttributes) { options = validateAndSetDefaultsForFileAndDirectoryCreateCommonOptions(options); @@ -1748,7 +1727,7 @@ export class ShareDirectoryClient extends StorageClient { metadata: options.metadata, filePermission: options.filePermission, filePermissionKey: options.filePermissionKey, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) } ); } catch (e) { @@ -1772,15 +1751,12 @@ export class ShareDirectoryClient extends StorageClient { public async createIfNotExists( options: DirectoryCreateOptions = {} ): Promise { - const { span, spanOptions } = createSpan( + const { span, updatedOptions } = createSpan( "ShareDirectoryClient-createIfNotExists", - options.tracingOptions + options ); try { - const res = await this.create({ - ...options, - tracingOptions: { ...options!.tracingOptions, spanOptions } - }); + const res = await this.create(updatedOptions); return { succeeded: true, ...res @@ -1817,9 +1793,9 @@ export class ShareDirectoryClient extends StorageClient { public async setProperties( properties: DirectoryProperties = {} ): Promise { - const { span, spanOptions } = createSpan( + const { span, updatedOptions } = createSpan( "ShareDirectoryClient-setProperties", - properties.tracingOptions + properties ); try { properties = validateAndSetDefaultsForFileAndDirectorySetPropertiesCommonOptions(properties); @@ -1832,7 +1808,7 @@ export class ShareDirectoryClient extends StorageClient { abortSignal: properties.abortSignal, filePermission: properties.filePermission, filePermissionKey: properties.filePermissionKey, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) } ); } catch (e) { @@ -1882,16 +1858,13 @@ export class ShareDirectoryClient extends StorageClient { directoryClient: ShareDirectoryClient; directoryCreateResponse: DirectoryCreateResponse; }> { - const { span, spanOptions } = createSpan( + const { span, updatedOptions } = createSpan( "ShareDirectoryClient-createSubdirectory", - options.tracingOptions + options ); try { const directoryClient = this.getDirectoryClient(directoryName); - const directoryCreateResponse = await directoryClient.create({ - ...options, - tracingOptions: { ...options!.tracingOptions, spanOptions } - }); + const directoryCreateResponse = await directoryClient.create(updatedOptions); return { directoryClient, directoryCreateResponse @@ -1920,16 +1893,13 @@ export class ShareDirectoryClient extends StorageClient { directoryName: string, options: DirectoryDeleteOptions = {} ): Promise { - const { span, spanOptions } = createSpan( + const { span, updatedOptions } = createSpan( "ShareDirectoryClient-deleteSubdirectory", - options.tracingOptions + options ); try { const directoryClient = this.getDirectoryClient(directoryName); - return await directoryClient.delete({ - ...options, - tracingOptions: { ...options!.tracingOptions, spanOptions } - }); + return await directoryClient.delete(updatedOptions); } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, @@ -1955,16 +1925,13 @@ export class ShareDirectoryClient extends StorageClient { size: number, options: FileCreateOptions = {} ): Promise<{ fileClient: ShareFileClient; fileCreateResponse: FileCreateResponse }> { - const { span, spanOptions } = createSpan( + const { span, updatedOptions } = createSpan( "ShareDirectoryClient-createFile", - options.tracingOptions + options ); try { const fileClient = this.getFileClient(fileName); - const fileCreateResponse = await fileClient.create(size, { - ...options, - tracingOptions: { ...options!.tracingOptions, spanOptions } - }); + const fileCreateResponse = await fileClient.create(size, updatedOptions); return { fileClient, fileCreateResponse @@ -2002,16 +1969,13 @@ export class ShareDirectoryClient extends StorageClient { fileName: string, options: FileDeleteOptions = {} ): Promise { - const { span, spanOptions } = createSpan( + const { span, updatedOptions } = createSpan( "ShareDirectoryClient-deleteFile", - options.tracingOptions + options ); try { const fileClient = this.getFileClient(fileName); - return await fileClient.delete({ - ...options, - tracingOptions: { ...options!.tracingOptions, spanOptions } - }); + return await fileClient.delete(updatedOptions); } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, @@ -2060,13 +2024,13 @@ export class ShareDirectoryClient extends StorageClient { * @param options - options to Exists operation. */ public async exists(options: DirectoryExistsOptions = {}): Promise { - const { span, spanOptions } = createSpan("ShareDirectoryClient-exists", options.tracingOptions); + const { span, updatedOptions } = createSpan("ShareDirectoryClient-exists", options); try { await this.getProperties({ abortSignal: options.abortSignal, tracingOptions: { ...options.tracingOptions, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) } }); return true; @@ -2100,14 +2064,14 @@ export class ShareDirectoryClient extends StorageClient { public async getProperties( options: DirectoryGetPropertiesOptions = {} ): Promise { - const { span, spanOptions } = createSpan( + const { span, updatedOptions } = createSpan( "ShareDirectoryClient-getProperties", - options.tracingOptions + options ); try { return await this.context.getProperties({ abortSignal: options.abortSignal, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) }); } catch (e) { span.setStatus({ @@ -2129,11 +2093,11 @@ export class ShareDirectoryClient extends StorageClient { * @returns Response data for the Directory Delete operation. */ public async delete(options: DirectoryDeleteOptions = {}): Promise { - const { span, spanOptions } = createSpan("ShareDirectoryClient-delete", options.tracingOptions); + const { span, updatedOptions } = createSpan("ShareDirectoryClient-delete", options); try { return await this.context.deleteMethod({ abortSignal: options.abortSignal, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) }); } catch (e) { span.setStatus({ @@ -2156,15 +2120,12 @@ export class ShareDirectoryClient extends StorageClient { public async deleteIfExists( options: DirectoryDeleteOptions = {} ): Promise { - const { span, spanOptions } = createSpan( + const { span, updatedOptions } = createSpan( "ShareDirectoryClient-deleteIfExists", - options.tracingOptions + options ); try { - const res = await this.delete({ - ...options, - tracingOptions: { ...options!.tracingOptions, spanOptions } - }); + const res = await this.delete(updatedOptions); return { succeeded: true, ...res @@ -2206,15 +2167,15 @@ export class ShareDirectoryClient extends StorageClient { metadata?: Metadata, options: DirectorySetMetadataOptions = {} ): Promise { - const { span, spanOptions } = createSpan( + const { span, updatedOptions } = createSpan( "ShareDirectoryClient-setMetadata", - options.tracingOptions + options ); try { return await this.context.setMetadata({ abortSignal: options.abortSignal, metadata, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) }); } catch (e) { span.setStatus({ @@ -2423,9 +2384,9 @@ export class ShareDirectoryClient extends StorageClient { marker?: string, options: DirectoryListFilesAndDirectoriesSegmentOptions = {} ): Promise { - const { span, spanOptions } = createSpan( + const { span, updatedOptions } = createSpan( "ShareDirectoryClient-listFilesAndDirectoriesSegment", - options.tracingOptions + options ); if (options.prefix === "") { @@ -2436,7 +2397,7 @@ export class ShareDirectoryClient extends StorageClient { return await this.context.listFilesAndDirectoriesSegment({ marker, ...options, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) }); } catch (e) { span.setStatus({ @@ -2612,16 +2573,16 @@ export class ShareDirectoryClient extends StorageClient { marker?: string, options: DirectoryListHandlesSegmentOptions = {} ): Promise { - const { span, spanOptions } = createSpan( + const { span, updatedOptions } = createSpan( "ShareDirectoryClient-listHandlesSegment", - options.tracingOptions + options ); try { marker = marker === "" ? undefined : marker; const response = await this.context.listHandles({ marker, ...options, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) }); // TODO: Protocol layer issue that when handle list is in returned XML @@ -2656,16 +2617,16 @@ export class ShareDirectoryClient extends StorageClient { marker?: string, options: DirectoryForceCloseHandlesSegmentOptions = {} ): Promise { - const { span, spanOptions } = createSpan( + const { span, updatedOptions } = createSpan( "ShareDirectoryClient-forceCloseHandlesSegment", - options.tracingOptions + options ); try { marker = marker === "" ? undefined : marker; const rawResponse = await this.context.forceCloseHandles("*", { marker, ...options, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) }); const response = rawResponse as DirectoryForceCloseHandlesResponse; response.closedHandlesCount = rawResponse.numberOfHandlesClosed || 0; @@ -2691,9 +2652,9 @@ export class ShareDirectoryClient extends StorageClient { public async forceCloseAllHandles( options: DirectoryForceCloseHandlesSegmentOptions = {} ): Promise { - const { span, spanOptions } = createSpan( + const { span, updatedOptions } = createSpan( "ShareDirectoryClient-forceCloseAllHandles", - options.tracingOptions + options ); try { let handlesClosed = 0; @@ -2703,7 +2664,7 @@ export class ShareDirectoryClient extends StorageClient { do { const response: DirectoryForceCloseHandlesResponse = await this.forceCloseHandlesSegment( marker, - { ...options, tracingOptions: { ...options!.tracingOptions, spanOptions } } + updatedOptions ); marker = response.marker; response.closedHandlesCount && (handlesClosed += response.closedHandlesCount); @@ -2736,9 +2697,9 @@ export class ShareDirectoryClient extends StorageClient { handleId: string, options: DirectoryForceCloseHandlesOptions = {} ): Promise { - const { span, spanOptions } = createSpan( + const { span, updatedOptions } = createSpan( "ShareDirectoryClient-forceCloseHandle", - options.tracingOptions + options ); try { if (handleId === "*") { @@ -2749,7 +2710,7 @@ export class ShareDirectoryClient extends StorageClient { const rawResponse = await this.context.forceCloseHandles(handleId, { abortSignal: options.abortSignal, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) }); const response = rawResponse as DirectoryForceCloseHandlesResponse; response.closedHandlesCount = rawResponse.numberOfHandlesClosed || 0; @@ -2807,7 +2768,7 @@ export interface FileProperties extends FileAndDirectorySetPropertiesCommonOptio leaseAccessConditions?: LeaseAccessConditions; } -export interface SetPropertiesResponse extends FileSetHTTPHeadersResponse {} +export interface SetPropertiesResponse extends FileSetHTTPHeadersResponse { } /** * Options to configure the {@link ShareFileClient.delete} operation. @@ -3078,7 +3039,7 @@ export interface FileSetMetadataOptions extends CommonOptions { */ export interface FileSetHttpHeadersOptions extends FileAndDirectorySetPropertiesCommonOptions, - CommonOptions { + CommonOptions { /** * An implementation of the `AbortSignalLike` interface to signal the request to cancel the operation. * For example, use the @azure/abort-controller to create an `AbortSignal`. @@ -3110,7 +3071,7 @@ export interface FileAbortCopyFromURLOptions extends CommonOptions { */ export interface FileResizeOptions extends FileAndDirectorySetPropertiesCommonOptions, - CommonOptions { + CommonOptions { /** * An implementation of the `AbortSignalLike` interface to signal the request to cancel the operation. * For example, use the @azure/abort-controller to create an `AbortSignal`. @@ -3495,7 +3456,7 @@ export class ShareFileClient extends StorageClient { * ``` */ public async create(size: number, options: FileCreateOptions = {}): Promise { - const { span, spanOptions } = createSpan("ShareFileClient-create", options.tracingOptions); + const { span, updatedOptions } = createSpan("ShareFileClient-create", options); try { if (size < 0 || size > FILE_MAX_SIZE_BYTES) { throw new RangeError(`File size must >= 0 and < ${FILE_MAX_SIZE_BYTES}.`); @@ -3523,7 +3484,7 @@ export class ShareFileClient extends StorageClient { filePermission: options.filePermission, filePermissionKey: options.filePermissionKey, leaseAccessConditions: options.leaseAccessConditions, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) } ); } catch (e) { @@ -3603,7 +3564,7 @@ export class ShareFileClient extends StorageClient { count?: number, options: FileDownloadOptions = {} ): Promise { - const { span, spanOptions } = createSpan("ShareFileClient-download", options.tracingOptions); + const { span, updatedOptions } = createSpan("ShareFileClient-download", options); try { if (options.rangeGetContentMD5 && offset === 0 && count === undefined) { throw new RangeError(`rangeGetContentMD5 only works with partial data downloading`); @@ -3616,7 +3577,7 @@ export class ShareFileClient extends StorageClient { range: downloadFullFile ? undefined : rangeToString({ offset, count }), rangeGetContentMD5: options.rangeGetContentMD5, leaseAccessConditions: options.leaseAccessConditions, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) }); // Return browser response immediately @@ -3660,7 +3621,7 @@ export class ShareFileClient extends StorageClient { abortSignal: options.abortSignal, leaseAccessConditions: options.leaseAccessConditions, ...updatedOptions, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) }) ).readableStreamBody!; }, @@ -3693,13 +3654,13 @@ export class ShareFileClient extends StorageClient { * @param options - options to Exists operation. */ public async exists(options: FileExistsOptions = {}): Promise { - const { span, spanOptions } = createSpan("ShareFileClient-exists", options.tracingOptions); + const { span, updatedOptions } = createSpan("ShareFileClient-exists", options); try { await this.getProperties({ abortSignal: options.abortSignal, tracingOptions: { ...options.tracingOptions, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) } }); return true; @@ -3732,15 +3693,15 @@ export class ShareFileClient extends StorageClient { public async getProperties( options: FileGetPropertiesOptions = {} ): Promise { - const { span, spanOptions } = createSpan( + const { span, updatedOptions } = createSpan( "ShareFileClient-getProperties", - options.tracingOptions + options ); try { return this.context.getProperties({ abortSignal: options.abortSignal, leaseAccessConditions: options.leaseAccessConditions, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) }); } catch (e) { span.setStatus({ @@ -3763,9 +3724,9 @@ export class ShareFileClient extends StorageClient { * existing values will be preserved. */ public async setProperties(properties: FileProperties = {}): Promise { - const { span, spanOptions } = createSpan( + const { span, updatedOptions } = createSpan( "ShareFileClient-setProperties", - properties.tracingOptions + properties ); try { properties = validateAndSetDefaultsForFileAndDirectorySetPropertiesCommonOptions(properties); @@ -3782,7 +3743,7 @@ export class ShareFileClient extends StorageClient { filePermission: properties.filePermission, filePermissionKey: properties.filePermissionKey, leaseAccessConditions: properties.leaseAccessConditions, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) } ); } catch (e) { @@ -3814,12 +3775,12 @@ export class ShareFileClient extends StorageClient { * @returns Response data for the File Delete operation. */ public async delete(options: FileDeleteOptions = {}): Promise { - const { span, spanOptions } = createSpan("ShareFileClient-delete", options.tracingOptions); + const { span, updatedOptions } = createSpan("ShareFileClient-delete", options); try { return await this.context.deleteMethod({ abortSignal: options.abortSignal, leaseAccessConditions: options.leaseAccessConditions, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) }); } catch (e) { span.setStatus({ @@ -3851,15 +3812,12 @@ export class ShareFileClient extends StorageClient { public async deleteIfExists( options: FileDeleteOptions = {} ): Promise { - const { span, spanOptions } = createSpan( + const { span, updatedOptions } = createSpan( "ShareFileClient-deleteIfExists", - options.tracingOptions + options ); try { - const res = await this.delete({ - ...options, - tracingOptions: { ...options!.tracingOptions, spanOptions } - }); + const res = await this.delete(updatedOptions); return { succeeded: true, ...res @@ -3905,9 +3863,9 @@ export class ShareFileClient extends StorageClient { fileHttpHeaders: FileHttpHeaders = {}, options: FileSetHttpHeadersOptions = {} ): Promise { - const { span, spanOptions } = createSpan( + const { span, updatedOptions } = createSpan( "ShareFileClient-setHTTPHeaders", - options.tracingOptions + options ); try { // FileAttributes, filePermission, createTime, lastWriteTime will all be preserved @@ -3922,7 +3880,7 @@ export class ShareFileClient extends StorageClient { filePermission: options.filePermission, filePermissionKey: options.filePermissionKey, leaseAccessConditions: options.leaseAccessConditions, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) } ); } catch (e) { @@ -3951,7 +3909,7 @@ export class ShareFileClient extends StorageClient { length: number, options: FileResizeOptions = {} ): Promise { - const { span, spanOptions } = createSpan("ShareFileClient-resize", options.tracingOptions); + const { span, updatedOptions } = createSpan("ShareFileClient-resize", options); try { if (length < 0) { throw new RangeError(`Size cannot less than 0 when resizing file.`); @@ -3969,7 +3927,7 @@ export class ShareFileClient extends StorageClient { filePermission: options.filePermission, filePermissionKey: options.filePermissionKey, leaseAccessConditions: options.leaseAccessConditions, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) } ); } catch (e) { @@ -3998,13 +3956,13 @@ export class ShareFileClient extends StorageClient { metadata: Metadata = {}, options: FileSetMetadataOptions = {} ): Promise { - const { span, spanOptions } = createSpan("ShareFileClient-setMetadata", options.tracingOptions); + const { span, updatedOptions } = createSpan("ShareFileClient-setMetadata", options); try { return await this.context.setMetadata({ abortSignal: options.abortSignal, metadata, leaseAccessConditions: options.leaseAccessConditions, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) }); } catch (e) { span.setStatus({ @@ -4050,7 +4008,7 @@ export class ShareFileClient extends StorageClient { contentLength: number, options: FileUploadRangeOptions = {} ): Promise { - const { span, spanOptions } = createSpan("ShareFileClient-uploadRange", options.tracingOptions); + const { span, updatedOptions } = createSpan("ShareFileClient-uploadRange", options); try { if (offset < 0) { throw new RangeError(`offset must be >= 0`); @@ -4073,7 +4031,7 @@ export class ShareFileClient extends StorageClient { contentMD5: options.contentMD5, onUploadProgress: options.onProgress, body: body, - spanOptions, + ...convertTracingToRequestOptionsBase(updatedOptions), leaseAccessConditions: options.leaseAccessConditions } ); @@ -4105,9 +4063,9 @@ export class ShareFileClient extends StorageClient { count: number, options: FileUploadRangeFromURLOptions = {} ): Promise { - const { span, spanOptions } = createSpan( + const { span, updatedOptions } = createSpan( "ShareFileClient-uploadRangeFromURL", - options.tracingOptions + options ); try { if (sourceOffset < 0 || destOffset < 0) { @@ -4127,7 +4085,7 @@ export class ShareFileClient extends StorageClient { sourceRange: rangeToString({ offset: sourceOffset, count }), sourceModifiedAccessConditions: options.sourceConditions, ...options, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) } ); } catch (e) { @@ -4153,7 +4111,7 @@ export class ShareFileClient extends StorageClient { contentLength: number, options: FileClearRangeOptions = {} ): Promise { - const { span, spanOptions } = createSpan("ShareFileClient-clearRange", options.tracingOptions); + const { span, updatedOptions } = createSpan("ShareFileClient-clearRange", options); try { if (offset < 0 || contentLength <= 0) { throw new RangeError(`offset must >= 0 and contentLength must be > 0`); @@ -4165,7 +4123,7 @@ export class ShareFileClient extends StorageClient { 0, { abortSignal: options.abortSignal, - spanOptions, + ...convertTracingToRequestOptionsBase(updatedOptions), leaseAccessConditions: options.leaseAccessConditions } ); @@ -4188,16 +4146,16 @@ export class ShareFileClient extends StorageClient { public async getRangeList( options: FileGetRangeListOptions = {} ): Promise { - const { span, spanOptions } = createSpan( + const { span, updatedOptions } = createSpan( "ShareFileClient-getRangeList", - options.tracingOptions + options ); try { const originalResponse = await this.context.getRangeList({ abortSignal: options.abortSignal, range: options.range ? rangeToString(options.range) : undefined, leaseAccessConditions: options.leaseAccessConditions, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) }); // Only returns ranges, ignoring clearRanges. @@ -4230,16 +4188,16 @@ export class ShareFileClient extends StorageClient { prevShareSnapshot: string, options: FileGetRangeListOptions = {} ): Promise { - const { span, spanOptions } = createSpan( + const { span, updatedOptions } = createSpan( "ShareFileClient-getRangeListDiff", - options.tracingOptions + options ); try { return await this.context.getRangeList({ prevsharesnapshot: prevShareSnapshot, ...options, range: options.range ? rangeToString(options.range) : undefined, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) }); } catch (e) { span.setStatus({ @@ -4268,9 +4226,9 @@ export class ShareFileClient extends StorageClient { copySource: string, options: FileStartCopyOptions = {} ): Promise { - const { span, spanOptions } = createSpan( + const { span, updatedOptions } = createSpan( "ShareFileClient-startCopyFromURL", - options.tracingOptions + options ); try { return await this.context.startCopy(copySource, { @@ -4280,7 +4238,7 @@ export class ShareFileClient extends StorageClient { filePermission: options.filePermission, filePermissionKey: options.filePermissionKey, copyFileSmbInfo: options.copyFileSmbInfo, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) }); } catch (e) { span.setStatus({ @@ -4305,15 +4263,15 @@ export class ShareFileClient extends StorageClient { copyId: string, options: FileAbortCopyFromURLOptions = {} ): Promise { - const { span, spanOptions } = createSpan( + const { span, updatedOptions } = createSpan( "ShareFileClient-abortCopyFromURL", - options.tracingOptions + options ); try { return await this.context.abortCopy(copyId, { abortSignal: options.abortSignal, leaseAccessConditions: options.leaseAccessConditions, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) }); } catch (e) { span.setStatus({ @@ -4338,7 +4296,7 @@ export class ShareFileClient extends StorageClient { data: Buffer | Blob | ArrayBuffer | ArrayBufferView, options: FileParallelUploadOptions = {} ): Promise { - const { span, spanOptions } = createSpan("ShareFileClient-uploadData", options.tracingOptions); + const { span, updatedOptions } = createSpan("ShareFileClient-uploadData", options); try { if (isNode) { let buffer: Buffer; @@ -4354,17 +4312,14 @@ export class ShareFileClient extends StorageClient { return this.uploadSeekableInternal( (offset: number, size: number): Buffer => buffer.slice(offset, offset + size), buffer.byteLength, - { - ...options, - tracingOptions: { ...options!.tracingOptions, spanOptions } - } + updatedOptions ); } else { const browserBlob = new Blob([data]); return this.uploadSeekableInternal( (offset: number, size: number): Blob => browserBlob.slice(offset, offset + size), browserBlob.size, - { ...options, tracingOptions: { ...options!.tracingOptions, spanOptions } } + updatedOptions ); } } catch (e) { @@ -4393,15 +4348,12 @@ export class ShareFileClient extends StorageClient { size: number, options: FileParallelUploadOptions = {} ): Promise { - const { span, spanOptions } = createSpan( + const { span, updatedOptions } = createSpan( "ShareFileClient-UploadSeekableBlob", - options.tracingOptions + options ); try { - return this.uploadSeekableInternal(blobFactory, size, { - ...options, - tracingOptions: { ...options!.tracingOptions, spanOptions } - }); + return this.uploadSeekableInternal(blobFactory, size, updatedOptions); } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, @@ -4426,7 +4378,7 @@ export class ShareFileClient extends StorageClient { filePath: string, options: FileParallelUploadOptions = {} ): Promise { - const { span, spanOptions } = createSpan("ShareFileClient-uploadFile", options.tracingOptions); + const { span, updatedOptions } = createSpan("ShareFileClient-uploadFile", options); try { const size = (await fsStat(filePath)).size; return await this.uploadSeekableInternal( @@ -4439,7 +4391,7 @@ export class ShareFileClient extends StorageClient { }); }, size, - { ...options, tracingOptions: { ...options!.tracingOptions, spanOptions } } + updatedOptions ); } catch (e) { span.setStatus({ @@ -4470,9 +4422,9 @@ export class ShareFileClient extends StorageClient { size: number, options: FileParallelUploadOptions = {} ): Promise { - const { span, spanOptions } = createSpan( + const { span, updatedOptions } = createSpan( "ShareFileClient-uploadResetableStream", - options.tracingOptions + options ); try { return await this.uploadSeekableInternal( @@ -4480,7 +4432,7 @@ export class ShareFileClient extends StorageClient { return () => streamFactory(offset, count); }, size, - { ...options, tracingOptions: { ...options!.tracingOptions, spanOptions } } + updatedOptions ); } catch (e) { span.setStatus({ @@ -4505,9 +4457,9 @@ export class ShareFileClient extends StorageClient { size: number, options: FileParallelUploadOptions = {} ): Promise { - const { span, spanOptions } = createSpan( + const { span, updatedOptions } = createSpan( "ShareFileClient-uploadSeekableInternal", - options.tracingOptions + options ); try { if (!options.rangeSize) { @@ -4534,7 +4486,7 @@ export class ShareFileClient extends StorageClient { fileHttpHeaders: options.fileHttpHeaders, metadata: options.metadata, leaseAccessConditions: options.leaseAccessConditions, - tracingOptions: { ...options!.tracingOptions, spanOptions } + tracingOptions: updatedOptions.tracingOptions }); const numBlocks: number = Math.floor((size - 1) / options.rangeSize) + 1; @@ -4550,7 +4502,7 @@ export class ShareFileClient extends StorageClient { await this.uploadRange(bodyFactory(start, contentLength), start, contentLength, { abortSignal: options.abortSignal, leaseAccessConditions: options.leaseAccessConditions, - tracingOptions: { ...options!.tracingOptions, spanOptions } + tracingOptions: updatedOptions.tracingOptions }); // Update progress after block is successfully uploaded to server, in case of block trying transferProgress += contentLength; @@ -4635,9 +4587,9 @@ export class ShareFileClient extends StorageClient { options = (countOrOptions as FileDownloadToBufferOptions) || {}; } - const { span, spanOptions } = createSpan( + const { span, updatedOptions } = createSpan( "ShareFileClient-downloadToBuffer", - options.tracingOptions + options ); try { @@ -4668,7 +4620,7 @@ export class ShareFileClient extends StorageClient { const response = await this.getProperties({ abortSignal: options.abortSignal, leaseAccessConditions: options.leaseAccessConditions, - tracingOptions: { ...options!.tracingOptions, spanOptions } + tracingOptions: updatedOptions.tracingOptions }); count = response.contentLength! - offset; if (count < 0) { @@ -4684,8 +4636,8 @@ export class ShareFileClient extends StorageClient { } catch (error) { throw new Error( `Unable to allocate a buffer of size: ${count} bytes. Please try passing your own Buffer to ` + - 'the "downloadToBuffer method or try using other methods like "download" or "downloadToFile".' + - `\t ${error.message}` + 'the "downloadToBuffer method or try using other methods like "download" or "downloadToFile".' + + `\t ${error.message}` ); } } @@ -4709,7 +4661,7 @@ export class ShareFileClient extends StorageClient { abortSignal: options.abortSignal, maxRetryRequests: options.maxRetryRequestsPerRange, leaseAccessConditions: options.leaseAccessConditions, - tracingOptions: { ...options!.tracingOptions, spanOptions } + tracingOptions: updatedOptions.tracingOptions }); const stream = response.readableStreamBody!; await streamToBuffer(stream, buffer!, off - offset, chunkEnd - offset); @@ -4763,9 +4715,9 @@ export class ShareFileClient extends StorageClient { maxBuffers: number, options: FileUploadStreamOptions = {} ): Promise { - const { span, spanOptions } = createSpan( + const { span, updatedOptions } = createSpan( "ShareFileClient-uploadStream", - options.tracingOptions + options ); try { if (!options.fileHttpHeaders) { @@ -4786,7 +4738,7 @@ export class ShareFileClient extends StorageClient { fileHttpHeaders: options.fileHttpHeaders, metadata: options.metadata, leaseAccessConditions: options.leaseAccessConditions, - tracingOptions: { ...options!.tracingOptions, spanOptions } + tracingOptions: updatedOptions.tracingOptions }); let transferProgress: number = 0; @@ -4798,14 +4750,14 @@ export class ShareFileClient extends StorageClient { if (transferProgress + buffer.length > size) { throw new RangeError( `Stream size is larger than file size ${size} bytes, uploading failed. ` + - `Please make sure stream length is less or equal than file size.` + `Please make sure stream length is less or equal than file size.` ); } await this.uploadRange(buffer, offset!, buffer.length, { abortSignal: options.abortSignal, leaseAccessConditions: options.leaseAccessConditions, - tracingOptions: { ...options!.tracingOptions, spanOptions } + tracingOptions: updatedOptions.tracingOptions }); // Update progress after block is successfully uploaded to server, in case of block trying @@ -4854,15 +4806,12 @@ export class ShareFileClient extends StorageClient { count?: number, options: FileDownloadOptions = {} ): Promise { - const { span, spanOptions } = createSpan( + const { span, updatedOptions } = createSpan( "ShareFileClient-downloadToFile", - options.tracingOptions + options ); try { - const response = await this.download(offset, count, { - ...options, - tracingOptions: { ...options!.tracingOptions, spanOptions } - }); + const response = await this.download(offset, count, updatedOptions); if (response.readableStreamBody) { await readStreamToLocalFile(response.readableStreamBody, filePath); } @@ -4896,9 +4845,9 @@ export class ShareFileClient extends StorageClient { marker?: string, options: FileListHandlesSegmentOptions = {} ): Promise { - const { span, spanOptions } = createSpan( + const { span, updatedOptions } = createSpan( "ShareFileClient-listHandlesSegment", - options.tracingOptions + options ); try { marker = marker === "" ? undefined : marker; @@ -4906,7 +4855,7 @@ export class ShareFileClient extends StorageClient { abortSignal: options.abortSignal, marker, ...options, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) }); // TODO: Protocol layer issue that when handle list is in returned XML @@ -5023,16 +4972,16 @@ export class ShareFileClient extends StorageClient { marker?: string, options: FileForceCloseHandlesOptions = {} ): Promise { - const { span, spanOptions } = createSpan( + const { span, updatedOptions } = createSpan( "ShareFileClient-forceCloseHandlesSegment", - options.tracingOptions + options ); try { marker = marker === "" ? undefined : marker; const rawResponse = await this.context.forceCloseHandles("*", { abortSignal: options.abortSignal, marker, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) }); const response = rawResponse as FileForceCloseHandlesResponse; response.closedHandlesCount = rawResponse.numberOfHandlesClosed || 0; @@ -5058,9 +5007,9 @@ export class ShareFileClient extends StorageClient { public async forceCloseAllHandles( options: FileForceCloseHandlesOptions = {} ): Promise { - const { span, spanOptions } = createSpan( + const { span, updatedOptions } = createSpan( "ShareFileClient-forceCloseAllHandles", - options.tracingOptions + options ); try { let handlesClosed = 0; @@ -5070,7 +5019,7 @@ export class ShareFileClient extends StorageClient { do { const response: FileForceCloseHandlesResponse = await this.forceCloseHandlesSegment( marker, - { tracingOptions: { ...options!.tracingOptions, spanOptions } } + { tracingOptions: updatedOptions.tracingOptions } ); marker = response.marker; response.closedHandlesCount && (handlesClosed += response.closedHandlesCount); @@ -5104,9 +5053,9 @@ export class ShareFileClient extends StorageClient { handleId: string, options: FileForceCloseHandlesOptions = {} ): Promise { - const { span, spanOptions } = createSpan( + const { span, updatedOptions } = createSpan( "ShareFileClient-forceCloseHandle", - options.tracingOptions + options ); try { if (handleId === "*") { @@ -5117,7 +5066,7 @@ export class ShareFileClient extends StorageClient { const rawResponse = await this.context.forceCloseHandles(handleId, { abortSignal: options.abortSignal, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) }); const response = rawResponse as FileForceCloseHandlesResponse; response.closedHandlesCount = rawResponse.numberOfHandlesClosed || 0; @@ -5311,16 +5260,16 @@ export class ShareLeaseClient { duration: number = -1, options: LeaseOperationOptions = {} ): Promise { - const { span, spanOptions } = createSpan( + const { span, updatedOptions } = createSpan( "ShareLeaseClient-acquireLease", - options.tracingOptions + options ); try { return await this.fileOrShare.acquireLease({ abortSignal: options.abortSignal, duration, proposedLeaseId: this._leaseId, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) }); } catch (e) { span.setStatus({ @@ -5344,15 +5293,15 @@ export class ShareLeaseClient { proposedLeaseId: string, options: LeaseOperationOptions = {} ): Promise { - const { span, spanOptions } = createSpan( + const { span, updatedOptions } = createSpan( "ShareLeaseClient-changeLease", - options.tracingOptions + options ); try { const response = await this.fileOrShare.changeLease(this._leaseId, { proposedLeaseId, abortSignal: options.abortSignal, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) }); this._leaseId = proposedLeaseId; return response; @@ -5375,14 +5324,14 @@ export class ShareLeaseClient { * @returns Response data for release lease operation. */ public async releaseLease(options: LeaseOperationOptions = {}): Promise { - const { span, spanOptions } = createSpan( + const { span, updatedOptions } = createSpan( "ShareLeaseClient-releaseLease", - options.tracingOptions + options ); try { return await this.fileOrShare.releaseLease(this._leaseId, { abortSignal: options.abortSignal, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) }); } catch (e) { span.setStatus({ @@ -5402,11 +5351,11 @@ export class ShareLeaseClient { * @returns Response data for break lease operation. */ public async breakLease(options: LeaseOperationOptions = {}): Promise { - const { span, spanOptions } = createSpan("ShareLeaseClient-breakLease", options.tracingOptions); + const { span, updatedOptions } = createSpan("ShareLeaseClient-breakLease", options); try { return await this.fileOrShare.breakLease({ abortSignal: options.abortSignal, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) }); } catch (e) { span.setStatus({ @@ -5428,7 +5377,7 @@ export class ShareLeaseClient { * @returns Response data for renew lease operation. */ public async renewLease(options: LeaseOperationOptions = {}): Promise { - const { span, spanOptions } = createSpan("ShareLeaseClient-renewLease", options.tracingOptions); + const { span, updatedOptions } = createSpan("ShareLeaseClient-renewLease", options); if (!this.isShare) { throw new RangeError("The renewLease operation is not available for lease on file."); @@ -5437,7 +5386,7 @@ export class ShareLeaseClient { try { return await (this.fileOrShare as Share).renewLease(this._leaseId, { abortSignal: options.abortSignal, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) }); } catch (e) { span.setStatus({ diff --git a/sdk/storage/storage-file-share/src/ShareServiceClient.ts b/sdk/storage/storage-file-share/src/ShareServiceClient.ts index f9d7cb272ac6..712a141ffe42 100644 --- a/sdk/storage/storage-file-share/src/ShareServiceClient.ts +++ b/sdk/storage/storage-file-share/src/ShareServiceClient.ts @@ -26,7 +26,7 @@ import "@azure/core-paging"; import { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging"; import { isNode, HttpResponse } from "@azure/core-http"; import { CanonicalCode } from "@opentelemetry/api"; -import { createSpan } from "./utils/tracing"; +import { convertTracingToRequestOptionsBase, createSpan } from "./utils/tracing"; import { ShareProtocols, toShareProtocols } from "./models"; import { AccountSASPermissions } from "./AccountSASPermissions"; import { generateAccountSASQueryParameters } from "./AccountSASSignatureValues"; @@ -335,16 +335,13 @@ export class ShareServiceClient extends StorageClient { shareName: string, options: ShareCreateOptions = {} ): Promise<{ shareCreateResponse: ShareCreateResponse; shareClient: ShareClient }> { - const { span, spanOptions } = createSpan( + const { span, updatedOptions } = createSpan( "ShareServiceClient-createShare", - options.tracingOptions + options ); try { const shareClient = this.getShareClient(shareName); - const shareCreateResponse = await shareClient.create({ - ...options, - tracingOptions: { ...options!.tracingOptions, spanOptions } - }); + const shareCreateResponse = await shareClient.create(updatedOptions); return { shareCreateResponse, shareClient @@ -371,16 +368,13 @@ export class ShareServiceClient extends StorageClient { shareName: string, options: ShareDeleteMethodOptions = {} ): Promise { - const { span, spanOptions } = createSpan( + const { span, updatedOptions } = createSpan( "ShareServiceClient-deleteShare", - options.tracingOptions + options ); try { const shareClient = this.getShareClient(shareName); - return await shareClient.delete({ - ...options, - tracingOptions: { ...options!.tracingOptions, spanOptions } - }); + return await shareClient.delete(updatedOptions); } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, @@ -403,14 +397,14 @@ export class ShareServiceClient extends StorageClient { public async getProperties( options: ServiceGetPropertiesOptions = {} ): Promise { - const { span, spanOptions } = createSpan( + const { span, updatedOptions } = createSpan( "ShareServiceClient-getProperties", - options.tracingOptions + options ); try { return await this.serviceContext.getProperties({ abortSignal: options.abortSignal, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) }); } catch (e) { span.setStatus({ @@ -436,14 +430,14 @@ export class ShareServiceClient extends StorageClient { properties: FileServiceProperties, options: ServiceSetPropertiesOptions = {} ): Promise { - const { span, spanOptions } = createSpan( + const { span, updatedOptions } = createSpan( "ShareServiceClient-setProperties", - options.tracingOptions + options ); try { return await this.serviceContext.setProperties(properties, { abortSignal: options.abortSignal, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) }); } catch (e) { span.setStatus({ @@ -645,9 +639,9 @@ export class ShareServiceClient extends StorageClient { marker?: string, options: ServiceListSharesSegmentOptions = {} ): Promise { - const { span, spanOptions } = createSpan( + const { span, updatedOptions } = createSpan( "ShareServiceClient-listSharesSegment", - options.tracingOptions + options ); if (options.prefix === "") { @@ -658,7 +652,7 @@ export class ShareServiceClient extends StorageClient { const res = await this.serviceContext.listSharesSegment({ marker, ...options, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) }); // parse protocols @@ -696,9 +690,9 @@ export class ShareServiceClient extends StorageClient { deletedShareVersion: string, options: ServiceUndeleteShareOptions = {} ): Promise { - const { span, spanOptions } = createSpan( + const { span, updatedOptions } = createSpan( "ShareServiceClient-undeleteShare", - options.tracingOptions + options ); try { const shareClient = this.getShareClient(deletedShareName); @@ -706,7 +700,7 @@ export class ShareServiceClient extends StorageClient { deletedShareName: deletedShareName, deletedShareVersion: deletedShareVersion, aborterSignal: options.abortSignal, - spanOptions + ...convertTracingToRequestOptionsBase(updatedOptions) }); return shareClient; } catch (e) { diff --git a/sdk/storage/storage-file-share/src/utils/tracing.ts b/sdk/storage/storage-file-share/src/utils/tracing.ts index f803ba5acffb..2ad2f29025b9 100644 --- a/sdk/storage/storage-file-share/src/utils/tracing.ts +++ b/sdk/storage/storage-file-share/src/utils/tracing.ts @@ -1,6 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. +import { OperationOptions, RequestOptionsBase } from "@azure/core-http"; import { createSpanFunction } from "@azure/core-tracing"; /** @@ -11,3 +12,18 @@ export const createSpan = createSpanFunction({ packagePrefix: "Azure.Storage.File", namespace: "Microsoft.Storage" }); + +/** + * @internal + * + * Adapt the tracing options from OperationOptions to what they need to be for + * RequestOptionsBase (when we update to later OpenTelemetry versions this is now + * two separate fields, not just one). + */ +export function convertTracingToRequestOptionsBase( + options?: OperationOptions +): Pick { + return { + spanOptions: options?.tracingOptions?.spanOptions + }; +} From 4bd53630cc1ee5c92bf100c13e9a53664943cb21 Mon Sep 17 00:00:00 2001 From: Richard Park <51494936+richardpark-msft@users.noreply.github.com> Date: Sat, 20 Feb 2021 06:15:47 +0000 Subject: [PATCH 24/52] Formatting --- sdk/storage/storage-file-share/src/Clients.ts | 214 +++++------------- .../src/ShareServiceClient.ts | 30 +-- 2 files changed, 62 insertions(+), 182 deletions(-) diff --git a/sdk/storage/storage-file-share/src/Clients.ts b/sdk/storage/storage-file-share/src/Clients.ts index 901310387384..d5ed2701023b 100644 --- a/sdk/storage/storage-file-share/src/Clients.ts +++ b/sdk/storage/storage-file-share/src/Clients.ts @@ -338,24 +338,24 @@ export interface SignedIdentifier { export declare type ShareGetAccessPolicyResponse = { signedIdentifiers: SignedIdentifier[]; } & ShareGetAccessPolicyHeaders & { - /** - * The underlying HTTP response. - */ - _response: HttpResponse & { - /** - * The parsed HTTP response headers. - */ - parsedHeaders: ShareGetAccessPolicyHeaders; - /** - * The response body as text (string format) - */ - bodyAsText: string; /** - * The response body as parsed JSON or XML + * The underlying HTTP response. */ - parsedBody: SignedIdentifierModel[]; + _response: HttpResponse & { + /** + * The parsed HTTP response headers. + */ + parsedHeaders: ShareGetAccessPolicyHeaders; + /** + * The response body as text (string format) + */ + bodyAsText: string; + /** + * The response body as parsed JSON or XML + */ + parsedBody: SignedIdentifierModel[]; + }; }; -}; /** * Options to configure the {@link ShareClient.createSnapshot} operation. @@ -673,10 +673,7 @@ export class ShareClient extends StorageClient { public async createIfNotExists( options: ShareCreateOptions = {} ): Promise { - const { span, updatedOptions } = createSpan( - "ShareClient-createIfNotExists", - options - ); + const { span, updatedOptions } = createSpan("ShareClient-createIfNotExists", options); try { const res = await this.create(updatedOptions); return { @@ -1279,10 +1276,7 @@ export class ShareClient extends StorageClient { filePermission: string, options: ShareCreatePermissionOptions = {} ): Promise { - const { span, updatedOptions } = createSpan( - "ShareClient-createPermission", - options - ); + const { span, updatedOptions } = createSpan("ShareClient-createPermission", options); try { return await this.context.createPermission( { @@ -1380,7 +1374,7 @@ export interface DirectoryCreateOptions extends FileAndDirectoryCreateCommonOpti export interface DirectoryProperties extends FileAndDirectorySetPropertiesCommonOptions, - CommonOptions { + CommonOptions { /** * An implementation of the `AbortSignalLike` interface to signal the request to cancel the operation. * For example, use the @azure/abort-controller to create an `AbortSignal`. @@ -1751,10 +1745,7 @@ export class ShareDirectoryClient extends StorageClient { public async createIfNotExists( options: DirectoryCreateOptions = {} ): Promise { - const { span, updatedOptions } = createSpan( - "ShareDirectoryClient-createIfNotExists", - options - ); + const { span, updatedOptions } = createSpan("ShareDirectoryClient-createIfNotExists", options); try { const res = await this.create(updatedOptions); return { @@ -1793,10 +1784,7 @@ export class ShareDirectoryClient extends StorageClient { public async setProperties( properties: DirectoryProperties = {} ): Promise { - const { span, updatedOptions } = createSpan( - "ShareDirectoryClient-setProperties", - properties - ); + const { span, updatedOptions } = createSpan("ShareDirectoryClient-setProperties", properties); try { properties = validateAndSetDefaultsForFileAndDirectorySetPropertiesCommonOptions(properties); @@ -1858,10 +1846,7 @@ export class ShareDirectoryClient extends StorageClient { directoryClient: ShareDirectoryClient; directoryCreateResponse: DirectoryCreateResponse; }> { - const { span, updatedOptions } = createSpan( - "ShareDirectoryClient-createSubdirectory", - options - ); + const { span, updatedOptions } = createSpan("ShareDirectoryClient-createSubdirectory", options); try { const directoryClient = this.getDirectoryClient(directoryName); const directoryCreateResponse = await directoryClient.create(updatedOptions); @@ -1893,10 +1878,7 @@ export class ShareDirectoryClient extends StorageClient { directoryName: string, options: DirectoryDeleteOptions = {} ): Promise { - const { span, updatedOptions } = createSpan( - "ShareDirectoryClient-deleteSubdirectory", - options - ); + const { span, updatedOptions } = createSpan("ShareDirectoryClient-deleteSubdirectory", options); try { const directoryClient = this.getDirectoryClient(directoryName); return await directoryClient.delete(updatedOptions); @@ -1925,10 +1907,7 @@ export class ShareDirectoryClient extends StorageClient { size: number, options: FileCreateOptions = {} ): Promise<{ fileClient: ShareFileClient; fileCreateResponse: FileCreateResponse }> { - const { span, updatedOptions } = createSpan( - "ShareDirectoryClient-createFile", - options - ); + const { span, updatedOptions } = createSpan("ShareDirectoryClient-createFile", options); try { const fileClient = this.getFileClient(fileName); const fileCreateResponse = await fileClient.create(size, updatedOptions); @@ -1969,10 +1948,7 @@ export class ShareDirectoryClient extends StorageClient { fileName: string, options: FileDeleteOptions = {} ): Promise { - const { span, updatedOptions } = createSpan( - "ShareDirectoryClient-deleteFile", - options - ); + const { span, updatedOptions } = createSpan("ShareDirectoryClient-deleteFile", options); try { const fileClient = this.getFileClient(fileName); return await fileClient.delete(updatedOptions); @@ -2064,10 +2040,7 @@ export class ShareDirectoryClient extends StorageClient { public async getProperties( options: DirectoryGetPropertiesOptions = {} ): Promise { - const { span, updatedOptions } = createSpan( - "ShareDirectoryClient-getProperties", - options - ); + const { span, updatedOptions } = createSpan("ShareDirectoryClient-getProperties", options); try { return await this.context.getProperties({ abortSignal: options.abortSignal, @@ -2120,10 +2093,7 @@ export class ShareDirectoryClient extends StorageClient { public async deleteIfExists( options: DirectoryDeleteOptions = {} ): Promise { - const { span, updatedOptions } = createSpan( - "ShareDirectoryClient-deleteIfExists", - options - ); + const { span, updatedOptions } = createSpan("ShareDirectoryClient-deleteIfExists", options); try { const res = await this.delete(updatedOptions); return { @@ -2167,10 +2137,7 @@ export class ShareDirectoryClient extends StorageClient { metadata?: Metadata, options: DirectorySetMetadataOptions = {} ): Promise { - const { span, updatedOptions } = createSpan( - "ShareDirectoryClient-setMetadata", - options - ); + const { span, updatedOptions } = createSpan("ShareDirectoryClient-setMetadata", options); try { return await this.context.setMetadata({ abortSignal: options.abortSignal, @@ -2573,10 +2540,7 @@ export class ShareDirectoryClient extends StorageClient { marker?: string, options: DirectoryListHandlesSegmentOptions = {} ): Promise { - const { span, updatedOptions } = createSpan( - "ShareDirectoryClient-listHandlesSegment", - options - ); + const { span, updatedOptions } = createSpan("ShareDirectoryClient-listHandlesSegment", options); try { marker = marker === "" ? undefined : marker; const response = await this.context.listHandles({ @@ -2697,10 +2661,7 @@ export class ShareDirectoryClient extends StorageClient { handleId: string, options: DirectoryForceCloseHandlesOptions = {} ): Promise { - const { span, updatedOptions } = createSpan( - "ShareDirectoryClient-forceCloseHandle", - options - ); + const { span, updatedOptions } = createSpan("ShareDirectoryClient-forceCloseHandle", options); try { if (handleId === "*") { throw new RangeError( @@ -2768,7 +2729,7 @@ export interface FileProperties extends FileAndDirectorySetPropertiesCommonOptio leaseAccessConditions?: LeaseAccessConditions; } -export interface SetPropertiesResponse extends FileSetHTTPHeadersResponse { } +export interface SetPropertiesResponse extends FileSetHTTPHeadersResponse {} /** * Options to configure the {@link ShareFileClient.delete} operation. @@ -3039,7 +3000,7 @@ export interface FileSetMetadataOptions extends CommonOptions { */ export interface FileSetHttpHeadersOptions extends FileAndDirectorySetPropertiesCommonOptions, - CommonOptions { + CommonOptions { /** * An implementation of the `AbortSignalLike` interface to signal the request to cancel the operation. * For example, use the @azure/abort-controller to create an `AbortSignal`. @@ -3071,7 +3032,7 @@ export interface FileAbortCopyFromURLOptions extends CommonOptions { */ export interface FileResizeOptions extends FileAndDirectorySetPropertiesCommonOptions, - CommonOptions { + CommonOptions { /** * An implementation of the `AbortSignalLike` interface to signal the request to cancel the operation. * For example, use the @azure/abort-controller to create an `AbortSignal`. @@ -3693,10 +3654,7 @@ export class ShareFileClient extends StorageClient { public async getProperties( options: FileGetPropertiesOptions = {} ): Promise { - const { span, updatedOptions } = createSpan( - "ShareFileClient-getProperties", - options - ); + const { span, updatedOptions } = createSpan("ShareFileClient-getProperties", options); try { return this.context.getProperties({ abortSignal: options.abortSignal, @@ -3724,10 +3682,7 @@ export class ShareFileClient extends StorageClient { * existing values will be preserved. */ public async setProperties(properties: FileProperties = {}): Promise { - const { span, updatedOptions } = createSpan( - "ShareFileClient-setProperties", - properties - ); + const { span, updatedOptions } = createSpan("ShareFileClient-setProperties", properties); try { properties = validateAndSetDefaultsForFileAndDirectorySetPropertiesCommonOptions(properties); @@ -3812,10 +3767,7 @@ export class ShareFileClient extends StorageClient { public async deleteIfExists( options: FileDeleteOptions = {} ): Promise { - const { span, updatedOptions } = createSpan( - "ShareFileClient-deleteIfExists", - options - ); + const { span, updatedOptions } = createSpan("ShareFileClient-deleteIfExists", options); try { const res = await this.delete(updatedOptions); return { @@ -3863,10 +3815,7 @@ export class ShareFileClient extends StorageClient { fileHttpHeaders: FileHttpHeaders = {}, options: FileSetHttpHeadersOptions = {} ): Promise { - const { span, updatedOptions } = createSpan( - "ShareFileClient-setHTTPHeaders", - options - ); + const { span, updatedOptions } = createSpan("ShareFileClient-setHTTPHeaders", options); try { // FileAttributes, filePermission, createTime, lastWriteTime will all be preserved options = validateAndSetDefaultsForFileAndDirectorySetPropertiesCommonOptions(options); @@ -4063,10 +4012,7 @@ export class ShareFileClient extends StorageClient { count: number, options: FileUploadRangeFromURLOptions = {} ): Promise { - const { span, updatedOptions } = createSpan( - "ShareFileClient-uploadRangeFromURL", - options - ); + const { span, updatedOptions } = createSpan("ShareFileClient-uploadRangeFromURL", options); try { if (sourceOffset < 0 || destOffset < 0) { throw new RangeError(`sourceOffset and destOffset must be >= 0`); @@ -4146,10 +4092,7 @@ export class ShareFileClient extends StorageClient { public async getRangeList( options: FileGetRangeListOptions = {} ): Promise { - const { span, updatedOptions } = createSpan( - "ShareFileClient-getRangeList", - options - ); + const { span, updatedOptions } = createSpan("ShareFileClient-getRangeList", options); try { const originalResponse = await this.context.getRangeList({ abortSignal: options.abortSignal, @@ -4188,10 +4131,7 @@ export class ShareFileClient extends StorageClient { prevShareSnapshot: string, options: FileGetRangeListOptions = {} ): Promise { - const { span, updatedOptions } = createSpan( - "ShareFileClient-getRangeListDiff", - options - ); + const { span, updatedOptions } = createSpan("ShareFileClient-getRangeListDiff", options); try { return await this.context.getRangeList({ prevsharesnapshot: prevShareSnapshot, @@ -4226,10 +4166,7 @@ export class ShareFileClient extends StorageClient { copySource: string, options: FileStartCopyOptions = {} ): Promise { - const { span, updatedOptions } = createSpan( - "ShareFileClient-startCopyFromURL", - options - ); + const { span, updatedOptions } = createSpan("ShareFileClient-startCopyFromURL", options); try { return await this.context.startCopy(copySource, { abortSignal: options.abortSignal, @@ -4263,10 +4200,7 @@ export class ShareFileClient extends StorageClient { copyId: string, options: FileAbortCopyFromURLOptions = {} ): Promise { - const { span, updatedOptions } = createSpan( - "ShareFileClient-abortCopyFromURL", - options - ); + const { span, updatedOptions } = createSpan("ShareFileClient-abortCopyFromURL", options); try { return await this.context.abortCopy(copyId, { abortSignal: options.abortSignal, @@ -4348,10 +4282,7 @@ export class ShareFileClient extends StorageClient { size: number, options: FileParallelUploadOptions = {} ): Promise { - const { span, updatedOptions } = createSpan( - "ShareFileClient-UploadSeekableBlob", - options - ); + const { span, updatedOptions } = createSpan("ShareFileClient-UploadSeekableBlob", options); try { return this.uploadSeekableInternal(blobFactory, size, updatedOptions); } catch (e) { @@ -4422,10 +4353,7 @@ export class ShareFileClient extends StorageClient { size: number, options: FileParallelUploadOptions = {} ): Promise { - const { span, updatedOptions } = createSpan( - "ShareFileClient-uploadResetableStream", - options - ); + const { span, updatedOptions } = createSpan("ShareFileClient-uploadResetableStream", options); try { return await this.uploadSeekableInternal( (offset: number, count?: number) => { @@ -4457,10 +4385,7 @@ export class ShareFileClient extends StorageClient { size: number, options: FileParallelUploadOptions = {} ): Promise { - const { span, updatedOptions } = createSpan( - "ShareFileClient-uploadSeekableInternal", - options - ); + const { span, updatedOptions } = createSpan("ShareFileClient-uploadSeekableInternal", options); try { if (!options.rangeSize) { options.rangeSize = FILE_RANGE_MAX_SIZE_BYTES; @@ -4587,10 +4512,7 @@ export class ShareFileClient extends StorageClient { options = (countOrOptions as FileDownloadToBufferOptions) || {}; } - const { span, updatedOptions } = createSpan( - "ShareFileClient-downloadToBuffer", - options - ); + const { span, updatedOptions } = createSpan("ShareFileClient-downloadToBuffer", options); try { if (!options.rangeSize) { @@ -4636,8 +4558,8 @@ export class ShareFileClient extends StorageClient { } catch (error) { throw new Error( `Unable to allocate a buffer of size: ${count} bytes. Please try passing your own Buffer to ` + - 'the "downloadToBuffer method or try using other methods like "download" or "downloadToFile".' + - `\t ${error.message}` + 'the "downloadToBuffer method or try using other methods like "download" or "downloadToFile".' + + `\t ${error.message}` ); } } @@ -4715,10 +4637,7 @@ export class ShareFileClient extends StorageClient { maxBuffers: number, options: FileUploadStreamOptions = {} ): Promise { - const { span, updatedOptions } = createSpan( - "ShareFileClient-uploadStream", - options - ); + const { span, updatedOptions } = createSpan("ShareFileClient-uploadStream", options); try { if (!options.fileHttpHeaders) { options.fileHttpHeaders = {}; @@ -4750,7 +4669,7 @@ export class ShareFileClient extends StorageClient { if (transferProgress + buffer.length > size) { throw new RangeError( `Stream size is larger than file size ${size} bytes, uploading failed. ` + - `Please make sure stream length is less or equal than file size.` + `Please make sure stream length is less or equal than file size.` ); } @@ -4806,10 +4725,7 @@ export class ShareFileClient extends StorageClient { count?: number, options: FileDownloadOptions = {} ): Promise { - const { span, updatedOptions } = createSpan( - "ShareFileClient-downloadToFile", - options - ); + const { span, updatedOptions } = createSpan("ShareFileClient-downloadToFile", options); try { const response = await this.download(offset, count, updatedOptions); if (response.readableStreamBody) { @@ -4845,10 +4761,7 @@ export class ShareFileClient extends StorageClient { marker?: string, options: FileListHandlesSegmentOptions = {} ): Promise { - const { span, updatedOptions } = createSpan( - "ShareFileClient-listHandlesSegment", - options - ); + const { span, updatedOptions } = createSpan("ShareFileClient-listHandlesSegment", options); try { marker = marker === "" ? undefined : marker; const response = await this.context.listHandles({ @@ -5007,10 +4920,7 @@ export class ShareFileClient extends StorageClient { public async forceCloseAllHandles( options: FileForceCloseHandlesOptions = {} ): Promise { - const { span, updatedOptions } = createSpan( - "ShareFileClient-forceCloseAllHandles", - options - ); + const { span, updatedOptions } = createSpan("ShareFileClient-forceCloseAllHandles", options); try { let handlesClosed = 0; let numberOfHandlesFailedToClose = 0; @@ -5053,10 +4963,7 @@ export class ShareFileClient extends StorageClient { handleId: string, options: FileForceCloseHandlesOptions = {} ): Promise { - const { span, updatedOptions } = createSpan( - "ShareFileClient-forceCloseHandle", - options - ); + const { span, updatedOptions } = createSpan("ShareFileClient-forceCloseHandle", options); try { if (handleId === "*") { throw new RangeError( @@ -5260,10 +5167,7 @@ export class ShareLeaseClient { duration: number = -1, options: LeaseOperationOptions = {} ): Promise { - const { span, updatedOptions } = createSpan( - "ShareLeaseClient-acquireLease", - options - ); + const { span, updatedOptions } = createSpan("ShareLeaseClient-acquireLease", options); try { return await this.fileOrShare.acquireLease({ abortSignal: options.abortSignal, @@ -5293,10 +5197,7 @@ export class ShareLeaseClient { proposedLeaseId: string, options: LeaseOperationOptions = {} ): Promise { - const { span, updatedOptions } = createSpan( - "ShareLeaseClient-changeLease", - options - ); + const { span, updatedOptions } = createSpan("ShareLeaseClient-changeLease", options); try { const response = await this.fileOrShare.changeLease(this._leaseId, { proposedLeaseId, @@ -5324,10 +5225,7 @@ export class ShareLeaseClient { * @returns Response data for release lease operation. */ public async releaseLease(options: LeaseOperationOptions = {}): Promise { - const { span, updatedOptions } = createSpan( - "ShareLeaseClient-releaseLease", - options - ); + const { span, updatedOptions } = createSpan("ShareLeaseClient-releaseLease", options); try { return await this.fileOrShare.releaseLease(this._leaseId, { abortSignal: options.abortSignal, diff --git a/sdk/storage/storage-file-share/src/ShareServiceClient.ts b/sdk/storage/storage-file-share/src/ShareServiceClient.ts index 712a141ffe42..3912992b3dfe 100644 --- a/sdk/storage/storage-file-share/src/ShareServiceClient.ts +++ b/sdk/storage/storage-file-share/src/ShareServiceClient.ts @@ -335,10 +335,7 @@ export class ShareServiceClient extends StorageClient { shareName: string, options: ShareCreateOptions = {} ): Promise<{ shareCreateResponse: ShareCreateResponse; shareClient: ShareClient }> { - const { span, updatedOptions } = createSpan( - "ShareServiceClient-createShare", - options - ); + const { span, updatedOptions } = createSpan("ShareServiceClient-createShare", options); try { const shareClient = this.getShareClient(shareName); const shareCreateResponse = await shareClient.create(updatedOptions); @@ -368,10 +365,7 @@ export class ShareServiceClient extends StorageClient { shareName: string, options: ShareDeleteMethodOptions = {} ): Promise { - const { span, updatedOptions } = createSpan( - "ShareServiceClient-deleteShare", - options - ); + const { span, updatedOptions } = createSpan("ShareServiceClient-deleteShare", options); try { const shareClient = this.getShareClient(shareName); return await shareClient.delete(updatedOptions); @@ -397,10 +391,7 @@ export class ShareServiceClient extends StorageClient { public async getProperties( options: ServiceGetPropertiesOptions = {} ): Promise { - const { span, updatedOptions } = createSpan( - "ShareServiceClient-getProperties", - options - ); + const { span, updatedOptions } = createSpan("ShareServiceClient-getProperties", options); try { return await this.serviceContext.getProperties({ abortSignal: options.abortSignal, @@ -430,10 +421,7 @@ export class ShareServiceClient extends StorageClient { properties: FileServiceProperties, options: ServiceSetPropertiesOptions = {} ): Promise { - const { span, updatedOptions } = createSpan( - "ShareServiceClient-setProperties", - options - ); + const { span, updatedOptions } = createSpan("ShareServiceClient-setProperties", options); try { return await this.serviceContext.setProperties(properties, { abortSignal: options.abortSignal, @@ -639,10 +627,7 @@ export class ShareServiceClient extends StorageClient { marker?: string, options: ServiceListSharesSegmentOptions = {} ): Promise { - const { span, updatedOptions } = createSpan( - "ShareServiceClient-listSharesSegment", - options - ); + const { span, updatedOptions } = createSpan("ShareServiceClient-listSharesSegment", options); if (options.prefix === "") { options.prefix = undefined; @@ -690,10 +675,7 @@ export class ShareServiceClient extends StorageClient { deletedShareVersion: string, options: ServiceUndeleteShareOptions = {} ): Promise { - const { span, updatedOptions } = createSpan( - "ShareServiceClient-undeleteShare", - options - ); + const { span, updatedOptions } = createSpan("ShareServiceClient-undeleteShare", options); try { const shareClient = this.getShareClient(deletedShareName); await new ShareClientInternal(shareClient.url, this.pipeline).restore({ From b9c51e62d18de79067da9c7fe29502ec2b90dfb8 Mon Sep 17 00:00:00 2001 From: Richard Park <51494936+richardpark-msft@users.noreply.github.com> Date: Mon, 22 Feb 2021 19:37:53 +0000 Subject: [PATCH 25/52] Removing export of core-tracing functions from core-client and core-http --- .../core-client/review/core-client.api.md | 10 --- sdk/core/core-client/src/createSpan.ts | 23 ------ sdk/core/core-client/src/index.ts | 1 - sdk/core/core-client/test/createSpan.spec.ts | 82 ------------------- sdk/core/core-http/review/core-http.api.md | 12 --- sdk/core/core-http/src/coreHttp.ts | 1 - sdk/core/core-http/src/createSpan.ts | 23 ------ .../core-tracing/review/core-tracing.api.md | 2 +- sdk/core/core-tracing/src/createSpan.ts | 2 +- 9 files changed, 2 insertions(+), 154 deletions(-) delete mode 100644 sdk/core/core-client/src/createSpan.ts delete mode 100644 sdk/core/core-client/test/createSpan.spec.ts delete mode 100644 sdk/core/core-http/src/createSpan.ts diff --git a/sdk/core/core-client/review/core-client.api.md b/sdk/core/core-client/review/core-client.api.md index 4c798606ea94..d4968686fd4c 100644 --- a/sdk/core/core-client/review/core-client.api.md +++ b/sdk/core/core-client/review/core-client.api.md @@ -13,8 +13,6 @@ import { Pipeline } from '@azure/core-https'; import { PipelinePolicy } from '@azure/core-https'; import { PipelineRequest } from '@azure/core-https'; import { PipelineResponse } from '@azure/core-https'; -import { Span } from '@opentelemetry/api'; -import { SpanConfig as SpanConfig_3 } from '@azure/core-tracing'; import { TokenCredential } from '@azure/core-auth'; import { TransferProgressEvent } from '@azure/core-https'; @@ -78,14 +76,6 @@ export function createSerializer(modelMappers?: { [key: string]: any; }, isXML?: boolean): Serializer; -// Warning: (ae-forgotten-export) The symbol "SpanConfig" needs to be exported by the entry point index.d.ts -// -// @public (undocumented) -export function createSpanFunction(spanConfig: SpanConfig_2): (operationName: string, operationOptions: T) => { - span: Span; - updatedOptions: T; -}; - // @public export interface DeserializationContentTypes { json?: string[]; diff --git a/sdk/core/core-client/src/createSpan.ts b/sdk/core/core-client/src/createSpan.ts deleted file mode 100644 index 3bae5e190a4a..000000000000 --- a/sdk/core/core-client/src/createSpan.ts +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -import { - SpanConfig as coreTracingSpanConfig, - createSpanFunction as coreTracingCreateSpanFunction -} from "@azure/core-tracing"; -import { Span } from "@opentelemetry/api"; -import { OperationOptions } from "./interfaces"; - -export interface SpanConfig extends coreTracingSpanConfig {} - -export function createSpanFunction( - spanConfig: SpanConfig -): ( - operationName: string, - operationOptions: T -) => { - span: Span; - updatedOptions: T; -} { - return coreTracingCreateSpanFunction(spanConfig); -} diff --git a/sdk/core/core-client/src/index.ts b/sdk/core/core-client/src/index.ts index 28a0857a8769..71c454ee303c 100644 --- a/sdk/core/core-client/src/index.ts +++ b/sdk/core/core-client/src/index.ts @@ -2,7 +2,6 @@ // Licensed under the MIT license. export { createSerializer, MapperTypeNames } from "./serializer"; -export { createSpanFunction } from "./createSpan"; export { ServiceClient, ServiceClientOptions } from "./serviceClient"; export { createClientPipeline, ClientPipelineOptions } from "./pipeline"; export { diff --git a/sdk/core/core-client/test/createSpan.spec.ts b/sdk/core/core-client/test/createSpan.spec.ts deleted file mode 100644 index 8d94c7792c2a..000000000000 --- a/sdk/core/core-client/test/createSpan.spec.ts +++ /dev/null @@ -1,82 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -import { assert } from "chai"; -import { SpanKind, TraceFlags } from "@opentelemetry/api"; -import { setTracer, TestSpan, TestTracer } from "@azure/core-tracing"; -import sinon from "sinon"; -import { createSpanFunction } from "../src/createSpan"; -import { OperationOptions } from "../src/interfaces"; - -const createSpan = createSpanFunction({ namespace: "Microsoft.Test", packagePrefix: "Azure.Test" }); - -describe("createSpan", () => { - it("returns a created span with the right metadata", () => { - const tracer = new TestTracer(); - const testSpan = new TestSpan( - tracer, - "testing", - { traceId: "", spanId: "", traceFlags: TraceFlags.NONE }, - SpanKind.INTERNAL - ); - const setAttributeSpy = sinon.spy(testSpan, "setAttribute"); - const startSpanStub = sinon.stub(tracer, "startSpan"); - startSpanStub.returns(testSpan); - setTracer(tracer); - const { span } = createSpan("testMethod", {}); - assert.strictEqual(span, testSpan, "Should return mocked span"); - assert.isTrue(startSpanStub.calledOnce); - const [name, options] = startSpanStub.firstCall.args; - assert.strictEqual(name, "Azure.Test.testMethod"); - assert.deepEqual(options, { kind: SpanKind.INTERNAL }); - assert.isTrue(setAttributeSpy.calledOnceWithExactly("az.namespace", "Microsoft.Test")); - }); - - it("returns updated SpanOptions", () => { - const options: OperationOptions = {}; - const { span, updatedOptions } = createSpan("testMethod", options); - assert.isEmpty(options, "original options should not be modified"); - assert.notStrictEqual(updatedOptions, options, "should return new object"); - const expected: OperationOptions = { - tracingOptions: { - spanOptions: { - parent: span.context(), - attributes: { - "az.namespace": "Microsoft.Test" - } - } - } - }; - assert.deepEqual(updatedOptions, expected); - }); - - it("preserves existing attributes", () => { - const options: OperationOptions = { - tracingOptions: { - spanOptions: { - attributes: { - foo: "bar" - } - } - } - }; - const { span, updatedOptions } = createSpan("testMethod", options); - assert.notStrictEqual(updatedOptions, options, "should return new object"); - const expected: OperationOptions = { - tracingOptions: { - spanOptions: { - parent: span.context(), - attributes: { - "az.namespace": "Microsoft.Test", - foo: "bar" - } - } - } - }; - assert.deepEqual(updatedOptions, expected); - }); - - afterEach(() => { - sinon.restore(); - }); -}); diff --git a/sdk/core/core-http/review/core-http.api.md b/sdk/core/core-http/review/core-http.api.md index 979729484ad2..c9695f771766 100644 --- a/sdk/core/core-http/review/core-http.api.md +++ b/sdk/core/core-http/review/core-http.api.md @@ -10,8 +10,6 @@ import { Debugger } from '@azure/logger'; import { GetTokenOptions } from '@azure/core-auth'; import { isTokenCredential } from '@azure/core-auth'; import { OperationTracingOptions } from '@azure/core-tracing'; -import { Span } from '@opentelemetry/api'; -import { SpanConfig as SpanConfig_2 } from '@azure/core-tracing'; import { SpanOptions } from '@azure/core-tracing'; import { TokenCredential } from '@azure/core-auth'; @@ -158,12 +156,6 @@ export const Constants: { // @public (undocumented) export function createPipelineFromOptions(pipelineOptions: InternalPipelineOptions, authPolicyFactory?: RequestPolicyFactory): ServiceClientOptions; -// @public (undocumented) -export function createSpanFunction(spanConfig: SpanConfig): (operationName: string, operationOptions: T) => { - span: Span; - updatedOptions: T; -}; - // Warning: (ae-forgotten-export) The symbol "FetchHttpClient" needs to be exported by the entry point coreHttp.d.ts // // @public (undocumented) @@ -799,10 +791,6 @@ export interface SimpleMapperType { name: "Base64Url" | "Boolean" | "ByteArray" | "Date" | "DateTime" | "DateTimeRfc1123" | "Object" | "Stream" | "String" | "TimeSpan" | "UnixTime" | "Uuid" | "Number" | "any"; } -// @public (undocumented) -export interface SpanConfig extends SpanConfig_2 { -} - // @public export function stringifyXML(obj: unknown, opts?: SerializerOptions): string; diff --git a/sdk/core/core-http/src/coreHttp.ts b/sdk/core/core-http/src/coreHttp.ts index 0d0d2d279204..e9809d3f9205 100644 --- a/sdk/core/core-http/src/coreHttp.ts +++ b/sdk/core/core-http/src/coreHttp.ts @@ -43,7 +43,6 @@ export { ProxySettings, ProxyOptions } from "./serviceClient"; -export { createSpanFunction, SpanConfig } from "./createSpan"; export { PipelineOptions, InternalPipelineOptions } from "./pipelineOptions"; export { QueryCollectionFormat } from "./queryCollectionFormat"; export { Constants } from "./util/constants"; diff --git a/sdk/core/core-http/src/createSpan.ts b/sdk/core/core-http/src/createSpan.ts deleted file mode 100644 index 6587deab716a..000000000000 --- a/sdk/core/core-http/src/createSpan.ts +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -import { - SpanConfig as coreTracingSpanConfig, - createSpanFunction as coreTracingCreateSpanFunction -} from "@azure/core-tracing"; -import { Span } from "@opentelemetry/api"; -import { OperationOptions } from "./operationOptions"; - -export interface SpanConfig extends coreTracingSpanConfig {} - -export function createSpanFunction( - spanConfig: SpanConfig -): ( - operationName: string, - operationOptions: T -) => { - span: Span; - updatedOptions: T; -} { - return coreTracingCreateSpanFunction(spanConfig); -} diff --git a/sdk/core/core-tracing/review/core-tracing.api.md b/sdk/core/core-tracing/review/core-tracing.api.md index f93e4e42cfd7..1e87b2a8d22d 100644 --- a/sdk/core/core-tracing/review/core-tracing.api.md +++ b/sdk/core/core-tracing/review/core-tracing.api.md @@ -19,7 +19,7 @@ import { TracerBase } from '@opencensus/web-types'; // @public export function createSpanFunction({ packagePrefix, namespace }: SpanConfig): (operationName: string, operationOptions: T) => { +}>(operationName: string, operationOptions: T) => { span: Span; updatedOptions: T; }; diff --git a/sdk/core/core-tracing/src/createSpan.ts b/sdk/core/core-tracing/src/createSpan.ts index 6dae79c2d16c..ed36d17255c2 100644 --- a/sdk/core/core-tracing/src/createSpan.ts +++ b/sdk/core/core-tracing/src/createSpan.ts @@ -27,7 +27,7 @@ export interface SpanConfig { * @param tracingOptions - The options for the underlying http request. */ export function createSpanFunction({ packagePrefix, namespace }: SpanConfig) { - return function( + return function ( operationName: string, operationOptions: T ): { span: Span; updatedOptions: T } { From 6365b721ee334abe01c2f2ee22db363be07a26af Mon Sep 17 00:00:00 2001 From: Richard Park <51494936+richardpark-msft@users.noreply.github.com> Date: Mon, 22 Feb 2021 19:38:08 +0000 Subject: [PATCH 26/52] Formatting --- sdk/core/core-tracing/src/createSpan.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/core/core-tracing/src/createSpan.ts b/sdk/core/core-tracing/src/createSpan.ts index ed36d17255c2..5d65f1087b9b 100644 --- a/sdk/core/core-tracing/src/createSpan.ts +++ b/sdk/core/core-tracing/src/createSpan.ts @@ -27,7 +27,7 @@ export interface SpanConfig { * @param tracingOptions - The options for the underlying http request. */ export function createSpanFunction({ packagePrefix, namespace }: SpanConfig) { - return function ( + return function( operationName: string, operationOptions: T ): { span: Span; updatedOptions: T } { From 4b0e99ef35a33201d0a39147088f0202257fb09f Mon Sep 17 00:00:00 2001 From: Richard Park <51494936+richardpark-msft@users.noreply.github.com> Date: Mon, 22 Feb 2021 22:14:59 +0000 Subject: [PATCH 27/52] - createSpa now guarantees it's return value is not null (eliminates some more code doing || {} - synapse-artifacts: fixing a .tracingOptions slicing issue where RequestOptionsBase was being passed to createSpan, which expected an OperationOptions. --- .../core-tracing/review/core-tracing.api.md | 4 +- sdk/core/core-tracing/src/createSpan.ts | 8 ++-- sdk/synapse/synapse-artifacts/package.json | 3 +- .../src/operations/bigDataPools.ts | 11 ++--- .../src/operations/dataFlow.ts | 24 +++++------ .../src/operations/dataFlowDebugSession.ts | 24 +++++------ .../src/operations/dataset.ts | 24 +++++------ .../src/operations/integrationRuntimes.ts | 8 ++-- .../src/operations/library.ts | 28 ++++++------- .../src/operations/linkedService.ts | 24 +++++------ .../src/operations/notebook.ts | 32 +++++++-------- .../src/operations/pipeline.ts | 28 ++++++------- .../src/operations/pipelineRun.ts | 16 ++++---- .../src/operations/sparkJobDefinition.ts | 32 +++++++-------- .../src/operations/sqlPools.ts | 8 ++-- .../src/operations/sqlScript.ts | 24 +++++------ .../src/operations/trigger.ts | 40 +++++++++---------- .../src/operations/triggerRun.ts | 12 +++--- .../src/operations/workspace.ts | 4 +- .../operations/workspaceGitRepoManagement.ts | 4 +- sdk/synapse/synapse-artifacts/src/tracing.ts | 2 +- 21 files changed, 181 insertions(+), 179 deletions(-) diff --git a/sdk/core/core-tracing/review/core-tracing.api.md b/sdk/core/core-tracing/review/core-tracing.api.md index 1e87b2a8d22d..ece7cfd5715c 100644 --- a/sdk/core/core-tracing/review/core-tracing.api.md +++ b/sdk/core/core-tracing/review/core-tracing.api.md @@ -19,9 +19,9 @@ import { TracerBase } from '@opencensus/web-types'; // @public export function createSpanFunction({ packagePrefix, namespace }: SpanConfig): (operationName: string, operationOptions: T) => { +} | undefined>(operationName: string, operationOptions: T) => { span: Span; - updatedOptions: T; + updatedOptions: NonNullable; }; // @public diff --git a/sdk/core/core-tracing/src/createSpan.ts b/sdk/core/core-tracing/src/createSpan.ts index 5d65f1087b9b..fc7b0c204d6f 100644 --- a/sdk/core/core-tracing/src/createSpan.ts +++ b/sdk/core/core-tracing/src/createSpan.ts @@ -27,10 +27,10 @@ export interface SpanConfig { * @param tracingOptions - The options for the underlying http request. */ export function createSpanFunction({ packagePrefix, namespace }: SpanConfig) { - return function( + return function ( operationName: string, operationOptions: T - ): { span: Span; updatedOptions: T } { + ): { span: Span; updatedOptions: NonNullable } { const tracer = getTracer(); const tracingOptions = operationOptions?.tracingOptions || {}; const spanOptions: SpanOptions = { @@ -60,10 +60,10 @@ export function createSpanFunction({ packagePrefix, namespace }: SpanConfig) { // TODO: .context soon. }; - const newOperationOptions: T = { + const newOperationOptions: NonNullable = { ...operationOptions, tracingOptions: newTracingOptions - }; + } as NonNullable; return { span, diff --git a/sdk/synapse/synapse-artifacts/package.json b/sdk/synapse/synapse-artifacts/package.json index 268864491bd6..1e548c105fa1 100644 --- a/sdk/synapse/synapse-artifacts/package.json +++ b/sdk/synapse/synapse-artifacts/package.json @@ -10,6 +10,7 @@ "@azure/core-lro": "^1.0.2", "@azure/core-paging": "^1.1.1", "@azure/core-http": "^1.2.0", + "@azure/core-tracing": "1.0.0-preview.10", "@opentelemetry/api": "^0.10.2", "tslib": "^2.0.0" }, @@ -78,4 +79,4 @@ }, "sideEffects": false, "autoPublish": true -} +} \ No newline at end of file diff --git a/sdk/synapse/synapse-artifacts/src/operations/bigDataPools.ts b/sdk/synapse/synapse-artifacts/src/operations/bigDataPools.ts index 6d2569067c71..b421ce47e48a 100644 --- a/sdk/synapse/synapse-artifacts/src/operations/bigDataPools.ts +++ b/sdk/synapse/synapse-artifacts/src/operations/bigDataPools.ts @@ -27,10 +27,10 @@ export class BigDataPools { async list(options?: coreHttp.OperationOptions): Promise { const { span, updatedOptions } = createSpan( "ArtifactsClient-list", - coreHttp.operationOptionsToRequestOptionsBase(options || {}) - ); + options); + const operationArguments: coreHttp.OperationArguments = { - options: updatedOptions + options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) }; try { const result = await this.client.sendOperationRequest(operationArguments, listOperationSpec); @@ -57,11 +57,12 @@ export class BigDataPools { ): Promise { const { span, updatedOptions } = createSpan( "ArtifactsClient-get", - coreHttp.operationOptionsToRequestOptionsBase(options || {}) + options ); + const operationArguments: coreHttp.OperationArguments = { bigDataPoolName, - options: updatedOptions + options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) }; try { const result = await this.client.sendOperationRequest(operationArguments, getOperationSpec); diff --git a/sdk/synapse/synapse-artifacts/src/operations/dataFlow.ts b/sdk/synapse/synapse-artifacts/src/operations/dataFlow.ts index bf0a7b5dab4e..510658c6b396 100644 --- a/sdk/synapse/synapse-artifacts/src/operations/dataFlow.ts +++ b/sdk/synapse/synapse-artifacts/src/operations/dataFlow.ts @@ -86,12 +86,12 @@ export class DataFlow { ): Promise> { const { span, updatedOptions } = createSpan( "ArtifactsClient-createOrUpdateDataFlow", - this.getOperationOptions(options, "undefined") + options ); const operationArguments: coreHttp.OperationArguments = { dataFlowName, dataFlow, - options: updatedOptions + options: this.getOperationOptions(updatedOptions, "undefined") }; const sendOperation = async ( args: coreHttp.OperationArguments, @@ -134,11 +134,11 @@ export class DataFlow { ): Promise { const { span, updatedOptions } = createSpan( "ArtifactsClient-getDataFlow", - coreHttp.operationOptionsToRequestOptionsBase(options || {}) + options ); const operationArguments: coreHttp.OperationArguments = { dataFlowName, - options: updatedOptions + options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) }; try { const result = await this.client.sendOperationRequest( @@ -168,11 +168,11 @@ export class DataFlow { ): Promise> { const { span, updatedOptions } = createSpan( "ArtifactsClient-deleteDataFlow", - this.getOperationOptions(options, "undefined") + options ); const operationArguments: coreHttp.OperationArguments = { dataFlowName, - options: updatedOptions + options: this.getOperationOptions(updatedOptions, "undefined") }; const sendOperation = async ( args: coreHttp.OperationArguments, @@ -217,12 +217,12 @@ export class DataFlow { ): Promise> { const { span, updatedOptions } = createSpan( "ArtifactsClient-renameDataFlow", - this.getOperationOptions(options, "undefined") + options ); const operationArguments: coreHttp.OperationArguments = { dataFlowName, request, - options: updatedOptions + options: this.getOperationOptions(updatedOptions, "undefined") }; const sendOperation = async ( args: coreHttp.OperationArguments, @@ -263,10 +263,10 @@ export class DataFlow { ): Promise { const { span, updatedOptions } = createSpan( "ArtifactsClient-_getDataFlowsByWorkspace", - coreHttp.operationOptionsToRequestOptionsBase(options || {}) + options ); const operationArguments: coreHttp.OperationArguments = { - options: updatedOptions + options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) }; try { const result = await this.client.sendOperationRequest( @@ -297,11 +297,11 @@ export class DataFlow { ): Promise { const { span, updatedOptions } = createSpan( "ArtifactsClient-_getDataFlowsByWorkspaceNext", - coreHttp.operationOptionsToRequestOptionsBase(options || {}) + options ); const operationArguments: coreHttp.OperationArguments = { nextLink, - options: updatedOptions + options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) }; try { const result = await this.client.sendOperationRequest( diff --git a/sdk/synapse/synapse-artifacts/src/operations/dataFlowDebugSession.ts b/sdk/synapse/synapse-artifacts/src/operations/dataFlowDebugSession.ts index ae834b9efea8..ed2eeb304cf8 100644 --- a/sdk/synapse/synapse-artifacts/src/operations/dataFlowDebugSession.ts +++ b/sdk/synapse/synapse-artifacts/src/operations/dataFlowDebugSession.ts @@ -86,11 +86,11 @@ export class DataFlowDebugSession { ): Promise> { const { span, updatedOptions } = createSpan( "ArtifactsClient-createDataFlowDebugSession", - this.getOperationOptions(options, "undefined") + options ); const operationArguments: coreHttp.OperationArguments = { request, - options: updatedOptions + options: this.getOperationOptions(updatedOptions, "undefined") }; const sendOperation = async ( args: coreHttp.OperationArguments, @@ -131,10 +131,10 @@ export class DataFlowDebugSession { ): Promise { const { span, updatedOptions } = createSpan( "ArtifactsClient-_queryDataFlowDebugSessionsByWorkspace", - coreHttp.operationOptionsToRequestOptionsBase(options || {}) + options ); const operationArguments: coreHttp.OperationArguments = { - options: updatedOptions + options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) }; try { const result = await this.client.sendOperationRequest( @@ -164,11 +164,11 @@ export class DataFlowDebugSession { ): Promise { const { span, updatedOptions } = createSpan( "ArtifactsClient-addDataFlow", - coreHttp.operationOptionsToRequestOptionsBase(options || {}) + options ); const operationArguments: coreHttp.OperationArguments = { request, - options: updatedOptions + options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) }; try { const result = await this.client.sendOperationRequest( @@ -198,11 +198,11 @@ export class DataFlowDebugSession { ): Promise { const { span, updatedOptions } = createSpan( "ArtifactsClient-deleteDataFlowDebugSession", - coreHttp.operationOptionsToRequestOptionsBase(options || {}) + options ); const operationArguments: coreHttp.OperationArguments = { request, - options: updatedOptions + options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) }; try { const result = await this.client.sendOperationRequest( @@ -232,11 +232,11 @@ export class DataFlowDebugSession { ): Promise> { const { span, updatedOptions } = createSpan( "ArtifactsClient-executeCommand", - this.getOperationOptions(options, "undefined") + options ); const operationArguments: coreHttp.OperationArguments = { request, - options: updatedOptions + options: this.getOperationOptions(updatedOptions, "undefined") }; const sendOperation = async ( args: coreHttp.OperationArguments, @@ -280,11 +280,11 @@ export class DataFlowDebugSession { ): Promise { const { span, updatedOptions } = createSpan( "ArtifactsClient-_queryDataFlowDebugSessionsByWorkspaceNext", - coreHttp.operationOptionsToRequestOptionsBase(options || {}) + options ); const operationArguments: coreHttp.OperationArguments = { nextLink, - options: updatedOptions + options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) }; try { const result = await this.client.sendOperationRequest( diff --git a/sdk/synapse/synapse-artifacts/src/operations/dataset.ts b/sdk/synapse/synapse-artifacts/src/operations/dataset.ts index f91bd321185b..0c3f0ea231c3 100644 --- a/sdk/synapse/synapse-artifacts/src/operations/dataset.ts +++ b/sdk/synapse/synapse-artifacts/src/operations/dataset.ts @@ -82,10 +82,10 @@ export class Dataset { ): Promise { const { span, updatedOptions } = createSpan( "ArtifactsClient-_getDatasetsByWorkspace", - coreHttp.operationOptionsToRequestOptionsBase(options || {}) + options ); const operationArguments: coreHttp.OperationArguments = { - options: updatedOptions + options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) }; try { const result = await this.client.sendOperationRequest( @@ -117,12 +117,12 @@ export class Dataset { ): Promise> { const { span, updatedOptions } = createSpan( "ArtifactsClient-createOrUpdateDataset", - this.getOperationOptions(options, "undefined") + options ); const operationArguments: coreHttp.OperationArguments = { datasetName, dataset, - options: updatedOptions + options: this.getOperationOptions(updatedOptions, "undefined") }; const sendOperation = async ( args: coreHttp.OperationArguments, @@ -165,11 +165,11 @@ export class Dataset { ): Promise { const { span, updatedOptions } = createSpan( "ArtifactsClient-getDataset", - coreHttp.operationOptionsToRequestOptionsBase(options || {}) + options ); const operationArguments: coreHttp.OperationArguments = { datasetName, - options: updatedOptions + options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) }; try { const result = await this.client.sendOperationRequest( @@ -199,11 +199,11 @@ export class Dataset { ): Promise> { const { span, updatedOptions } = createSpan( "ArtifactsClient-deleteDataset", - this.getOperationOptions(options, "undefined") + options ); const operationArguments: coreHttp.OperationArguments = { datasetName, - options: updatedOptions + options: this.getOperationOptions(updatedOptions, "undefined") }; const sendOperation = async ( args: coreHttp.OperationArguments, @@ -248,12 +248,12 @@ export class Dataset { ): Promise> { const { span, updatedOptions } = createSpan( "ArtifactsClient-renameDataset", - this.getOperationOptions(options, "undefined") + options ); const operationArguments: coreHttp.OperationArguments = { datasetName, request, - options: updatedOptions + options: this.getOperationOptions(updatedOptions, "undefined") }; const sendOperation = async ( args: coreHttp.OperationArguments, @@ -296,11 +296,11 @@ export class Dataset { ): Promise { const { span, updatedOptions } = createSpan( "ArtifactsClient-_getDatasetsByWorkspaceNext", - coreHttp.operationOptionsToRequestOptionsBase(options || {}) + options ); const operationArguments: coreHttp.OperationArguments = { nextLink, - options: updatedOptions + options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) }; try { const result = await this.client.sendOperationRequest( diff --git a/sdk/synapse/synapse-artifacts/src/operations/integrationRuntimes.ts b/sdk/synapse/synapse-artifacts/src/operations/integrationRuntimes.ts index 50b6c8b1d795..4c0fa1bec0cd 100644 --- a/sdk/synapse/synapse-artifacts/src/operations/integrationRuntimes.ts +++ b/sdk/synapse/synapse-artifacts/src/operations/integrationRuntimes.ts @@ -27,10 +27,10 @@ export class IntegrationRuntimes { async list(options?: coreHttp.OperationOptions): Promise { const { span, updatedOptions } = createSpan( "ArtifactsClient-list", - coreHttp.operationOptionsToRequestOptionsBase(options || {}) + options ); const operationArguments: coreHttp.OperationArguments = { - options: updatedOptions + options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) }; try { const result = await this.client.sendOperationRequest(operationArguments, listOperationSpec); @@ -57,11 +57,11 @@ export class IntegrationRuntimes { ): Promise { const { span, updatedOptions } = createSpan( "ArtifactsClient-get", - coreHttp.operationOptionsToRequestOptionsBase(options || {}) + options ); const operationArguments: coreHttp.OperationArguments = { integrationRuntimeName, - options: updatedOptions + options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) }; try { const result = await this.client.sendOperationRequest(operationArguments, getOperationSpec); diff --git a/sdk/synapse/synapse-artifacts/src/operations/library.ts b/sdk/synapse/synapse-artifacts/src/operations/library.ts index dca79830fb19..f655e1fd5e65 100644 --- a/sdk/synapse/synapse-artifacts/src/operations/library.ts +++ b/sdk/synapse/synapse-artifacts/src/operations/library.ts @@ -76,10 +76,10 @@ export class Library { private async _list(options?: coreHttp.OperationOptions): Promise { const { span, updatedOptions } = createSpan( "ArtifactsClient-_list", - coreHttp.operationOptionsToRequestOptionsBase(options || {}) + options ); const operationArguments: coreHttp.OperationArguments = { - options: updatedOptions + options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) }; try { const result = await this.client.sendOperationRequest(operationArguments, listOperationSpec); @@ -107,11 +107,11 @@ export class Library { ): Promise> { const { span, updatedOptions } = createSpan( "ArtifactsClient-flush", - this.getOperationOptions(options, "undefined") + options ); const operationArguments: coreHttp.OperationArguments = { libraryName, - options: updatedOptions + options: this.getOperationOptions(updatedOptions, "undefined") }; const sendOperation = async ( args: coreHttp.OperationArguments, @@ -151,11 +151,11 @@ export class Library { ): Promise { const { span, updatedOptions } = createSpan( "ArtifactsClient-getOperationResult", - coreHttp.operationOptionsToRequestOptionsBase(options || {}) + options ); const operationArguments: coreHttp.OperationArguments = { operationId, - options: updatedOptions + options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) }; try { const result = await this.client.sendOperationRequest( @@ -186,11 +186,11 @@ export class Library { ): Promise> { const { span, updatedOptions } = createSpan( "ArtifactsClient-delete", - this.getOperationOptions(options, "undefined") + options ); const operationArguments: coreHttp.OperationArguments = { libraryName, - options: updatedOptions + options: this.getOperationOptions(updatedOptions, "undefined") }; const sendOperation = async ( args: coreHttp.OperationArguments, @@ -228,11 +228,11 @@ export class Library { async get(libraryName: string, options?: coreHttp.OperationOptions): Promise { const { span, updatedOptions } = createSpan( "ArtifactsClient-get", - coreHttp.operationOptionsToRequestOptionsBase(options || {}) + options ); const operationArguments: coreHttp.OperationArguments = { libraryName, - options: updatedOptions + options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) }; try { const result = await this.client.sendOperationRequest(operationArguments, getOperationSpec); @@ -263,12 +263,12 @@ export class Library { ): Promise> { const { span, updatedOptions } = createSpan( "ArtifactsClient-createOrAppend", - this.getOperationOptions(options, "undefined") + options ); const operationArguments: coreHttp.OperationArguments = { libraryName, content, - options: updatedOptions + options: this.getOperationOptions(updatedOptions, "undefined") }; const sendOperation = async ( args: coreHttp.OperationArguments, @@ -311,11 +311,11 @@ export class Library { ): Promise { const { span, updatedOptions } = createSpan( "ArtifactsClient-_listNext", - coreHttp.operationOptionsToRequestOptionsBase(options || {}) + options ); const operationArguments: coreHttp.OperationArguments = { nextLink, - options: updatedOptions + options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) }; try { const result = await this.client.sendOperationRequest( diff --git a/sdk/synapse/synapse-artifacts/src/operations/linkedService.ts b/sdk/synapse/synapse-artifacts/src/operations/linkedService.ts index ae3c1ddfd384..d7cb16a444c2 100644 --- a/sdk/synapse/synapse-artifacts/src/operations/linkedService.ts +++ b/sdk/synapse/synapse-artifacts/src/operations/linkedService.ts @@ -82,10 +82,10 @@ export class LinkedService { ): Promise { const { span, updatedOptions } = createSpan( "ArtifactsClient-_getLinkedServicesByWorkspace", - coreHttp.operationOptionsToRequestOptionsBase(options || {}) + options ); const operationArguments: coreHttp.OperationArguments = { - options: updatedOptions + options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) }; try { const result = await this.client.sendOperationRequest( @@ -117,12 +117,12 @@ export class LinkedService { ): Promise> { const { span, updatedOptions } = createSpan( "ArtifactsClient-createOrUpdateLinkedService", - this.getOperationOptions(options, "undefined") + options ); const operationArguments: coreHttp.OperationArguments = { linkedServiceName, linkedService, - options: updatedOptions + options: this.getOperationOptions(updatedOptions, "undefined") }; const sendOperation = async ( args: coreHttp.OperationArguments, @@ -165,11 +165,11 @@ export class LinkedService { ): Promise { const { span, updatedOptions } = createSpan( "ArtifactsClient-getLinkedService", - coreHttp.operationOptionsToRequestOptionsBase(options || {}) + options ); const operationArguments: coreHttp.OperationArguments = { linkedServiceName, - options: updatedOptions + options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) }; try { const result = await this.client.sendOperationRequest( @@ -199,11 +199,11 @@ export class LinkedService { ): Promise> { const { span, updatedOptions } = createSpan( "ArtifactsClient-deleteLinkedService", - this.getOperationOptions(options, "undefined") + options ); const operationArguments: coreHttp.OperationArguments = { linkedServiceName, - options: updatedOptions + options: this.getOperationOptions(updatedOptions, "undefined") }; const sendOperation = async ( args: coreHttp.OperationArguments, @@ -248,12 +248,12 @@ export class LinkedService { ): Promise> { const { span, updatedOptions } = createSpan( "ArtifactsClient-renameLinkedService", - this.getOperationOptions(options, "undefined") + options ); const operationArguments: coreHttp.OperationArguments = { linkedServiceName, request, - options: updatedOptions + options: this.getOperationOptions(updatedOptions, "undefined") }; const sendOperation = async ( args: coreHttp.OperationArguments, @@ -297,11 +297,11 @@ export class LinkedService { ): Promise { const { span, updatedOptions } = createSpan( "ArtifactsClient-_getLinkedServicesByWorkspaceNext", - coreHttp.operationOptionsToRequestOptionsBase(options || {}) + options ); const operationArguments: coreHttp.OperationArguments = { nextLink, - options: updatedOptions + options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) }; try { const result = await this.client.sendOperationRequest( diff --git a/sdk/synapse/synapse-artifacts/src/operations/notebook.ts b/sdk/synapse/synapse-artifacts/src/operations/notebook.ts index efbf1d810a79..ce268dc5d777 100644 --- a/sdk/synapse/synapse-artifacts/src/operations/notebook.ts +++ b/sdk/synapse/synapse-artifacts/src/operations/notebook.ts @@ -126,10 +126,10 @@ export class Notebook { ): Promise { const { span, updatedOptions } = createSpan( "ArtifactsClient-_getNotebooksByWorkspace", - coreHttp.operationOptionsToRequestOptionsBase(options || {}) + options ); const operationArguments: coreHttp.OperationArguments = { - options: updatedOptions + options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) }; try { const result = await this.client.sendOperationRequest( @@ -157,10 +157,10 @@ export class Notebook { ): Promise { const { span, updatedOptions } = createSpan( "ArtifactsClient-_getNotebookSummaryByWorkSpace", - coreHttp.operationOptionsToRequestOptionsBase(options || {}) + options ); const operationArguments: coreHttp.OperationArguments = { - options: updatedOptions + options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) }; try { const result = await this.client.sendOperationRequest( @@ -192,12 +192,12 @@ export class Notebook { ): Promise> { const { span, updatedOptions } = createSpan( "ArtifactsClient-createOrUpdateNotebook", - this.getOperationOptions(options, "undefined") + options ); const operationArguments: coreHttp.OperationArguments = { notebookName, notebook, - options: updatedOptions + options: this.getOperationOptions(updatedOptions, "undefined") }; const sendOperation = async ( args: coreHttp.OperationArguments, @@ -240,11 +240,11 @@ export class Notebook { ): Promise { const { span, updatedOptions } = createSpan( "ArtifactsClient-getNotebook", - coreHttp.operationOptionsToRequestOptionsBase(options || {}) + options ); const operationArguments: coreHttp.OperationArguments = { notebookName, - options: updatedOptions + options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) }; try { const result = await this.client.sendOperationRequest( @@ -274,11 +274,11 @@ export class Notebook { ): Promise> { const { span, updatedOptions } = createSpan( "ArtifactsClient-deleteNotebook", - this.getOperationOptions(options, "undefined") + options ); const operationArguments: coreHttp.OperationArguments = { notebookName, - options: updatedOptions + options: this.getOperationOptions(updatedOptions, "undefined") }; const sendOperation = async ( args: coreHttp.OperationArguments, @@ -323,12 +323,12 @@ export class Notebook { ): Promise> { const { span, updatedOptions } = createSpan( "ArtifactsClient-renameNotebook", - this.getOperationOptions(options, "undefined") + options ); const operationArguments: coreHttp.OperationArguments = { notebookName, request, - options: updatedOptions + options: this.getOperationOptions(updatedOptions, "undefined") }; const sendOperation = async ( args: coreHttp.OperationArguments, @@ -372,11 +372,11 @@ export class Notebook { ): Promise { const { span, updatedOptions } = createSpan( "ArtifactsClient-_getNotebooksByWorkspaceNext", - coreHttp.operationOptionsToRequestOptionsBase(options || {}) + options ); const operationArguments: coreHttp.OperationArguments = { nextLink, - options: updatedOptions + options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) }; try { const result = await this.client.sendOperationRequest( @@ -407,11 +407,11 @@ export class Notebook { ): Promise { const { span, updatedOptions } = createSpan( "ArtifactsClient-_getNotebookSummaryByWorkSpaceNext", - coreHttp.operationOptionsToRequestOptionsBase(options || {}) + options ); const operationArguments: coreHttp.OperationArguments = { nextLink, - options: updatedOptions + options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) }; try { const result = await this.client.sendOperationRequest( diff --git a/sdk/synapse/synapse-artifacts/src/operations/pipeline.ts b/sdk/synapse/synapse-artifacts/src/operations/pipeline.ts index 38b55e8d9bd5..56b94751db4c 100644 --- a/sdk/synapse/synapse-artifacts/src/operations/pipeline.ts +++ b/sdk/synapse/synapse-artifacts/src/operations/pipeline.ts @@ -84,10 +84,10 @@ export class Pipeline { ): Promise { const { span, updatedOptions } = createSpan( "ArtifactsClient-_getPipelinesByWorkspace", - coreHttp.operationOptionsToRequestOptionsBase(options || {}) + options ); const operationArguments: coreHttp.OperationArguments = { - options: updatedOptions + options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) }; try { const result = await this.client.sendOperationRequest( @@ -119,12 +119,12 @@ export class Pipeline { ): Promise> { const { span, updatedOptions } = createSpan( "ArtifactsClient-createOrUpdatePipeline", - this.getOperationOptions(options, "undefined") + options ); const operationArguments: coreHttp.OperationArguments = { pipelineName, pipeline, - options: updatedOptions + options: this.getOperationOptions(updatedOptions, "undefined") }; const sendOperation = async ( args: coreHttp.OperationArguments, @@ -167,11 +167,11 @@ export class Pipeline { ): Promise { const { span, updatedOptions } = createSpan( "ArtifactsClient-getPipeline", - coreHttp.operationOptionsToRequestOptionsBase(options || {}) + options ); const operationArguments: coreHttp.OperationArguments = { pipelineName, - options: updatedOptions + options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) }; try { const result = await this.client.sendOperationRequest( @@ -201,11 +201,11 @@ export class Pipeline { ): Promise> { const { span, updatedOptions } = createSpan( "ArtifactsClient-deletePipeline", - this.getOperationOptions(options, "undefined") + options ); const operationArguments: coreHttp.OperationArguments = { pipelineName, - options: updatedOptions + options: this.getOperationOptions(updatedOptions, "undefined") }; const sendOperation = async ( args: coreHttp.OperationArguments, @@ -250,12 +250,12 @@ export class Pipeline { ): Promise> { const { span, updatedOptions } = createSpan( "ArtifactsClient-renamePipeline", - this.getOperationOptions(options, "undefined") + options ); const operationArguments: coreHttp.OperationArguments = { pipelineName, request, - options: updatedOptions + options: this.getOperationOptions(updatedOptions, "undefined") }; const sendOperation = async ( args: coreHttp.OperationArguments, @@ -298,11 +298,11 @@ export class Pipeline { ): Promise { const { span, updatedOptions } = createSpan( "ArtifactsClient-createPipelineRun", - coreHttp.operationOptionsToRequestOptionsBase(options || {}) + options ); const operationArguments: coreHttp.OperationArguments = { pipelineName, - options: updatedOptions + options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) }; try { const result = await this.client.sendOperationRequest( @@ -333,11 +333,11 @@ export class Pipeline { ): Promise { const { span, updatedOptions } = createSpan( "ArtifactsClient-_getPipelinesByWorkspaceNext", - coreHttp.operationOptionsToRequestOptionsBase(options || {}) + options ); const operationArguments: coreHttp.OperationArguments = { nextLink, - options: updatedOptions + options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) }; try { const result = await this.client.sendOperationRequest( diff --git a/sdk/synapse/synapse-artifacts/src/operations/pipelineRun.ts b/sdk/synapse/synapse-artifacts/src/operations/pipelineRun.ts index e0303a0aec15..a28101742263 100644 --- a/sdk/synapse/synapse-artifacts/src/operations/pipelineRun.ts +++ b/sdk/synapse/synapse-artifacts/src/operations/pipelineRun.ts @@ -37,11 +37,11 @@ export class PipelineRun { ): Promise { const { span, updatedOptions } = createSpan( "ArtifactsClient-queryPipelineRunsByWorkspace", - coreHttp.operationOptionsToRequestOptionsBase(options || {}) + options ); const operationArguments: coreHttp.OperationArguments = { filterParameters, - options: updatedOptions + options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) }; try { const result = await this.client.sendOperationRequest( @@ -71,11 +71,11 @@ export class PipelineRun { ): Promise { const { span, updatedOptions } = createSpan( "ArtifactsClient-getPipelineRun", - coreHttp.operationOptionsToRequestOptionsBase(options || {}) + options ); const operationArguments: coreHttp.OperationArguments = { runId, - options: updatedOptions + options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) }; try { const result = await this.client.sendOperationRequest( @@ -109,13 +109,13 @@ export class PipelineRun { ): Promise { const { span, updatedOptions } = createSpan( "ArtifactsClient-queryActivityRuns", - coreHttp.operationOptionsToRequestOptionsBase(options || {}) + options ); const operationArguments: coreHttp.OperationArguments = { pipelineName, runId, filterParameters, - options: updatedOptions + options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) }; try { const result = await this.client.sendOperationRequest( @@ -145,11 +145,11 @@ export class PipelineRun { ): Promise { const { span, updatedOptions } = createSpan( "ArtifactsClient-cancelPipelineRun", - coreHttp.operationOptionsToRequestOptionsBase(options || {}) + options ); const operationArguments: coreHttp.OperationArguments = { runId, - options: updatedOptions + options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) }; try { const result = await this.client.sendOperationRequest( diff --git a/sdk/synapse/synapse-artifacts/src/operations/sparkJobDefinition.ts b/sdk/synapse/synapse-artifacts/src/operations/sparkJobDefinition.ts index f1d87432c05d..c35453e244a2 100644 --- a/sdk/synapse/synapse-artifacts/src/operations/sparkJobDefinition.ts +++ b/sdk/synapse/synapse-artifacts/src/operations/sparkJobDefinition.ts @@ -84,10 +84,10 @@ export class SparkJobDefinition { ): Promise { const { span, updatedOptions } = createSpan( "ArtifactsClient-_getSparkJobDefinitionsByWorkspace", - coreHttp.operationOptionsToRequestOptionsBase(options || {}) + options ); const operationArguments: coreHttp.OperationArguments = { - options: updatedOptions + options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) }; try { const result = await this.client.sendOperationRequest( @@ -119,12 +119,12 @@ export class SparkJobDefinition { ): Promise> { const { span, updatedOptions } = createSpan( "ArtifactsClient-createOrUpdateSparkJobDefinition", - this.getOperationOptions(options, "undefined") + options ); const operationArguments: coreHttp.OperationArguments = { sparkJobDefinitionName, sparkJobDefinition, - options: updatedOptions + options: this.getOperationOptions(updatedOptions, "undefined") }; const sendOperation = async ( args: coreHttp.OperationArguments, @@ -167,11 +167,11 @@ export class SparkJobDefinition { ): Promise { const { span, updatedOptions } = createSpan( "ArtifactsClient-getSparkJobDefinition", - coreHttp.operationOptionsToRequestOptionsBase(options || {}) + options ); const operationArguments: coreHttp.OperationArguments = { sparkJobDefinitionName, - options: updatedOptions + options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) }; try { const result = await this.client.sendOperationRequest( @@ -201,11 +201,11 @@ export class SparkJobDefinition { ): Promise> { const { span, updatedOptions } = createSpan( "ArtifactsClient-deleteSparkJobDefinition", - this.getOperationOptions(options, "undefined") + options ); const operationArguments: coreHttp.OperationArguments = { sparkJobDefinitionName, - options: updatedOptions + options: this.getOperationOptions(updatedOptions, "undefined") }; const sendOperation = async ( args: coreHttp.OperationArguments, @@ -248,11 +248,11 @@ export class SparkJobDefinition { ): Promise> { const { span, updatedOptions } = createSpan( "ArtifactsClient-executeSparkJobDefinition", - this.getOperationOptions(options, "location") + options ); const operationArguments: coreHttp.OperationArguments = { sparkJobDefinitionName, - options: updatedOptions + options: this.getOperationOptions(updatedOptions, "location") }; const sendOperation = async ( args: coreHttp.OperationArguments, @@ -298,12 +298,12 @@ export class SparkJobDefinition { ): Promise> { const { span, updatedOptions } = createSpan( "ArtifactsClient-renameSparkJobDefinition", - this.getOperationOptions(options, "undefined") + options ); const operationArguments: coreHttp.OperationArguments = { sparkJobDefinitionName, request, - options: updatedOptions + options: this.getOperationOptions(updatedOptions, "undefined") }; const sendOperation = async ( args: coreHttp.OperationArguments, @@ -346,11 +346,11 @@ export class SparkJobDefinition { ): Promise> { const { span, updatedOptions } = createSpan( "ArtifactsClient-debugSparkJobDefinition", - this.getOperationOptions(options, "location") + options ); const operationArguments: coreHttp.OperationArguments = { sparkJobDefinitionAzureResource, - options: updatedOptions + options: this.getOperationOptions(updatedOptions, "location") }; const sendOperation = async ( args: coreHttp.OperationArguments, @@ -395,11 +395,11 @@ export class SparkJobDefinition { ): Promise { const { span, updatedOptions } = createSpan( "ArtifactsClient-_getSparkJobDefinitionsByWorkspaceNext", - coreHttp.operationOptionsToRequestOptionsBase(options || {}) + options ); const operationArguments: coreHttp.OperationArguments = { nextLink, - options: updatedOptions + options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) }; try { const result = await this.client.sendOperationRequest( diff --git a/sdk/synapse/synapse-artifacts/src/operations/sqlPools.ts b/sdk/synapse/synapse-artifacts/src/operations/sqlPools.ts index 05848db9e408..bdeb92507764 100644 --- a/sdk/synapse/synapse-artifacts/src/operations/sqlPools.ts +++ b/sdk/synapse/synapse-artifacts/src/operations/sqlPools.ts @@ -27,10 +27,10 @@ export class SqlPools { async list(options?: coreHttp.OperationOptions): Promise { const { span, updatedOptions } = createSpan( "ArtifactsClient-list", - coreHttp.operationOptionsToRequestOptionsBase(options || {}) + options ); const operationArguments: coreHttp.OperationArguments = { - options: updatedOptions + options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) }; try { const result = await this.client.sendOperationRequest(operationArguments, listOperationSpec); @@ -57,11 +57,11 @@ export class SqlPools { ): Promise { const { span, updatedOptions } = createSpan( "ArtifactsClient-get", - coreHttp.operationOptionsToRequestOptionsBase(options || {}) + options ); const operationArguments: coreHttp.OperationArguments = { sqlPoolName, - options: updatedOptions + options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) }; try { const result = await this.client.sendOperationRequest(operationArguments, getOperationSpec); diff --git a/sdk/synapse/synapse-artifacts/src/operations/sqlScript.ts b/sdk/synapse/synapse-artifacts/src/operations/sqlScript.ts index 255ec198f0c3..c46a5b430381 100644 --- a/sdk/synapse/synapse-artifacts/src/operations/sqlScript.ts +++ b/sdk/synapse/synapse-artifacts/src/operations/sqlScript.ts @@ -82,10 +82,10 @@ export class SqlScript { ): Promise { const { span, updatedOptions } = createSpan( "ArtifactsClient-_getSqlScriptsByWorkspace", - coreHttp.operationOptionsToRequestOptionsBase(options || {}) + options ); const operationArguments: coreHttp.OperationArguments = { - options: updatedOptions + options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) }; try { const result = await this.client.sendOperationRequest( @@ -117,12 +117,12 @@ export class SqlScript { ): Promise> { const { span, updatedOptions } = createSpan( "ArtifactsClient-createOrUpdateSqlScript", - this.getOperationOptions(options, "undefined") + options ); const operationArguments: coreHttp.OperationArguments = { sqlScriptName, sqlScript, - options: updatedOptions + options: this.getOperationOptions(updatedOptions, "undefined") }; const sendOperation = async ( args: coreHttp.OperationArguments, @@ -165,11 +165,11 @@ export class SqlScript { ): Promise { const { span, updatedOptions } = createSpan( "ArtifactsClient-getSqlScript", - coreHttp.operationOptionsToRequestOptionsBase(options || {}) + options ); const operationArguments: coreHttp.OperationArguments = { sqlScriptName, - options: updatedOptions + options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) }; try { const result = await this.client.sendOperationRequest( @@ -199,11 +199,11 @@ export class SqlScript { ): Promise> { const { span, updatedOptions } = createSpan( "ArtifactsClient-deleteSqlScript", - this.getOperationOptions(options, "undefined") + options ); const operationArguments: coreHttp.OperationArguments = { sqlScriptName, - options: updatedOptions + options: this.getOperationOptions(updatedOptions, "undefined") }; const sendOperation = async ( args: coreHttp.OperationArguments, @@ -248,12 +248,12 @@ export class SqlScript { ): Promise> { const { span, updatedOptions } = createSpan( "ArtifactsClient-renameSqlScript", - this.getOperationOptions(options, "undefined") + options ); const operationArguments: coreHttp.OperationArguments = { sqlScriptName, request, - options: updatedOptions + options: this.getOperationOptions(updatedOptions, "undefined") }; const sendOperation = async ( args: coreHttp.OperationArguments, @@ -297,11 +297,11 @@ export class SqlScript { ): Promise { const { span, updatedOptions } = createSpan( "ArtifactsClient-_getSqlScriptsByWorkspaceNext", - coreHttp.operationOptionsToRequestOptionsBase(options || {}) + options ); const operationArguments: coreHttp.OperationArguments = { nextLink, - options: updatedOptions + options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) }; try { const result = await this.client.sendOperationRequest( diff --git a/sdk/synapse/synapse-artifacts/src/operations/trigger.ts b/sdk/synapse/synapse-artifacts/src/operations/trigger.ts index 503cd613b8ed..468ab70d9510 100644 --- a/sdk/synapse/synapse-artifacts/src/operations/trigger.ts +++ b/sdk/synapse/synapse-artifacts/src/operations/trigger.ts @@ -84,10 +84,10 @@ export class Trigger { ): Promise { const { span, updatedOptions } = createSpan( "ArtifactsClient-_getTriggersByWorkspace", - coreHttp.operationOptionsToRequestOptionsBase(options || {}) + options ); const operationArguments: coreHttp.OperationArguments = { - options: updatedOptions + options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) }; try { const result = await this.client.sendOperationRequest( @@ -119,12 +119,12 @@ export class Trigger { ): Promise> { const { span, updatedOptions } = createSpan( "ArtifactsClient-createOrUpdateTrigger", - this.getOperationOptions(options, "undefined") + options ); const operationArguments: coreHttp.OperationArguments = { triggerName, trigger, - options: updatedOptions + options: this.getOperationOptions(updatedOptions, "undefined") }; const sendOperation = async ( args: coreHttp.OperationArguments, @@ -167,11 +167,11 @@ export class Trigger { ): Promise { const { span, updatedOptions } = createSpan( "ArtifactsClient-getTrigger", - coreHttp.operationOptionsToRequestOptionsBase(options || {}) + options ); const operationArguments: coreHttp.OperationArguments = { triggerName, - options: updatedOptions + options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) }; try { const result = await this.client.sendOperationRequest( @@ -201,11 +201,11 @@ export class Trigger { ): Promise> { const { span, updatedOptions } = createSpan( "ArtifactsClient-deleteTrigger", - this.getOperationOptions(options, "undefined") + options ); const operationArguments: coreHttp.OperationArguments = { triggerName, - options: updatedOptions + options: this.getOperationOptions(updatedOptions, "undefined") }; const sendOperation = async ( args: coreHttp.OperationArguments, @@ -248,11 +248,11 @@ export class Trigger { ): Promise> { const { span, updatedOptions } = createSpan( "ArtifactsClient-subscribeTriggerToEvents", - this.getOperationOptions(options, "undefined") + options ); const operationArguments: coreHttp.OperationArguments = { triggerName, - options: updatedOptions + options: this.getOperationOptions(updatedOptions, "undefined") }; const sendOperation = async ( args: coreHttp.OperationArguments, @@ -295,11 +295,11 @@ export class Trigger { ): Promise { const { span, updatedOptions } = createSpan( "ArtifactsClient-getEventSubscriptionStatus", - coreHttp.operationOptionsToRequestOptionsBase(options || {}) + options ); const operationArguments: coreHttp.OperationArguments = { triggerName, - options: updatedOptions + options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) }; try { const result = await this.client.sendOperationRequest( @@ -329,11 +329,11 @@ export class Trigger { ): Promise> { const { span, updatedOptions } = createSpan( "ArtifactsClient-unsubscribeTriggerFromEvents", - this.getOperationOptions(options, "undefined") + options ); const operationArguments: coreHttp.OperationArguments = { triggerName, - options: updatedOptions + options: this.getOperationOptions(updatedOptions, "undefined") }; const sendOperation = async ( args: coreHttp.OperationArguments, @@ -376,11 +376,11 @@ export class Trigger { ): Promise> { const { span, updatedOptions } = createSpan( "ArtifactsClient-startTrigger", - this.getOperationOptions(options, "undefined") + options ); const operationArguments: coreHttp.OperationArguments = { triggerName, - options: updatedOptions + options: this.getOperationOptions(updatedOptions, "undefined") }; const sendOperation = async ( args: coreHttp.OperationArguments, @@ -423,11 +423,11 @@ export class Trigger { ): Promise> { const { span, updatedOptions } = createSpan( "ArtifactsClient-stopTrigger", - this.getOperationOptions(options, "undefined") + options ); const operationArguments: coreHttp.OperationArguments = { triggerName, - options: updatedOptions + options: this.getOperationOptions(updatedOptions, "undefined") }; const sendOperation = async ( args: coreHttp.OperationArguments, @@ -470,11 +470,11 @@ export class Trigger { ): Promise { const { span, updatedOptions } = createSpan( "ArtifactsClient-_getTriggersByWorkspaceNext", - coreHttp.operationOptionsToRequestOptionsBase(options || {}) + options ); const operationArguments: coreHttp.OperationArguments = { nextLink, - options: updatedOptions + options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) }; try { const result = await this.client.sendOperationRequest( diff --git a/sdk/synapse/synapse-artifacts/src/operations/triggerRun.ts b/sdk/synapse/synapse-artifacts/src/operations/triggerRun.ts index 4dafcc9228da..7896b006baac 100644 --- a/sdk/synapse/synapse-artifacts/src/operations/triggerRun.ts +++ b/sdk/synapse/synapse-artifacts/src/operations/triggerRun.ts @@ -33,12 +33,12 @@ export class TriggerRun { ): Promise { const { span, updatedOptions } = createSpan( "ArtifactsClient-rerunTriggerInstance", - coreHttp.operationOptionsToRequestOptionsBase(options || {}) + options ); const operationArguments: coreHttp.OperationArguments = { triggerName, runId, - options: updatedOptions + options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) }; try { const result = await this.client.sendOperationRequest( @@ -70,12 +70,12 @@ export class TriggerRun { ): Promise { const { span, updatedOptions } = createSpan( "ArtifactsClient-cancelTriggerInstance", - coreHttp.operationOptionsToRequestOptionsBase(options || {}) + options ); const operationArguments: coreHttp.OperationArguments = { triggerName, runId, - options: updatedOptions + options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) }; try { const result = await this.client.sendOperationRequest( @@ -105,11 +105,11 @@ export class TriggerRun { ): Promise { const { span, updatedOptions } = createSpan( "ArtifactsClient-queryTriggerRunsByWorkspace", - coreHttp.operationOptionsToRequestOptionsBase(options || {}) + options ); const operationArguments: coreHttp.OperationArguments = { filterParameters, - options: updatedOptions + options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) }; try { const result = await this.client.sendOperationRequest( diff --git a/sdk/synapse/synapse-artifacts/src/operations/workspace.ts b/sdk/synapse/synapse-artifacts/src/operations/workspace.ts index 9fab49db7fd5..8a78f73cfb2b 100644 --- a/sdk/synapse/synapse-artifacts/src/operations/workspace.ts +++ b/sdk/synapse/synapse-artifacts/src/operations/workspace.ts @@ -27,10 +27,10 @@ export class Workspace { async get(options?: coreHttp.OperationOptions): Promise { const { span, updatedOptions } = createSpan( "ArtifactsClient-get", - coreHttp.operationOptionsToRequestOptionsBase(options || {}) + options ); const operationArguments: coreHttp.OperationArguments = { - options: updatedOptions + options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) }; try { const result = await this.client.sendOperationRequest(operationArguments, getOperationSpec); diff --git a/sdk/synapse/synapse-artifacts/src/operations/workspaceGitRepoManagement.ts b/sdk/synapse/synapse-artifacts/src/operations/workspaceGitRepoManagement.ts index 910b262a5cf4..5bb7746b1fb4 100644 --- a/sdk/synapse/synapse-artifacts/src/operations/workspaceGitRepoManagement.ts +++ b/sdk/synapse/synapse-artifacts/src/operations/workspaceGitRepoManagement.ts @@ -35,11 +35,11 @@ export class WorkspaceGitRepoManagement { ): Promise { const { span, updatedOptions } = createSpan( "ArtifactsClient-getGitHubAccessToken", - coreHttp.operationOptionsToRequestOptionsBase(options || {}) + options ); const operationArguments: coreHttp.OperationArguments = { gitHubAccessTokenRequest, - options: updatedOptions + options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) }; try { const result = await this.client.sendOperationRequest( diff --git a/sdk/synapse/synapse-artifacts/src/tracing.ts b/sdk/synapse/synapse-artifacts/src/tracing.ts index 36ffdc4f7e26..91d8fa2dcf21 100644 --- a/sdk/synapse/synapse-artifacts/src/tracing.ts +++ b/sdk/synapse/synapse-artifacts/src/tracing.ts @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -import { createSpanFunction } from "@azure/core-http"; +import { createSpanFunction } from "@azure/core-tracing"; export const createSpan = createSpanFunction({ namespace: "Azure.Synapse.Artifacts", From 3404d31a7f331f1fa7e947223a6a49ce57a19ab8 Mon Sep 17 00:00:00 2001 From: Richard Park <51494936+richardpark-msft@users.noreply.github.com> Date: Mon, 22 Feb 2021 22:16:22 +0000 Subject: [PATCH 28/52] Formatting --- sdk/core/core-tracing/src/createSpan.ts | 2 +- sdk/synapse/synapse-artifacts/package.json | 2 +- .../src/operations/bigDataPools.ts | 9 ++--- .../src/operations/dataFlow.ts | 20 +++-------- .../src/operations/dataFlowDebugSession.ts | 10 ++---- .../src/operations/dataset.ts | 25 +++---------- .../src/operations/integrationRuntimes.ts | 10 ++---- .../src/operations/library.ts | 35 ++++--------------- .../src/operations/linkedService.ts | 15 ++------ .../src/operations/notebook.ts | 20 +++-------- .../src/operations/pipeline.ts | 25 +++---------- .../src/operations/pipelineRun.ts | 15 ++------ .../src/operations/sparkJobDefinition.ts | 10 ++---- .../src/operations/sqlPools.ts | 10 ++---- .../src/operations/sqlScript.ts | 20 +++-------- .../src/operations/trigger.ts | 30 ++++------------ .../src/operations/triggerRun.ts | 10 ++---- .../src/operations/workspace.ts | 5 +-- .../operations/workspaceGitRepoManagement.ts | 5 +-- 19 files changed, 57 insertions(+), 221 deletions(-) diff --git a/sdk/core/core-tracing/src/createSpan.ts b/sdk/core/core-tracing/src/createSpan.ts index fc7b0c204d6f..b4dd0278bc92 100644 --- a/sdk/core/core-tracing/src/createSpan.ts +++ b/sdk/core/core-tracing/src/createSpan.ts @@ -27,7 +27,7 @@ export interface SpanConfig { * @param tracingOptions - The options for the underlying http request. */ export function createSpanFunction({ packagePrefix, namespace }: SpanConfig) { - return function ( + return function( operationName: string, operationOptions: T ): { span: Span; updatedOptions: NonNullable } { diff --git a/sdk/synapse/synapse-artifacts/package.json b/sdk/synapse/synapse-artifacts/package.json index 1e548c105fa1..ed2b7672c31a 100644 --- a/sdk/synapse/synapse-artifacts/package.json +++ b/sdk/synapse/synapse-artifacts/package.json @@ -79,4 +79,4 @@ }, "sideEffects": false, "autoPublish": true -} \ No newline at end of file +} diff --git a/sdk/synapse/synapse-artifacts/src/operations/bigDataPools.ts b/sdk/synapse/synapse-artifacts/src/operations/bigDataPools.ts index b421ce47e48a..96074d78373e 100644 --- a/sdk/synapse/synapse-artifacts/src/operations/bigDataPools.ts +++ b/sdk/synapse/synapse-artifacts/src/operations/bigDataPools.ts @@ -25,9 +25,7 @@ export class BigDataPools { * @param options The options parameters. */ async list(options?: coreHttp.OperationOptions): Promise { - const { span, updatedOptions } = createSpan( - "ArtifactsClient-list", - options); + const { span, updatedOptions } = createSpan("ArtifactsClient-list", options); const operationArguments: coreHttp.OperationArguments = { options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) @@ -55,10 +53,7 @@ export class BigDataPools { bigDataPoolName: string, options?: coreHttp.OperationOptions ): Promise { - const { span, updatedOptions } = createSpan( - "ArtifactsClient-get", - options - ); + const { span, updatedOptions } = createSpan("ArtifactsClient-get", options); const operationArguments: coreHttp.OperationArguments = { bigDataPoolName, diff --git a/sdk/synapse/synapse-artifacts/src/operations/dataFlow.ts b/sdk/synapse/synapse-artifacts/src/operations/dataFlow.ts index 510658c6b396..fbfb22b8bf78 100644 --- a/sdk/synapse/synapse-artifacts/src/operations/dataFlow.ts +++ b/sdk/synapse/synapse-artifacts/src/operations/dataFlow.ts @@ -84,10 +84,7 @@ export class DataFlow { dataFlow: DataFlowResource, options?: DataFlowCreateOrUpdateDataFlowOptionalParams ): Promise> { - const { span, updatedOptions } = createSpan( - "ArtifactsClient-createOrUpdateDataFlow", - options - ); + const { span, updatedOptions } = createSpan("ArtifactsClient-createOrUpdateDataFlow", options); const operationArguments: coreHttp.OperationArguments = { dataFlowName, dataFlow, @@ -132,10 +129,7 @@ export class DataFlow { dataFlowName: string, options?: DataFlowGetDataFlowOptionalParams ): Promise { - const { span, updatedOptions } = createSpan( - "ArtifactsClient-getDataFlow", - options - ); + const { span, updatedOptions } = createSpan("ArtifactsClient-getDataFlow", options); const operationArguments: coreHttp.OperationArguments = { dataFlowName, options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) @@ -166,10 +160,7 @@ export class DataFlow { dataFlowName: string, options?: coreHttp.OperationOptions ): Promise> { - const { span, updatedOptions } = createSpan( - "ArtifactsClient-deleteDataFlow", - options - ); + const { span, updatedOptions } = createSpan("ArtifactsClient-deleteDataFlow", options); const operationArguments: coreHttp.OperationArguments = { dataFlowName, options: this.getOperationOptions(updatedOptions, "undefined") @@ -215,10 +206,7 @@ export class DataFlow { request: ArtifactRenameRequest, options?: coreHttp.OperationOptions ): Promise> { - const { span, updatedOptions } = createSpan( - "ArtifactsClient-renameDataFlow", - options - ); + const { span, updatedOptions } = createSpan("ArtifactsClient-renameDataFlow", options); const operationArguments: coreHttp.OperationArguments = { dataFlowName, request, diff --git a/sdk/synapse/synapse-artifacts/src/operations/dataFlowDebugSession.ts b/sdk/synapse/synapse-artifacts/src/operations/dataFlowDebugSession.ts index ed2eeb304cf8..0e1d94e49ba4 100644 --- a/sdk/synapse/synapse-artifacts/src/operations/dataFlowDebugSession.ts +++ b/sdk/synapse/synapse-artifacts/src/operations/dataFlowDebugSession.ts @@ -162,10 +162,7 @@ export class DataFlowDebugSession { request: DataFlowDebugPackage, options?: coreHttp.OperationOptions ): Promise { - const { span, updatedOptions } = createSpan( - "ArtifactsClient-addDataFlow", - options - ); + const { span, updatedOptions } = createSpan("ArtifactsClient-addDataFlow", options); const operationArguments: coreHttp.OperationArguments = { request, options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) @@ -230,10 +227,7 @@ export class DataFlowDebugSession { request: DataFlowDebugCommandRequest, options?: coreHttp.OperationOptions ): Promise> { - const { span, updatedOptions } = createSpan( - "ArtifactsClient-executeCommand", - options - ); + const { span, updatedOptions } = createSpan("ArtifactsClient-executeCommand", options); const operationArguments: coreHttp.OperationArguments = { request, options: this.getOperationOptions(updatedOptions, "undefined") diff --git a/sdk/synapse/synapse-artifacts/src/operations/dataset.ts b/sdk/synapse/synapse-artifacts/src/operations/dataset.ts index 0c3f0ea231c3..f313d4e8b78e 100644 --- a/sdk/synapse/synapse-artifacts/src/operations/dataset.ts +++ b/sdk/synapse/synapse-artifacts/src/operations/dataset.ts @@ -80,10 +80,7 @@ export class Dataset { private async _getDatasetsByWorkspace( options?: coreHttp.OperationOptions ): Promise { - const { span, updatedOptions } = createSpan( - "ArtifactsClient-_getDatasetsByWorkspace", - options - ); + const { span, updatedOptions } = createSpan("ArtifactsClient-_getDatasetsByWorkspace", options); const operationArguments: coreHttp.OperationArguments = { options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) }; @@ -115,10 +112,7 @@ export class Dataset { dataset: DatasetResource, options?: DatasetCreateOrUpdateDatasetOptionalParams ): Promise> { - const { span, updatedOptions } = createSpan( - "ArtifactsClient-createOrUpdateDataset", - options - ); + const { span, updatedOptions } = createSpan("ArtifactsClient-createOrUpdateDataset", options); const operationArguments: coreHttp.OperationArguments = { datasetName, dataset, @@ -163,10 +157,7 @@ export class Dataset { datasetName: string, options?: DatasetGetDatasetOptionalParams ): Promise { - const { span, updatedOptions } = createSpan( - "ArtifactsClient-getDataset", - options - ); + const { span, updatedOptions } = createSpan("ArtifactsClient-getDataset", options); const operationArguments: coreHttp.OperationArguments = { datasetName, options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) @@ -197,10 +188,7 @@ export class Dataset { datasetName: string, options?: coreHttp.OperationOptions ): Promise> { - const { span, updatedOptions } = createSpan( - "ArtifactsClient-deleteDataset", - options - ); + const { span, updatedOptions } = createSpan("ArtifactsClient-deleteDataset", options); const operationArguments: coreHttp.OperationArguments = { datasetName, options: this.getOperationOptions(updatedOptions, "undefined") @@ -246,10 +234,7 @@ export class Dataset { request: ArtifactRenameRequest, options?: coreHttp.OperationOptions ): Promise> { - const { span, updatedOptions } = createSpan( - "ArtifactsClient-renameDataset", - options - ); + const { span, updatedOptions } = createSpan("ArtifactsClient-renameDataset", options); const operationArguments: coreHttp.OperationArguments = { datasetName, request, diff --git a/sdk/synapse/synapse-artifacts/src/operations/integrationRuntimes.ts b/sdk/synapse/synapse-artifacts/src/operations/integrationRuntimes.ts index 4c0fa1bec0cd..da4b56b8910e 100644 --- a/sdk/synapse/synapse-artifacts/src/operations/integrationRuntimes.ts +++ b/sdk/synapse/synapse-artifacts/src/operations/integrationRuntimes.ts @@ -25,10 +25,7 @@ export class IntegrationRuntimes { * @param options The options parameters. */ async list(options?: coreHttp.OperationOptions): Promise { - const { span, updatedOptions } = createSpan( - "ArtifactsClient-list", - options - ); + const { span, updatedOptions } = createSpan("ArtifactsClient-list", options); const operationArguments: coreHttp.OperationArguments = { options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) }; @@ -55,10 +52,7 @@ export class IntegrationRuntimes { integrationRuntimeName: string, options?: coreHttp.OperationOptions ): Promise { - const { span, updatedOptions } = createSpan( - "ArtifactsClient-get", - options - ); + const { span, updatedOptions } = createSpan("ArtifactsClient-get", options); const operationArguments: coreHttp.OperationArguments = { integrationRuntimeName, options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) diff --git a/sdk/synapse/synapse-artifacts/src/operations/library.ts b/sdk/synapse/synapse-artifacts/src/operations/library.ts index f655e1fd5e65..279995660418 100644 --- a/sdk/synapse/synapse-artifacts/src/operations/library.ts +++ b/sdk/synapse/synapse-artifacts/src/operations/library.ts @@ -74,10 +74,7 @@ export class Library { * @param options The options parameters. */ private async _list(options?: coreHttp.OperationOptions): Promise { - const { span, updatedOptions } = createSpan( - "ArtifactsClient-_list", - options - ); + const { span, updatedOptions } = createSpan("ArtifactsClient-_list", options); const operationArguments: coreHttp.OperationArguments = { options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) }; @@ -105,10 +102,7 @@ export class Library { libraryName: string, options?: coreHttp.OperationOptions ): Promise> { - const { span, updatedOptions } = createSpan( - "ArtifactsClient-flush", - options - ); + const { span, updatedOptions } = createSpan("ArtifactsClient-flush", options); const operationArguments: coreHttp.OperationArguments = { libraryName, options: this.getOperationOptions(updatedOptions, "undefined") @@ -149,10 +143,7 @@ export class Library { operationId: string, options?: coreHttp.OperationOptions ): Promise { - const { span, updatedOptions } = createSpan( - "ArtifactsClient-getOperationResult", - options - ); + const { span, updatedOptions } = createSpan("ArtifactsClient-getOperationResult", options); const operationArguments: coreHttp.OperationArguments = { operationId, options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) @@ -184,10 +175,7 @@ export class Library { libraryName: string, options?: coreHttp.OperationOptions ): Promise> { - const { span, updatedOptions } = createSpan( - "ArtifactsClient-delete", - options - ); + const { span, updatedOptions } = createSpan("ArtifactsClient-delete", options); const operationArguments: coreHttp.OperationArguments = { libraryName, options: this.getOperationOptions(updatedOptions, "undefined") @@ -226,10 +214,7 @@ export class Library { * @param options The options parameters. */ async get(libraryName: string, options?: coreHttp.OperationOptions): Promise { - const { span, updatedOptions } = createSpan( - "ArtifactsClient-get", - options - ); + const { span, updatedOptions } = createSpan("ArtifactsClient-get", options); const operationArguments: coreHttp.OperationArguments = { libraryName, options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) @@ -261,10 +246,7 @@ export class Library { content: coreHttp.HttpRequestBody, options?: LibraryCreateOrAppendOptionalParams ): Promise> { - const { span, updatedOptions } = createSpan( - "ArtifactsClient-createOrAppend", - options - ); + const { span, updatedOptions } = createSpan("ArtifactsClient-createOrAppend", options); const operationArguments: coreHttp.OperationArguments = { libraryName, content, @@ -309,10 +291,7 @@ export class Library { nextLink: string, options?: coreHttp.OperationOptions ): Promise { - const { span, updatedOptions } = createSpan( - "ArtifactsClient-_listNext", - options - ); + const { span, updatedOptions } = createSpan("ArtifactsClient-_listNext", options); const operationArguments: coreHttp.OperationArguments = { nextLink, options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) diff --git a/sdk/synapse/synapse-artifacts/src/operations/linkedService.ts b/sdk/synapse/synapse-artifacts/src/operations/linkedService.ts index d7cb16a444c2..516228766151 100644 --- a/sdk/synapse/synapse-artifacts/src/operations/linkedService.ts +++ b/sdk/synapse/synapse-artifacts/src/operations/linkedService.ts @@ -163,10 +163,7 @@ export class LinkedService { linkedServiceName: string, options?: LinkedServiceGetLinkedServiceOptionalParams ): Promise { - const { span, updatedOptions } = createSpan( - "ArtifactsClient-getLinkedService", - options - ); + const { span, updatedOptions } = createSpan("ArtifactsClient-getLinkedService", options); const operationArguments: coreHttp.OperationArguments = { linkedServiceName, options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) @@ -197,10 +194,7 @@ export class LinkedService { linkedServiceName: string, options?: coreHttp.OperationOptions ): Promise> { - const { span, updatedOptions } = createSpan( - "ArtifactsClient-deleteLinkedService", - options - ); + const { span, updatedOptions } = createSpan("ArtifactsClient-deleteLinkedService", options); const operationArguments: coreHttp.OperationArguments = { linkedServiceName, options: this.getOperationOptions(updatedOptions, "undefined") @@ -246,10 +240,7 @@ export class LinkedService { request: ArtifactRenameRequest, options?: coreHttp.OperationOptions ): Promise> { - const { span, updatedOptions } = createSpan( - "ArtifactsClient-renameLinkedService", - options - ); + const { span, updatedOptions } = createSpan("ArtifactsClient-renameLinkedService", options); const operationArguments: coreHttp.OperationArguments = { linkedServiceName, request, diff --git a/sdk/synapse/synapse-artifacts/src/operations/notebook.ts b/sdk/synapse/synapse-artifacts/src/operations/notebook.ts index ce268dc5d777..79180b5df90c 100644 --- a/sdk/synapse/synapse-artifacts/src/operations/notebook.ts +++ b/sdk/synapse/synapse-artifacts/src/operations/notebook.ts @@ -190,10 +190,7 @@ export class Notebook { notebook: NotebookResource, options?: NotebookCreateOrUpdateNotebookOptionalParams ): Promise> { - const { span, updatedOptions } = createSpan( - "ArtifactsClient-createOrUpdateNotebook", - options - ); + const { span, updatedOptions } = createSpan("ArtifactsClient-createOrUpdateNotebook", options); const operationArguments: coreHttp.OperationArguments = { notebookName, notebook, @@ -238,10 +235,7 @@ export class Notebook { notebookName: string, options?: NotebookGetNotebookOptionalParams ): Promise { - const { span, updatedOptions } = createSpan( - "ArtifactsClient-getNotebook", - options - ); + const { span, updatedOptions } = createSpan("ArtifactsClient-getNotebook", options); const operationArguments: coreHttp.OperationArguments = { notebookName, options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) @@ -272,10 +266,7 @@ export class Notebook { notebookName: string, options?: coreHttp.OperationOptions ): Promise> { - const { span, updatedOptions } = createSpan( - "ArtifactsClient-deleteNotebook", - options - ); + const { span, updatedOptions } = createSpan("ArtifactsClient-deleteNotebook", options); const operationArguments: coreHttp.OperationArguments = { notebookName, options: this.getOperationOptions(updatedOptions, "undefined") @@ -321,10 +312,7 @@ export class Notebook { request: ArtifactRenameRequest, options?: coreHttp.OperationOptions ): Promise> { - const { span, updatedOptions } = createSpan( - "ArtifactsClient-renameNotebook", - options - ); + const { span, updatedOptions } = createSpan("ArtifactsClient-renameNotebook", options); const operationArguments: coreHttp.OperationArguments = { notebookName, request, diff --git a/sdk/synapse/synapse-artifacts/src/operations/pipeline.ts b/sdk/synapse/synapse-artifacts/src/operations/pipeline.ts index 56b94751db4c..b6b4397106da 100644 --- a/sdk/synapse/synapse-artifacts/src/operations/pipeline.ts +++ b/sdk/synapse/synapse-artifacts/src/operations/pipeline.ts @@ -117,10 +117,7 @@ export class Pipeline { pipeline: PipelineResource, options?: PipelineCreateOrUpdatePipelineOptionalParams ): Promise> { - const { span, updatedOptions } = createSpan( - "ArtifactsClient-createOrUpdatePipeline", - options - ); + const { span, updatedOptions } = createSpan("ArtifactsClient-createOrUpdatePipeline", options); const operationArguments: coreHttp.OperationArguments = { pipelineName, pipeline, @@ -165,10 +162,7 @@ export class Pipeline { pipelineName: string, options?: PipelineGetPipelineOptionalParams ): Promise { - const { span, updatedOptions } = createSpan( - "ArtifactsClient-getPipeline", - options - ); + const { span, updatedOptions } = createSpan("ArtifactsClient-getPipeline", options); const operationArguments: coreHttp.OperationArguments = { pipelineName, options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) @@ -199,10 +193,7 @@ export class Pipeline { pipelineName: string, options?: coreHttp.OperationOptions ): Promise> { - const { span, updatedOptions } = createSpan( - "ArtifactsClient-deletePipeline", - options - ); + const { span, updatedOptions } = createSpan("ArtifactsClient-deletePipeline", options); const operationArguments: coreHttp.OperationArguments = { pipelineName, options: this.getOperationOptions(updatedOptions, "undefined") @@ -248,10 +239,7 @@ export class Pipeline { request: ArtifactRenameRequest, options?: coreHttp.OperationOptions ): Promise> { - const { span, updatedOptions } = createSpan( - "ArtifactsClient-renamePipeline", - options - ); + const { span, updatedOptions } = createSpan("ArtifactsClient-renamePipeline", options); const operationArguments: coreHttp.OperationArguments = { pipelineName, request, @@ -296,10 +284,7 @@ export class Pipeline { pipelineName: string, options?: PipelineCreatePipelineRunOptionalParams ): Promise { - const { span, updatedOptions } = createSpan( - "ArtifactsClient-createPipelineRun", - options - ); + const { span, updatedOptions } = createSpan("ArtifactsClient-createPipelineRun", options); const operationArguments: coreHttp.OperationArguments = { pipelineName, options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) diff --git a/sdk/synapse/synapse-artifacts/src/operations/pipelineRun.ts b/sdk/synapse/synapse-artifacts/src/operations/pipelineRun.ts index a28101742263..0f54e1716736 100644 --- a/sdk/synapse/synapse-artifacts/src/operations/pipelineRun.ts +++ b/sdk/synapse/synapse-artifacts/src/operations/pipelineRun.ts @@ -69,10 +69,7 @@ export class PipelineRun { runId: string, options?: coreHttp.OperationOptions ): Promise { - const { span, updatedOptions } = createSpan( - "ArtifactsClient-getPipelineRun", - options - ); + const { span, updatedOptions } = createSpan("ArtifactsClient-getPipelineRun", options); const operationArguments: coreHttp.OperationArguments = { runId, options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) @@ -107,10 +104,7 @@ export class PipelineRun { filterParameters: RunFilterParameters, options?: coreHttp.OperationOptions ): Promise { - const { span, updatedOptions } = createSpan( - "ArtifactsClient-queryActivityRuns", - options - ); + const { span, updatedOptions } = createSpan("ArtifactsClient-queryActivityRuns", options); const operationArguments: coreHttp.OperationArguments = { pipelineName, runId, @@ -143,10 +137,7 @@ export class PipelineRun { runId: string, options?: PipelineRunCancelPipelineRunOptionalParams ): Promise { - const { span, updatedOptions } = createSpan( - "ArtifactsClient-cancelPipelineRun", - options - ); + const { span, updatedOptions } = createSpan("ArtifactsClient-cancelPipelineRun", options); const operationArguments: coreHttp.OperationArguments = { runId, options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) diff --git a/sdk/synapse/synapse-artifacts/src/operations/sparkJobDefinition.ts b/sdk/synapse/synapse-artifacts/src/operations/sparkJobDefinition.ts index c35453e244a2..fc8bec0ad299 100644 --- a/sdk/synapse/synapse-artifacts/src/operations/sparkJobDefinition.ts +++ b/sdk/synapse/synapse-artifacts/src/operations/sparkJobDefinition.ts @@ -165,10 +165,7 @@ export class SparkJobDefinition { sparkJobDefinitionName: string, options?: SparkJobDefinitionGetSparkJobDefinitionOptionalParams ): Promise { - const { span, updatedOptions } = createSpan( - "ArtifactsClient-getSparkJobDefinition", - options - ); + const { span, updatedOptions } = createSpan("ArtifactsClient-getSparkJobDefinition", options); const operationArguments: coreHttp.OperationArguments = { sparkJobDefinitionName, options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) @@ -344,10 +341,7 @@ export class SparkJobDefinition { sparkJobDefinitionAzureResource: SparkJobDefinitionResource, options?: coreHttp.OperationOptions ): Promise> { - const { span, updatedOptions } = createSpan( - "ArtifactsClient-debugSparkJobDefinition", - options - ); + const { span, updatedOptions } = createSpan("ArtifactsClient-debugSparkJobDefinition", options); const operationArguments: coreHttp.OperationArguments = { sparkJobDefinitionAzureResource, options: this.getOperationOptions(updatedOptions, "location") diff --git a/sdk/synapse/synapse-artifacts/src/operations/sqlPools.ts b/sdk/synapse/synapse-artifacts/src/operations/sqlPools.ts index bdeb92507764..92f522939d1a 100644 --- a/sdk/synapse/synapse-artifacts/src/operations/sqlPools.ts +++ b/sdk/synapse/synapse-artifacts/src/operations/sqlPools.ts @@ -25,10 +25,7 @@ export class SqlPools { * @param options The options parameters. */ async list(options?: coreHttp.OperationOptions): Promise { - const { span, updatedOptions } = createSpan( - "ArtifactsClient-list", - options - ); + const { span, updatedOptions } = createSpan("ArtifactsClient-list", options); const operationArguments: coreHttp.OperationArguments = { options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) }; @@ -55,10 +52,7 @@ export class SqlPools { sqlPoolName: string, options?: coreHttp.OperationOptions ): Promise { - const { span, updatedOptions } = createSpan( - "ArtifactsClient-get", - options - ); + const { span, updatedOptions } = createSpan("ArtifactsClient-get", options); const operationArguments: coreHttp.OperationArguments = { sqlPoolName, options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) diff --git a/sdk/synapse/synapse-artifacts/src/operations/sqlScript.ts b/sdk/synapse/synapse-artifacts/src/operations/sqlScript.ts index c46a5b430381..8c41ab577075 100644 --- a/sdk/synapse/synapse-artifacts/src/operations/sqlScript.ts +++ b/sdk/synapse/synapse-artifacts/src/operations/sqlScript.ts @@ -115,10 +115,7 @@ export class SqlScript { sqlScript: SqlScriptResource, options?: SqlScriptCreateOrUpdateSqlScriptOptionalParams ): Promise> { - const { span, updatedOptions } = createSpan( - "ArtifactsClient-createOrUpdateSqlScript", - options - ); + const { span, updatedOptions } = createSpan("ArtifactsClient-createOrUpdateSqlScript", options); const operationArguments: coreHttp.OperationArguments = { sqlScriptName, sqlScript, @@ -163,10 +160,7 @@ export class SqlScript { sqlScriptName: string, options?: SqlScriptGetSqlScriptOptionalParams ): Promise { - const { span, updatedOptions } = createSpan( - "ArtifactsClient-getSqlScript", - options - ); + const { span, updatedOptions } = createSpan("ArtifactsClient-getSqlScript", options); const operationArguments: coreHttp.OperationArguments = { sqlScriptName, options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) @@ -197,10 +191,7 @@ export class SqlScript { sqlScriptName: string, options?: coreHttp.OperationOptions ): Promise> { - const { span, updatedOptions } = createSpan( - "ArtifactsClient-deleteSqlScript", - options - ); + const { span, updatedOptions } = createSpan("ArtifactsClient-deleteSqlScript", options); const operationArguments: coreHttp.OperationArguments = { sqlScriptName, options: this.getOperationOptions(updatedOptions, "undefined") @@ -246,10 +237,7 @@ export class SqlScript { request: ArtifactRenameRequest, options?: coreHttp.OperationOptions ): Promise> { - const { span, updatedOptions } = createSpan( - "ArtifactsClient-renameSqlScript", - options - ); + const { span, updatedOptions } = createSpan("ArtifactsClient-renameSqlScript", options); const operationArguments: coreHttp.OperationArguments = { sqlScriptName, request, diff --git a/sdk/synapse/synapse-artifacts/src/operations/trigger.ts b/sdk/synapse/synapse-artifacts/src/operations/trigger.ts index 468ab70d9510..f94cd6188ef7 100644 --- a/sdk/synapse/synapse-artifacts/src/operations/trigger.ts +++ b/sdk/synapse/synapse-artifacts/src/operations/trigger.ts @@ -82,10 +82,7 @@ export class Trigger { private async _getTriggersByWorkspace( options?: coreHttp.OperationOptions ): Promise { - const { span, updatedOptions } = createSpan( - "ArtifactsClient-_getTriggersByWorkspace", - options - ); + const { span, updatedOptions } = createSpan("ArtifactsClient-_getTriggersByWorkspace", options); const operationArguments: coreHttp.OperationArguments = { options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) }; @@ -117,10 +114,7 @@ export class Trigger { trigger: TriggerResource, options?: TriggerCreateOrUpdateTriggerOptionalParams ): Promise> { - const { span, updatedOptions } = createSpan( - "ArtifactsClient-createOrUpdateTrigger", - options - ); + const { span, updatedOptions } = createSpan("ArtifactsClient-createOrUpdateTrigger", options); const operationArguments: coreHttp.OperationArguments = { triggerName, trigger, @@ -165,10 +159,7 @@ export class Trigger { triggerName: string, options?: TriggerGetTriggerOptionalParams ): Promise { - const { span, updatedOptions } = createSpan( - "ArtifactsClient-getTrigger", - options - ); + const { span, updatedOptions } = createSpan("ArtifactsClient-getTrigger", options); const operationArguments: coreHttp.OperationArguments = { triggerName, options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) @@ -199,10 +190,7 @@ export class Trigger { triggerName: string, options?: coreHttp.OperationOptions ): Promise> { - const { span, updatedOptions } = createSpan( - "ArtifactsClient-deleteTrigger", - options - ); + const { span, updatedOptions } = createSpan("ArtifactsClient-deleteTrigger", options); const operationArguments: coreHttp.OperationArguments = { triggerName, options: this.getOperationOptions(updatedOptions, "undefined") @@ -374,10 +362,7 @@ export class Trigger { triggerName: string, options?: coreHttp.OperationOptions ): Promise> { - const { span, updatedOptions } = createSpan( - "ArtifactsClient-startTrigger", - options - ); + const { span, updatedOptions } = createSpan("ArtifactsClient-startTrigger", options); const operationArguments: coreHttp.OperationArguments = { triggerName, options: this.getOperationOptions(updatedOptions, "undefined") @@ -421,10 +406,7 @@ export class Trigger { triggerName: string, options?: coreHttp.OperationOptions ): Promise> { - const { span, updatedOptions } = createSpan( - "ArtifactsClient-stopTrigger", - options - ); + const { span, updatedOptions } = createSpan("ArtifactsClient-stopTrigger", options); const operationArguments: coreHttp.OperationArguments = { triggerName, options: this.getOperationOptions(updatedOptions, "undefined") diff --git a/sdk/synapse/synapse-artifacts/src/operations/triggerRun.ts b/sdk/synapse/synapse-artifacts/src/operations/triggerRun.ts index 7896b006baac..dd8202fc3dc0 100644 --- a/sdk/synapse/synapse-artifacts/src/operations/triggerRun.ts +++ b/sdk/synapse/synapse-artifacts/src/operations/triggerRun.ts @@ -31,10 +31,7 @@ export class TriggerRun { runId: string, options?: coreHttp.OperationOptions ): Promise { - const { span, updatedOptions } = createSpan( - "ArtifactsClient-rerunTriggerInstance", - options - ); + const { span, updatedOptions } = createSpan("ArtifactsClient-rerunTriggerInstance", options); const operationArguments: coreHttp.OperationArguments = { triggerName, runId, @@ -68,10 +65,7 @@ export class TriggerRun { runId: string, options?: coreHttp.OperationOptions ): Promise { - const { span, updatedOptions } = createSpan( - "ArtifactsClient-cancelTriggerInstance", - options - ); + const { span, updatedOptions } = createSpan("ArtifactsClient-cancelTriggerInstance", options); const operationArguments: coreHttp.OperationArguments = { triggerName, runId, diff --git a/sdk/synapse/synapse-artifacts/src/operations/workspace.ts b/sdk/synapse/synapse-artifacts/src/operations/workspace.ts index 8a78f73cfb2b..46d6c87b83bb 100644 --- a/sdk/synapse/synapse-artifacts/src/operations/workspace.ts +++ b/sdk/synapse/synapse-artifacts/src/operations/workspace.ts @@ -25,10 +25,7 @@ export class Workspace { * @param options The options parameters. */ async get(options?: coreHttp.OperationOptions): Promise { - const { span, updatedOptions } = createSpan( - "ArtifactsClient-get", - options - ); + const { span, updatedOptions } = createSpan("ArtifactsClient-get", options); const operationArguments: coreHttp.OperationArguments = { options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) }; diff --git a/sdk/synapse/synapse-artifacts/src/operations/workspaceGitRepoManagement.ts b/sdk/synapse/synapse-artifacts/src/operations/workspaceGitRepoManagement.ts index 5bb7746b1fb4..9a34ca199221 100644 --- a/sdk/synapse/synapse-artifacts/src/operations/workspaceGitRepoManagement.ts +++ b/sdk/synapse/synapse-artifacts/src/operations/workspaceGitRepoManagement.ts @@ -33,10 +33,7 @@ export class WorkspaceGitRepoManagement { gitHubAccessTokenRequest: GitHubAccessTokenRequest, options?: WorkspaceGitRepoManagementGetGitHubAccessTokenOptionalParams ): Promise { - const { span, updatedOptions } = createSpan( - "ArtifactsClient-getGitHubAccessToken", - options - ); + const { span, updatedOptions } = createSpan("ArtifactsClient-getGitHubAccessToken", options); const operationArguments: coreHttp.OperationArguments = { gitHubAccessTokenRequest, options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) From 78877027008ab84f81eec60eb1ad4fb0212b719b Mon Sep 17 00:00:00 2001 From: Richard Park <51494936+richardpark-msft@users.noreply.github.com> Date: Mon, 22 Feb 2021 22:18:49 +0000 Subject: [PATCH 29/52] synapse-access-control: use core-tracing createSpan --- .../synapse-access-control/package.json | 1 + .../src/accessControlClient.ts | 32 +++++++++---------- .../synapse-access-control/src/tracing.ts | 2 +- 3 files changed, 18 insertions(+), 17 deletions(-) diff --git a/sdk/synapse/synapse-access-control/package.json b/sdk/synapse/synapse-access-control/package.json index bc159c210dc5..ec39b12ceef5 100644 --- a/sdk/synapse/synapse-access-control/package.json +++ b/sdk/synapse/synapse-access-control/package.json @@ -9,6 +9,7 @@ "dependencies": { "@azure/core-paging": "^1.1.1", "@azure/core-http": "^1.2.0", + "@azure/core-tracing": "1.0.0-preview.10", "tslib": "^2.0.0" }, "keywords": [ diff --git a/sdk/synapse/synapse-access-control/src/accessControlClient.ts b/sdk/synapse/synapse-access-control/src/accessControlClient.ts index 01a072537bb0..6f12bd203301 100644 --- a/sdk/synapse/synapse-access-control/src/accessControlClient.ts +++ b/sdk/synapse/synapse-access-control/src/accessControlClient.ts @@ -88,10 +88,10 @@ export class AccessControlClient extends AccessControlClientContext { ): Promise { const { span, updatedOptions } = createSpan( "AccessControlClient-_getRoleDefinitions", - coreHttp.operationOptionsToRequestOptionsBase(options || {}) + options ); const operationArguments: coreHttp.OperationArguments = { - options: updatedOptions + options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) }; try { const result = await this.sendOperationRequest( @@ -121,11 +121,11 @@ export class AccessControlClient extends AccessControlClientContext { ): Promise { const { span, updatedOptions } = createSpan( "AccessControlClient-getRoleDefinitionById", - coreHttp.operationOptionsToRequestOptionsBase(options || {}) + options ); const operationArguments: coreHttp.OperationArguments = { roleId, - options: updatedOptions + options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) }; try { const result = await this.sendOperationRequest( @@ -155,11 +155,11 @@ export class AccessControlClient extends AccessControlClientContext { ): Promise { const { span, updatedOptions } = createSpan( "AccessControlClient-createRoleAssignment", - coreHttp.operationOptionsToRequestOptionsBase(options || {}) + options ); const operationArguments: coreHttp.OperationArguments = { createRoleAssignmentOptions, - options: updatedOptions + options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) }; try { const result = await this.sendOperationRequest( @@ -187,10 +187,10 @@ export class AccessControlClient extends AccessControlClientContext { ): Promise { const { span, updatedOptions } = createSpan( "AccessControlClient-getRoleAssignments", - coreHttp.operationOptionsToRequestOptionsBase(options || {}) + options ); const operationArguments: coreHttp.OperationArguments = { - options: updatedOptions + options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) }; try { const result = await this.sendOperationRequest( @@ -220,11 +220,11 @@ export class AccessControlClient extends AccessControlClientContext { ): Promise { const { span, updatedOptions } = createSpan( "AccessControlClient-getRoleAssignmentById", - coreHttp.operationOptionsToRequestOptionsBase(options || {}) + options ); const operationArguments: coreHttp.OperationArguments = { roleAssignmentId, - options: updatedOptions + options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) }; try { const result = await this.sendOperationRequest( @@ -254,11 +254,11 @@ export class AccessControlClient extends AccessControlClientContext { ): Promise { const { span, updatedOptions } = createSpan( "AccessControlClient-deleteRoleAssignmentById", - coreHttp.operationOptionsToRequestOptionsBase(options || {}) + options ); const operationArguments: coreHttp.OperationArguments = { roleAssignmentId, - options: updatedOptions + options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) }; try { const result = await this.sendOperationRequest( @@ -286,10 +286,10 @@ export class AccessControlClient extends AccessControlClientContext { ): Promise { const { span, updatedOptions } = createSpan( "AccessControlClient-getCallerRoleAssignments", - coreHttp.operationOptionsToRequestOptionsBase(options || {}) + options ); const operationArguments: coreHttp.OperationArguments = { - options: updatedOptions + options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) }; try { const result = await this.sendOperationRequest( @@ -319,11 +319,11 @@ export class AccessControlClient extends AccessControlClientContext { ): Promise { const { span, updatedOptions } = createSpan( "AccessControlClient-_getRoleDefinitionsNext", - coreHttp.operationOptionsToRequestOptionsBase(options || {}) + options ); const operationArguments: coreHttp.OperationArguments = { nextLink, - options: updatedOptions + options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) }; try { const result = await this.sendOperationRequest( diff --git a/sdk/synapse/synapse-access-control/src/tracing.ts b/sdk/synapse/synapse-access-control/src/tracing.ts index bd5964daaed0..05a45bbbe4bc 100644 --- a/sdk/synapse/synapse-access-control/src/tracing.ts +++ b/sdk/synapse/synapse-access-control/src/tracing.ts @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -import { createSpanFunction } from "@azure/core-http"; +import { createSpanFunction } from "@azure/core-tracing"; export const createSpan = createSpanFunction({ namespace: "Azure.Synapse.AccessControl", From 5a71f9280659e5bea6286db44b304ac8f25f04b7 Mon Sep 17 00:00:00 2001 From: Richard Park <51494936+richardpark-msft@users.noreply.github.com> Date: Mon, 22 Feb 2021 22:22:42 +0000 Subject: [PATCH 30/52] Formatting --- .../synapse-access-control/src/accessControlClient.ts | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/sdk/synapse/synapse-access-control/src/accessControlClient.ts b/sdk/synapse/synapse-access-control/src/accessControlClient.ts index 6f12bd203301..bd77c5092885 100644 --- a/sdk/synapse/synapse-access-control/src/accessControlClient.ts +++ b/sdk/synapse/synapse-access-control/src/accessControlClient.ts @@ -86,10 +86,7 @@ export class AccessControlClient extends AccessControlClientContext { private async _getRoleDefinitions( options?: coreHttp.OperationOptions ): Promise { - const { span, updatedOptions } = createSpan( - "AccessControlClient-_getRoleDefinitions", - options - ); + const { span, updatedOptions } = createSpan("AccessControlClient-_getRoleDefinitions", options); const operationArguments: coreHttp.OperationArguments = { options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) }; @@ -185,10 +182,7 @@ export class AccessControlClient extends AccessControlClientContext { async getRoleAssignments( options?: AccessControlClientGetRoleAssignmentsOptionalParams ): Promise { - const { span, updatedOptions } = createSpan( - "AccessControlClient-getRoleAssignments", - options - ); + const { span, updatedOptions } = createSpan("AccessControlClient-getRoleAssignments", options); const operationArguments: coreHttp.OperationArguments = { options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) }; From e86b11dcdf977c56bdb59164db7a284d2ca87cf7 Mon Sep 17 00:00:00 2001 From: Richard Park <51494936+richardpark-msft@users.noreply.github.com> Date: Mon, 22 Feb 2021 22:23:27 +0000 Subject: [PATCH 31/52] synapse-managed-privateendpoints: update to use core-tracing --- .../package.json | 1 + .../src/operations/managedPrivateEndpoints.ts | 20 +++++++++---------- .../src/tracing.ts | 2 +- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/sdk/synapse/synapse-managed-private-endpoints/package.json b/sdk/synapse/synapse-managed-private-endpoints/package.json index f0c06ce1961e..fac1a4ea043c 100644 --- a/sdk/synapse/synapse-managed-private-endpoints/package.json +++ b/sdk/synapse/synapse-managed-private-endpoints/package.json @@ -9,6 +9,7 @@ "dependencies": { "@azure/core-paging": "^1.1.1", "@azure/core-http": "^1.2.0", + "@azure/core-tracing": "1.0.0-preview.10", "@opentelemetry/api": "^0.10.2", "tslib": "^2.0.0" }, diff --git a/sdk/synapse/synapse-managed-private-endpoints/src/operations/managedPrivateEndpoints.ts b/sdk/synapse/synapse-managed-private-endpoints/src/operations/managedPrivateEndpoints.ts index b089042fd23f..16b671787190 100644 --- a/sdk/synapse/synapse-managed-private-endpoints/src/operations/managedPrivateEndpoints.ts +++ b/sdk/synapse/synapse-managed-private-endpoints/src/operations/managedPrivateEndpoints.ts @@ -86,12 +86,12 @@ export class ManagedPrivateEndpoints { ): Promise { const { span, updatedOptions } = createSpan( "ManagedPrivateEndpointsClient-get", - coreHttp.operationOptionsToRequestOptionsBase(options || {}) + options ); const operationArguments: coreHttp.OperationArguments = { managedVirtualNetworkName, managedPrivateEndpointName, - options: updatedOptions + options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) }; try { const result = await this.client.sendOperationRequest(operationArguments, getOperationSpec); @@ -122,13 +122,13 @@ export class ManagedPrivateEndpoints { ): Promise { const { span, updatedOptions } = createSpan( "ManagedPrivateEndpointsClient-create", - coreHttp.operationOptionsToRequestOptionsBase(options || {}) + options ); const operationArguments: coreHttp.OperationArguments = { managedVirtualNetworkName, managedPrivateEndpointName, managedPrivateEndpoint, - options: updatedOptions + options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) }; try { const result = await this.client.sendOperationRequest( @@ -160,12 +160,12 @@ export class ManagedPrivateEndpoints { ): Promise { const { span, updatedOptions } = createSpan( "ManagedPrivateEndpointsClient-delete", - coreHttp.operationOptionsToRequestOptionsBase(options || {}) + options ); const operationArguments: coreHttp.OperationArguments = { managedVirtualNetworkName, managedPrivateEndpointName, - options: updatedOptions + options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) }; try { const result = await this.client.sendOperationRequest( @@ -195,11 +195,11 @@ export class ManagedPrivateEndpoints { ): Promise { const { span, updatedOptions } = createSpan( "ManagedPrivateEndpointsClient-_list", - coreHttp.operationOptionsToRequestOptionsBase(options || {}) + options ); const operationArguments: coreHttp.OperationArguments = { managedVirtualNetworkName, - options: updatedOptions + options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) }; try { const result = await this.client.sendOperationRequest(operationArguments, listOperationSpec); @@ -228,12 +228,12 @@ export class ManagedPrivateEndpoints { ): Promise { const { span, updatedOptions } = createSpan( "ManagedPrivateEndpointsClient-_listNext", - coreHttp.operationOptionsToRequestOptionsBase(options || {}) + options ); const operationArguments: coreHttp.OperationArguments = { managedVirtualNetworkName, nextLink, - options: updatedOptions + options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) }; try { const result = await this.client.sendOperationRequest( diff --git a/sdk/synapse/synapse-managed-private-endpoints/src/tracing.ts b/sdk/synapse/synapse-managed-private-endpoints/src/tracing.ts index ec5a2da97e89..a2368a37a779 100644 --- a/sdk/synapse/synapse-managed-private-endpoints/src/tracing.ts +++ b/sdk/synapse/synapse-managed-private-endpoints/src/tracing.ts @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -import { createSpanFunction } from "@azure/core-http"; +import { createSpanFunction } from "@azure/core-tracing"; export const createSpan = createSpanFunction({ namespace: "Azure.Synapse.ManagedPrivateEndpoints", From 36e30c1150a79e56405304c361febd326f2c9c9f Mon Sep 17 00:00:00 2001 From: Richard Park <51494936+richardpark-msft@users.noreply.github.com> Date: Mon, 22 Feb 2021 22:23:52 +0000 Subject: [PATCH 32/52] Formatting --- .../src/operations/managedPrivateEndpoints.ts | 25 ++++--------------- 1 file changed, 5 insertions(+), 20 deletions(-) diff --git a/sdk/synapse/synapse-managed-private-endpoints/src/operations/managedPrivateEndpoints.ts b/sdk/synapse/synapse-managed-private-endpoints/src/operations/managedPrivateEndpoints.ts index 16b671787190..23b267eaa645 100644 --- a/sdk/synapse/synapse-managed-private-endpoints/src/operations/managedPrivateEndpoints.ts +++ b/sdk/synapse/synapse-managed-private-endpoints/src/operations/managedPrivateEndpoints.ts @@ -84,10 +84,7 @@ export class ManagedPrivateEndpoints { managedPrivateEndpointName: string, options?: coreHttp.OperationOptions ): Promise { - const { span, updatedOptions } = createSpan( - "ManagedPrivateEndpointsClient-get", - options - ); + const { span, updatedOptions } = createSpan("ManagedPrivateEndpointsClient-get", options); const operationArguments: coreHttp.OperationArguments = { managedVirtualNetworkName, managedPrivateEndpointName, @@ -120,10 +117,7 @@ export class ManagedPrivateEndpoints { managedPrivateEndpoint: ManagedPrivateEndpoint, options?: coreHttp.OperationOptions ): Promise { - const { span, updatedOptions } = createSpan( - "ManagedPrivateEndpointsClient-create", - options - ); + const { span, updatedOptions } = createSpan("ManagedPrivateEndpointsClient-create", options); const operationArguments: coreHttp.OperationArguments = { managedVirtualNetworkName, managedPrivateEndpointName, @@ -158,10 +152,7 @@ export class ManagedPrivateEndpoints { managedPrivateEndpointName: string, options?: coreHttp.OperationOptions ): Promise { - const { span, updatedOptions } = createSpan( - "ManagedPrivateEndpointsClient-delete", - options - ); + const { span, updatedOptions } = createSpan("ManagedPrivateEndpointsClient-delete", options); const operationArguments: coreHttp.OperationArguments = { managedVirtualNetworkName, managedPrivateEndpointName, @@ -193,10 +184,7 @@ export class ManagedPrivateEndpoints { managedVirtualNetworkName: string, options?: coreHttp.OperationOptions ): Promise { - const { span, updatedOptions } = createSpan( - "ManagedPrivateEndpointsClient-_list", - options - ); + const { span, updatedOptions } = createSpan("ManagedPrivateEndpointsClient-_list", options); const operationArguments: coreHttp.OperationArguments = { managedVirtualNetworkName, options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) @@ -226,10 +214,7 @@ export class ManagedPrivateEndpoints { nextLink: string, options?: coreHttp.OperationOptions ): Promise { - const { span, updatedOptions } = createSpan( - "ManagedPrivateEndpointsClient-_listNext", - options - ); + const { span, updatedOptions } = createSpan("ManagedPrivateEndpointsClient-_listNext", options); const operationArguments: coreHttp.OperationArguments = { managedVirtualNetworkName, nextLink, From 5e3fada4a075e706d25c474df3b74c7cbbbd3fcc Mon Sep 17 00:00:00 2001 From: Richard Park <51494936+richardpark-msft@users.noreply.github.com> Date: Mon, 22 Feb 2021 22:28:50 +0000 Subject: [PATCH 33/52] synapse-monitoring: change to use core-tracing --- .../synapse-monitoring/src/operations/monitoring.ts | 8 ++++---- sdk/synapse/synapse-monitoring/src/tracing.ts | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/sdk/synapse/synapse-monitoring/src/operations/monitoring.ts b/sdk/synapse/synapse-monitoring/src/operations/monitoring.ts index d6ee4e590a64..f89a876046ee 100644 --- a/sdk/synapse/synapse-monitoring/src/operations/monitoring.ts +++ b/sdk/synapse/synapse-monitoring/src/operations/monitoring.ts @@ -34,10 +34,10 @@ export class Monitoring { ): Promise { const { span, updatedOptions } = createSpan( "MonitoringClient-getSparkJobList", - coreHttp.operationOptionsToRequestOptionsBase(options || {}) + options ); const operationArguments: coreHttp.OperationArguments = { - options: updatedOptions + options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) }; try { const result = await this.client.sendOperationRequest( @@ -65,10 +65,10 @@ export class Monitoring { ): Promise { const { span, updatedOptions } = createSpan( "MonitoringClient-getSqlJobQueryString", - coreHttp.operationOptionsToRequestOptionsBase(options || {}) + options ); const operationArguments: coreHttp.OperationArguments = { - options: updatedOptions + options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) }; try { const result = await this.client.sendOperationRequest( diff --git a/sdk/synapse/synapse-monitoring/src/tracing.ts b/sdk/synapse/synapse-monitoring/src/tracing.ts index bf65d560face..200976381478 100644 --- a/sdk/synapse/synapse-monitoring/src/tracing.ts +++ b/sdk/synapse/synapse-monitoring/src/tracing.ts @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -import { createSpanFunction } from "@azure/core-http"; +import { createSpanFunction } from "@azure/core-tracing"; export const createSpan = createSpanFunction({ namespace: "Azure.Synapse.Monitoring", From fc4e05ff9aa198c12b9f02ba064fabfd8624a2e5 Mon Sep 17 00:00:00 2001 From: Richard Park <51494936+richardpark-msft@users.noreply.github.com> Date: Mon, 22 Feb 2021 22:31:26 +0000 Subject: [PATCH 34/52] synapse-spark: changed to use core-tracing --- sdk/synapse/synapse-spark/package.json | 3 +- .../src/operations/sparkBatch.ts | 16 ++++----- .../src/operations/sparkSession.ts | 36 +++++++++---------- sdk/synapse/synapse-spark/src/tracing.ts | 2 +- 4 files changed, 29 insertions(+), 28 deletions(-) diff --git a/sdk/synapse/synapse-spark/package.json b/sdk/synapse/synapse-spark/package.json index b339a5f8b89f..47c5a4f4304a 100644 --- a/sdk/synapse/synapse-spark/package.json +++ b/sdk/synapse/synapse-spark/package.json @@ -8,6 +8,7 @@ "version": "1.0.0-beta.3", "dependencies": { "@azure/core-http": "^1.2.0", + "@azure/core-tracing": "1.0.0-preview.10", "@opentelemetry/api": "^0.10.2", "tslib": "^2.0.0" }, @@ -76,4 +77,4 @@ }, "sideEffects": false, "autoPublish": true -} +} \ No newline at end of file diff --git a/sdk/synapse/synapse-spark/src/operations/sparkBatch.ts b/sdk/synapse/synapse-spark/src/operations/sparkBatch.ts index 56d101867c09..fc509f376e58 100644 --- a/sdk/synapse/synapse-spark/src/operations/sparkBatch.ts +++ b/sdk/synapse/synapse-spark/src/operations/sparkBatch.ts @@ -37,10 +37,10 @@ export class SparkBatch { ): Promise { const { span, updatedOptions } = createSpan( "SparkClient-getSparkBatchJobs", - coreHttp.operationOptionsToRequestOptionsBase(options || {}) + options ); const operationArguments: coreHttp.OperationArguments = { - options: updatedOptions + options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) }; try { const result = await this.client.sendOperationRequest( @@ -70,11 +70,11 @@ export class SparkBatch { ): Promise { const { span, updatedOptions } = createSpan( "SparkClient-createSparkBatchJob", - coreHttp.operationOptionsToRequestOptionsBase(options || {}) + options ); const operationArguments: coreHttp.OperationArguments = { sparkBatchJobOptions, - options: updatedOptions + options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) }; try { const result = await this.client.sendOperationRequest( @@ -104,11 +104,11 @@ export class SparkBatch { ): Promise { const { span, updatedOptions } = createSpan( "SparkClient-getSparkBatchJob", - coreHttp.operationOptionsToRequestOptionsBase(options || {}) + options ); const operationArguments: coreHttp.OperationArguments = { batchId, - options: updatedOptions + options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) }; try { const result = await this.client.sendOperationRequest( @@ -138,11 +138,11 @@ export class SparkBatch { ): Promise { const { span, updatedOptions } = createSpan( "SparkClient-cancelSparkBatchJob", - coreHttp.operationOptionsToRequestOptionsBase(options || {}) + options ); const operationArguments: coreHttp.OperationArguments = { batchId, - options: updatedOptions + options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) }; try { const result = await this.client.sendOperationRequest( diff --git a/sdk/synapse/synapse-spark/src/operations/sparkSession.ts b/sdk/synapse/synapse-spark/src/operations/sparkSession.ts index 0780d182a66a..993f1022ae99 100644 --- a/sdk/synapse/synapse-spark/src/operations/sparkSession.ts +++ b/sdk/synapse/synapse-spark/src/operations/sparkSession.ts @@ -42,10 +42,10 @@ export class SparkSession { ): Promise { const { span, updatedOptions } = createSpan( "SparkClient-getSparkSessions", - coreHttp.operationOptionsToRequestOptionsBase(options || {}) + options ); const operationArguments: coreHttp.OperationArguments = { - options: updatedOptions + options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) }; try { const result = await this.client.sendOperationRequest( @@ -75,11 +75,11 @@ export class SparkSession { ): Promise { const { span, updatedOptions } = createSpan( "SparkClient-createSparkSession", - coreHttp.operationOptionsToRequestOptionsBase(options || {}) + options ); const operationArguments: coreHttp.OperationArguments = { sparkSessionOptions, - options: updatedOptions + options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) }; try { const result = await this.client.sendOperationRequest( @@ -109,11 +109,11 @@ export class SparkSession { ): Promise { const { span, updatedOptions } = createSpan( "SparkClient-getSparkSession", - coreHttp.operationOptionsToRequestOptionsBase(options || {}) + options ); const operationArguments: coreHttp.OperationArguments = { sessionId, - options: updatedOptions + options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) }; try { const result = await this.client.sendOperationRequest( @@ -143,11 +143,11 @@ export class SparkSession { ): Promise { const { span, updatedOptions } = createSpan( "SparkClient-cancelSparkSession", - coreHttp.operationOptionsToRequestOptionsBase(options || {}) + options ); const operationArguments: coreHttp.OperationArguments = { sessionId, - options: updatedOptions + options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) }; try { const result = await this.client.sendOperationRequest( @@ -177,11 +177,11 @@ export class SparkSession { ): Promise { const { span, updatedOptions } = createSpan( "SparkClient-resetSparkSessionTimeout", - coreHttp.operationOptionsToRequestOptionsBase(options || {}) + options ); const operationArguments: coreHttp.OperationArguments = { sessionId, - options: updatedOptions + options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) }; try { const result = await this.client.sendOperationRequest( @@ -211,11 +211,11 @@ export class SparkSession { ): Promise { const { span, updatedOptions } = createSpan( "SparkClient-getSparkStatements", - coreHttp.operationOptionsToRequestOptionsBase(options || {}) + options ); const operationArguments: coreHttp.OperationArguments = { sessionId, - options: updatedOptions + options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) }; try { const result = await this.client.sendOperationRequest( @@ -247,12 +247,12 @@ export class SparkSession { ): Promise { const { span, updatedOptions } = createSpan( "SparkClient-createSparkStatement", - coreHttp.operationOptionsToRequestOptionsBase(options || {}) + options ); const operationArguments: coreHttp.OperationArguments = { sessionId, sparkStatementOptions, - options: updatedOptions + options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) }; try { const result = await this.client.sendOperationRequest( @@ -284,12 +284,12 @@ export class SparkSession { ): Promise { const { span, updatedOptions } = createSpan( "SparkClient-getSparkStatement", - coreHttp.operationOptionsToRequestOptionsBase(options || {}) + options ); const operationArguments: coreHttp.OperationArguments = { sessionId, statementId, - options: updatedOptions + options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) }; try { const result = await this.client.sendOperationRequest( @@ -321,12 +321,12 @@ export class SparkSession { ): Promise { const { span, updatedOptions } = createSpan( "SparkClient-cancelSparkStatement", - coreHttp.operationOptionsToRequestOptionsBase(options || {}) + options ); const operationArguments: coreHttp.OperationArguments = { sessionId, statementId, - options: updatedOptions + options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) }; try { const result = await this.client.sendOperationRequest( diff --git a/sdk/synapse/synapse-spark/src/tracing.ts b/sdk/synapse/synapse-spark/src/tracing.ts index 08ce4428a831..9d08d59a6c3e 100644 --- a/sdk/synapse/synapse-spark/src/tracing.ts +++ b/sdk/synapse/synapse-spark/src/tracing.ts @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -import { createSpanFunction } from "@azure/core-http"; +import { createSpanFunction } from "@azure/core-tracing"; export const createSpan = createSpanFunction({ namespace: "Azure.Synapse.Spark", From 3785e5e0b27981383f9d1d58ec7cec9dabc85d17 Mon Sep 17 00:00:00 2001 From: Richard Park <51494936+richardpark-msft@users.noreply.github.com> Date: Mon, 22 Feb 2021 22:32:03 +0000 Subject: [PATCH 35/52] Formatting --- .../src/operations/monitoring.ts | 10 +---- sdk/synapse/synapse-spark/package.json | 2 +- .../src/operations/sparkBatch.ts | 20 ++------- .../src/operations/sparkSession.ts | 45 ++++--------------- 4 files changed, 16 insertions(+), 61 deletions(-) diff --git a/sdk/synapse/synapse-monitoring/src/operations/monitoring.ts b/sdk/synapse/synapse-monitoring/src/operations/monitoring.ts index f89a876046ee..d07da553832c 100644 --- a/sdk/synapse/synapse-monitoring/src/operations/monitoring.ts +++ b/sdk/synapse/synapse-monitoring/src/operations/monitoring.ts @@ -32,10 +32,7 @@ export class Monitoring { async getSparkJobList( options?: MonitoringGetSparkJobListOptionalParams ): Promise { - const { span, updatedOptions } = createSpan( - "MonitoringClient-getSparkJobList", - options - ); + const { span, updatedOptions } = createSpan("MonitoringClient-getSparkJobList", options); const operationArguments: coreHttp.OperationArguments = { options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) }; @@ -63,10 +60,7 @@ export class Monitoring { async getSqlJobQueryString( options?: MonitoringGetSqlJobQueryStringOptionalParams ): Promise { - const { span, updatedOptions } = createSpan( - "MonitoringClient-getSqlJobQueryString", - options - ); + const { span, updatedOptions } = createSpan("MonitoringClient-getSqlJobQueryString", options); const operationArguments: coreHttp.OperationArguments = { options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) }; diff --git a/sdk/synapse/synapse-spark/package.json b/sdk/synapse/synapse-spark/package.json index 47c5a4f4304a..949308634568 100644 --- a/sdk/synapse/synapse-spark/package.json +++ b/sdk/synapse/synapse-spark/package.json @@ -77,4 +77,4 @@ }, "sideEffects": false, "autoPublish": true -} \ No newline at end of file +} diff --git a/sdk/synapse/synapse-spark/src/operations/sparkBatch.ts b/sdk/synapse/synapse-spark/src/operations/sparkBatch.ts index fc509f376e58..2d358ddfb88e 100644 --- a/sdk/synapse/synapse-spark/src/operations/sparkBatch.ts +++ b/sdk/synapse/synapse-spark/src/operations/sparkBatch.ts @@ -35,10 +35,7 @@ export class SparkBatch { async getSparkBatchJobs( options?: SparkBatchGetSparkBatchJobsOptionalParams ): Promise { - const { span, updatedOptions } = createSpan( - "SparkClient-getSparkBatchJobs", - options - ); + const { span, updatedOptions } = createSpan("SparkClient-getSparkBatchJobs", options); const operationArguments: coreHttp.OperationArguments = { options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) }; @@ -68,10 +65,7 @@ export class SparkBatch { sparkBatchJobOptions: SparkBatchJobOptions, options?: SparkBatchCreateSparkBatchJobOptionalParams ): Promise { - const { span, updatedOptions } = createSpan( - "SparkClient-createSparkBatchJob", - options - ); + const { span, updatedOptions } = createSpan("SparkClient-createSparkBatchJob", options); const operationArguments: coreHttp.OperationArguments = { sparkBatchJobOptions, options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) @@ -102,10 +96,7 @@ export class SparkBatch { batchId: number, options?: SparkBatchGetSparkBatchJobOptionalParams ): Promise { - const { span, updatedOptions } = createSpan( - "SparkClient-getSparkBatchJob", - options - ); + const { span, updatedOptions } = createSpan("SparkClient-getSparkBatchJob", options); const operationArguments: coreHttp.OperationArguments = { batchId, options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) @@ -136,10 +127,7 @@ export class SparkBatch { batchId: number, options?: coreHttp.OperationOptions ): Promise { - const { span, updatedOptions } = createSpan( - "SparkClient-cancelSparkBatchJob", - options - ); + const { span, updatedOptions } = createSpan("SparkClient-cancelSparkBatchJob", options); const operationArguments: coreHttp.OperationArguments = { batchId, options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) diff --git a/sdk/synapse/synapse-spark/src/operations/sparkSession.ts b/sdk/synapse/synapse-spark/src/operations/sparkSession.ts index 993f1022ae99..d2e44b95646a 100644 --- a/sdk/synapse/synapse-spark/src/operations/sparkSession.ts +++ b/sdk/synapse/synapse-spark/src/operations/sparkSession.ts @@ -40,10 +40,7 @@ export class SparkSession { async getSparkSessions( options?: SparkSessionGetSparkSessionsOptionalParams ): Promise { - const { span, updatedOptions } = createSpan( - "SparkClient-getSparkSessions", - options - ); + const { span, updatedOptions } = createSpan("SparkClient-getSparkSessions", options); const operationArguments: coreHttp.OperationArguments = { options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) }; @@ -73,10 +70,7 @@ export class SparkSession { sparkSessionOptions: SparkSessionOptions, options?: SparkSessionCreateSparkSessionOptionalParams ): Promise { - const { span, updatedOptions } = createSpan( - "SparkClient-createSparkSession", - options - ); + const { span, updatedOptions } = createSpan("SparkClient-createSparkSession", options); const operationArguments: coreHttp.OperationArguments = { sparkSessionOptions, options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) @@ -107,10 +101,7 @@ export class SparkSession { sessionId: number, options?: SparkSessionGetSparkSessionOptionalParams ): Promise { - const { span, updatedOptions } = createSpan( - "SparkClient-getSparkSession", - options - ); + const { span, updatedOptions } = createSpan("SparkClient-getSparkSession", options); const operationArguments: coreHttp.OperationArguments = { sessionId, options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) @@ -141,10 +132,7 @@ export class SparkSession { sessionId: number, options?: coreHttp.OperationOptions ): Promise { - const { span, updatedOptions } = createSpan( - "SparkClient-cancelSparkSession", - options - ); + const { span, updatedOptions } = createSpan("SparkClient-cancelSparkSession", options); const operationArguments: coreHttp.OperationArguments = { sessionId, options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) @@ -175,10 +163,7 @@ export class SparkSession { sessionId: number, options?: coreHttp.OperationOptions ): Promise { - const { span, updatedOptions } = createSpan( - "SparkClient-resetSparkSessionTimeout", - options - ); + const { span, updatedOptions } = createSpan("SparkClient-resetSparkSessionTimeout", options); const operationArguments: coreHttp.OperationArguments = { sessionId, options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) @@ -209,10 +194,7 @@ export class SparkSession { sessionId: number, options?: coreHttp.OperationOptions ): Promise { - const { span, updatedOptions } = createSpan( - "SparkClient-getSparkStatements", - options - ); + const { span, updatedOptions } = createSpan("SparkClient-getSparkStatements", options); const operationArguments: coreHttp.OperationArguments = { sessionId, options: coreHttp.operationOptionsToRequestOptionsBase(updatedOptions) @@ -245,10 +227,7 @@ export class SparkSession { sparkStatementOptions: SparkStatementOptions, options?: coreHttp.OperationOptions ): Promise { - const { span, updatedOptions } = createSpan( - "SparkClient-createSparkStatement", - options - ); + const { span, updatedOptions } = createSpan("SparkClient-createSparkStatement", options); const operationArguments: coreHttp.OperationArguments = { sessionId, sparkStatementOptions, @@ -282,10 +261,7 @@ export class SparkSession { statementId: number, options?: coreHttp.OperationOptions ): Promise { - const { span, updatedOptions } = createSpan( - "SparkClient-getSparkStatement", - options - ); + const { span, updatedOptions } = createSpan("SparkClient-getSparkStatement", options); const operationArguments: coreHttp.OperationArguments = { sessionId, statementId, @@ -319,10 +295,7 @@ export class SparkSession { statementId: number, options?: coreHttp.OperationOptions ): Promise { - const { span, updatedOptions } = createSpan( - "SparkClient-cancelSparkStatement", - options - ); + const { span, updatedOptions } = createSpan("SparkClient-cancelSparkStatement", options); const operationArguments: coreHttp.OperationArguments = { sessionId, statementId, From 00cbabac1dc13c5a6a1b118477ac3b95fd0e1472 Mon Sep 17 00:00:00 2001 From: Richard Park <51494936+richardpark-msft@users.noreply.github.com> Date: Mon, 22 Feb 2021 22:41:22 +0000 Subject: [PATCH 36/52] Updated to use core-tracing directly --- sdk/template/template/src/tracing.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/template/template/src/tracing.ts b/sdk/template/template/src/tracing.ts index 6281d205232e..fa1e65d70523 100644 --- a/sdk/template/template/src/tracing.ts +++ b/sdk/template/template/src/tracing.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. // -import { createSpanFunction } from "@azure/core-http"; +import { createSpanFunction } from "@azure/core-tracing"; /** * Creates a span using the global tracer. From 81d17b762ce266bbe422ca44fb7ad4bc11b78ad9 Mon Sep 17 00:00:00 2001 From: Richard Park <51494936+richardpark-msft@users.noreply.github.com> Date: Mon, 22 Feb 2021 23:24:58 +0000 Subject: [PATCH 37/52] our semver rule was tripping over using preview.10 as the version. Just switching over to -beta.1, which is what it as upgraded to originally. --- sdk/anomalydetector/ai-anomaly-detector/package.json | 4 ++-- sdk/appconfiguration/app-configuration/package.json | 4 ++-- sdk/communication/communication-administration/package.json | 4 ++-- sdk/communication/communication-chat/package.json | 4 ++-- sdk/communication/communication-identity/package.json | 4 ++-- sdk/communication/communication-sms/package.json | 4 ++-- sdk/core/core-client/package.json | 4 ++-- sdk/core/core-http/package.json | 4 ++-- sdk/core/core-https/package.json | 4 ++-- sdk/core/core-tracing/package.json | 4 ++-- sdk/digitaltwins/digital-twins-core/package.json | 4 ++-- sdk/eventgrid/eventgrid/package.json | 4 ++-- sdk/eventhub/event-hubs/package.json | 4 ++-- sdk/formrecognizer/ai-form-recognizer/package.json | 4 ++-- sdk/identity/identity/package.json | 4 ++-- sdk/keyvault/keyvault-admin/package.json | 4 ++-- sdk/keyvault/keyvault-certificates/package.json | 4 ++-- sdk/keyvault/keyvault-common/package.json | 4 ++-- sdk/keyvault/keyvault-keys/package.json | 4 ++-- sdk/keyvault/keyvault-secrets/package.json | 4 ++-- sdk/metricsadvisor/ai-metrics-advisor/package.json | 4 ++-- sdk/mixedreality/mixedreality-authentication/package.json | 4 ++-- sdk/search/search-documents/package.json | 4 ++-- sdk/servicebus/service-bus/package.json | 4 ++-- sdk/storage/storage-blob-changefeed/package.json | 4 ++-- sdk/storage/storage-blob/package.json | 4 ++-- sdk/storage/storage-file-datalake/package.json | 4 ++-- sdk/storage/storage-file-share/package.json | 4 ++-- sdk/storage/storage-queue/package.json | 4 ++-- sdk/synapse/synapse-access-control/package.json | 4 ++-- sdk/synapse/synapse-artifacts/package.json | 4 ++-- sdk/synapse/synapse-managed-private-endpoints/package.json | 4 ++-- sdk/synapse/synapse-monitoring/package.json | 4 ++-- sdk/synapse/synapse-spark/package.json | 4 ++-- sdk/tables/data-tables/package.json | 4 ++-- sdk/template/template/package.json | 4 ++-- sdk/textanalytics/ai-text-analytics/package.json | 4 ++-- 37 files changed, 74 insertions(+), 74 deletions(-) diff --git a/sdk/anomalydetector/ai-anomaly-detector/package.json b/sdk/anomalydetector/ai-anomaly-detector/package.json index 99dc77aff5a0..a00ace35424a 100644 --- a/sdk/anomalydetector/ai-anomaly-detector/package.json +++ b/sdk/anomalydetector/ai-anomaly-detector/package.json @@ -67,7 +67,7 @@ "@azure/logger": "^1.0.0", "@opentelemetry/api": "^0.10.2", "tslib": "^2.0.0", - "@azure/core-tracing": "1.0.0-preview.10" + "@azure/core-tracing": "1.0.0-beta.1" }, "devDependencies": { "@azure/dev-tool": "^1.0.0", @@ -129,4 +129,4 @@ } ] } -} +} \ No newline at end of file diff --git a/sdk/appconfiguration/app-configuration/package.json b/sdk/appconfiguration/app-configuration/package.json index 092ea3f5dde8..251adb70d7d0 100644 --- a/sdk/appconfiguration/app-configuration/package.json +++ b/sdk/appconfiguration/app-configuration/package.json @@ -89,7 +89,7 @@ "@azure/core-asynciterator-polyfill": "^1.0.0", "@azure/core-http": "^1.2.0", "@azure/core-paging": "^1.1.1", - "@azure/core-tracing": "1.0.0-preview.10", + "@azure/core-tracing": "1.0.0-beta.1", "@opentelemetry/api": "^0.10.2", "tslib": "^2.0.0" }, @@ -142,4 +142,4 @@ "cross-env": "^7.0.2", "typedoc": "0.15.2" } -} +} \ No newline at end of file diff --git a/sdk/communication/communication-administration/package.json b/sdk/communication/communication-administration/package.json index caeafaa478a2..8ff2f2cf6add 100644 --- a/sdk/communication/communication-administration/package.json +++ b/sdk/communication/communication-administration/package.json @@ -73,7 +73,7 @@ "@azure/core-lro": "^1.0.2", "@azure/core-paging": "^1.1.1", "@azure/logger": "^1.0.0", - "@azure/core-tracing": "1.0.0-preview.10", + "@azure/core-tracing": "1.0.0-beta.1", "@opentelemetry/api": "^0.10.2", "events": "^3.0.0", "tslib": "^2.0.0" @@ -132,4 +132,4 @@ "purchasePhoneNumber.js" ] } -} +} \ No newline at end of file diff --git a/sdk/communication/communication-chat/package.json b/sdk/communication/communication-chat/package.json index 9cfe8688aac1..f13d413c7683 100644 --- a/sdk/communication/communication-chat/package.json +++ b/sdk/communication/communication-chat/package.json @@ -69,7 +69,7 @@ "@azure/communication-signaling": "1.0.0-beta.2", "@azure/core-auth": "^1.2.0", "@azure/core-http": "^1.2.0", - "@azure/core-tracing": "1.0.0-preview.10", + "@azure/core-tracing": "1.0.0-beta.1", "@azure/logger": "^1.0.0", "@opentelemetry/api": "^0.10.2", "events": "^3.0.0", @@ -124,4 +124,4 @@ "util": "^0.12.1", "typedoc": "0.15.2" } -} +} \ No newline at end of file diff --git a/sdk/communication/communication-identity/package.json b/sdk/communication/communication-identity/package.json index ca503398c977..bbb9c49ab7b3 100644 --- a/sdk/communication/communication-identity/package.json +++ b/sdk/communication/communication-identity/package.json @@ -72,7 +72,7 @@ "@azure/core-lro": "^1.0.2", "@azure/core-paging": "^1.1.1", "@azure/logger": "^1.0.0", - "@azure/core-tracing": "1.0.0-preview.10", + "@azure/core-tracing": "1.0.0-beta.1", "@opentelemetry/api": "^0.10.2", "events": "^3.0.0", "tslib": "^2.0.0" @@ -126,4 +126,4 @@ "typescript": "4.1.2", "typedoc": "0.15.2" } -} +} \ No newline at end of file diff --git a/sdk/communication/communication-sms/package.json b/sdk/communication/communication-sms/package.json index 0e32a7706727..019792c0f3e9 100644 --- a/sdk/communication/communication-sms/package.json +++ b/sdk/communication/communication-sms/package.json @@ -71,7 +71,7 @@ "@azure/communication-common": "1.0.0-beta.6", "@azure/core-auth": "^1.2.0", "@azure/core-http": "^1.2.0", - "@azure/core-tracing": "1.0.0-preview.10", + "@azure/core-tracing": "1.0.0-beta.1", "@azure/logger": "^1.0.0", "@opentelemetry/api": "^0.10.2", "events": "^3.0.0", @@ -127,4 +127,4 @@ "//sampleConfiguration": { "skipFolder": true } -} +} \ No newline at end of file diff --git a/sdk/core/core-client/package.json b/sdk/core/core-client/package.json index cefedf47590c..8a644d59ee17 100644 --- a/sdk/core/core-client/package.json +++ b/sdk/core/core-client/package.json @@ -79,7 +79,7 @@ "@azure/abort-controller": "^1.0.0", "@azure/core-auth": "^1.2.0", "@azure/core-https": "1.0.0-beta.2", - "@azure/core-tracing": "1.0.0-preview.10", + "@azure/core-tracing": "1.0.0-beta.1", "@opentelemetry/api": "^0.10.2", "tslib": "^2.0.0" }, @@ -125,4 +125,4 @@ "util": "^0.12.1", "typedoc": "0.15.2" } -} +} \ No newline at end of file diff --git a/sdk/core/core-http/package.json b/sdk/core/core-http/package.json index 6442218547df..ad819841f177 100644 --- a/sdk/core/core-http/package.json +++ b/sdk/core/core-http/package.json @@ -132,7 +132,7 @@ "dependencies": { "@azure/abort-controller": "^1.0.0", "@azure/core-auth": "^1.2.0", - "@azure/core-tracing": "1.0.0-preview.10", + "@azure/core-tracing": "1.0.0-beta.1", "@azure/logger": "^1.0.0", "@opentelemetry/api": "^0.10.2", "@types/node-fetch": "^2.5.0", @@ -198,4 +198,4 @@ "xhr-mock": "^2.4.1", "typedoc": "0.15.2" } -} +} \ No newline at end of file diff --git a/sdk/core/core-https/package.json b/sdk/core/core-https/package.json index 6902abfdeaca..eda79fc99704 100644 --- a/sdk/core/core-https/package.json +++ b/sdk/core/core-https/package.json @@ -90,7 +90,7 @@ "dependencies": { "@azure/abort-controller": "^1.0.0", "@azure/core-auth": "^1.2.0", - "@azure/core-tracing": "1.0.0-preview.10", + "@azure/core-tracing": "1.0.0-beta.1", "@azure/logger": "^1.0.0", "@opentelemetry/api": "^0.10.2", "form-data": "^3.0.0", @@ -141,4 +141,4 @@ "util": "^0.12.1", "typedoc": "0.15.2" } -} +} \ No newline at end of file diff --git a/sdk/core/core-tracing/package.json b/sdk/core/core-tracing/package.json index e00b2c1bece4..205a887bc840 100644 --- a/sdk/core/core-tracing/package.json +++ b/sdk/core/core-tracing/package.json @@ -1,6 +1,6 @@ { "name": "@azure/core-tracing", - "version": "1.0.0-preview.10", + "version": "1.0.0-beta.1", "description": "Provides low-level interfaces and helper methods for tracing in Azure SDK", "sdk-type": "client", "main": "dist/index.js", @@ -92,4 +92,4 @@ "sinon": "^9.0.2", "@types/sinon": "^9.0.4" } -} +} \ No newline at end of file diff --git a/sdk/digitaltwins/digital-twins-core/package.json b/sdk/digitaltwins/digital-twins-core/package.json index 98c76383a736..1b56779a887e 100644 --- a/sdk/digitaltwins/digital-twins-core/package.json +++ b/sdk/digitaltwins/digital-twins-core/package.json @@ -68,7 +68,7 @@ "dependencies": { "@azure/core-http": "^1.2.0", "@azure/core-paging": "^1.1.1", - "@azure/core-tracing": "1.0.0-preview.10", + "@azure/core-tracing": "1.0.0-beta.1", "@azure/logger": "^1.0.0", "@opentelemetry/api": "^0.10.2", "tslib": "^2.0.0" @@ -125,4 +125,4 @@ "//sampleConfiguration": { "skipFolder": true } -} +} \ No newline at end of file diff --git a/sdk/eventgrid/eventgrid/package.json b/sdk/eventgrid/eventgrid/package.json index acc1adfc5024..6ffc815ecf6a 100644 --- a/sdk/eventgrid/eventgrid/package.json +++ b/sdk/eventgrid/eventgrid/package.json @@ -82,7 +82,7 @@ "@azure/core-auth": "^1.2.0", "@azure/core-client": "1.0.0-beta.2", "@azure/core-https": "1.0.0-beta.2", - "@azure/core-tracing": "1.0.0-preview.10", + "@azure/core-tracing": "1.0.0-beta.1", "@azure/logger": "^1.0.0", "@opentelemetry/api": "^0.10.2", "tslib": "^2.0.0", @@ -139,4 +139,4 @@ "typescript": "4.1.2", "typedoc": "0.15.2" } -} +} \ No newline at end of file diff --git a/sdk/eventhub/event-hubs/package.json b/sdk/eventhub/event-hubs/package.json index eb92d0b3394b..36b1d88722af 100644 --- a/sdk/eventhub/event-hubs/package.json +++ b/sdk/eventhub/event-hubs/package.json @@ -92,7 +92,7 @@ "@azure/abort-controller": "^1.0.0", "@azure/core-amqp": "^2.1.0", "@azure/core-asynciterator-polyfill": "^1.0.0", - "@azure/core-tracing": "1.0.0-preview.10", + "@azure/core-tracing": "1.0.0-beta.1", "@azure/core-auth": "^1.2.0", "@azure/logger": "^1.0.0", "@opentelemetry/api": "^0.10.2", @@ -166,4 +166,4 @@ "ws": "^7.1.1", "typedoc": "0.15.2" } -} +} \ No newline at end of file diff --git a/sdk/formrecognizer/ai-form-recognizer/package.json b/sdk/formrecognizer/ai-form-recognizer/package.json index 327136df4622..5772f232b85e 100644 --- a/sdk/formrecognizer/ai-form-recognizer/package.json +++ b/sdk/formrecognizer/ai-form-recognizer/package.json @@ -82,7 +82,7 @@ "@azure/core-lro": "^1.0.2", "@azure/core-paging": "^1.1.1", "@azure/core-http": "^1.2.0", - "@azure/core-tracing": "1.0.0-preview.10", + "@azure/core-tracing": "1.0.0-beta.1", "@azure/logger": "^1.0.0", "@opentelemetry/api": "^0.10.2", "tslib": "^2.0.0" @@ -143,4 +143,4 @@ "deleteAllModels.js" ] } -} +} \ No newline at end of file diff --git a/sdk/identity/identity/package.json b/sdk/identity/identity/package.json index 4a83601bcb63..2a4507ba9c0c 100644 --- a/sdk/identity/identity/package.json +++ b/sdk/identity/identity/package.json @@ -81,7 +81,7 @@ "sideEffects": false, "dependencies": { "@azure/core-http": "^1.2.0", - "@azure/core-tracing": "1.0.0-preview.10", + "@azure/core-tracing": "1.0.0-beta.1", "@azure/logger": "^1.0.0", "@azure/msal-node": "1.0.0-beta.6", "@azure/msal-browser": "2.9.0", @@ -143,4 +143,4 @@ "mock-fs": "^4.10.4", "typedoc": "0.15.2" } -} +} \ No newline at end of file diff --git a/sdk/keyvault/keyvault-admin/package.json b/sdk/keyvault/keyvault-admin/package.json index 64f0418c94e5..b478e150a02a 100644 --- a/sdk/keyvault/keyvault-admin/package.json +++ b/sdk/keyvault/keyvault-admin/package.json @@ -81,7 +81,7 @@ "@azure/core-http": "^1.2.0", "@azure/core-lro": "^1.0.2", "@azure/core-paging": "^1.1.1", - "@azure/core-tracing": "1.0.0-preview.10", + "@azure/core-tracing": "1.0.0-beta.1", "@azure/logger": "^1.0.0", "@opentelemetry/api": "^0.10.2", "tslib": "^2.0.0" @@ -128,4 +128,4 @@ "uuid": "^8.3.0", "typedoc": "0.15.2" } -} +} \ No newline at end of file diff --git a/sdk/keyvault/keyvault-certificates/package.json b/sdk/keyvault/keyvault-certificates/package.json index db693b5098a5..686852c51576 100644 --- a/sdk/keyvault/keyvault-certificates/package.json +++ b/sdk/keyvault/keyvault-certificates/package.json @@ -95,7 +95,7 @@ "@azure/core-http": "^1.2.0", "@azure/core-lro": "^1.0.2", "@azure/core-paging": "^1.1.1", - "@azure/core-tracing": "1.0.0-preview.10", + "@azure/core-tracing": "1.0.0-beta.1", "@azure/logger": "^1.0.0", "@opentelemetry/api": "^0.10.2", "tslib": "^2.0.0" @@ -154,4 +154,4 @@ "url": "^0.11.0", "typedoc": "0.15.2" } -} +} \ No newline at end of file diff --git a/sdk/keyvault/keyvault-common/package.json b/sdk/keyvault/keyvault-common/package.json index 998fa6a23b84..b6ffb129e08b 100644 --- a/sdk/keyvault/keyvault-common/package.json +++ b/sdk/keyvault/keyvault-common/package.json @@ -59,7 +59,7 @@ "dependencies": { "@azure/core-http": "^1.2.0", "tslib": "^2.0.0", - "@azure/core-tracing": "1.0.0-preview.10", + "@azure/core-tracing": "1.0.0-beta.1", "@opentelemetry/api": "^0.10.2" }, "devDependencies": { @@ -69,4 +69,4 @@ "rimraf": "^3.0.0", "typescript": "4.1.2" } -} +} \ No newline at end of file diff --git a/sdk/keyvault/keyvault-keys/package.json b/sdk/keyvault/keyvault-keys/package.json index 31fc9690720d..810613227f4c 100644 --- a/sdk/keyvault/keyvault-keys/package.json +++ b/sdk/keyvault/keyvault-keys/package.json @@ -88,7 +88,7 @@ "@azure/core-http": "^1.2.0", "@azure/core-lro": "^1.0.2", "@azure/core-paging": "^1.1.1", - "@azure/core-tracing": "1.0.0-preview.10", + "@azure/core-tracing": "1.0.0-beta.1", "@azure/logger": "^1.0.0", "@opentelemetry/api": "^0.10.2", "tslib": "^2.0.0" @@ -149,4 +149,4 @@ "url": "^0.11.0", "typedoc": "0.15.2" } -} +} \ No newline at end of file diff --git a/sdk/keyvault/keyvault-secrets/package.json b/sdk/keyvault/keyvault-secrets/package.json index 3be80130695b..da53e1fdb10e 100644 --- a/sdk/keyvault/keyvault-secrets/package.json +++ b/sdk/keyvault/keyvault-secrets/package.json @@ -94,7 +94,7 @@ "@azure/core-http": "^1.2.0", "@azure/core-lro": "^1.0.2", "@azure/core-paging": "^1.1.1", - "@azure/core-tracing": "1.0.0-preview.10", + "@azure/core-tracing": "1.0.0-beta.1", "@azure/logger": "^1.0.0", "@opentelemetry/api": "^0.10.2", "tslib": "^2.0.0" @@ -152,4 +152,4 @@ "url": "^0.11.0", "typedoc": "0.15.2" } -} +} \ No newline at end of file diff --git a/sdk/metricsadvisor/ai-metrics-advisor/package.json b/sdk/metricsadvisor/ai-metrics-advisor/package.json index 81219aec357d..1e94911804e7 100644 --- a/sdk/metricsadvisor/ai-metrics-advisor/package.json +++ b/sdk/metricsadvisor/ai-metrics-advisor/package.json @@ -81,7 +81,7 @@ "@azure/core-lro": "^1.0.2", "@azure/core-paging": "^1.1.1", "@azure/core-http": "^1.2.0", - "@azure/core-tracing": "1.0.0-preview.10", + "@azure/core-tracing": "1.0.0-beta.1", "@azure/logger": "^1.0.0", "@opentelemetry/api": "^0.10.2", "tslib": "^2.0.0" @@ -140,4 +140,4 @@ "seriesData.js" ] } -} +} \ No newline at end of file diff --git a/sdk/mixedreality/mixedreality-authentication/package.json b/sdk/mixedreality/mixedreality-authentication/package.json index 3e8f08a7d555..2e69f7c14ed7 100644 --- a/sdk/mixedreality/mixedreality-authentication/package.json +++ b/sdk/mixedreality/mixedreality-authentication/package.json @@ -69,7 +69,7 @@ "dependencies": { "@azure/core-auth": "^1.2.0", "@azure/core-http": "^1.2.0", - "@azure/core-tracing": "1.0.0-preview.10", + "@azure/core-tracing": "1.0.0-beta.1", "@azure/logger": "^1.0.0", "@opentelemetry/api": "^0.10.2", "tslib": "^2.0.0" @@ -115,4 +115,4 @@ "//smokeTestConfiguration": { "skipFolder": true } -} +} \ No newline at end of file diff --git a/sdk/search/search-documents/package.json b/sdk/search/search-documents/package.json index b6b8c9ca9e11..1e1437082b47 100644 --- a/sdk/search/search-documents/package.json +++ b/sdk/search/search-documents/package.json @@ -78,7 +78,7 @@ "@azure/core-auth": "^1.2.0", "@azure/core-http": "^1.2.0", "@azure/core-paging": "^1.1.1", - "@azure/core-tracing": "1.0.0-preview.10", + "@azure/core-tracing": "1.0.0-beta.1", "@azure/logger": "^1.0.0", "@opentelemetry/api": "^0.10.2", "tslib": "^2.0.0", @@ -132,4 +132,4 @@ "util": "^0.12.1", "typedoc": "0.15.2" } -} +} \ No newline at end of file diff --git a/sdk/servicebus/service-bus/package.json b/sdk/servicebus/service-bus/package.json index 19b0b99512c6..24c42f51c26d 100644 --- a/sdk/servicebus/service-bus/package.json +++ b/sdk/servicebus/service-bus/package.json @@ -99,7 +99,7 @@ "@azure/core-amqp": "^2.1.0", "@azure/core-asynciterator-polyfill": "^1.0.0", "@azure/core-http": "^1.2.0", - "@azure/core-tracing": "1.0.0-preview.10", + "@azure/core-tracing": "1.0.0-beta.1", "@azure/core-paging": "^1.1.1", "@azure/core-auth": "^1.2.0", "@azure/logger": "^1.0.0", @@ -177,4 +177,4 @@ "events": "^3.0.0", "typedoc": "0.15.2" } -} +} \ No newline at end of file diff --git a/sdk/storage/storage-blob-changefeed/package.json b/sdk/storage/storage-blob-changefeed/package.json index 464ae5dcc14a..f0e1878dfd04 100644 --- a/sdk/storage/storage-blob-changefeed/package.json +++ b/sdk/storage/storage-blob-changefeed/package.json @@ -99,7 +99,7 @@ "@azure/core-http": "^1.2.0", "@azure/core-lro": "^1.0.2", "@azure/core-paging": "^1.1.1", - "@azure/core-tracing": "1.0.0-preview.10", + "@azure/core-tracing": "1.0.0-beta.1", "@azure/logger": "^1.0.0", "@opentelemetry/api": "^0.10.2", "events": "^3.0.0", @@ -160,4 +160,4 @@ "//sampleConfiguration": { "skipFolder": true } -} +} \ No newline at end of file diff --git a/sdk/storage/storage-blob/package.json b/sdk/storage/storage-blob/package.json index e1cccb6d0ab1..7616e0162eaa 100644 --- a/sdk/storage/storage-blob/package.json +++ b/sdk/storage/storage-blob/package.json @@ -122,7 +122,7 @@ "@azure/core-http": "^1.2.0", "@azure/core-lro": "^1.0.2", "@azure/core-paging": "^1.1.1", - "@azure/core-tracing": "1.0.0-preview.10", + "@azure/core-tracing": "1.0.0-beta.1", "@azure/logger": "^1.0.0", "@opentelemetry/api": "^0.10.2", "events": "^3.0.0", @@ -183,4 +183,4 @@ "util": "^0.12.1", "typedoc": "0.15.2" } -} +} \ No newline at end of file diff --git a/sdk/storage/storage-file-datalake/package.json b/sdk/storage/storage-file-datalake/package.json index 9d704f0ededf..b8872e912de3 100644 --- a/sdk/storage/storage-file-datalake/package.json +++ b/sdk/storage/storage-file-datalake/package.json @@ -101,7 +101,7 @@ "@azure/abort-controller": "^1.0.0", "@azure/core-http": "^1.2.0", "@azure/core-paging": "^1.1.1", - "@azure/core-tracing": "1.0.0-preview.10", + "@azure/core-tracing": "1.0.0-beta.1", "@azure/logger": "^1.0.0", "@azure/storage-blob": "^12.5.0-beta.1", "events": "^3.0.0", @@ -163,4 +163,4 @@ "util": "^0.12.1", "typedoc": "0.15.2" } -} +} \ No newline at end of file diff --git a/sdk/storage/storage-file-share/package.json b/sdk/storage/storage-file-share/package.json index 303255c2ef13..15f5e682de35 100644 --- a/sdk/storage/storage-file-share/package.json +++ b/sdk/storage/storage-file-share/package.json @@ -113,7 +113,7 @@ "@azure/abort-controller": "^1.0.0", "@azure/core-http": "^1.2.0", "@azure/core-paging": "^1.1.1", - "@azure/core-tracing": "1.0.0-preview.10", + "@azure/core-tracing": "1.0.0-beta.1", "@azure/logger": "^1.0.0", "@opentelemetry/api": "^0.10.2", "events": "^3.0.0", @@ -169,4 +169,4 @@ "util": "^0.12.1", "typedoc": "0.15.2" } -} +} \ No newline at end of file diff --git a/sdk/storage/storage-queue/package.json b/sdk/storage/storage-queue/package.json index 4031c1ba7f25..2b77a5016ded 100644 --- a/sdk/storage/storage-queue/package.json +++ b/sdk/storage/storage-queue/package.json @@ -108,7 +108,7 @@ "@azure/abort-controller": "^1.0.0", "@azure/core-http": "^1.2.0", "@azure/core-paging": "^1.1.1", - "@azure/core-tracing": "1.0.0-preview.10", + "@azure/core-tracing": "1.0.0-beta.1", "@azure/logger": "^1.0.0", "@opentelemetry/api": "^0.10.2", "tslib": "^2.0.0" @@ -163,4 +163,4 @@ "util": "^0.12.1", "typedoc": "0.15.2" } -} +} \ No newline at end of file diff --git a/sdk/synapse/synapse-access-control/package.json b/sdk/synapse/synapse-access-control/package.json index ec39b12ceef5..11b731261428 100644 --- a/sdk/synapse/synapse-access-control/package.json +++ b/sdk/synapse/synapse-access-control/package.json @@ -9,7 +9,7 @@ "dependencies": { "@azure/core-paging": "^1.1.1", "@azure/core-http": "^1.2.0", - "@azure/core-tracing": "1.0.0-preview.10", + "@azure/core-tracing": "1.0.0-beta.1", "tslib": "^2.0.0" }, "keywords": [ @@ -78,4 +78,4 @@ }, "sideEffects": false, "autoPublish": true -} +} \ No newline at end of file diff --git a/sdk/synapse/synapse-artifacts/package.json b/sdk/synapse/synapse-artifacts/package.json index ed2b7672c31a..fa9aea944d57 100644 --- a/sdk/synapse/synapse-artifacts/package.json +++ b/sdk/synapse/synapse-artifacts/package.json @@ -10,7 +10,7 @@ "@azure/core-lro": "^1.0.2", "@azure/core-paging": "^1.1.1", "@azure/core-http": "^1.2.0", - "@azure/core-tracing": "1.0.0-preview.10", + "@azure/core-tracing": "1.0.0-beta.1", "@opentelemetry/api": "^0.10.2", "tslib": "^2.0.0" }, @@ -79,4 +79,4 @@ }, "sideEffects": false, "autoPublish": true -} +} \ No newline at end of file diff --git a/sdk/synapse/synapse-managed-private-endpoints/package.json b/sdk/synapse/synapse-managed-private-endpoints/package.json index fac1a4ea043c..c4813423a48b 100644 --- a/sdk/synapse/synapse-managed-private-endpoints/package.json +++ b/sdk/synapse/synapse-managed-private-endpoints/package.json @@ -9,7 +9,7 @@ "dependencies": { "@azure/core-paging": "^1.1.1", "@azure/core-http": "^1.2.0", - "@azure/core-tracing": "1.0.0-preview.10", + "@azure/core-tracing": "1.0.0-beta.1", "@opentelemetry/api": "^0.10.2", "tslib": "^2.0.0" }, @@ -78,4 +78,4 @@ }, "sideEffects": false, "autoPublish": true -} +} \ No newline at end of file diff --git a/sdk/synapse/synapse-monitoring/package.json b/sdk/synapse/synapse-monitoring/package.json index 1a9f23a9527e..e7028b8ced80 100644 --- a/sdk/synapse/synapse-monitoring/package.json +++ b/sdk/synapse/synapse-monitoring/package.json @@ -8,7 +8,7 @@ "version": "1.0.0-beta.3", "dependencies": { "@azure/core-http": "^1.2.0", - "@azure/core-tracing": "1.0.0-preview.10", + "@azure/core-tracing": "1.0.0-beta.1", "@opentelemetry/api": "^0.10.2", "tslib": "^2.0.0" }, @@ -77,4 +77,4 @@ }, "sideEffects": false, "autoPublish": true -} +} \ No newline at end of file diff --git a/sdk/synapse/synapse-spark/package.json b/sdk/synapse/synapse-spark/package.json index 949308634568..7e7b491cbed9 100644 --- a/sdk/synapse/synapse-spark/package.json +++ b/sdk/synapse/synapse-spark/package.json @@ -8,7 +8,7 @@ "version": "1.0.0-beta.3", "dependencies": { "@azure/core-http": "^1.2.0", - "@azure/core-tracing": "1.0.0-preview.10", + "@azure/core-tracing": "1.0.0-beta.1", "@opentelemetry/api": "^0.10.2", "tslib": "^2.0.0" }, @@ -77,4 +77,4 @@ }, "sideEffects": false, "autoPublish": true -} +} \ No newline at end of file diff --git a/sdk/tables/data-tables/package.json b/sdk/tables/data-tables/package.json index 3f00337ecc8a..3341accf9dec 100644 --- a/sdk/tables/data-tables/package.json +++ b/sdk/tables/data-tables/package.json @@ -71,7 +71,7 @@ "@azure/core-paging": "^1.1.1", "@azure/core-xml": "1.0.0-beta.1", "@azure/logger": "^1.0.0", - "@azure/core-tracing": "1.0.0-preview.10", + "@azure/core-tracing": "1.0.0-beta.1", "@opentelemetry/api": "^0.10.2", "tslib": "^2.0.0", "uuid": "^8.3.0" @@ -137,4 +137,4 @@ } ] } -} +} \ No newline at end of file diff --git a/sdk/template/template/package.json b/sdk/template/template/package.json index 035e382705c0..adb719f6a407 100644 --- a/sdk/template/template/package.json +++ b/sdk/template/template/package.json @@ -74,7 +74,7 @@ "dependencies": { "@azure/core-auth": "^1.2.0", "@azure/core-http": "^1.2.0", - "@azure/core-tracing": "1.0.0-preview.10", + "@azure/core-tracing": "1.0.0-beta.1", "@azure/logger": "^1.0.0", "@opentelemetry/api": "^0.10.2", "tslib": "^2.0.0" @@ -120,4 +120,4 @@ "//sampleConfiguration": { "skipFolder": false } -} +} \ No newline at end of file diff --git a/sdk/textanalytics/ai-text-analytics/package.json b/sdk/textanalytics/ai-text-analytics/package.json index e5debb1ea2e1..50fd8be1c5c5 100644 --- a/sdk/textanalytics/ai-text-analytics/package.json +++ b/sdk/textanalytics/ai-text-analytics/package.json @@ -86,7 +86,7 @@ "@azure/core-http": "^1.2.0", "@azure/core-lro": "^1.0.2", "@azure/core-paging": "^1.1.1", - "@azure/core-tracing": "1.0.0-preview.10", + "@azure/core-tracing": "1.0.0-beta.1", "@azure/logger": "^1.0.0", "@opentelemetry/api": "^0.10.2", "tslib": "^2.0.0" @@ -133,4 +133,4 @@ "karma-source-map-support": "~1.4.0", "typedoc": "0.15.2" } -} +} \ No newline at end of file From b48f98c6fad1f78638677ae798e9341572b001ce Mon Sep 17 00:00:00 2001 From: Richard Park <51494936+richardpark-msft@users.noreply.github.com> Date: Tue, 23 Feb 2021 00:31:56 +0000 Subject: [PATCH 38/52] Bring back a compatible createSpan function so we don't cause runtime issues in already released packages that might upgrade to this core-http version. --- sdk/core/core-http/src/createSpanLegacy.ts | 40 ++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 sdk/core/core-http/src/createSpanLegacy.ts diff --git a/sdk/core/core-http/src/createSpanLegacy.ts b/sdk/core/core-http/src/createSpanLegacy.ts new file mode 100644 index 000000000000..f067ea701b3d --- /dev/null +++ b/sdk/core/core-http/src/createSpanLegacy.ts @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +// NOTE: we've moved this code into core-tracing but these functions +// were a part of the GA'd library and can't be removed until the next major +// release. They currently get called always, even if tracing is not enabled. + +import { createSpanFunction as coreTracingCreateSpanFunction } from "@azure/core-tracing"; +import { Span } from "@opentelemetry/api"; +import { OperationOptions } from "./operationOptions"; + +/** + * Configuration for creating a new Tracing Span + * @hidden + */ +export interface SpanConfig { + /** + * Package name prefix + */ + packagePrefix: string; + /** + * Service namespace + */ + namespace: string; +} + + +/** + * DEPRECATED: This function is only here for compatibility. Use createSpanFunction in core-tracing. + * @hidden + + * @param spanConfig - The name of the operation being performed. + * @param tracingOptions - The options for the underlying http request. + */ +export function createSpanFunction(args: SpanConfig): ( + operationName: string, + operationOptions: T +) => { span: Span; updatedOptions: T } { + return coreTracingCreateSpanFunction(args); +} \ No newline at end of file From 5cf928830aa2e8962ae9219ad403e2a893582019 Mon Sep 17 00:00:00 2001 From: Richard Park <51494936+richardpark-msft@users.noreply.github.com> Date: Tue, 23 Feb 2021 00:37:00 +0000 Subject: [PATCH 39/52] After talking with @joheredi it's obvious we can't remove this function as it'd cause errors in existing packages that update to the latest core-http. Will have to reserve for a major version update. --- sdk/core/core-http/review/core-http.api.md | 13 +++++++++++++ sdk/core/core-http/src/coreHttp.ts | 3 +++ sdk/core/core-http/src/createSpanLegacy.ts | 7 ++++--- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/sdk/core/core-http/review/core-http.api.md b/sdk/core/core-http/review/core-http.api.md index c9695f771766..7adbf79b4b9a 100644 --- a/sdk/core/core-http/review/core-http.api.md +++ b/sdk/core/core-http/review/core-http.api.md @@ -10,6 +10,7 @@ import { Debugger } from '@azure/logger'; import { GetTokenOptions } from '@azure/core-auth'; import { isTokenCredential } from '@azure/core-auth'; import { OperationTracingOptions } from '@azure/core-tracing'; +import { Span } from '@opentelemetry/api'; import { SpanOptions } from '@azure/core-tracing'; import { TokenCredential } from '@azure/core-auth'; @@ -156,6 +157,12 @@ export const Constants: { // @public (undocumented) export function createPipelineFromOptions(pipelineOptions: InternalPipelineOptions, authPolicyFactory?: RequestPolicyFactory): ServiceClientOptions; +// @public +export function createSpanFunction(args: SpanConfig): (operationName: string, operationOptions: T) => { + span: Span; + updatedOptions: T; +}; + // Warning: (ae-forgotten-export) The symbol "FetchHttpClient" needs to be exported by the entry point coreHttp.d.ts // // @public (undocumented) @@ -791,6 +798,12 @@ export interface SimpleMapperType { name: "Base64Url" | "Boolean" | "ByteArray" | "Date" | "DateTime" | "DateTimeRfc1123" | "Object" | "Stream" | "String" | "TimeSpan" | "UnixTime" | "Uuid" | "Number" | "any"; } +// @public +export interface SpanConfig { + namespace: string; + packagePrefix: string; +} + // @public export function stringifyXML(obj: unknown, opts?: SerializerOptions): string; diff --git a/sdk/core/core-http/src/coreHttp.ts b/sdk/core/core-http/src/coreHttp.ts index e9809d3f9205..698405441732 100644 --- a/sdk/core/core-http/src/coreHttp.ts +++ b/sdk/core/core-http/src/coreHttp.ts @@ -114,6 +114,9 @@ export { export { URLBuilder, URLQuery } from "./url"; export { AbortSignalLike } from "@azure/abort-controller"; +// legacy exports. Use core-tracing instead (and remove on next major version update of core-http). +export { createSpanFunction, SpanConfig } from "./createSpanLegacy"; + // Credentials export { TokenCredential, GetTokenOptions, AccessToken, isTokenCredential } from "@azure/core-auth"; export { AccessTokenCache, ExpiringAccessTokenCache } from "./credentials/accessTokenCache"; diff --git a/sdk/core/core-http/src/createSpanLegacy.ts b/sdk/core/core-http/src/createSpanLegacy.ts index f067ea701b3d..a98857d45bc9 100644 --- a/sdk/core/core-http/src/createSpanLegacy.ts +++ b/sdk/core/core-http/src/createSpanLegacy.ts @@ -24,7 +24,6 @@ export interface SpanConfig { namespace: string; } - /** * DEPRECATED: This function is only here for compatibility. Use createSpanFunction in core-tracing. * @hidden @@ -32,9 +31,11 @@ export interface SpanConfig { * @param spanConfig - The name of the operation being performed. * @param tracingOptions - The options for the underlying http request. */ -export function createSpanFunction(args: SpanConfig): ( +export function createSpanFunction( + args: SpanConfig +): ( operationName: string, operationOptions: T ) => { span: Span; updatedOptions: T } { return coreTracingCreateSpanFunction(args); -} \ No newline at end of file +} From 0b5e2d6284b663a749eca9efa9868874fcadf03e Mon Sep 17 00:00:00 2001 From: Richard Park <51494936+richardpark-msft@users.noreply.github.com> Date: Tue, 23 Feb 2021 00:38:38 +0000 Subject: [PATCH 40/52] Formatting --- sdk/anomalydetector/ai-anomaly-detector/package.json | 2 +- sdk/appconfiguration/app-configuration/package.json | 2 +- sdk/communication/communication-administration/package.json | 2 +- sdk/communication/communication-chat/package.json | 2 +- sdk/communication/communication-identity/package.json | 2 +- sdk/communication/communication-sms/package.json | 2 +- sdk/core/core-client/package.json | 2 +- sdk/core/core-http/package.json | 2 +- sdk/core/core-https/package.json | 2 +- sdk/core/core-tracing/package.json | 2 +- sdk/digitaltwins/digital-twins-core/package.json | 2 +- sdk/eventgrid/eventgrid/package.json | 2 +- sdk/eventhub/event-hubs/package.json | 2 +- sdk/formrecognizer/ai-form-recognizer/package.json | 2 +- sdk/identity/identity/package.json | 2 +- sdk/keyvault/keyvault-admin/package.json | 2 +- sdk/keyvault/keyvault-certificates/package.json | 2 +- sdk/keyvault/keyvault-common/package.json | 2 +- sdk/keyvault/keyvault-keys/package.json | 2 +- sdk/keyvault/keyvault-secrets/package.json | 2 +- sdk/metricsadvisor/ai-metrics-advisor/package.json | 2 +- sdk/mixedreality/mixedreality-authentication/package.json | 2 +- sdk/search/search-documents/package.json | 2 +- sdk/servicebus/service-bus/package.json | 2 +- sdk/storage/storage-blob-changefeed/package.json | 2 +- sdk/storage/storage-blob/package.json | 2 +- sdk/storage/storage-file-datalake/package.json | 2 +- sdk/storage/storage-file-share/package.json | 2 +- sdk/storage/storage-queue/package.json | 2 +- sdk/synapse/synapse-access-control/package.json | 2 +- sdk/synapse/synapse-artifacts/package.json | 2 +- sdk/synapse/synapse-managed-private-endpoints/package.json | 2 +- sdk/synapse/synapse-monitoring/package.json | 2 +- sdk/synapse/synapse-spark/package.json | 2 +- sdk/tables/data-tables/package.json | 2 +- sdk/template/template/package.json | 2 +- sdk/textanalytics/ai-text-analytics/package.json | 2 +- 37 files changed, 37 insertions(+), 37 deletions(-) diff --git a/sdk/anomalydetector/ai-anomaly-detector/package.json b/sdk/anomalydetector/ai-anomaly-detector/package.json index a00ace35424a..c8ad2bd27fd8 100644 --- a/sdk/anomalydetector/ai-anomaly-detector/package.json +++ b/sdk/anomalydetector/ai-anomaly-detector/package.json @@ -129,4 +129,4 @@ } ] } -} \ No newline at end of file +} diff --git a/sdk/appconfiguration/app-configuration/package.json b/sdk/appconfiguration/app-configuration/package.json index 251adb70d7d0..901080f61a30 100644 --- a/sdk/appconfiguration/app-configuration/package.json +++ b/sdk/appconfiguration/app-configuration/package.json @@ -142,4 +142,4 @@ "cross-env": "^7.0.2", "typedoc": "0.15.2" } -} \ No newline at end of file +} diff --git a/sdk/communication/communication-administration/package.json b/sdk/communication/communication-administration/package.json index 8ff2f2cf6add..33f6f26c5f36 100644 --- a/sdk/communication/communication-administration/package.json +++ b/sdk/communication/communication-administration/package.json @@ -132,4 +132,4 @@ "purchasePhoneNumber.js" ] } -} \ No newline at end of file +} diff --git a/sdk/communication/communication-chat/package.json b/sdk/communication/communication-chat/package.json index f13d413c7683..f45d16161bb2 100644 --- a/sdk/communication/communication-chat/package.json +++ b/sdk/communication/communication-chat/package.json @@ -124,4 +124,4 @@ "util": "^0.12.1", "typedoc": "0.15.2" } -} \ No newline at end of file +} diff --git a/sdk/communication/communication-identity/package.json b/sdk/communication/communication-identity/package.json index bbb9c49ab7b3..ed9e9e076a15 100644 --- a/sdk/communication/communication-identity/package.json +++ b/sdk/communication/communication-identity/package.json @@ -126,4 +126,4 @@ "typescript": "4.1.2", "typedoc": "0.15.2" } -} \ No newline at end of file +} diff --git a/sdk/communication/communication-sms/package.json b/sdk/communication/communication-sms/package.json index 019792c0f3e9..6c7513ba7561 100644 --- a/sdk/communication/communication-sms/package.json +++ b/sdk/communication/communication-sms/package.json @@ -127,4 +127,4 @@ "//sampleConfiguration": { "skipFolder": true } -} \ No newline at end of file +} diff --git a/sdk/core/core-client/package.json b/sdk/core/core-client/package.json index 8a644d59ee17..938ed3bf33af 100644 --- a/sdk/core/core-client/package.json +++ b/sdk/core/core-client/package.json @@ -125,4 +125,4 @@ "util": "^0.12.1", "typedoc": "0.15.2" } -} \ No newline at end of file +} diff --git a/sdk/core/core-http/package.json b/sdk/core/core-http/package.json index ad819841f177..6a6345bc843c 100644 --- a/sdk/core/core-http/package.json +++ b/sdk/core/core-http/package.json @@ -198,4 +198,4 @@ "xhr-mock": "^2.4.1", "typedoc": "0.15.2" } -} \ No newline at end of file +} diff --git a/sdk/core/core-https/package.json b/sdk/core/core-https/package.json index eda79fc99704..4b0153e097b2 100644 --- a/sdk/core/core-https/package.json +++ b/sdk/core/core-https/package.json @@ -141,4 +141,4 @@ "util": "^0.12.1", "typedoc": "0.15.2" } -} \ No newline at end of file +} diff --git a/sdk/core/core-tracing/package.json b/sdk/core/core-tracing/package.json index 205a887bc840..61e8ac551bf3 100644 --- a/sdk/core/core-tracing/package.json +++ b/sdk/core/core-tracing/package.json @@ -92,4 +92,4 @@ "sinon": "^9.0.2", "@types/sinon": "^9.0.4" } -} \ No newline at end of file +} diff --git a/sdk/digitaltwins/digital-twins-core/package.json b/sdk/digitaltwins/digital-twins-core/package.json index 1b56779a887e..e10d9d628930 100644 --- a/sdk/digitaltwins/digital-twins-core/package.json +++ b/sdk/digitaltwins/digital-twins-core/package.json @@ -125,4 +125,4 @@ "//sampleConfiguration": { "skipFolder": true } -} \ No newline at end of file +} diff --git a/sdk/eventgrid/eventgrid/package.json b/sdk/eventgrid/eventgrid/package.json index 6ffc815ecf6a..3ddd006a6b69 100644 --- a/sdk/eventgrid/eventgrid/package.json +++ b/sdk/eventgrid/eventgrid/package.json @@ -139,4 +139,4 @@ "typescript": "4.1.2", "typedoc": "0.15.2" } -} \ No newline at end of file +} diff --git a/sdk/eventhub/event-hubs/package.json b/sdk/eventhub/event-hubs/package.json index 36b1d88722af..d27422188a4d 100644 --- a/sdk/eventhub/event-hubs/package.json +++ b/sdk/eventhub/event-hubs/package.json @@ -166,4 +166,4 @@ "ws": "^7.1.1", "typedoc": "0.15.2" } -} \ No newline at end of file +} diff --git a/sdk/formrecognizer/ai-form-recognizer/package.json b/sdk/formrecognizer/ai-form-recognizer/package.json index 5772f232b85e..a2634efa5c1f 100644 --- a/sdk/formrecognizer/ai-form-recognizer/package.json +++ b/sdk/formrecognizer/ai-form-recognizer/package.json @@ -143,4 +143,4 @@ "deleteAllModels.js" ] } -} \ No newline at end of file +} diff --git a/sdk/identity/identity/package.json b/sdk/identity/identity/package.json index 2a4507ba9c0c..fc232b0c5999 100644 --- a/sdk/identity/identity/package.json +++ b/sdk/identity/identity/package.json @@ -143,4 +143,4 @@ "mock-fs": "^4.10.4", "typedoc": "0.15.2" } -} \ No newline at end of file +} diff --git a/sdk/keyvault/keyvault-admin/package.json b/sdk/keyvault/keyvault-admin/package.json index b478e150a02a..48d4abf25331 100644 --- a/sdk/keyvault/keyvault-admin/package.json +++ b/sdk/keyvault/keyvault-admin/package.json @@ -128,4 +128,4 @@ "uuid": "^8.3.0", "typedoc": "0.15.2" } -} \ No newline at end of file +} diff --git a/sdk/keyvault/keyvault-certificates/package.json b/sdk/keyvault/keyvault-certificates/package.json index 686852c51576..81b18086f10a 100644 --- a/sdk/keyvault/keyvault-certificates/package.json +++ b/sdk/keyvault/keyvault-certificates/package.json @@ -154,4 +154,4 @@ "url": "^0.11.0", "typedoc": "0.15.2" } -} \ No newline at end of file +} diff --git a/sdk/keyvault/keyvault-common/package.json b/sdk/keyvault/keyvault-common/package.json index b6ffb129e08b..517aa3a12a58 100644 --- a/sdk/keyvault/keyvault-common/package.json +++ b/sdk/keyvault/keyvault-common/package.json @@ -69,4 +69,4 @@ "rimraf": "^3.0.0", "typescript": "4.1.2" } -} \ No newline at end of file +} diff --git a/sdk/keyvault/keyvault-keys/package.json b/sdk/keyvault/keyvault-keys/package.json index 810613227f4c..c9421dc8dc28 100644 --- a/sdk/keyvault/keyvault-keys/package.json +++ b/sdk/keyvault/keyvault-keys/package.json @@ -149,4 +149,4 @@ "url": "^0.11.0", "typedoc": "0.15.2" } -} \ No newline at end of file +} diff --git a/sdk/keyvault/keyvault-secrets/package.json b/sdk/keyvault/keyvault-secrets/package.json index da53e1fdb10e..84e158678e04 100644 --- a/sdk/keyvault/keyvault-secrets/package.json +++ b/sdk/keyvault/keyvault-secrets/package.json @@ -152,4 +152,4 @@ "url": "^0.11.0", "typedoc": "0.15.2" } -} \ No newline at end of file +} diff --git a/sdk/metricsadvisor/ai-metrics-advisor/package.json b/sdk/metricsadvisor/ai-metrics-advisor/package.json index 1e94911804e7..8f0f1f8699e7 100644 --- a/sdk/metricsadvisor/ai-metrics-advisor/package.json +++ b/sdk/metricsadvisor/ai-metrics-advisor/package.json @@ -140,4 +140,4 @@ "seriesData.js" ] } -} \ No newline at end of file +} diff --git a/sdk/mixedreality/mixedreality-authentication/package.json b/sdk/mixedreality/mixedreality-authentication/package.json index 2e69f7c14ed7..c16938b1e573 100644 --- a/sdk/mixedreality/mixedreality-authentication/package.json +++ b/sdk/mixedreality/mixedreality-authentication/package.json @@ -115,4 +115,4 @@ "//smokeTestConfiguration": { "skipFolder": true } -} \ No newline at end of file +} diff --git a/sdk/search/search-documents/package.json b/sdk/search/search-documents/package.json index 1e1437082b47..8cbe5327e4c0 100644 --- a/sdk/search/search-documents/package.json +++ b/sdk/search/search-documents/package.json @@ -132,4 +132,4 @@ "util": "^0.12.1", "typedoc": "0.15.2" } -} \ No newline at end of file +} diff --git a/sdk/servicebus/service-bus/package.json b/sdk/servicebus/service-bus/package.json index 24c42f51c26d..7b2102ace707 100644 --- a/sdk/servicebus/service-bus/package.json +++ b/sdk/servicebus/service-bus/package.json @@ -177,4 +177,4 @@ "events": "^3.0.0", "typedoc": "0.15.2" } -} \ No newline at end of file +} diff --git a/sdk/storage/storage-blob-changefeed/package.json b/sdk/storage/storage-blob-changefeed/package.json index f0e1878dfd04..43658380a5ee 100644 --- a/sdk/storage/storage-blob-changefeed/package.json +++ b/sdk/storage/storage-blob-changefeed/package.json @@ -160,4 +160,4 @@ "//sampleConfiguration": { "skipFolder": true } -} \ No newline at end of file +} diff --git a/sdk/storage/storage-blob/package.json b/sdk/storage/storage-blob/package.json index 7616e0162eaa..5ff54ca01baa 100644 --- a/sdk/storage/storage-blob/package.json +++ b/sdk/storage/storage-blob/package.json @@ -183,4 +183,4 @@ "util": "^0.12.1", "typedoc": "0.15.2" } -} \ No newline at end of file +} diff --git a/sdk/storage/storage-file-datalake/package.json b/sdk/storage/storage-file-datalake/package.json index b8872e912de3..4c38f64ecf52 100644 --- a/sdk/storage/storage-file-datalake/package.json +++ b/sdk/storage/storage-file-datalake/package.json @@ -163,4 +163,4 @@ "util": "^0.12.1", "typedoc": "0.15.2" } -} \ No newline at end of file +} diff --git a/sdk/storage/storage-file-share/package.json b/sdk/storage/storage-file-share/package.json index 15f5e682de35..47d5c51ea781 100644 --- a/sdk/storage/storage-file-share/package.json +++ b/sdk/storage/storage-file-share/package.json @@ -169,4 +169,4 @@ "util": "^0.12.1", "typedoc": "0.15.2" } -} \ No newline at end of file +} diff --git a/sdk/storage/storage-queue/package.json b/sdk/storage/storage-queue/package.json index 2b77a5016ded..58db2ad01306 100644 --- a/sdk/storage/storage-queue/package.json +++ b/sdk/storage/storage-queue/package.json @@ -163,4 +163,4 @@ "util": "^0.12.1", "typedoc": "0.15.2" } -} \ No newline at end of file +} diff --git a/sdk/synapse/synapse-access-control/package.json b/sdk/synapse/synapse-access-control/package.json index 11b731261428..65cfb27fefac 100644 --- a/sdk/synapse/synapse-access-control/package.json +++ b/sdk/synapse/synapse-access-control/package.json @@ -78,4 +78,4 @@ }, "sideEffects": false, "autoPublish": true -} \ No newline at end of file +} diff --git a/sdk/synapse/synapse-artifacts/package.json b/sdk/synapse/synapse-artifacts/package.json index fa9aea944d57..27e60bca0d41 100644 --- a/sdk/synapse/synapse-artifacts/package.json +++ b/sdk/synapse/synapse-artifacts/package.json @@ -79,4 +79,4 @@ }, "sideEffects": false, "autoPublish": true -} \ No newline at end of file +} diff --git a/sdk/synapse/synapse-managed-private-endpoints/package.json b/sdk/synapse/synapse-managed-private-endpoints/package.json index c4813423a48b..493d320ee257 100644 --- a/sdk/synapse/synapse-managed-private-endpoints/package.json +++ b/sdk/synapse/synapse-managed-private-endpoints/package.json @@ -78,4 +78,4 @@ }, "sideEffects": false, "autoPublish": true -} \ No newline at end of file +} diff --git a/sdk/synapse/synapse-monitoring/package.json b/sdk/synapse/synapse-monitoring/package.json index e7028b8ced80..3140e4016a93 100644 --- a/sdk/synapse/synapse-monitoring/package.json +++ b/sdk/synapse/synapse-monitoring/package.json @@ -77,4 +77,4 @@ }, "sideEffects": false, "autoPublish": true -} \ No newline at end of file +} diff --git a/sdk/synapse/synapse-spark/package.json b/sdk/synapse/synapse-spark/package.json index 7e7b491cbed9..9d1a75ac6689 100644 --- a/sdk/synapse/synapse-spark/package.json +++ b/sdk/synapse/synapse-spark/package.json @@ -77,4 +77,4 @@ }, "sideEffects": false, "autoPublish": true -} \ No newline at end of file +} diff --git a/sdk/tables/data-tables/package.json b/sdk/tables/data-tables/package.json index 3341accf9dec..45aecf7fd670 100644 --- a/sdk/tables/data-tables/package.json +++ b/sdk/tables/data-tables/package.json @@ -137,4 +137,4 @@ } ] } -} \ No newline at end of file +} diff --git a/sdk/template/template/package.json b/sdk/template/template/package.json index adb719f6a407..18ffb652e71f 100644 --- a/sdk/template/template/package.json +++ b/sdk/template/template/package.json @@ -120,4 +120,4 @@ "//sampleConfiguration": { "skipFolder": false } -} \ No newline at end of file +} diff --git a/sdk/textanalytics/ai-text-analytics/package.json b/sdk/textanalytics/ai-text-analytics/package.json index 50fd8be1c5c5..d33bf2f207d3 100644 --- a/sdk/textanalytics/ai-text-analytics/package.json +++ b/sdk/textanalytics/ai-text-analytics/package.json @@ -133,4 +133,4 @@ "karma-source-map-support": "~1.4.0", "typedoc": "0.15.2" } -} \ No newline at end of file +} From bd1a4e80e5b3837f068ffda1ba46c67f80c1aad4 Mon Sep 17 00:00:00 2001 From: Richard Park <51494936+richardpark-msft@users.noreply.github.com> Date: Tue, 23 Feb 2021 00:52:12 +0000 Subject: [PATCH 41/52] Change name from SpanConfig (which is too generic!) to CreateSpanFunctionArgs, which is hyper-specific and cannot be confused for anything but the arguments for createSpanFunction Also, added some doc comments to createSpanFunction --- sdk/core/core-tracing/src/createSpan.ts | 34 +++++++++++++++++-------- sdk/core/core-tracing/src/index.ts | 2 +- 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/sdk/core/core-tracing/src/createSpan.ts b/sdk/core/core-tracing/src/createSpan.ts index b4dd0278bc92..9513226e8071 100644 --- a/sdk/core/core-tracing/src/createSpan.ts +++ b/sdk/core/core-tracing/src/createSpan.ts @@ -6,10 +6,12 @@ import { getTracer } from "../src/tracerProxy"; import { OperationTracingOptions } from "./interfaces"; /** - * Configuration for creating a new Tracing Span + * Arguments for `createSpanFunction` that allow you to specify the + * prefix for each created span as well as the `az.namespace` attribute. + * * @hidden */ -export interface SpanConfig { +export interface CreateSpanFunctionArgs { /** * Package name prefix */ @@ -21,13 +23,25 @@ export interface SpanConfig { } /** - * Creates a function called createSpan to create spans using the global tracer. + * Creates a function that can be used to create spans using the global tracer. + * + * Usage: + * + * ```typescript + * // once + * const createSpan = createSpanFunction({ packagePrefix: "Azure.Data.AppConfiguration", namespace: "Microsoft.AppConfiguration" }); + * + * // in each operation + * const span = createSpan("deleteConfigurationSetting", operationOptions); + * // code... + * span.end(); + * ``` + * * @hidden - * @param spanConfig - The name of the operation being performed. - * @param tracingOptions - The options for the underlying http request. + * @param args - allows configuration of the prefix for each span as well as the az.namespace field. */ -export function createSpanFunction({ packagePrefix, namespace }: SpanConfig) { - return function( +export function createSpanFunction(args: CreateSpanFunctionArgs) { + return function ( operationName: string, operationOptions: T ): { span: Span; updatedOptions: NonNullable } { @@ -38,9 +52,9 @@ export function createSpanFunction({ packagePrefix, namespace }: SpanConfig) { kind: SpanKind.INTERNAL }; - const span = tracer.startSpan(`${packagePrefix}.${operationName}`, spanOptions); + const span = tracer.startSpan(`${args.packagePrefix}.${operationName}`, spanOptions); - span.setAttribute("az.namespace", namespace); + span.setAttribute("az.namespace", args.namespace); let newSpanOptions = tracingOptions.spanOptions || {}; if (span.isRecording()) { @@ -49,7 +63,7 @@ export function createSpanFunction({ packagePrefix, namespace }: SpanConfig) { parent: span.context(), attributes: { ...spanOptions.attributes, - "az.namespace": namespace + "az.namespace": args.namespace } }; } diff --git a/sdk/core/core-tracing/src/index.ts b/sdk/core/core-tracing/src/index.ts index eb2615991c89..a18b1f01e095 100644 --- a/sdk/core/core-tracing/src/index.ts +++ b/sdk/core/core-tracing/src/index.ts @@ -10,7 +10,7 @@ export { OpenCensusSpanWrapper } from "./tracers/opencensus/openCensusSpanWrappe export { OpenCensusTracerWrapper } from "./tracers/opencensus/openCensusTracerWrapper"; export { TestTracer, SpanGraph, SpanGraphNode } from "./tracers/test/testTracer"; export { TestSpan } from "./tracers/test/testSpan"; -export { createSpanFunction, SpanConfig } from "./createSpan"; +export { createSpanFunction, CreateSpanFunctionArgs } from "./createSpan"; // Shared interfaces export { SpanContext, SpanOptions, TraceFlags } from "./interfaces"; From b168a327ba7982a28d0ef5e78028040aff105aed Mon Sep 17 00:00:00 2001 From: Richard Park <51494936+richardpark-msft@users.noreply.github.com> Date: Tue, 23 Feb 2021 00:57:54 +0000 Subject: [PATCH 42/52] Formatting again. --- sdk/core/core-tracing/src/createSpan.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/sdk/core/core-tracing/src/createSpan.ts b/sdk/core/core-tracing/src/createSpan.ts index 9513226e8071..0e0f9a67c149 100644 --- a/sdk/core/core-tracing/src/createSpan.ts +++ b/sdk/core/core-tracing/src/createSpan.ts @@ -6,9 +6,9 @@ import { getTracer } from "../src/tracerProxy"; import { OperationTracingOptions } from "./interfaces"; /** - * Arguments for `createSpanFunction` that allow you to specify the + * Arguments for `createSpanFunction` that allow you to specify the * prefix for each created span as well as the `az.namespace` attribute. - * + * * @hidden */ export interface CreateSpanFunctionArgs { @@ -26,22 +26,22 @@ export interface CreateSpanFunctionArgs { * Creates a function that can be used to create spans using the global tracer. * * Usage: - * + * * ```typescript * // once * const createSpan = createSpanFunction({ packagePrefix: "Azure.Data.AppConfiguration", namespace: "Microsoft.AppConfiguration" }); - * + * * // in each operation * const span = createSpan("deleteConfigurationSetting", operationOptions); * // code... * span.end(); * ``` - * + * * @hidden * @param args - allows configuration of the prefix for each span as well as the az.namespace field. */ export function createSpanFunction(args: CreateSpanFunctionArgs) { - return function ( + return function( operationName: string, operationOptions: T ): { span: Span; updatedOptions: NonNullable } { From bed4e50bb5a61d6bf690188c6d0b313695ffc363 Mon Sep 17 00:00:00 2001 From: Richard Park <51494936+richardpark-msft@users.noreply.github.com> Date: Tue, 23 Feb 2021 01:00:30 +0000 Subject: [PATCH 43/52] Updating changelog for core-client to note that createSpanFunction has been removed. --- sdk/core/core-client/CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sdk/core/core-client/CHANGELOG.md b/sdk/core/core-client/CHANGELOG.md index 4b351adba731..333ee40d677e 100644 --- a/sdk/core/core-client/CHANGELOG.md +++ b/sdk/core/core-client/CHANGELOG.md @@ -2,6 +2,11 @@ ## 1.0.0-beta.2 (Unreleased) +### Breaking Changes: + +- Removed `createSpanFunction` and `SpanConfig`. These have been moved into + `@azure/core-tracing`. + ## 1.0.0-beta.1 (2021-02-04) - First release of package, see README.md for details. From af57992fc98fab670c4301bfc9d86d0ceac986ba Mon Sep 17 00:00:00 2001 From: Richard Park <51494936+richardpark-msft@users.noreply.github.com> Date: Tue, 23 Feb 2021 01:41:17 +0000 Subject: [PATCH 44/52] Renamed SpanOptions to CreateSpanFunctionArgs --- sdk/core/core-tracing/review/core-tracing.api.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/sdk/core/core-tracing/review/core-tracing.api.md b/sdk/core/core-tracing/review/core-tracing.api.md index ece7cfd5715c..754bcd8ca8ae 100644 --- a/sdk/core/core-tracing/review/core-tracing.api.md +++ b/sdk/core/core-tracing/review/core-tracing.api.md @@ -17,13 +17,19 @@ import { Tracer } from '@opentelemetry/api'; import { TracerBase } from '@opencensus/web-types'; // @public -export function createSpanFunction({ packagePrefix, namespace }: SpanConfig): (operationName: string, operationOptions: T) => { span: Span; updatedOptions: NonNullable; }; +// @public +export interface CreateSpanFunctionArgs { + namespace: string; + packagePrefix: string; +} + // @public export function extractSpanContextFromTraceParentHeader(traceParentHeader: string): SpanContext | undefined; @@ -94,12 +100,6 @@ export { OTSpanOptions } // @public export function setTracer(tracer: Tracer): void; -// @public -export interface SpanConfig { - namespace: string; - packagePrefix: string; -} - // @public export interface SpanContext { spanId: string; From bf06056a01462e5b4a6e050a47122c0716837d98 Mon Sep 17 00:00:00 2001 From: Richard Park <51494936+richardpark-msft@users.noreply.github.com> Date: Tue, 23 Feb 2021 01:55:17 +0000 Subject: [PATCH 45/52] Simplified the signature for createSpanFunction --- sdk/core/core-tracing/review/core-tracing.api.md | 4 ++-- sdk/core/core-tracing/src/createSpan.ts | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/sdk/core/core-tracing/review/core-tracing.api.md b/sdk/core/core-tracing/review/core-tracing.api.md index 754bcd8ca8ae..aa2fd0dc7e56 100644 --- a/sdk/core/core-tracing/review/core-tracing.api.md +++ b/sdk/core/core-tracing/review/core-tracing.api.md @@ -19,9 +19,9 @@ import { TracerBase } from '@opencensus/web-types'; // @public export function createSpanFunction(args: CreateSpanFunctionArgs): (operationName: string, operationOptions: T) => { +}>(operationName: string, operationOptions: T | undefined) => { span: Span; - updatedOptions: NonNullable; + updatedOptions: T; }; // @public diff --git a/sdk/core/core-tracing/src/createSpan.ts b/sdk/core/core-tracing/src/createSpan.ts index 0e0f9a67c149..566d06765b8d 100644 --- a/sdk/core/core-tracing/src/createSpan.ts +++ b/sdk/core/core-tracing/src/createSpan.ts @@ -41,10 +41,10 @@ export interface CreateSpanFunctionArgs { * @param args - allows configuration of the prefix for each span as well as the az.namespace field. */ export function createSpanFunction(args: CreateSpanFunctionArgs) { - return function( + return function ( operationName: string, - operationOptions: T - ): { span: Span; updatedOptions: NonNullable } { + operationOptions: T | undefined + ): { span: Span; updatedOptions: T } { const tracer = getTracer(); const tracingOptions = operationOptions?.tracingOptions || {}; const spanOptions: SpanOptions = { @@ -74,14 +74,14 @@ export function createSpanFunction(args: CreateSpanFunctionArgs) { // TODO: .context soon. }; - const newOperationOptions: NonNullable = { + const newOperationOptions = { ...operationOptions, tracingOptions: newTracingOptions - } as NonNullable; + } return { span, - updatedOptions: newOperationOptions + updatedOptions: newOperationOptions as T }; }; } From 0e3b80fb60db23e700b945c905c8f4b7d2f1d6d7 Mon Sep 17 00:00:00 2001 From: Richard Park <51494936+richardpark-msft@users.noreply.github.com> Date: Tue, 23 Feb 2021 01:55:28 +0000 Subject: [PATCH 46/52] Formatting --- sdk/core/core-tracing/src/createSpan.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sdk/core/core-tracing/src/createSpan.ts b/sdk/core/core-tracing/src/createSpan.ts index 566d06765b8d..2ab431f68a4e 100644 --- a/sdk/core/core-tracing/src/createSpan.ts +++ b/sdk/core/core-tracing/src/createSpan.ts @@ -41,7 +41,7 @@ export interface CreateSpanFunctionArgs { * @param args - allows configuration of the prefix for each span as well as the az.namespace field. */ export function createSpanFunction(args: CreateSpanFunctionArgs) { - return function ( + return function( operationName: string, operationOptions: T | undefined ): { span: Span; updatedOptions: T } { @@ -77,7 +77,7 @@ export function createSpanFunction(args: CreateSpanFunctionArgs) { const newOperationOptions = { ...operationOptions, tracingOptions: newTracingOptions - } + }; return { span, From 4900eb13d5a1b0b1e6b8218a5a2bd56dbdae6265 Mon Sep 17 00:00:00 2001 From: Richard Park <51494936+richardpark-msft@users.noreply.github.com> Date: Tue, 23 Feb 2021 18:25:25 +0000 Subject: [PATCH 47/52] Formalizing the deprecated'ness of the core-http exports by adding in the @deprecated JSDoc tag. --- sdk/core/core-http/review/core-http.api.md | 4 ++-- sdk/core/core-http/src/createSpanLegacy.ts | 16 ++++++++++------ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/sdk/core/core-http/review/core-http.api.md b/sdk/core/core-http/review/core-http.api.md index 7adbf79b4b9a..32b43607d81d 100644 --- a/sdk/core/core-http/review/core-http.api.md +++ b/sdk/core/core-http/review/core-http.api.md @@ -157,7 +157,7 @@ export const Constants: { // @public (undocumented) export function createPipelineFromOptions(pipelineOptions: InternalPipelineOptions, authPolicyFactory?: RequestPolicyFactory): ServiceClientOptions; -// @public +// @public @deprecated export function createSpanFunction(args: SpanConfig): (operationName: string, operationOptions: T) => { span: Span; updatedOptions: T; @@ -798,7 +798,7 @@ export interface SimpleMapperType { name: "Base64Url" | "Boolean" | "ByteArray" | "Date" | "DateTime" | "DateTimeRfc1123" | "Object" | "Stream" | "String" | "TimeSpan" | "UnixTime" | "Uuid" | "Number" | "any"; } -// @public +// @public @deprecated export interface SpanConfig { namespace: string; packagePrefix: string; diff --git a/sdk/core/core-http/src/createSpanLegacy.ts b/sdk/core/core-http/src/createSpanLegacy.ts index a98857d45bc9..726151e082be 100644 --- a/sdk/core/core-http/src/createSpanLegacy.ts +++ b/sdk/core/core-http/src/createSpanLegacy.ts @@ -10,7 +10,9 @@ import { Span } from "@opentelemetry/api"; import { OperationOptions } from "./operationOptions"; /** - * Configuration for creating a new Tracing Span + * This function is only here for compatibility. Use createSpanFunction in core-tracing. + * + * @deprecated This function is only here for compatibility. Use core-tracing instead. * @hidden */ export interface SpanConfig { @@ -25,8 +27,10 @@ export interface SpanConfig { } /** - * DEPRECATED: This function is only here for compatibility. Use createSpanFunction in core-tracing. - * @hidden + * This function is only here for compatibility. Use createSpanFunction in core-tracing. + * + * @deprecated This function is only here for compatibility. Use createSpanFunction in core-tracing. + * @hidden * @param spanConfig - The name of the operation being performed. * @param tracingOptions - The options for the underlying http request. @@ -34,8 +38,8 @@ export interface SpanConfig { export function createSpanFunction( args: SpanConfig ): ( - operationName: string, - operationOptions: T -) => { span: Span; updatedOptions: T } { + operationName: string, + operationOptions: T + ) => { span: Span; updatedOptions: T } { return coreTracingCreateSpanFunction(args); } From caf7f63b31e126a054d63c41170c8aa1cc391a5e Mon Sep 17 00:00:00 2001 From: Richard Park <51494936+richardpark-msft@users.noreply.github.com> Date: Tue, 23 Feb 2021 18:25:38 +0000 Subject: [PATCH 48/52] Formatting --- sdk/core/core-http/src/createSpanLegacy.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/sdk/core/core-http/src/createSpanLegacy.ts b/sdk/core/core-http/src/createSpanLegacy.ts index 726151e082be..8291a678ac10 100644 --- a/sdk/core/core-http/src/createSpanLegacy.ts +++ b/sdk/core/core-http/src/createSpanLegacy.ts @@ -10,8 +10,8 @@ import { Span } from "@opentelemetry/api"; import { OperationOptions } from "./operationOptions"; /** - * This function is only here for compatibility. Use createSpanFunction in core-tracing. - * + * This function is only here for compatibility. Use createSpanFunction in core-tracing. + * * @deprecated This function is only here for compatibility. Use core-tracing instead. * @hidden */ @@ -38,8 +38,8 @@ export interface SpanConfig { export function createSpanFunction( args: SpanConfig ): ( - operationName: string, - operationOptions: T - ) => { span: Span; updatedOptions: T } { + operationName: string, + operationOptions: T +) => { span: Span; updatedOptions: T } { return coreTracingCreateSpanFunction(args); } From 7f7ecc5957b465f9fe609f04aa5197ec9a1c3ea4 Mon Sep 17 00:00:00 2001 From: Richard Park <51494936+richardpark-msft@users.noreply.github.com> Date: Tue, 23 Feb 2021 18:29:08 +0000 Subject: [PATCH 49/52] Formatting of the breaking changes was incorrect. --- sdk/core/core-client/CHANGELOG.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/sdk/core/core-client/CHANGELOG.md b/sdk/core/core-client/CHANGELOG.md index 333ee40d677e..a47a4d1cf2fc 100644 --- a/sdk/core/core-client/CHANGELOG.md +++ b/sdk/core/core-client/CHANGELOG.md @@ -2,9 +2,7 @@ ## 1.0.0-beta.2 (Unreleased) -### Breaking Changes: - -- Removed `createSpanFunction` and `SpanConfig`. These have been moved into +- [Breaking] Removed `createSpanFunction` and `SpanConfig`. These have been moved into `@azure/core-tracing`. ## 1.0.0-beta.1 (2021-02-04) From 8f62518673ed554775c386c7e3443a0da38a9f27 Mon Sep 17 00:00:00 2001 From: Richard Park <51494936+richardpark-msft@users.noreply.github.com> Date: Wed, 24 Feb 2021 20:57:00 +0000 Subject: [PATCH 50/52] Removed unused import --- sdk/storage/storage-queue/src/QueueClient.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/storage/storage-queue/src/QueueClient.ts b/sdk/storage/storage-queue/src/QueueClient.ts index 08dabd8300e6..1f065eb9fa72 100644 --- a/sdk/storage/storage-queue/src/QueueClient.ts +++ b/sdk/storage/storage-queue/src/QueueClient.ts @@ -44,7 +44,7 @@ import { } from "./utils/utils.common"; import { StorageSharedKeyCredential } from "./credentials/StorageSharedKeyCredential"; import { AnonymousCredential } from "./credentials/AnonymousCredential"; -import { convertTracingToRequestOptionsBase, createSpan } from "./utils/tracing"; +import { createSpan } from "./utils/tracing"; import { Metadata } from "./models"; import { generateQueueSASQueryParameters } from "./QueueSASSignatureValues"; import { SasIPRange } from "./SasIPRange"; From fce32380cb51d16a6801837f41252c6f219332a7 Mon Sep 17 00:00:00 2001 From: Richard Park <51494936+richardpark-msft@users.noreply.github.com> Date: Wed, 24 Feb 2021 20:58:56 +0000 Subject: [PATCH 51/52] Remove unused functions. --- sdk/storage/storage-queue/src/QueueClient.ts | 168 +++++++----------- .../storage-queue/src/QueueServiceClient.ts | 2 +- 2 files changed, 64 insertions(+), 106 deletions(-) diff --git a/sdk/storage/storage-queue/src/QueueClient.ts b/sdk/storage/storage-queue/src/QueueClient.ts index 1f065eb9fa72..e52ada8050d4 100644 --- a/sdk/storage/storage-queue/src/QueueClient.ts +++ b/sdk/storage/storage-queue/src/QueueClient.ts @@ -168,24 +168,24 @@ export interface SignedIdentifier { export declare type QueueGetAccessPolicyResponse = { signedIdentifiers: SignedIdentifier[]; } & QueueGetAccessPolicyHeaders & { - /** - * The underlying HTTP response. - */ - _response: HttpResponse & { - /** - * The parsed HTTP response headers. - */ - parsedHeaders: QueueGetAccessPolicyHeaders; - /** - * The response body as text (string format) - */ - bodyAsText: string; /** - * The response body as parsed JSON or XML + * The underlying HTTP response. */ - parsedBody: SignedIdentifierModel[]; + _response: HttpResponse & { + /** + * The parsed HTTP response headers. + */ + parsedHeaders: QueueGetAccessPolicyHeaders; + /** + * The response body as text (string format) + */ + bodyAsText: string; + /** + * The response body as parsed JSON or XML + */ + parsedBody: SignedIdentifierModel[]; + }; }; -}; /** * Options to configure {@link QueueClient.clearMessages} operation @@ -213,7 +213,7 @@ export interface MessagesEnqueueOptionalParams extends RequestOptionsBase { /** * Options to configure {@link QueueClient.sendMessage} operation */ -export interface QueueSendMessageOptions extends MessagesEnqueueOptionalParams, CommonOptions { } +export interface QueueSendMessageOptions extends MessagesEnqueueOptionalParams, CommonOptions {} /** Optional parameters. */ export interface MessagesDequeueOptionalParams extends RequestOptionsBase { @@ -230,7 +230,7 @@ export interface MessagesDequeueOptionalParams extends RequestOptionsBase { /** * Options to configure {@link QueueClient.receiveMessages} operation */ -export interface QueueReceiveMessageOptions extends MessagesDequeueOptionalParams, CommonOptions { } +export interface QueueReceiveMessageOptions extends MessagesDequeueOptionalParams, CommonOptions {} /** Optional parameters. */ export interface MessagesPeekOptionalParams extends RequestOptionsBase { @@ -245,7 +245,7 @@ export interface MessagesPeekOptionalParams extends RequestOptionsBase { /** * Options to configure {@link QueueClient.peekMessages} operation */ -export interface QueuePeekMessagesOptions extends MessagesPeekOptionalParams, CommonOptions { } +export interface QueuePeekMessagesOptions extends MessagesPeekOptionalParams, CommonOptions {} /** * Contains the response data for the {@link QueueClient.sendMessage} operation. @@ -277,24 +277,24 @@ export declare type QueueSendMessageResponse = { */ nextVisibleOn: Date; } & MessagesEnqueueHeaders & { - /** - * The underlying HTTP response. - */ - _response: HttpResponse & { - /** - * The parsed HTTP response headers. - */ - parsedHeaders: MessagesEnqueueHeaders; - /** - * The response body as text (string format) - */ - bodyAsText: string; /** - * The response body as parsed JSON or XML + * The underlying HTTP response. */ - parsedBody: EnqueuedMessage[]; + _response: HttpResponse & { + /** + * The parsed HTTP response headers. + */ + parsedHeaders: MessagesEnqueueHeaders; + /** + * The response body as text (string format) + */ + bodyAsText: string; + /** + * The response body as parsed JSON or XML + */ + parsedBody: EnqueuedMessage[]; + }; }; -}; /** * The object returned in the `receivedMessageItems` array when calling {@link QueueClient.receiveMessages}. @@ -309,24 +309,24 @@ export declare type ReceivedMessageItem = DequeuedMessageItem; export declare type QueueReceiveMessageResponse = { receivedMessageItems: ReceivedMessageItem[]; } & MessagesDequeueHeaders & { - /** - * The underlying HTTP response. - */ - _response: HttpResponse & { - /** - * The parsed HTTP response headers. - */ - parsedHeaders: MessagesDequeueHeaders; - /** - * The response body as text (string format) - */ - bodyAsText: string; /** - * The response body as parsed JSON or XML + * The underlying HTTP response. */ - parsedBody: ReceivedMessageItem[]; + _response: HttpResponse & { + /** + * The parsed HTTP response headers. + */ + parsedHeaders: MessagesDequeueHeaders; + /** + * The response body as text (string format) + */ + bodyAsText: string; + /** + * The response body as parsed JSON or XML + */ + parsedBody: ReceivedMessageItem[]; + }; }; -}; /** * Contains the response data for the {@link QueueClient.peekMessages} operation. @@ -334,24 +334,24 @@ export declare type QueueReceiveMessageResponse = { export declare type QueuePeekMessagesResponse = { peekedMessageItems: PeekedMessageItem[]; } & MessagesPeekHeaders & { - /** - * The underlying HTTP response. - */ - _response: HttpResponse & { - /** - * The parsed HTTP response headers. - */ - parsedHeaders: MessagesPeekHeaders; /** - * The response body as text (string format) + * The underlying HTTP response. */ - bodyAsText: string; - /** - * The response body as parsed JSON or XML - */ - parsedBody: PeekedMessageItem[]; + _response: HttpResponse & { + /** + * The parsed HTTP response headers. + */ + parsedHeaders: MessagesPeekHeaders; + /** + * The response body as text (string format) + */ + bodyAsText: string; + /** + * The response body as parsed JSON or XML + */ + parsedBody: PeekedMessageItem[]; + }; }; -}; /** * Options to configure the {@link QueueClient.deleteMessage} operation @@ -1302,45 +1302,3 @@ export class QueueClient extends StorageClient { return appendToURLQuery(this.url, sas); } } - -/** - * Converts an RequestOptionsBase to a OperationOptions - * - * @param opts - RequestOptionsBase object to convert to OperationOptions - */ -function requestOptionsBaseToOperationOptions( - opts: T, - spanOptions?: SpanOptions -): OperationOptions { - const { - abortSignal, - customHeaders, - timeout, - onUploadProgress, - onDownloadProgress, - shouldDeserialize, - ...additionalOptions - } = opts; - - let result: OperationOptions = { ...additionalOptions }; - - if (abortSignal) { - result.abortSignal = abortSignal; - } - - result.requestOptions = { - customHeaders: customHeaders ?? undefined, - timeout: timeout ?? undefined, - onUploadProgress: onUploadProgress ?? undefined, - onDownloadProgress: onDownloadProgress ?? undefined, - shouldDeserialize: shouldDeserialize ?? undefined - }; - - if (spanOptions) { - result.tracingOptions = { - spanOptions: spanOptions - }; - } - - return result; -} diff --git a/sdk/storage/storage-queue/src/QueueServiceClient.ts b/sdk/storage/storage-queue/src/QueueServiceClient.ts index 23a709ef0887..bdc542c0a976 100644 --- a/sdk/storage/storage-queue/src/QueueServiceClient.ts +++ b/sdk/storage/storage-queue/src/QueueServiceClient.ts @@ -31,7 +31,7 @@ import { } from "./utils/utils.common"; import { StorageSharedKeyCredential } from "./credentials/StorageSharedKeyCredential"; import { AnonymousCredential } from "./credentials/AnonymousCredential"; -import { convertTracingToRequestOptionsBase, createSpan } from "./utils/tracing"; +import { createSpan } from "./utils/tracing"; import { QueueClient, QueueCreateOptions, QueueDeleteOptions } from "./QueueClient"; import { AccountSASPermissions } from "./AccountSASPermissions"; import { generateAccountSASQueryParameters } from "./AccountSASSignatureValues"; From 72d141fdd67aa017f933c8472737dadd8660f7b6 Mon Sep 17 00:00:00 2001 From: Richard Park <51494936+richardpark-msft@users.noreply.github.com> Date: Wed, 24 Feb 2021 21:13:45 +0000 Subject: [PATCH 52/52] Remove two unused imports --- sdk/storage/storage-queue/src/QueueClient.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/sdk/storage/storage-queue/src/QueueClient.ts b/sdk/storage/storage-queue/src/QueueClient.ts index e52ada8050d4..d78021020cc1 100644 --- a/sdk/storage/storage-queue/src/QueueClient.ts +++ b/sdk/storage/storage-queue/src/QueueClient.ts @@ -8,8 +8,7 @@ import { isNode, getDefaultProxySettings, URLBuilder, - RequestOptionsBase, - OperationOptions + RequestOptionsBase } from "@azure/core-http"; import { CanonicalCode } from "@opentelemetry/api"; import { @@ -50,7 +49,6 @@ import { generateQueueSASQueryParameters } from "./QueueSASSignatureValues"; import { SasIPRange } from "./SasIPRange"; import { QueueSASPermissions } from "./QueueSASPermissions"; import { SASProtocol } from "./SASQueryParameters"; -import { SpanOptions } from "@azure/core-tracing"; /** * Options to configure {@link QueueClient.create} operation