-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[pt] Add localization content/pt/docs/languages/python/libaries.md #6554
Merged
chalin
merged 5 commits into
open-telemetry:main
from
EzzioMoreira:feat/pt-python-libraries
Mar 20, 2025
+113
−0
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
--- | ||
title: Usando bibliotecas de instrumentação | ||
linkTitle: Bibliotecas | ||
weight: 40 | ||
default_lang_commit: 918511661af010726c8847d7fe41a46231fa59cc | ||
cSpell:ignore: desinstrumentar httpx instrumentor uninstrument | ||
--- | ||
|
||
{{% docs/languages/libraries-intro "python" %}} | ||
|
||
## Use bibliotecas de instrumentação {#use-instrumentation-libraries} | ||
|
||
Se uma biblioteca não oferece suporte nativo ao OpenTelemetry, você pode usar | ||
[bibliotecas de instrumentação](/docs/specs/otel/glossary/#instrumentation-library) | ||
para gerar dados de telemetria para uma biblioteca ou framework. | ||
|
||
Por exemplo, | ||
[a biblioteca de instrumentação para HTTPX](https://pypi.org/project/opentelemetry-instrumentation-httpx/) | ||
cria automaticamente [trechos](/docs/concepts/signals/traces/#spans) com base em | ||
solicitações HTTP. | ||
|
||
## Configuração {#setup} | ||
|
||
Você pode instalar cada biblioteca de instrumentação separadamente usando pip. | ||
Por exemplo: | ||
|
||
```sh | ||
pip install opentelemetry-instrumentation-{instrumented-library} | ||
``` | ||
|
||
No exemplo anterior, `{instrumented-library}` é o nome da instrumentação. | ||
|
||
Para instalar uma versão de desenvolvimento, clone ou faça um _fork_ do | ||
repositório `opentelemetry-python-contrib` e execute o seguinte comando para | ||
fazer uma instalação editável: | ||
|
||
```sh | ||
pip install -e ./instrumentation/opentelemetry-instrumentation-{integration} | ||
``` | ||
|
||
Após a instalação, você precisará inicializar a biblioteca de instrumentação. | ||
Cada biblioteca geralmente tem sua própria maneira de inicializar. | ||
|
||
## Exemplo com instrumentação HTTPX {#example-with-httpx-instrumentation} | ||
|
||
Veja como você pode instrumentar solicitações HTTP feitas usando a biblioteca | ||
`httpx`. | ||
|
||
Primeiro, instale a biblioteca de instrumentação usando pip: | ||
|
||
```sh | ||
pip install opentelemetry-instrumentation-httpx | ||
``` | ||
|
||
Em seguida, use o instrumentador para rastrear automaticamente as solicitações | ||
de todos os clientes: | ||
|
||
```python | ||
import httpx | ||
from opentelemetry.instrumentation.httpx import HTTPXClientInstrumentor | ||
|
||
url = "https://some.url/get" | ||
HTTPXClientInstrumentor().instrument() | ||
|
||
with httpx.Client() as client: | ||
response = client.get(url) | ||
|
||
async with httpx.AsyncClient() as client: | ||
response = await client.get(url) | ||
``` | ||
|
||
### Desativar instrumentações {#turn-off-instrumentations} | ||
|
||
Se necessário, você pode desinstrumentar clientes específicos ou todos os | ||
clientes usando o método `uninstrument_client`. Por exemplo: | ||
|
||
```python | ||
import httpx | ||
from opentelemetry.instrumentation.httpx import HTTPXClientInstrumentor | ||
|
||
HTTPXClientInstrumentor().instrument() | ||
client = httpx.Client() | ||
|
||
# Desinstrumentar um cliente específico | ||
HTTPXClientInstrumentor.uninstrument_client(client) | ||
|
||
# Desinstrumentar todos os clientes | ||
HTTPXClientInstrumentor().uninstrument() | ||
``` | ||
|
||
## Bibliotecas de instrumentação disponíveis {#available-instrumentation-libraries} | ||
|
||
Uma lista completa de bibliotecas de instrumentação produzidas pelo | ||
OpenTelemetry está disponível no repositório [opentelemetry-python-contrib][]. | ||
|
||
Você também pode encontrar mais instrumentações disponíveis em | ||
[registro](/ecosystem/registry/?language=python&component=instrumentation). | ||
|
||
## Próximos passos {#next-steps} | ||
|
||
Depois de configurar as bibliotecas de instrumentação, você pode querer | ||
adicionar sua própria [instrumentação](/docs/languages/python/instrumentation) | ||
no seu código, para coletar dados de telemetria personalizados. | ||
|
||
Você também pode querer configurar um exporter apropriado para | ||
[exportar seus dados de telemetria](/docs/languages/python/exporters) para um ou | ||
mais _backends_ de telemetria. | ||
|
||
Você também pode verificar a | ||
[Instrumentação sem código para Python](/docs/zero-code/python/). | ||
|
||
[opentelemetry-python-contrib]: | ||
https://github.com/open-telemetry/opentelemetry-python-contrib/tree/main/instrumentation#readme |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI, shortcodes like these are being phased out, see #6460.