From e8854183651eb6119912ea0ba86c8ab9b9b590ab Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 28 Feb 2026 08:03:26 +0000 Subject: [PATCH 1/2] Initial plan From 51cbda179fb5f9e4ab6336345dff7289d6954c1c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 28 Feb 2026 08:10:30 +0000 Subject: [PATCH 2/2] docs: update outdated documentation across multiple files Co-authored-by: msyyc <70930885+msyyc@users.noreply.github.com> --- docs/client/initializing.md | 6 +-- docs/client/operations.md | 14 ++--- docs/client/tracing.md | 52 ++----------------- .../sdk_from_swagger_and_typespec.md | 2 +- docs/migrate/readme.md | 4 +- 5 files changed, 15 insertions(+), 63 deletions(-) diff --git a/docs/client/initializing.md b/docs/client/initializing.md index 008202e5bf4..494cc62d306 100644 --- a/docs/client/initializing.md +++ b/docs/client/initializing.md @@ -22,9 +22,8 @@ The following are core libraries your generated code depend on, and the minimum | Library | Description | Min Version | | -------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------- | -| [`azure-core`][azure_core_library] | The most important library to have installed. It provides shared exceptions and modules for all the Python SDK client libraries. | 1.24.0 | -| [`msrest`][msrest_library] | Library mainly used for serializing and deserializing objects | 0.7.0 | -| [`azure-mgmt-core`][azure_mgmt_core_library] | Required if you're generating mgmt plane code (see `--azure-arm` flag in our [flag index][flag_index]. Provides mgmt plane specific shared exceptions and modules. | 1.2.1 | +| [`azure-core`][azure_core_library] | The most important library to have installed. It provides shared exceptions and modules for all the Python SDK client libraries. | 1.37.0 | +| [`azure-mgmt-core`][azure_mgmt_core_library] | Required if you're generating mgmt plane code (see `--azure-arm` flag in our [flag index][flag_index]. Provides mgmt plane specific shared exceptions and modules. | 1.6.0 | > Note: We highly recommend tying your library to a major version, for instance, adding `azure-core<2.0.0` to tie the `azure-core` library to `1.x.x` @@ -71,7 +70,6 @@ based on inputs. [azure_core_library]: https://pypi.org/project/azure-core/ -[msrest_library]: https://pypi.org/project/msrest/ [azure_mgmt_core_library]: https://pypi.org/project/azure-mgmt-core/ [azure_identity_library]: https://pypi.org/project/azure-identity/ [flag_index]: https://github.com/Azure/autorest/tree/master/docs/generate/flags.md diff --git a/docs/client/operations.md b/docs/client/operations.md index 7cc037123ce..8defc388f52 100644 --- a/docs/client/operations.md +++ b/docs/client/operations.md @@ -42,9 +42,7 @@ async def get_my_dog(): async with PetsClient(credential=credential) as client: dog = await client.get_dog() -loop = asyncio.get_event_loop() -loop.run_until_complete(get_my_dog()) -loop.close() +asyncio.run(get_my_dog()) ``` ## Long Running Operations @@ -88,9 +86,7 @@ async def basic_polling(): poller = await client.begin_basic_polling(product=input_product) output_product = await poller.result() -loop = asyncio.get_event_loop() -loop.run_until_complete(basic_polling()) -loop.close() +asyncio.run(basic_polling()) ``` ## Paging Operations @@ -131,9 +127,7 @@ async def basic_paging(): async for page in pages: # since network calls are only made during iteration, we await the network calls when iterating print(page) -loop = asyncio.get_event_loop() -loop.run_until_complete(basic_paging()) -loop.close() +asyncio.run(basic_paging()) ``` @@ -144,7 +138,7 @@ a pager that pages through the final lists of data. -[operation_group_example]: https://github.com/Azure/azure-rest-api-specs/blob/master/specification/batch/data-plane/Microsoft.Batch/stable/2020-09-01.12.0/BatchService.json#L64 +[operation_group_example]: https://github.com/Azure/azure-rest-api-specs/blob/main/specification/batch/data-plane/Azure.Batch/preview/2024-07-01.20.0/BatchService.json [mixin_example]: https://github.com/Azure/autorest/blob/master/docs/openapi/examples/pets.json#L20 [pets_swagger]: https://github.com/Azure/autorest/blob/master/docs/openapi/examples/pets.json [initializing]: https://github.com/Azure/autorest.python/blob/main/docs/client/initializing.md diff --git a/docs/client/tracing.md b/docs/client/tracing.md index 9e237ea0da9..0f61d6296ea 100644 --- a/docs/client/tracing.md +++ b/docs/client/tracing.md @@ -1,37 +1,8 @@ # Tracing -Our generated code can natively support tracing libraries [`OpenCensus`][open_census] and [`OpenTelemetry`][open_telemetry]. To do so, generate with flag `--trace` (see our [flag index][flag_index] for more information). +Our generated code natively supports tracing with [`OpenTelemetry`][open_telemetry]. To do so, generate with flag `--trace` (see our [flag index][flag_index] for more information). -## OpenCensus - -First step is to install our [`OpenCensus` library][our_open_census_library]: - -```python -pip install azure-core-tracing-opencensus -``` - -Our generated SDKs handle retrieving context for you, so there's no need to pass in any context. Additionally, the -OpenCensus threading plugin is included when installing this package. - -Since there is no explicit context you need to pass, you can create your usual OpenCensus tracer and call the generated SDKs. -The following example uses [`Azure Monitor`'s][azure_monitor] exporter, but you can use any exporter ([Zipkin][zipkin], etc.). - -```python -from opencensus.ext.azure.trace_exporter import AzureExporter -from opencensus.trace.tracer import Tracer -from opencensus.trace.samplers import AlwaysOnSampler - -from azure.identity import DefaultAzureCredential -from azure.pets import PetsClient - -exporter = AzureExporter( - instrumentation_key="uuid of the instrumentation key (see your Azure Monitor account)" -) -tracer = Tracer(exporter=exporter, sampler=AlwaysOnSampler()) -with tracer.span(name="MyApplication") as span: - client = PetsClient(credential=DefaultAzureCredential()) - dog = client.get_dog() # Call will be traced -``` +> **Note:** [`OpenCensus`][open_census] has been deprecated and is no longer supported. Please use [`OpenTelemetry`][open_telemetry] for tracing. ## OpenTelemetry @@ -43,38 +14,26 @@ pip install azure-core-tracing-opentelemetry Our generated SDKs handle retrieving context for you, so there's no need to pass in any context. Since there is no explicit context you need to pass, you can create your usual OpenTelemetry tracer and call the generated SDKs. -The following example uses [`Azure Monitor`'s][azure_monitor] exporter, but you can use any exporter ([Zipkin][zipkin], etc.). +The following example uses a console exporter, but you can use any exporter ([`Azure Monitor`][azure_monitor], [Zipkin][zipkin], etc.). ```python -# Declare OpenTelemetry as an enabled tracing plugin for Azure SDKs from azure.core.settings import settings from azure.core.tracing.ext.opentelemetry_span import OpenTelemetrySpan settings.tracing_implementation = OpenTelemetrySpan -# In the below example, we use the Azure Monitor exporter, but you can use anything OpenTelemetry supports -from azure_monitor import AzureMonitorSpanExporter -exporter = AzureMonitorSpanExporter( - instrumentation_key="uuid of the instrumentation key (see your Azure Monitor account)" -) - -# Regular open telemetry usage from here, see https://github.com/open-telemetry/opentelemetry-python -# for details from opentelemetry import trace from opentelemetry.sdk.trace import TracerProvider -from opentelemetry.sdk.trace.export import ConsoleSpanExporter -from opentelemetry.sdk.trace.export import SimpleExportSpanProcessor +from opentelemetry.sdk.trace.export import ConsoleSpanExporter, SimpleSpanProcessor -# Simple console exporter exporter = ConsoleSpanExporter() trace.set_tracer_provider(TracerProvider()) tracer = trace.get_tracer(__name__) trace.get_tracer_provider().add_span_processor( - SimpleExportSpanProcessor(exporter) + SimpleSpanProcessor(exporter) ) -# Example with our Pets example from azure.identity import DefaultAzureCredential from azure.pets import PetsClient @@ -86,7 +45,6 @@ dog = client.get_dog() # Call will be traced [open_census]: https://opencensus.io/ [open_telemetry]: https://opentelemetry.io/ [flag_index]: https://github.com/Azure/autorest/tree/master/docs/generate/flags.md -[our_open_census_library]: https://pypi.org/project/azure-core-tracing-opencensus/ [azure_monitor]: https://pypi.org/project/opentelemetry-azure-monitor/ [zipkin]: https://zipkin.io/ [our_open_telemetry_library]: https://pypi.org/project/azure-core-tracing-opentelemetry/ diff --git a/docs/developer/sdk_from_swagger_and_typespec.md b/docs/developer/sdk_from_swagger_and_typespec.md index 79eecce1f56..7c01f9fffdc 100644 --- a/docs/developer/sdk_from_swagger_and_typespec.md +++ b/docs/developer/sdk_from_swagger_and_typespec.md @@ -134,7 +134,7 @@ print(msrest_model.properties_properties_name) # B, equivalent to `msrest_model. dpg_model = Model(...) print(dpg_model.properties_name) # A, backwards compatible but not recommended print(dpg_model.properties.name) # equivalent to A -print.dpg_model.properties_properties_name) # no longer works +print(dpg_model.properties_properties_name) # no longer works print(dpg_model.properties.properties.name) # recommended approach after migration ``` diff --git a/docs/migrate/readme.md b/docs/migrate/readme.md index 9604b26871b..7d8aa06a40c 100644 --- a/docs/migrate/readme.md +++ b/docs/migrate/readme.md @@ -23,9 +23,11 @@ tell AutoRest during generation time to keep the current version file in the dir * Type annotations using the standard `typing` library. SDKs are [`mypy`][mypy] ready! * This client has stable and official support for async. Look in the `aio` namespace of your generated package to find the async client. -* The client now natively supports tracing libraries such as [`OpenCensus`][open_census] and [`OpenTelemetry`][open_telemetry]. Use the flag `--trace` to generate +* The client now natively supports tracing with [`OpenTelemetry`][open_telemetry]. Use the flag `--trace` to generate code for this, and you can see our [tracing docs][tracing_docs] for more information. +> **Note:** [`OpenCensus`][open_census] has been deprecated and is no longer supported. Please use [`OpenTelemetry`][open_telemetry] instead. + [main_docs]: https://github.com/Azure/autorest/blob/master/docs/migrate/readme.md