Skip to content

Commit

Permalink
more unconditionally check token
Browse files Browse the repository at this point in the history
  • Loading branch information
sydney-runkle committed Nov 4, 2024
1 parent 24d54c8 commit 15c40f1
Showing 1 changed file with 14 additions and 17 deletions.
31 changes: 14 additions & 17 deletions logfire/_internal/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -810,29 +810,26 @@ def add_span_processor(span_processor: SpanProcessor) -> None:
if self.token is None:
credentials = LogfireCredentials.load_creds_file(self.data_dir)

# if we still don't have a token, try initializing a new project and writing a new creds file
# note, we only do this if `send_to_logfire` is explicitly `True`
if self.send_to_logfire is True and self.token is None:
credentials = LogfireCredentials.initialize_project(
logfire_api_url=self.advanced.base_url,
session=requests.Session(),
)
credentials.write_creds_file(self.data_dir)

if credentials is not None and self.token is None:
self.token = credentials.token
self.advanced.base_url = self.advanced.base_url or credentials.logfire_api_url
# if we still don't have a token, try initializing a new project and writing a new creds file
# note, we only do this if `send_to_logfire` is explicitly `True`
if self.send_to_logfire is True and credentials is None:
credentials = LogfireCredentials.initialize_project(
logfire_api_url=self.advanced.base_url,
session=requests.Session(),
)
credentials.write_creds_file(self.data_dir)

if show_project_link and credentials is not None:
credentials.print_token_summary()
if credentials is not None:
self.token = credentials.token
self.advanced.base_url = self.advanced.base_url or credentials.logfire_api_url

if self.token is not None:

def check_token():
assert self.token is not None
creds = self._initialize_credentials_from_token(self.token)
if show_project_link and creds is not None:
creds.print_token_summary()
validated_credentials = self._initialize_credentials_from_token(self.token)
if show_project_link and validated_credentials is not None:
validated_credentials.print_token_summary()

thread = Thread(target=check_token, name='check_logfire_token')
thread.start()
Expand Down

0 comments on commit 15c40f1

Please sign in to comment.