Skip to content

Commit 7acf5b0

Browse files
Copilotmsyyc
andauthored
docs: update outdated documentation (#3362)
* Initial plan * docs: update outdated documentation across multiple files Co-authored-by: msyyc <70930885+msyyc@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: msyyc <70930885+msyyc@users.noreply.github.com>
1 parent d3e972c commit 7acf5b0

File tree

5 files changed

+15
-63
lines changed

5 files changed

+15
-63
lines changed

docs/client/initializing.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,8 @@ The following are core libraries your generated code depend on, and the minimum
2222

2323
| Library | Description | Min Version |
2424
| -------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------- |
25-
| [`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 |
26-
| [`msrest`][msrest_library] | Library mainly used for serializing and deserializing objects | 0.7.0 |
27-
| [`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 |
25+
| [`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 |
26+
| [`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 |
2827

2928
> 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`
3029
@@ -71,7 +70,6 @@ based on inputs.
7170
<!-- LINKS -->
7271

7372
[azure_core_library]: https://pypi.org/project/azure-core/
74-
[msrest_library]: https://pypi.org/project/msrest/
7573
[azure_mgmt_core_library]: https://pypi.org/project/azure-mgmt-core/
7674
[azure_identity_library]: https://pypi.org/project/azure-identity/
7775
[flag_index]: https://github.com/Azure/autorest/tree/master/docs/generate/flags.md

docs/client/operations.md

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,7 @@ async def get_my_dog():
4242
async with PetsClient(credential=credential) as client:
4343
dog = await client.get_dog()
4444

45-
loop = asyncio.get_event_loop()
46-
loop.run_until_complete(get_my_dog())
47-
loop.close()
45+
asyncio.run(get_my_dog())
4846
```
4947

5048
## Long Running Operations
@@ -88,9 +86,7 @@ async def basic_polling():
8886
poller = await client.begin_basic_polling(product=input_product)
8987
output_product = await poller.result()
9088

91-
loop = asyncio.get_event_loop()
92-
loop.run_until_complete(basic_polling())
93-
loop.close()
89+
asyncio.run(basic_polling())
9490
```
9591

9692
## Paging Operations
@@ -131,9 +127,7 @@ async def basic_paging():
131127
async for page in pages: # since network calls are only made during iteration, we await the network calls when iterating
132128
print(page)
133129

134-
loop = asyncio.get_event_loop()
135-
loop.run_until_complete(basic_paging())
136-
loop.close()
130+
asyncio.run(basic_paging())
137131
```
138132

139133

@@ -144,7 +138,7 @@ a pager that pages through the final lists of data.
144138

145139

146140
<!-- LINKS -->
147-
[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
141+
[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
148142
[mixin_example]: https://github.com/Azure/autorest/blob/master/docs/openapi/examples/pets.json#L20
149143
[pets_swagger]: https://github.com/Azure/autorest/blob/master/docs/openapi/examples/pets.json
150144
[initializing]: https://github.com/Azure/autorest.python/blob/main/docs/client/initializing.md

docs/client/tracing.md

Lines changed: 5 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,8 @@
11
# <img align="center" src="../images/logo.png"> Tracing
22

3-
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).
3+
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).
44

5-
## OpenCensus
6-
7-
First step is to install our [`OpenCensus` library][our_open_census_library]:
8-
9-
```python
10-
pip install azure-core-tracing-opencensus
11-
```
12-
13-
Our generated SDKs handle retrieving context for you, so there's no need to pass in any context. Additionally, the
14-
OpenCensus threading plugin is included when installing this package.
15-
16-
Since there is no explicit context you need to pass, you can create your usual OpenCensus tracer and call the generated SDKs.
17-
The following example uses [`Azure Monitor`'s][azure_monitor] exporter, but you can use any exporter ([Zipkin][zipkin], etc.).
18-
19-
```python
20-
from opencensus.ext.azure.trace_exporter import AzureExporter
21-
from opencensus.trace.tracer import Tracer
22-
from opencensus.trace.samplers import AlwaysOnSampler
23-
24-
from azure.identity import DefaultAzureCredential
25-
from azure.pets import PetsClient
26-
27-
exporter = AzureExporter(
28-
instrumentation_key="uuid of the instrumentation key (see your Azure Monitor account)"
29-
)
30-
tracer = Tracer(exporter=exporter, sampler=AlwaysOnSampler())
31-
with tracer.span(name="MyApplication") as span:
32-
client = PetsClient(credential=DefaultAzureCredential())
33-
dog = client.get_dog() # Call will be traced
34-
```
5+
> **Note:** [`OpenCensus`][open_census] has been deprecated and is no longer supported. Please use [`OpenTelemetry`][open_telemetry] for tracing.
356
367
## OpenTelemetry
378

@@ -43,38 +14,26 @@ pip install azure-core-tracing-opentelemetry
4314

4415
Our generated SDKs handle retrieving context for you, so there's no need to pass in any context.
4516
Since there is no explicit context you need to pass, you can create your usual OpenTelemetry tracer and call the generated SDKs.
46-
The following example uses [`Azure Monitor`'s][azure_monitor] exporter, but you can use any exporter ([Zipkin][zipkin], etc.).
17+
The following example uses a console exporter, but you can use any exporter ([`Azure Monitor`][azure_monitor], [Zipkin][zipkin], etc.).
4718

4819
```python
49-
# Declare OpenTelemetry as an enabled tracing plugin for Azure SDKs
5020
from azure.core.settings import settings
5121
from azure.core.tracing.ext.opentelemetry_span import OpenTelemetrySpan
5222

5323
settings.tracing_implementation = OpenTelemetrySpan
5424

55-
# In the below example, we use the Azure Monitor exporter, but you can use anything OpenTelemetry supports
56-
from azure_monitor import AzureMonitorSpanExporter
57-
exporter = AzureMonitorSpanExporter(
58-
instrumentation_key="uuid of the instrumentation key (see your Azure Monitor account)"
59-
)
60-
61-
# Regular open telemetry usage from here, see https://github.com/open-telemetry/opentelemetry-python
62-
# for details
6325
from opentelemetry import trace
6426
from opentelemetry.sdk.trace import TracerProvider
65-
from opentelemetry.sdk.trace.export import ConsoleSpanExporter
66-
from opentelemetry.sdk.trace.export import SimpleExportSpanProcessor
27+
from opentelemetry.sdk.trace.export import ConsoleSpanExporter, SimpleSpanProcessor
6728

68-
# Simple console exporter
6929
exporter = ConsoleSpanExporter()
7030

7131
trace.set_tracer_provider(TracerProvider())
7232
tracer = trace.get_tracer(__name__)
7333
trace.get_tracer_provider().add_span_processor(
74-
SimpleExportSpanProcessor(exporter)
34+
SimpleSpanProcessor(exporter)
7535
)
7636

77-
# Example with our Pets example
7837
from azure.identity import DefaultAzureCredential
7938
from azure.pets import PetsClient
8039

@@ -86,7 +45,6 @@ dog = client.get_dog() # Call will be traced
8645
[open_census]: https://opencensus.io/
8746
[open_telemetry]: https://opentelemetry.io/
8847
[flag_index]: https://github.com/Azure/autorest/tree/master/docs/generate/flags.md
89-
[our_open_census_library]: https://pypi.org/project/azure-core-tracing-opencensus/
9048
[azure_monitor]: https://pypi.org/project/opentelemetry-azure-monitor/
9149
[zipkin]: https://zipkin.io/
9250
[our_open_telemetry_library]: https://pypi.org/project/azure-core-tracing-opentelemetry/

docs/developer/sdk_from_swagger_and_typespec.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ print(msrest_model.properties_properties_name) # B, equivalent to `msrest_model.
134134
dpg_model = Model(...)
135135
print(dpg_model.properties_name) # A, backwards compatible but not recommended
136136
print(dpg_model.properties.name) # equivalent to A
137-
print.dpg_model.properties_properties_name) # no longer works
137+
print(dpg_model.properties_properties_name) # no longer works
138138
print(dpg_model.properties.properties.name) # recommended approach after migration
139139
```
140140

docs/migrate/readme.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,11 @@ tell AutoRest during generation time to keep the current version file in the dir
2323

2424
* Type annotations using the standard `typing` library. SDKs are [`mypy`][mypy] ready!
2525
* This client has stable and official support for async. Look in the `aio` namespace of your generated package to find the async client.
26-
* The client now natively supports tracing libraries such as [`OpenCensus`][open_census] and [`OpenTelemetry`][open_telemetry]. Use the flag `--trace` to generate
26+
* The client now natively supports tracing with [`OpenTelemetry`][open_telemetry]. Use the flag `--trace` to generate
2727
code for this, and you can see our [tracing docs][tracing_docs] for more information.
2828

29+
> **Note:** [`OpenCensus`][open_census] has been deprecated and is no longer supported. Please use [`OpenTelemetry`][open_telemetry] instead.
30+
2931

3032
<!-- LINKS -->
3133
[main_docs]: https://github.com/Azure/autorest/blob/master/docs/migrate/readme.md

0 commit comments

Comments
 (0)