Skip to content

allow LOGFIRE_BASE_URL to accept grpc endpoints #1048

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft

Conversation

davidhewitt
Copy link
Contributor

Related to #1042

The idea (from offline discussion) is that we can set LOGFIRE_BASE_URL to a grpc endpoint and everything can "just work", with the caveat that we wouldn't be able to do any token checking.

This is sufficient for a local test script to work for me:

# /// script
# requires-python = ">=3.11"
# dependencies = [
#   "logfire[grpc]",
# ]
# ///

import os

import logfire

os.environ['LOGFIRE_BASE_URL'] = 'grpc://localhost:4317'

logfire.configure(
    # Setting a service name is good practice in general, but especially
    # important for Jaeger, otherwise spans will be labeled as 'unknown_service'
    service_name='my_logfire_service',
)

with logfire.span('This is a span'):
    logfire.info('Logfire logs are also actually just spans!')

Steps to complete before merge:

  • Update documentation for OTEL collectors
  • Testing - not sure how much we want this covered? It seems painful to start up a full GRPC endpoint in testing, maybe there's a mock solution?

Copy link

cloudflare-workers-and-pages bot commented Apr 30, 2025

Deploying logfire-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: 25d335a
Status: ✅  Deploy successful!
Preview URL: https://a37bb325.logfire-docs.pages.dev
Branch Preview URL: https://dh-grpc.logfire-docs.pages.dev

View logs

self.token = credentials.token
self.advanced.base_url = self.advanced.base_url or credentials.logfire_api_url
except LogfireConfigError:
if self.advanced.base_url is not None:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should only allow this if it is a grpc url?

Alternatively, perhaps we could split the logic, and have different code paths depending on whether the endpoint is HTTP/gRPC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants