Skip to content

Conversation

Msksgm
Copy link
Member

@Msksgm Msksgm commented Sep 26, 2025

original.

preview.

drifted diffs.

> check:i18n
> scripts/check-i18n.sh -d content/ja/docs/zero-code/python/

Processing paths: content/ja/docs/zero-code/python/
diff --git a/content/en/docs/zero-code/python/troubleshooting.md b/content/en/docs/zero-code/python/troubleshooting.md
index 5a79a1e0..3068e167 100644
--- a/content/en/docs/zero-code/python/troubleshooting.md
+++ b/content/en/docs/zero-code/python/troubleshooting.md
@@ -2,6 +2,7 @@
 title: Troubleshooting Python automatic instrumentation issues
 linkTitle: Troubleshooting
 weight: 40
+cSpell:ignore: ASGI gunicorn uvicorn
 ---
 
 ## Installation issues
@@ -91,6 +92,108 @@ if __name__ == "__main__":
     app.run(port=8082, debug=True, use_reloader=False)

+### Pre-fork server issues
+
+A pre-fork server, such as Gunicorn with multiple workers, could be run like
+this:
+
+sh +gunicorn myapp.main:app --workers 4 +
+
+However, specifying more than one --workers may break the generation of
+metrics when auto-instrumentation is applied. This is because forking, the
+creation of worker/child processes, creates inconsistencies between each child
+in the background threads and locks assumed by key OpenTelemetry SDK components.
+Specifically, the PeriodicExportingMetricReader spawns its own thread to
+periodically flush data to the exporter. See also issues
+#2767 and
+#3307.
+After forking, each child seeks a thread object in memory that is not actually
+run, and any original locks may not unlock for each child. See also forks and
+deadlocks described in Python issue 6721.
+
+#### Workarounds
+
+There are some workarounds for pre-fork servers with OpenTelemetry. The
+following table summarizes the current support of signal export by different
+auto-instrumented web server gateway stacks that have been pre-forked with
+multiple workers. See below for more details and options:
+
+| Stack with multiple workers | Traces | Metrics | Logs |
+| --------------------------- | ------ | ------- | ---- |
+| Uvicorn | x | | x |
+| Gunicorn | x | | x |
+| Gunicorn + UvicornWorker | x | x | x |
+
+##### Deploy with Gunicorn and UvicornWorker
+
+To auto-instrument a server with multiple workers, it is recommended to deploy
+using Gunicorn with uvicorn.workers.UvicornWorker if it is an Asynchronous
+Server Gateway Interface (ASGI) app (FastAPI, Starlette, etc). The UvicornWorker
+class is specifically designed to handle forks with preservation of background
+processes and threads. For example:
+
+```sh
+opentelemetry-instrument gunicorn \

  • --workers 4 \
  • --worker-class uvicorn.workers.UvicornWorker \
  • --bind 0.0.0.0:8000 \
  • myapp.main:app
    +```

+##### Use programmatic auto-instrumentation
+
+Initialize OpenTelemetry inside the worker process with
+programmatic auto-instrumentation
+after the server fork, instead of with opentelemetry-instrument. For example:
+
+python +from opentelemetry.instrumentation.auto_instrumentation import initialize +initialize() + +from your_app import app +
+
+If using FastAPI, note that initialize() must be called before importing
+FastAPI because of how instrumentation is patched. For example:
+
+```python
+from opentelemetry.instrumentation.auto_instrumentation import initialize
+initialize()
+
+from fastapi import FastAPI
+
+app = FastAPI()
+
[email protected]("/")
+async def root():

  • return {"message": "Hello World"}
    +```

+Then, run the server with:
+
+sh +uvicorn main:app --workers 2 +
+
+##### Use Prometheus with direct OTLP
+
+Consider using a recent version of
+Prometheus to receive OTLP
+metrics directly. Set up a PeriodicExportingMetricReader and one OTLP worker
+per process to push to Prometheus server. We recommend not using
+PrometheusMetricReader with forking -- see issue
+#3747.
+
+##### Use a single worker
+
+Alternatively, use a single worker in pre-fork with zero-code instrumentation:
+
+sh +opentelemetry-instrument gunicorn your_app:app --workers 1 +
+

Connectivity issues

gRPC Connectivity

