ã¯ããã«
ãããã®ã½ãªã¹ããããã...ðððï¼ã¦ã¼ãã©3æä¸ææ¾éè¦ãï¼ nikkieã§ãã
ããµãµãããããã¨ã«æ°ã¥ãã¡ããã¾ãããã
Pydantic社ãæ§æ³ããLogfireãããã¤ã¯ãã¹ã¼ãï¼
ç®æ¬¡
- ã¯ããã«
- ç®æ¬¡
- pydantic-settingsã§CLIãä½ããï¼
- Logfire
- pydantic-settingsã«ããCLIã§ãPydanticã«ãããã¼ã¹çµæãåéãã
- Logfireã®Integration
- çµããã«
pydantic-settingsã§CLIãä½ããï¼
argparseããããã®æ°ã§ãããããªãã·ã§ã³å¼æ°ãç°å¢å¤æ°ãããæå®ã§ãããµãã¼ããé åçããã¦ãåæã¯pydantic-settingsãé¸ã³ãããªã£ã¦ãã¾ã
Logfire
Pydantic社ããªãªã¼ã¹ããå¯è¦³æ¸¬æ§ï¼observabilityï¼ãã¼ã«ã
SaaSã¨Pythonããã±ã¼ã¸ã®2ã¤ãããã¾ãã
å æ¥ã®ã¿ããªã®Pythonåå¼·ä¼ã§ããPydanticAIã¨Logfireãç°¡åã«é£æºã§ããã¨ç´¹ä»ããã¾ãã1ã
ä»åpydantic-settingsã§CLIãä½ãä¸ã§æ°ã¥ãã¡ãã£ããã§ãããã
PydanticAIã¨ç°¡åã«é£æºã§ãããªããpydantic-settingsã¨ãç°¡åã«é£æºã§ããã®ã§ã¯ãã¨
pydantic-settingsã«ããCLIã§ãPydanticã«ãããã¼ã¹çµæãåéãã
ããã¥ã¡ã³ãã®ããããã¼ã¸ã®å 容ããã£ã¦ããã¾ãã
SaaSã®Logfireã®è¨å®
- https://logfire.pydantic.dev/login ãããã°ã¤ã³
- GitHubã¢ã«ã¦ã³ãã§ãã°ã¤ã³ãã¾ãã
- ããã¸ã§ã¯ããä½æï¼ãNew projectãï¼2
- ããã¸ã§ã¯ãã§Write Tokenãçºè¡ï¼ããã¸ã§ã¯ãä½æå¾ã®æ示ã«å¾ãã°ããããããã¸ã§ã¯ãã®ãSettingsããæä½ãã¦ããï¼
ããã¥ã¡ã³ãã«ã¯logfireããã±ã¼ã¸ã«å«ã¾ããCLIã使ã£ãä¾ï¼logfire auth
ã»logfire projects use
ï¼ãããã¾ãããããã¯æ¬çªåãã§ã¯ãªãã¨ç¥ã£ãã®ã§ãWrite Tokenã«ãã¾ããã
https://logfire.pydantic.dev/docs/#__tabbed_2_1
ãã®è¨äºã§ã¯logfireããã±ã¼ã¸ã®CLIã¯ä½¿ã£ã¦ãã¾ãã
ããã¸ã§ã¯ãã®Write Tokenãç°å¢å¤æ°LOGFIRE_TOKEN
ã«è¨å®ãã¾ãã
ãã®ç¶æ
ã§Pythonå¦çç³»ã®å¯¾è©±ã¢ã¼ãã使ã£ã¦åä½ç¢ºèªã§ãã¾ãã
https://logfire.pydantic.dev/docs/#__tabbed_2_2 ã®ä¾ã対話ã¢ã¼ãã§å®è¡ãã¦ãã¾ãã
% uv run --with logfire python >>> import logfire >>> logfire.configure() Logfire project URL: https://logfire.pydantic.dev/ftnext/... >>> logfire.info("Hello, {name}!", name="world") 15:59:35.328 Hello, world!
ããã¸ã§ã¯ãã®Liveãè¦ãã¨
ä¸è¨ã®åä½ç¢ºèªã«ããspanã確èªã§ãã¾ããï¼3
CLIã¢ããªã±ã¼ã·ã§ã³ã§Logfireã使ãè¨å®
- logfireããã±ã¼ã¸ãä¾åã«è¿½å
- Pydanticã®ãã¼ã¹çµæãåéããã³ã¼ãã追å
import logfire
logfire.configure()
logfire.instrument_pydantic()
å ¨ä½å
CLIãå¼ã³åºãã ãã§ãã³ãã³ãã©ã¤ã³ã§æ¸¡ããå¼æ°ã®ãã¼ã¹çµæãè¨é²ããã¾ãï¼
% uv run --quiet cli.py position ã¨ããªã¼ 5 01:02:02.731 Pydantic Settings validate_python ã¨ããªã¼ã¨ããªã¼ã¨ããªã¼ã¨ããªã¼ã¨ããªã¼ Logfire project URL: https://logfire.pydantic.dev/ftnext/...
å ¥åã¨è§£æçµæãããããªè¨é²ããã¦ãã¾ãï¼
{ 'input_data': { 'position': { 'string': 'ã¨ããªã¼', 'number': '5', }, 'option': None, }, 'result': Settings( position=Position( string='ã¨ããªã¼', number=5, ), option=None, ), 'schema_name': 'Settings', 'success': True, 'validation_method': 'validate_python', }
åä½ç°å¢
- uv 0.4.27 (Homebrew 2024-10-25)
- Python 3.13.0
- pydantic-settings 2.7.1
- Pydantic 2.10.4
- Logfire 2.11.1
Logfireã®Integration
Integrationã¨ããä»çµã¿ã§å®ç¾ãã¦ãã¾ãã
https://logfire.pydantic.dev/docs/integrations/#custom-integrations
logfire.instrument_pydantic()
ã®ç¬¬1å¼æ°record
ã¯ã以ä¸ã®å¤ãåããã¾ãã
https://logfire.pydantic.dev/docs/reference/api/logfire/#logfire.Logfire.instrument_pydantic
"all"
ï¼ããã©ã«ãå¤ï¼"failure"
"metrics"
"off"
ä»åã¯ããã©ã«ãå¤ã®"all"
ã§è©¦ãã¦ãã¾ããããã¼ã¿ã®ããªãã¼ã·ã§ã³ã«å¤±æããã¨ãã ãè¨é²ãæ®ãã°ããã®ã§ããã°"failure"
ã®æå®ã«ãªãã¾ãã
ä»ã«ãè¨é²ã®æå®ãã¯ã©ã¹åä½ã«ããããã¿ã°ãä»ããããã§ããããã§ããï¼å®¿é¡äºé ï¼
çµããã«
pydantic-settingsã§ä½ãCLIã«Logfireãçµã¿è¾¼ãã¾ããã
CLIã«æ¸¡ããå¼æ°ã¨Pydanticã«ãããã¼ã¹çµæãè¨é²ãã¦ã¿ã¾ããï¼"all"
ï¼
2024å¹´5æã®US PyConã«è¡ã£ãæ¹ãããPydantic社ã®ãã¼ã¹ã§Logfireç´¹ä»ãã¦ãããã¨æãã¦ããã£ãè¨æ¶ãããã¾ãã
ãã®ã¨ãã¯ããªãã§ã¾ãï¼ãã¨ããæãã ã£ãã®ã§ãããå®éã«è§¦ã£ã¦ãPydantic社ãLogfireããªãªã¼ã¹ããã®ã«ç´å¾ãã¦ãã¾ãã
pydantic-settingsã®ä¾ãããPydanticã使ãããããããå ´é¢ã§Logfireã®åºçªãããã¾ãï¼4
åºãå¸å ´ãç²ãã«ãã£ãã¨ãããã¨ã§ããï¼æè¯ã®éçºè
ä½é¨ãæ§ç¯ã¨ãããã¸ã§ã³ãå®ç¾ããããã«ï¼ï¼
Pydantic社ãåºããLogfireãç°¡åã«ä½¿ãããã¦ã使ãæ©ä¼ããªããã ããªãã¨ãã¾ã¾ã§æ¥ç¹ãæããã«ããå¯è¦³æ¸¬æ§ï¼observabilityï¼ãOpenTelemetryã¨ããæ¦å¿µããããå¢ãã§è¿«ã£ã¦ãã¦ããã
— nikkie(ã«ã£ãã¼) / ã«ã£P (@ftnext) 2025å¹´1æ1æ¥
ç§ã¯ä¸ä»ã®æ©æ¢°å¦ç¿ã¨ã³ã¸ãã¢ãªãã§ããç¥ã£ã¨ããã»ãã使ãããªãããããªã©ã¤ãªã¼ã«å ¥éæ¸ããã㪠https://t.co/xxTEUArS0m
-
5代ç®LTçå襲åãããã§ã¨ããããã¾ãï¼
↩æ¬æ¥çºè¡¨ããã¦ããã ããè³æã§ãï¼ #stapyhttps://t.co/6w1XCCgpj5
— chimuichimu (@chimuichimu1) 2024å¹´12æ19æ¥ - ããã¸ã§ã¯ãä½æã§ã¯ã¹ã¯ã·ã§ç¨ã«ããã¸ã§ã¯ããä½ãã¾ããï¼ãã°ãè¨é²ããããã¸ã§ã¯ãã¨ã¯å¥ã§ãï¼↩
- åä½ç¢ºèªã®ãã°ã ã示ãããã«çµãè¾¼ãã§ãã¾ãï¼PydanticAIãçµã¿è¾¼ã¾ãã¦ã¦ãæ¥æ¬èªã§ãããããã¨æ¸ãããSQLã«ãªã£ããï¼ï¼↩
- Integrationã®ããã¥ã¡ã³ããããDjangoãªã©Pydanticãããã©ã«ãã§å ¥ã£ã¦ãªããããªé åã§ãLogfireã«é£æºã§ããããã§ãããOpenTelemetryäºæã謳ã£ã¦ããããã§ãããã¾ã¯æªç¥ã®æ¦å¿µã宿é¡ã ...↩