@azure/digital-twins-core 1.1.0-beta.1 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -560,7 +560,7 @@ const tracestate = {
560
560
  const apiVersion = {
561
561
  parameterPath: "apiVersion",
562
562
  mapper: {
563
- defaultValue: "2021-06-30-preview",
563
+ defaultValue: "2022-05-31",
564
564
  isConstant: true,
565
565
  serializedName: "api-version",
566
566
  type: {
@@ -1872,7 +1872,7 @@ const listNextOperationSpec = {
1872
1872
  * Changes may cause incorrect behavior and will be lost if the code is regenerated.
1873
1873
  */
1874
1874
  const packageName = "@azure/digital-twins-core";
1875
- const packageVersion = "1.1.0-beta.1";
1875
+ const packageVersion = "1.1.0";
1876
1876
  class AzureDigitalTwinsAPIContext extends coreHttp__namespace.ServiceClient {
1877
1877
  /**
1878
1878
  * Initializes a new instance of the AzureDigitalTwinsAPIContext class.
@@ -1894,7 +1894,7 @@ class AzureDigitalTwinsAPIContext extends coreHttp__namespace.ServiceClient {
1894
1894
  // Assigning values to Constant parameters
1895
1895
  this.$host =
1896
1896
  options.$host || "https://digitaltwins-name.digitaltwins.azure.net";
1897
- this.apiVersion = options.apiVersion || "2021-06-30-preview";
1897
+ this.apiVersion = options.apiVersion || "2022-05-31";
1898
1898
  }
1899
1899
  }
1900
1900
 
@@ -1919,14 +1919,19 @@ class AzureDigitalTwinsAPI extends AzureDigitalTwinsAPIContext {
1919
1919
  }
1920
1920
  }
1921
1921
 
1922
+ // Copyright (c) Microsoft Corporation.
1923
+ // Licensed under the MIT license.
1924
+ const SDK_VERSION$1 = "1.1.0";
1925
+
1922
1926
  // Copyright (c) Microsoft Corporation.
1923
1927
  /**
1924
- * Creates a span using the global tracer.
1928
+ * Creates a tracing client to manage tracing spans.
1925
1929
  * @internal
1926
1930
  */
1927
- const createSpan = coreTracing.createSpanFunction({
1928
- packagePrefix: "DigitalTwinsClient",
1931
+ const tracingClient = coreTracing.createTracingClient({
1929
1932
  namespace: "Microsoft.DigitalTwins",
1933
+ packageName: "@azure/digital-twins-core",
1934
+ packageVersion: SDK_VERSION$1,
1930
1935
  });
1931
1936
 
1932
1937
  // Copyright (c) Microsoft Corporation.
@@ -1936,7 +1941,7 @@ const createSpan = coreTracing.createSpanFunction({
1936
1941
  const logger = logger$1.createClientLogger("azure-digitaltwins-core");
1937
1942
 
1938
1943
  // Copyright (c) Microsoft Corporation.
1939
- const SDK_VERSION = "1.1.0-beta.1";
1944
+ const SDK_VERSION = "1.1.0";
1940
1945
  const DEFAULT_DIGITALTWINS_SCOPE = "https://digitaltwins.azure.net/.default";
1941
1946
  /**
1942
1947
  * Client for Azure IoT DigitalTwins API.
@@ -1959,10 +1964,6 @@ class DigitalTwinsClient {
1959
1964
  * @param options - Used to configure the service client.
1960
1965
  */
1961
1966
  constructor(endpointUrl, credential, options = {}) {
1962
- /**
1963
- * @deprecated Please use {@link DigitalTwinsClient.decommissionModel} instead.
1964
- */
1965
- this.decomissionModel = this.decommissionModel;
1966
1967
  const authPolicy = coreHttp.bearerTokenAuthenticationPolicy(credential, DEFAULT_DIGITALTWINS_SCOPE);
1967
1968
  const libInfo = `azsdk-js-digital-twins-core/${SDK_VERSION}`;
1968
1969
  const { apiVersion } = options, pipelineOptions = tslib.__rest(options, ["apiVersion"]);
@@ -1992,20 +1993,9 @@ class DigitalTwinsClient {
1992
1993
  * @returns The application/json digital twin and the http response.
1993
1994
  */
1994
1995
  getDigitalTwin(digitalTwinId, options = {}) {
1995
- const { span, updatedOptions } = createSpan("DigitalTwinsClient-getDigitalTwin", options);
1996
- try {
1996
+ return tracingClient.withSpan("DigitalTwinsClient.getDigitalTwin", options, async (updatedOptions) => {
1997
1997
  return this.client.digitalTwins.getById(digitalTwinId, updatedOptions);
1998
- }
1999
- catch (e) {
2000
- span.setStatus({
2001
- code: coreTracing.SpanStatusCode.ERROR,
2002
- message: e.message,
2003
- });
2004
- throw e;
2005
- }
2006
- finally {
2007
- span.end();
2008
- }
1998
+ });
2009
1999
  }
2010
2000
  /**
2011
2001
  * Create or update a digital twin
@@ -2017,21 +2007,10 @@ class DigitalTwinsClient {
2017
2007
  * @returns The created application/json digital twin and the http response.
2018
2008
  */
2019
2009
  upsertDigitalTwin(digitalTwinId, digitalTwinJson, options = {}) {
2020
- const { span, updatedOptions } = createSpan("DigitalTwinsClient-upsertDigitalTwin", options);
2021
- try {
2010
+ return tracingClient.withSpan("DigitalTwinsClient.upsertDigitalTwin", options, async (updatedOptions) => {
2022
2011
  const payload = JSON.parse(digitalTwinJson);
2023
2012
  return this.client.digitalTwins.add(digitalTwinId, payload, updatedOptions);
2024
- }
2025
- catch (e) {
2026
- span.setStatus({
2027
- code: coreTracing.SpanStatusCode.ERROR,
2028
- message: e.message,
2029
- });
2030
- throw e;
2031
- }
2032
- finally {
2033
- span.end();
2034
- }
2013
+ });
2035
2014
  }
2036
2015
  /**
2037
2016
  * Update a digital twin using a json patch.
@@ -2047,20 +2026,9 @@ class DigitalTwinsClient {
2047
2026
  updateDigitalTwin(digitalTwinId,
2048
2027
  // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types -- changing the type any would be a breaking change
2049
2028
  jsonPatch, options = {}) {
2050
- const { span, updatedOptions } = createSpan("DigitalTwinsClient-updateDigitalTwin", options);
2051
- try {
2029
+ return tracingClient.withSpan("DigitalTwinsClient.updateDigitalTwin", options, async (updatedOptions) => {
2052
2030
  return this.client.digitalTwins.update(digitalTwinId, jsonPatch, updatedOptions);
2053
- }
2054
- catch (e) {
2055
- span.setStatus({
2056
- code: coreTracing.SpanStatusCode.ERROR,
2057
- message: e.message,
2058
- });
2059
- throw e;
2060
- }
2061
- finally {
2062
- span.end();
2063
- }
2031
+ });
2064
2032
  }
2065
2033
  /**
2066
2034
  * Delete a digital twin
@@ -2071,20 +2039,9 @@ class DigitalTwinsClient {
2071
2039
  * @returns The http response.
2072
2040
  */
2073
2041
  deleteDigitalTwin(digitalTwinId, options = {}) {
2074
- const { span, updatedOptions } = createSpan("DigitalTwinsClient-deleteDigitalTwin", options);
2075
- try {
2042
+ return tracingClient.withSpan("DigitalTwinsClient.deleteDigitalTwin", options, async (updatedOptions) => {
2076
2043
  return this.client.digitalTwins.delete(digitalTwinId, updatedOptions);
2077
- }
2078
- catch (e) {
2079
- span.setStatus({
2080
- code: coreTracing.SpanStatusCode.ERROR,
2081
- message: e.message,
2082
- });
2083
- throw e;
2084
- }
2085
- finally {
2086
- span.end();
2087
- }
2044
+ });
2088
2045
  }
2089
2046
  /**
2090
2047
  * Get a component on a digital twin.
@@ -2095,20 +2052,9 @@ class DigitalTwinsClient {
2095
2052
  * @returns Json string representation of the component corresponding to the provided componentName and the HTTP response.
2096
2053
  */
2097
2054
  getComponent(digitalTwinId, componentName, options = {}) {
2098
- const { span, updatedOptions } = createSpan("DigitalTwinsClient-getComponent", options);
2099
- try {
2055
+ return tracingClient.withSpan("DigitalTwinsClient.getComponent", options, async (updatedOptions) => {
2100
2056
  return this.client.digitalTwins.getComponent(digitalTwinId, componentName, updatedOptions);
2101
- }
2102
- catch (e) {
2103
- span.setStatus({
2104
- code: coreTracing.SpanStatusCode.ERROR,
2105
- message: e.message,
2106
- });
2107
- throw e;
2108
- }
2109
- finally {
2110
- span.end();
2111
- }
2057
+ });
2112
2058
  }
2113
2059
  /**
2114
2060
  * Update properties of a component on a digital twin using a JSON patch.
@@ -2122,20 +2068,9 @@ class DigitalTwinsClient {
2122
2068
  * @returns The http response.
2123
2069
  */
2124
2070
  updateComponent(digitalTwinId, componentName, jsonPatch, options = {}) {
2125
- const { span, updatedOptions } = createSpan("DigitalTwinsClient-updateComponent", options);
2126
- try {
2071
+ return tracingClient.withSpan("DigitalTwinsClient.updateComponent", options, async (updatedOptions) => {
2127
2072
  return this.client.digitalTwins.updateComponent(digitalTwinId, componentName, jsonPatch, updatedOptions);
2128
- }
2129
- catch (e) {
2130
- span.setStatus({
2131
- code: coreTracing.SpanStatusCode.ERROR,
2132
- message: e.message,
2133
- });
2134
- throw e;
2135
- }
2136
- finally {
2137
- span.end();
2138
- }
2073
+ });
2139
2074
  }
2140
2075
  /**
2141
2076
  * Get a relationship on a digital twin.
@@ -2146,20 +2081,9 @@ class DigitalTwinsClient {
2146
2081
  * @returns The pageable list of application/json relationships belonging to the specified digital twin and the http response.
2147
2082
  */
2148
2083
  getRelationship(digitalTwinId, relationshipId, options = {}) {
2149
- const { span, updatedOptions } = createSpan("DigitalTwinsClient-getRelationship", options);
2150
- try {
2084
+ return tracingClient.withSpan("DigitalTwinsClient.getRelationship", options, async (updatedOptions) => {
2151
2085
  return this.client.digitalTwins.getRelationshipById(digitalTwinId, relationshipId, updatedOptions);
2152
- }
2153
- catch (e) {
2154
- span.setStatus({
2155
- code: coreTracing.SpanStatusCode.ERROR,
2156
- message: e.message,
2157
- });
2158
- throw e;
2159
- }
2160
- finally {
2161
- span.end();
2162
- }
2086
+ });
2163
2087
  }
2164
2088
  /**
2165
2089
  * Create or update a relationship on a digital twin.
@@ -2173,20 +2097,9 @@ class DigitalTwinsClient {
2173
2097
  upsertRelationship(digitalTwinId, relationshipId,
2174
2098
  // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types -- changing the type any would be a breaking change
2175
2099
  relationship, options = {}) {
2176
- const { span, updatedOptions } = createSpan("DigitalTwinsClient-upsertRelationship", options);
2177
- try {
2100
+ return tracingClient.withSpan("DigitalTwinsClient.upsertRelationship", options, async (updatedOptions) => {
2178
2101
  return this.client.digitalTwins.addRelationship(digitalTwinId, relationshipId, relationship, updatedOptions);
2179
- }
2180
- catch (e) {
2181
- span.setStatus({
2182
- code: coreTracing.SpanStatusCode.ERROR,
2183
- message: e.message,
2184
- });
2185
- throw e;
2186
- }
2187
- finally {
2188
- span.end();
2189
- }
2102
+ });
2190
2103
  }
2191
2104
  /**
2192
2105
  * Updates the properties of a relationship on a digital twin using a JSON patch.
@@ -2198,20 +2111,9 @@ class DigitalTwinsClient {
2198
2111
  * ifMatch: Only perform the operation if the entity's etag matches one of the etags provided or * is provided.
2199
2112
  */
2200
2113
  updateRelationship(digitalTwinId, relationshipId, jsonPatch, options = {}) {
2201
- const { span, updatedOptions } = createSpan("DigitalTwinsClient-updateRelationship", options);
2202
- try {
2114
+ return tracingClient.withSpan("DigitalTwinsClient.updateRelationship", options, async (updatedOptions) => {
2203
2115
  return this.client.digitalTwins.updateRelationship(digitalTwinId, relationshipId, jsonPatch, updatedOptions);
2204
- }
2205
- catch (e) {
2206
- span.setStatus({
2207
- code: coreTracing.SpanStatusCode.ERROR,
2208
- message: e.message,
2209
- });
2210
- throw e;
2211
- }
2212
- finally {
2213
- span.end();
2214
- }
2116
+ });
2215
2117
  }
2216
2118
  /**
2217
2119
  * Delete a relationship on a digital twin.
@@ -2223,20 +2125,9 @@ class DigitalTwinsClient {
2223
2125
  * @returns The http response.
2224
2126
  */
2225
2127
  deleteRelationship(digitalTwinId, relationshipId, options = {}) {
2226
- const { span, updatedOptions } = createSpan("DigitalTwinsClient-deleteRelationship", options);
2227
- try {
2128
+ return tracingClient.withSpan("DigitalTwinsClient.deleteRelationship", options, async (updatedOptions) => {
2228
2129
  return this.client.digitalTwins.deleteRelationship(digitalTwinId, relationshipId, updatedOptions);
2229
- }
2230
- catch (e) {
2231
- span.setStatus({
2232
- code: coreTracing.SpanStatusCode.ERROR,
2233
- message: e.message,
2234
- });
2235
- throw e;
2236
- }
2237
- finally {
2238
- span.end();
2239
- }
2130
+ });
2240
2131
  }
2241
2132
  /**
2242
2133
  * Deals with the pagination of {@link listRelationships}.
@@ -2292,29 +2183,16 @@ class DigitalTwinsClient {
2292
2183
  * @param digitalTwinId - The Id of the digital twin.
2293
2184
  */
2294
2185
  listRelationships(digitalTwinId, options = {}) {
2295
- const { span, updatedOptions } = createSpan("DigitalTwinsClient-listRelationships", options);
2296
- try {
2297
- const iter = this.listRelationshipsAll(digitalTwinId, updatedOptions);
2298
- return {
2299
- next() {
2300
- return iter.next();
2301
- },
2302
- [Symbol.asyncIterator]() {
2303
- return this;
2304
- },
2305
- byPage: (settings = {}) => this.listRelationshipsPage(digitalTwinId, updatedOptions, settings),
2306
- };
2307
- }
2308
- catch (e) {
2309
- span.setStatus({
2310
- code: coreTracing.SpanStatusCode.ERROR,
2311
- message: e.message,
2312
- });
2313
- throw e;
2314
- }
2315
- finally {
2316
- span.end();
2317
- }
2186
+ const iter = this.listRelationshipsAll(digitalTwinId, options);
2187
+ return {
2188
+ next() {
2189
+ return iter.next();
2190
+ },
2191
+ [Symbol.asyncIterator]() {
2192
+ return this;
2193
+ },
2194
+ byPage: (settings = {}) => this.listRelationshipsPage(digitalTwinId, options, settings),
2195
+ };
2318
2196
  }
2319
2197
  /**
2320
2198
  * Deals with the pagination of {@link listIncomingRelationships}.
@@ -2369,29 +2247,16 @@ class DigitalTwinsClient {
2369
2247
  * @param digitalTwinId - The Id of the digital twin.
2370
2248
  */
2371
2249
  listIncomingRelationships(digitalTwinId, options = {}) {
2372
- const { span, updatedOptions } = createSpan("DigitalTwinsClient-listIncomingRelationships", options);
2373
- try {
2374
- const iter = this.listIncomingRelationshipsAll(digitalTwinId, updatedOptions);
2375
- return {
2376
- next() {
2377
- return iter.next();
2378
- },
2379
- [Symbol.asyncIterator]() {
2380
- return this;
2381
- },
2382
- byPage: (settings = {}) => this.listIncomingRelationshipsPage(digitalTwinId, updatedOptions, settings),
2383
- };
2384
- }
2385
- catch (e) {
2386
- span.setStatus({
2387
- code: coreTracing.SpanStatusCode.ERROR,
2388
- message: e.message,
2389
- });
2390
- throw e;
2391
- }
2392
- finally {
2393
- span.end();
2394
- }
2250
+ const iter = this.listIncomingRelationshipsAll(digitalTwinId, options);
2251
+ return {
2252
+ next() {
2253
+ return iter.next();
2254
+ },
2255
+ [Symbol.asyncIterator]() {
2256
+ return this;
2257
+ },
2258
+ byPage: (settings = {}) => this.listIncomingRelationshipsPage(digitalTwinId, options, settings),
2259
+ };
2395
2260
  }
2396
2261
  /**
2397
2262
  * Publish telemetry from a digital twin, which is then consumed by one or many destination endpoints (subscribers) defined under.
@@ -2410,20 +2275,9 @@ class DigitalTwinsClient {
2410
2275
  if (!messageId) {
2411
2276
  messageId = coreHttp.generateUuid();
2412
2277
  }
2413
- const { span, updatedOptions } = createSpan("DigitalTwinsClient-publishTelemetry", digitalTwinsSendTelemetryOptionalParams);
2414
- try {
2278
+ return tracingClient.withSpan("DigitalTwinsClient.publishTelemetry", digitalTwinsSendTelemetryOptionalParams, async (updatedOptions) => {
2415
2279
  return this.client.digitalTwins.sendTelemetry(digitalTwinId, messageId, payload, updatedOptions);
2416
- }
2417
- catch (e) {
2418
- span.setStatus({
2419
- code: coreTracing.SpanStatusCode.ERROR,
2420
- message: e.message,
2421
- });
2422
- throw e;
2423
- }
2424
- finally {
2425
- span.end();
2426
- }
2280
+ });
2427
2281
  }
2428
2282
  /**
2429
2283
  * Publish telemetry from a digital twin's component, which is then consumed by one or many destination endpoints (subscribers) defined under.
@@ -2441,20 +2295,9 @@ class DigitalTwinsClient {
2441
2295
  if (!messageId) {
2442
2296
  messageId = coreHttp.generateUuid();
2443
2297
  }
2444
- const { span, updatedOptions } = createSpan("DigitalTwinsClient-publishComponentTelemetry", digitalTwinsSendComponentTelemetryOptionalParams);
2445
- try {
2298
+ return tracingClient.withSpan("DigitalTwinsClient.publishComponentTelemetry", digitalTwinsSendComponentTelemetryOptionalParams, async (updatedOptions) => {
2446
2299
  return this.client.digitalTwins.sendComponentTelemetry(digitalTwinId, componentName, payload, messageId, updatedOptions);
2447
- }
2448
- catch (e) {
2449
- span.setStatus({
2450
- code: coreTracing.SpanStatusCode.ERROR,
2451
- message: e.message,
2452
- });
2453
- throw e;
2454
- }
2455
- finally {
2456
- span.end();
2457
- }
2300
+ });
2458
2301
  }
2459
2302
  /**
2460
2303
  * Get a model, including the model metadata and the model definition.
@@ -2467,20 +2310,9 @@ class DigitalTwinsClient {
2467
2310
  getModel(modelId, includeModelDefinition = false, options = {}) {
2468
2311
  const digitalTwinModelsGetByIdOptionalParams = options;
2469
2312
  digitalTwinModelsGetByIdOptionalParams.includeModelDefinition = includeModelDefinition;
2470
- const { span, updatedOptions } = createSpan("DigitalTwinsClient-getModel", digitalTwinModelsGetByIdOptionalParams);
2471
- try {
2313
+ return tracingClient.withSpan("DigitalTwinsClient.getModel", digitalTwinModelsGetByIdOptionalParams, async (updatedOptions) => {
2472
2314
  return this.client.digitalTwinModels.getById(modelId, updatedOptions);
2473
- }
2474
- catch (e) {
2475
- span.setStatus({
2476
- code: coreTracing.SpanStatusCode.ERROR,
2477
- message: e.message,
2478
- });
2479
- throw e;
2480
- }
2481
- finally {
2482
- span.end();
2483
- }
2315
+ });
2484
2316
  }
2485
2317
  /**
2486
2318
  * Deals with the pagination of {@link list}.
@@ -2546,29 +2378,16 @@ class DigitalTwinsClient {
2546
2378
  dependenciesFor: dependeciesFor,
2547
2379
  includeModelDefinition: includeModelDefinition,
2548
2380
  };
2549
- const { span, updatedOptions } = createSpan("DigitalTwinsClient-listModels", digitalTwinModelsListOptionalParams);
2550
- try {
2551
- const iter = this.getModelsAll(updatedOptions);
2552
- return {
2553
- next() {
2554
- return iter.next();
2555
- },
2556
- [Symbol.asyncIterator]() {
2557
- return this;
2558
- },
2559
- byPage: (settings = {}) => this.getModelsPage(digitalTwinModelsListOptionalParams, settings),
2560
- };
2561
- }
2562
- catch (e) {
2563
- span.setStatus({
2564
- code: coreTracing.SpanStatusCode.ERROR,
2565
- message: e.message,
2566
- });
2567
- throw e;
2568
- }
2569
- finally {
2570
- span.end();
2571
- }
2381
+ const iter = this.getModelsAll(digitalTwinModelsListOptionalParams);
2382
+ return {
2383
+ next() {
2384
+ return iter.next();
2385
+ },
2386
+ [Symbol.asyncIterator]() {
2387
+ return this;
2388
+ },
2389
+ byPage: (settings = {}) => this.getModelsPage(digitalTwinModelsListOptionalParams, settings),
2390
+ };
2572
2391
  }
2573
2392
  /**
2574
2393
  * Create one or many
@@ -2580,20 +2399,9 @@ class DigitalTwinsClient {
2580
2399
  createModels(dtdlModels, options = {}) {
2581
2400
  const digitalTwinModelsAddOptionalParams = options;
2582
2401
  digitalTwinModelsAddOptionalParams.models = dtdlModels;
2583
- const { span, updatedOptions } = createSpan("DigitalTwinsClient-createModels", digitalTwinModelsAddOptionalParams);
2584
- try {
2402
+ return tracingClient.withSpan("DigitalTwinsClient.createModels", digitalTwinModelsAddOptionalParams, async (updatedOptions) => {
2585
2403
  return this.client.digitalTwinModels.add(updatedOptions);
2586
- }
2587
- catch (e) {
2588
- span.setStatus({
2589
- code: coreTracing.SpanStatusCode.ERROR,
2590
- message: e.message,
2591
- });
2592
- throw e;
2593
- }
2594
- finally {
2595
- span.end();
2596
- }
2404
+ });
2597
2405
  }
2598
2406
  /**
2599
2407
  * Decommission a model using a json patch.
@@ -2607,22 +2415,11 @@ class DigitalTwinsClient {
2607
2415
  * @returns The http response.
2608
2416
  *
2609
2417
  */
2610
- decommissionModel(modelId, options = {}) {
2418
+ decomissionModel(modelId, options = {}) {
2611
2419
  const jsonPatch = [{ op: "replace", path: "/decommissioned", value: true }];
2612
- const { span, updatedOptions } = createSpan("DigitalTwinsClient-decommissionModel", options);
2613
- try {
2420
+ return tracingClient.withSpan("DigitalTwinsClient.decomissionModel", options, async (updatedOptions) => {
2614
2421
  return this.client.digitalTwinModels.update(modelId, jsonPatch, updatedOptions);
2615
- }
2616
- catch (e) {
2617
- span.setStatus({
2618
- code: coreTracing.SpanStatusCode.ERROR,
2619
- message: e.message,
2620
- });
2621
- throw e;
2622
- }
2623
- finally {
2624
- span.end();
2625
- }
2422
+ });
2626
2423
  }
2627
2424
  /**
2628
2425
  * Delete a model.
@@ -2632,20 +2429,9 @@ class DigitalTwinsClient {
2632
2429
  * @returns The http response.
2633
2430
  */
2634
2431
  deleteModel(modelId, options = {}) {
2635
- const { span, updatedOptions } = createSpan("DigitalTwinsClient-deleteModel", options);
2636
- try {
2432
+ return tracingClient.withSpan("DigitalTwinsClient.deleteModel", options, async (updatedOptions) => {
2637
2433
  return this.client.digitalTwinModels.delete(modelId, updatedOptions);
2638
- }
2639
- catch (e) {
2640
- span.setStatus({
2641
- code: coreTracing.SpanStatusCode.ERROR,
2642
- message: e.message,
2643
- });
2644
- throw e;
2645
- }
2646
- finally {
2647
- span.end();
2648
- }
2434
+ });
2649
2435
  }
2650
2436
  /**
2651
2437
  * Get an event route.
@@ -2655,20 +2441,9 @@ class DigitalTwinsClient {
2655
2441
  * @returns The application/json event route and the http response.
2656
2442
  */
2657
2443
  getEventRoute(eventRouteId, options = {}) {
2658
- const { span, updatedOptions } = createSpan("DigitalTwinsClient-getEventRoute", options);
2659
- try {
2444
+ return tracingClient.withSpan("DigitalTwinsClient.getEventRoute", options, async (updatedOptions) => {
2660
2445
  return this.client.eventRoutes.getById(eventRouteId, updatedOptions);
2661
- }
2662
- catch (e) {
2663
- span.setStatus({
2664
- code: coreTracing.SpanStatusCode.ERROR,
2665
- message: e.message,
2666
- });
2667
- throw e;
2668
- }
2669
- finally {
2670
- span.end();
2671
- }
2446
+ });
2672
2447
  }
2673
2448
  /**
2674
2449
  * Deals with the pagination of {@link list}.
@@ -2731,29 +2506,16 @@ class DigitalTwinsClient {
2731
2506
  eventRoutesListOptionalParams = {
2732
2507
  maxItemsPerPage: resultsPerPage,
2733
2508
  };
2734
- const { span, updatedOptions } = createSpan("DigitalTwinsClient-listEventRoutes", eventRoutesListOptionalParams);
2735
- try {
2736
- const iter = this.getEventRoutesAll(updatedOptions);
2737
- return {
2738
- next() {
2739
- return iter.next();
2740
- },
2741
- [Symbol.asyncIterator]() {
2742
- return this;
2743
- },
2744
- byPage: (settings = {}) => this.getEventRoutesPage(eventRoutesListOptionalParams, settings),
2745
- };
2746
- }
2747
- catch (e) {
2748
- span.setStatus({
2749
- code: coreTracing.SpanStatusCode.ERROR,
2750
- message: e.message,
2751
- });
2752
- throw e;
2753
- }
2754
- finally {
2755
- span.end();
2756
- }
2509
+ const iter = this.getEventRoutesAll(eventRoutesListOptionalParams);
2510
+ return {
2511
+ next() {
2512
+ return iter.next();
2513
+ },
2514
+ [Symbol.asyncIterator]() {
2515
+ return this;
2516
+ },
2517
+ byPage: (settings = {}) => this.getEventRoutesPage(eventRoutesListOptionalParams, settings),
2518
+ };
2757
2519
  }
2758
2520
  /**
2759
2521
  * Create or update an event route.
@@ -2771,20 +2533,9 @@ class DigitalTwinsClient {
2771
2533
  filter: filter,
2772
2534
  };
2773
2535
  eventRoutesAddOptionalParams.eventRoute = eventRoute;
2774
- const { span, updatedOptions } = createSpan("DigitalTwinsClient-upsertEventRoute", eventRoutesAddOptionalParams);
2775
- try {
2536
+ return tracingClient.withSpan("DigitalTwinsClient.upsertEventRoute", eventRoutesAddOptionalParams, async (updatedOptions) => {
2776
2537
  return this.client.eventRoutes.add(eventRouteId, updatedOptions);
2777
- }
2778
- catch (e) {
2779
- span.setStatus({
2780
- code: coreTracing.SpanStatusCode.ERROR,
2781
- message: e.message,
2782
- });
2783
- throw e;
2784
- }
2785
- finally {
2786
- span.end();
2787
- }
2538
+ });
2788
2539
  }
2789
2540
  /**
2790
2541
  * Delete an event route.
@@ -2794,20 +2545,9 @@ class DigitalTwinsClient {
2794
2545
  * @returns The http response.
2795
2546
  */
2796
2547
  deleteEventRoute(eventRouteId, options = {}) {
2797
- const { span, updatedOptions } = createSpan("DigitalTwinsClient-deleteEventRoute", options);
2798
- try {
2548
+ return tracingClient.withSpan("DigitalTwinsClient.deleteEventRoute", options, async (updatedOptions) => {
2799
2549
  return this.client.eventRoutes.delete(eventRouteId, updatedOptions);
2800
- }
2801
- catch (e) {
2802
- span.setStatus({
2803
- code: coreTracing.SpanStatusCode.ERROR,
2804
- message: e.message,
2805
- });
2806
- throw e;
2807
- }
2808
- finally {
2809
- span.end();
2810
- }
2550
+ });
2811
2551
  }
2812
2552
  /**
2813
2553
  * Deals with the pagination of {@link query}.
@@ -2879,29 +2619,16 @@ class DigitalTwinsClient {
2879
2619
  queryQueryTwinsOptionalParams = {
2880
2620
  maxItemsPerPage: resultsPerPage,
2881
2621
  };
2882
- const { span, updatedOptions } = createSpan("DigitalTwinsClient-queryTwins", queryQueryTwinsOptionalParams);
2883
- try {
2884
- const iter = this.queryTwinsAll(query, updatedOptions);
2885
- return {
2886
- next() {
2887
- return iter.next();
2888
- },
2889
- [Symbol.asyncIterator]() {
2890
- return this;
2891
- },
2892
- byPage: (settings = {}) => this.queryTwinsPage(query, queryQueryTwinsOptionalParams, settings),
2893
- };
2894
- }
2895
- catch (e) {
2896
- span.setStatus({
2897
- code: coreTracing.SpanStatusCode.ERROR,
2898
- message: e.message,
2899
- });
2900
- throw e;
2901
- }
2902
- finally {
2903
- span.end();
2904
- }
2622
+ const iter = this.queryTwinsAll(query, queryQueryTwinsOptionalParams);
2623
+ return {
2624
+ next() {
2625
+ return iter.next();
2626
+ },
2627
+ [Symbol.asyncIterator]() {
2628
+ return this;
2629
+ },
2630
+ byPage: (settings = {}) => this.queryTwinsPage(query, queryQueryTwinsOptionalParams, settings),
2631
+ };
2905
2632
  }
2906
2633
  }
2907
2634