diff --git a/content/en/docs/zero-code/python/configuration.md b/content/en/docs/zero-code/python/configuration.md
index 4aa43d83..971332d9 100644
--- a/content/en/docs/zero-code/python/configuration.md
+++ b/content/en/docs/zero-code/python/configuration.md
@@ -5,7 +5,8 @@ weight: 10
aliases:

  • /docs/languages/python/automatic/configuration
  • /docs/languages/python/automatic/agent-config
    -cSpell:ignore: healthcheck instrumentor myapp pyproject Starlette urllib
    +# prettier-ignore
    +cSpell:ignore: gevent healthcheck instrumentor monkeypatch myapp pyproject Starlette urllib

The agent is highly configurable, either by:
@@ -146,6 +147,9 @@ specific category.

  • OTEL_PYTHON_ID_GENERATOR: to specify which IDs generator to use for the
    global Tracer Provider
  • OTEL_PYTHON_INSTRUMENTATION_SANITIZE_REDIS: to enable query sanitization
    +- OTEL_PYTHON_AUTO_INSTRUMENTATION_EXPERIMENTAL_GEVENT_PATCH: set to
  • patch_all to call gevent monkeypatch patch_all method before initializing
  • the SDK

Examples:

@@ -155,6 +159,7 @@ export OTEL_PYTHON_ELASTICSEARCH_NAME_PREFIX=my-custom-prefix
export OTEL_PYTHON_GRPC_EXCLUDED_SERVICES="GRPCTestServer,GRPCHealthServer"
export OTEL_PYTHON_ID_GENERATOR=xray
export OTEL_PYTHON_INSTRUMENTATION_SANITIZE_REDIS=true
+export OTEL_PYTHON_AUTO_INSTRUMENTATION_EXPERIMENTAL_GEVENT_PATCH=patch_all


## Disabling Specific Instrumentations
diff --git a/content/en/docs/zero-code/python/operator.md b/content/en/docs/zero-code/python/operator.md
index 98b59260..a331c7b5 100644
--- a/content/en/docs/zero-code/python/operator.md
+++ b/content/en/docs/zero-code/python/operator.md
@@ -3,7 +3,7 @@ title: Using the OpenTelemetry Operator to Inject Auto-Instrumentation
linkTitle: Operator
aliases: [/docs/languages/python/automatic/operator]
weight: 30
-cSpell:ignore: grpcio myapp psutil PYTHONPATH
+cSpell:ignore: gevent grpcio monkeypatch myapp psutil PYTHONPATH
---

If you run your Python service in Kubernetes, you can take advantage of the
@@ -40,3 +40,10 @@ your deployment file two environment variables:
  "/app"
- `DJANGO_SETTINGS_MODULE`, with the name of the Django settings module, e.g.
  "myapp.settings"
+
+#### gevent applications
+
+Since the OpenTelemetry Python 1.37.0/0.58b0 release if you set in your
+deployment file the `OTEL_PYTHON_AUTO_INSTRUMENTATION_EXPERIMENTAL_GEVENT_PATCH`
+environment variable to `patch_all` the auto-instrumentation code will call the
+gevent monkeypatch method with the same name before initializing itself.
DRIFTED files: 3 out of 6

@otelbot-docs otelbot-docs bot requested a review from a team September 26, 2025 23:32
@otelbot-docs otelbot-docs bot requested a review from a team September 26, 2025 23:33
@Msksgm Msksgm force-pushed the drifted-content-ja-docs-zero-code-python branch 3 times, most recently from 03cfbfe to 071eb7e Compare September 26, 2025 23:42
@Msksgm Msksgm force-pushed the drifted-content-ja-docs-zero-code-python branch from 071eb7e to 5f04642 Compare September 27, 2025 09:34
@Msksgm Msksgm marked this pull request as ready for review September 27, 2025 09:42
@Msksgm Msksgm requested a review from a team as a code owner September 27, 2025 09:42
@Msksgm Msksgm changed the title fix: drifted files of content/ja/docs/zero-code/python/ [ja] fix: drifted files of content/ja/docs/zero-code/python/ Sep 27, 2025
@vitorvasc vitorvasc added the sig-approval-missing Co-owning SIG didn't provide an approval label Sep 29, 2025
Copy link
Contributor

@kohbis kohbis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Msksgm いくつかコメントしました 🙇

@otelbot-docs otelbot-docs bot requested a review from a team October 6, 2025 23:00
@Msksgm
Copy link
Member Author

Msksgm commented Oct 6, 2025

@kohbis
ありがとうございます!取り入れました。

@Msksgm
Copy link
Member Author

Msksgm commented Oct 6, 2025

/fix:dict

@otelbot-docs
Copy link
Contributor

otelbot-docs bot commented Oct 6, 2025

fix:dict applied successfully in run 18296802010.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lang:ja sig-approval-missing Co-owning SIG didn't provide an approval

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

3 participants