Skip to content

Commit

Permalink
Set logfire OTEL scope to magentic (#298)
Browse files Browse the repository at this point in the history
* Set logfire OTEL scope to magentic

* Add TODOs for setting scope

* Set logfire otel_scope to magentic

* Add TODO for otel version
  • Loading branch information
jackmpcollins authored Aug 12, 2024
1 parent c7cb858 commit 3cb8c59
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 10 deletions.
3 changes: 1 addition & 2 deletions src/magentic/chat_model/retry_chat_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
from functools import singledispatchmethod
from typing import Any, TypeVar, overload

import logfire_api as logfire

from magentic.chat_model.base import (
ChatModel,
ToolSchemaParseError,
Expand All @@ -13,6 +11,7 @@
Message,
ToolResultMessage,
)
from magentic.logger import logfire

R = TypeVar("R")

Expand Down
3 changes: 1 addition & 2 deletions src/magentic/chatprompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,11 @@
overload,
)

import logfire_api as logfire

from magentic.backend import get_chat_model
from magentic.chat_model.base import ChatModel
from magentic.chat_model.message import Message
from magentic.chat_model.retry_chat_model import RetryChatModel
from magentic.logger import logfire
from magentic.typing import split_union_type

P = ParamSpec("P")
Expand Down
3 changes: 1 addition & 2 deletions src/magentic/function_call.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
)
from uuid import uuid4

import logfire_api as logfire

from magentic.logger import logfire
from magentic.streaming import CachedAsyncIterable, CachedIterable

T = TypeVar("T")
Expand Down
4 changes: 4 additions & 0 deletions src/magentic/logger.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import logging

import logfire_api

logger = logging.getLogger("magentic")
# Set default log level to WARNING so INFO logs must be explicitly enabled
if logger.level == logging.NOTSET:
logger.setLevel(logging.WARNING)

logfire = logfire_api.Logfire(otel_scope="magentic") # TODO: Pass version here too
3 changes: 1 addition & 2 deletions src/magentic/prompt_chain.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@
cast,
)

import logfire_api as logfire

from magentic.chat import Chat
from magentic.chat_model.base import ChatModel
from magentic.function_call import FunctionCall
from magentic.logger import logfire
from magentic.prompt_function import AsyncPromptFunction, PromptFunction

P = ParamSpec("P")
Expand Down
3 changes: 1 addition & 2 deletions src/magentic/prompt_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,11 @@
overload,
)

import logfire_api as logfire

from magentic.backend import get_chat_model
from magentic.chat_model.base import ChatModel
from magentic.chat_model.message import UserMessage
from magentic.chat_model.retry_chat_model import RetryChatModel
from magentic.logger import logfire
from magentic.typing import split_union_type

P = ParamSpec("P")
Expand Down

0 comments on commit 3cb8c59

Please sign in to comment.