Skip to content

Commit 3a09cbf

Browse files
alexmojakivre142
andauthored
Document combining configurations (#1454)
Co-authored-by: pipinstalled <[email protected]>
1 parent dfad71d commit 3a09cbf

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
Sometimes you need different Logfire configurations for different parts of your application. You can do this with [`logfire.configure(local=True, ...)`][logfire.configure(local)].
2+
3+
For example, here's how to disable console logging for database operations while keeping it enabled for other parts:
4+
5+
```python
6+
import logfire
7+
8+
# Global configuration is the default and should generally only be done once:
9+
logfire.configure()
10+
11+
# Locally configured instance without console logging
12+
no_console_logfire = logfire.configure(local=True, console=False)
13+
14+
# Simple demonstration:
15+
logfire.info('This uses the global config and will appear in the console')
16+
no_console_logfire.info('This uses the local config and will NOT appear in the console')
17+
18+
# Calling functions on the `logfire` module will use the global configuration
19+
# This will send spans about HTTP requests to both Logfire and the console
20+
logfire.instrument_httpx()
21+
22+
# This will send spans about DB queries to Logfire but not to the console
23+
no_console_logfire.instrument_psycopg()
24+
```

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ nav:
101101
- Export your Logfire Data: how-to-guides/query-api.md
102102
- Scrub Sensitive Data: how-to-guides/scrubbing.md
103103
- Trace across Multiple Services: how-to-guides/distributed-tracing.md
104+
- Combine Multiple Configurations: how-to-guides/different-configurations.md
104105
- Detect Service is Down: how-to-guides/detect-service-is-down.md
105106
- Suppress Spans and Metrics: how-to-guides/suppress.md
106107
- OpenTelemetry Collector:

0 commit comments

Comments
 (0)