File tree Expand file tree Collapse file tree 2 files changed +32
-28
lines changed
Expand file tree Collapse file tree 2 files changed +32
-28
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,12 @@ Install `logfire` with the `django` extra:
88
99{{ install_logfire(extras=[ 'django'] ) }}
1010
11+ !!! info
12+ If you use are using the ** [ Asynchronous support] ** of Django, you'll also need to
13+ install the ` asgi ` extra:
14+
15+ {{ install_logfire(extras=['django,asgi']) }}
16+
1117## Usage
1218
1319In the ` settings.py ` file, add the following lines:
@@ -41,3 +47,4 @@ which you can find more information about [here][opentelemetry-django].
4147[ django ] : https://www.djangoproject.com/
4248[ opentelemetry-django ] : https://opentelemetry-python-contrib.readthedocs.io/en/latest/instrumentation/django/django.html
4349[ django-instrumentor ] : https://opentelemetry-python-contrib.readthedocs.io/en/latest/instrumentation/django/django.html#opentelemetry.instrumentation.django.DjangoInstrumentor
50+ [ Asynchronous support ] : https://docs.djangoproject.com/en/dev/topics/async/#asynchronous-support
Original file line number Diff line number Diff line change @@ -135,37 +135,34 @@ def install_logfire(markdown: str, page: Page) -> str:
135135 extras = [arg .strip ('\' "' ) for arg in arguments [1 ].strip ('[]' ).split (',' )] if len (arguments ) > 1 else []
136136 package = 'logfire' if not extras else f"'logfire[{ ',' .join (extras )} ]'"
137137 extras_arg = ' ' .join (f'-E { extra } ' for extra in extras )
138- instructions = f"""
139- === "pip"
140- ```bash
141- pip install { package }
142- ```
143-
144- === "uv"
145- ```bash
146- uv add { package }
147- ```
148-
149- === "rye"
150- ```bash
151- rye add logfire { extras_arg }
152- ```
153-
154- === "poetry"
155- ```bash
156- poetry add { package }
157- ```
138+ instructions = [
139+ '=== "pip"' ,
140+ ' ```bash' ,
141+ f' pip install { package } ' ,
142+ ' ```' ,
143+ '=== "uv"' ,
144+ ' ```bash' ,
145+ f' uv add { package } ' ,
146+ ' ```' ,
147+ '=== "rye"' ,
148+ ' ```bash' ,
149+ f' rye add logfire { extras_arg } ' ,
150+ ' ```' ,
151+ '=== "poetry"' ,
152+ ' ```bash' ,
153+ f' poetry add { package } ' ,
154+ ' ```' ,
155+ ]
158156
159- """
160157 if not extras :
161- instructions += """
158+ instructions .extend (['=== "conda"' , ' ```bash' , ' conda install -c conda-forge logfire' , ' ```' ])
159+ instructions_str = '\n ' .join (instructions )
162160
163- === "conda"
164- ```bash
165- conda install -c conda-forge logfire
166- ```
167- """
168- markdown = re .sub (r'{{ *install_logfire\(.*\) *}}' , instructions , markdown , count = 1 )
161+ def replace_match (match : re .Match [str ]) -> str :
162+ indent = match .group ('indent' )
163+ return indent + instructions_str .replace ('\n ' , '\n ' + indent )
164+
165+ markdown = re .sub (r'(?P<indent> *){{ *install_logfire\(.*\) *}}' , replace_match , markdown , count = 1 )
169166 return markdown
170167
171168
You can’t perform that action at this time.
0 commit comments