Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions docs/client/initializing.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`

Expand Down Expand Up @@ -71,7 +70,6 @@ based on inputs.
<!-- LINKS -->

[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
Expand Down
14 changes: 4 additions & 10 deletions docs/client/operations.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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())
```


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


<!-- LINKS -->
[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
Expand Down
52 changes: 5 additions & 47 deletions docs/client/tracing.md
Original file line number Diff line number Diff line change
@@ -1,37 +1,8 @@
# <img align="center" src="../images/logo.png"> 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

Expand All @@ -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

Expand All @@ -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/
2 changes: 1 addition & 1 deletion docs/developer/sdk_from_swagger_and_typespec.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

Expand Down
4 changes: 3 additions & 1 deletion docs/migrate/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.


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