Make prettier in python folder (#2331)

This commit is contained in:
Michael 2023-02-13 02:35:48 +08:00 committed by GitHub
parent fd935b63dc
commit 0d5ca6d872
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 22 deletions

View File

@ -67,7 +67,9 @@ print(baggage.get_baggage("context", child_ctx))
## Manually setting span context
Usually your application or serving framework will take care of propagating your trace context for you. But in some cases, you may need to save your trace context (with `.inject`) and restore it elsewhere (with `.extract`) yourself.
Usually your application or serving framework will take care of propagating your
trace context for you. But in some cases, you may need to save your trace context
(with `.inject`) and restore it elsewhere (with `.extract`) yourself.
```python
from opentelemetry import trace, context

View File

@ -157,7 +157,10 @@ current_span.set_attribute("operation.other-stuff", [1, 2, 3])
### Add semantic attributes
[Semantic Attributes](/docs/reference/specification/trace/semantic_conventions/) are pre-defined [Attributes](/docs/concepts/signals/traces/#attributes) that are well-known naming conventions for common kinds of data. Using Semantic Attributes lets you normalize this kind of information across your systems.
[Semantic Attributes](/docs/reference/specification/trace/semantic_conventions/)
are pre-defined [Attributes](/docs/concepts/signals/traces/#attributes) that are
well-known naming conventions for common kinds of data. Using Semantic Attributes
lets you normalize this kind of information across your systems.
To use Semantic Attributes in Python, ensure you have the semantic conventions package:
@ -312,8 +315,8 @@ Note that environment variables will override what's configured in code.
### Creating and using synchronous instruments
Instruments are used to make measurements of your application. [Synchronous
instruments](/docs/reference/specification/metrics/api/#synchronous-and-asynchronous-instruments)
Instruments are used to make measurements of your application.
[Synchronous instruments](/docs/reference/specification/metrics/api/#synchronous-and-asynchronous-instruments)
are used inline with application/business processing logic, like when handling a
request or calling another service.
@ -328,9 +331,8 @@ work_counter = meter.create_counter(
)
```
Using the Counter's [add
operation](/docs/reference/specification/metrics/api/#add), the code below
increments the count by one, using the work item's type as an attribute.
Using the Counter's [add operation](/docs/reference/specification/metrics/api/#add),
the code below increments the count by one, using the work item's type as an attribute.
```python
def do_work(work_item):
@ -341,17 +343,15 @@ def do_work(work_item):
### Creating and using asynchronous instruments
[Asynchronous
instruments](/docs/reference/specification/metrics/api/#synchronous-and-asynchronous-instruments)
[Asynchronous instruments](/docs/reference/specification/metrics/api/#synchronous-and-asynchronous-instruments)
give the user a way to register callback functions, which are invoked on demand
to make measurements. This is useful to periodically measure a value that cannot
be instrumented directly. Async instruments are created with zero or more
callbacks which will be invoked during metric collection. Each callback accepts
options from the SDK and returns its observations.
This example uses an [Asynchronous
Gauge](/docs/reference/specification/metrics/api/#asynchronous-gauge) instrument
to report the current config version provided by a configuration server by
This example uses an [Asynchronous Gauge](/docs/reference/specification/metrics/api/#asynchronous-gauge)
instrument to report the current config version provided by a configuration server by
scraping an HTTP endpoint. First, write a callback to make observations:
```python
@ -385,16 +385,11 @@ meter.create_observable_gauge(
- Trace
- [Trace Concepts](/docs/concepts/signals/traces/)
- [Trace
Specification](/docs/reference/specification/overview/#tracing-signal)
- [Python Trace API
Documentation](https://opentelemetry-python.readthedocs.io/en/latest/api/trace.html)
- [Python Trace SDK
Documentation](https://opentelemetry-python.readthedocs.io/en/latest/sdk/trace.html)
- [Trace Specification](/docs/reference/specification/overview/#tracing-signal)
- [Python Trace API Documentation](https://opentelemetry-python.readthedocs.io/en/latest/api/trace.html)
- [Python Trace SDK Documentation](https://opentelemetry-python.readthedocs.io/en/latest/sdk/trace.html)
- Metrics
- [Metrics Concepts](/docs/concepts/signals/metrics/)
- [Metrics Specification](/docs/reference/specification/metrics/)
- [Python Metrics API
Documentation](https://opentelemetry-python.readthedocs.io/en/latest/api/metrics.html)
- [Python Metrics SDK
Documentation](https://opentelemetry-python.readthedocs.io/en/latest/sdk/metrics.html)
- [Python Metrics API Documentation](https://opentelemetry-python.readthedocs.io/en/latest/api/metrics.html)
- [Python Metrics SDK Documentation](https://opentelemetry-python.readthedocs.io/en/latest/sdk/metrics.html)