-
Notifications
You must be signed in to change notification settings - Fork 223
feat(client): add native environments #1122
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
19 file(s) reviewed, 1 comment(s)
Edit PR Review Bot Settings | Greptile
langfuse/client.py
Outdated
| self.environment = environment or os.environ.get("LANGFUSE_TRACING_ENVIRONMENT") | ||
|
|
||
| if self.environment and not bool( | ||
| re.match(ENVIRONMENT_PATTERN, self.environment) | ||
| ): | ||
| self.log.warning( | ||
| f'Invalid environment specified "{environment}" that does not match validation pattern ("{ENVIRONMENT_PATTERN}"). Setting will be ignored.' | ||
| ) | ||
| self.environment = None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: There's an inconsistency in error handling between the main Langfuse class and StatefulClient. The main class logs an error for invalid environments but still keeps the value, while StatefulClient logs a warning and sets the environment to None. These should be consistent.
| ): | ||
| self.log.error( | ||
| f'Invalid environment specified "{environment}" that does not match validation pattern ("{ENVIRONMENT_PATTERN}"). Events will be rejected by Langfuse servers.' | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If an invalid environment is specified, consider resetting self.environment to None after logging the error to prevent subsequent events from carrying an invalid value.
| ) | |
| self.environment = None |
| enabled: Enables or disables the Langfuse client. Defaults to True. If disabled, no observability data will be sent to Langfuse. If data is requested while disabled, an error will be raised. | ||
| mask (Callable): Function that masks sensitive information from input and output in log messages. | ||
| environment (optional): The tracing environment. Can be any lowercase alphanumeric string with hyphens and underscores that does not start with 'langfuse'. Can bet set via `LANGFUSE_TRACING_ENVIRONMENT` environment variable. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typographical error: In the environment parameter description, change 'Can bet set via LANGFUSE_TRACING_ENVIRONMENT environment variable.' to 'Can be set via LANGFUSE_TRACING_ENVIRONMENT environment variable.'
| environment (optional): The tracing environment. Can be any lowercase alphanumeric string with hyphens and underscores that does not start with 'langfuse'. Can bet set via `LANGFUSE_TRACING_ENVIRONMENT` environment variable. | |
| environment (optional): The tracing environment. Can be any lowercase alphanumeric string with hyphens and underscores that does not start with 'langfuse'. Can be set via `LANGFUSE_TRACING_ENVIRONMENT` environment variable. |
Important
Add native environment support to Langfuse Python SDK, allowing users to specify environments for better telemetry data organization.
environmentfield to core models (Observation,Trace,BaseScore,ScoreBody) with validation for lowercase alphanumeric strings with hyphens/underscores.Langfuseclient constructor with support for setting viaLANGFUSE_TRACING_ENVIRONMENTenvironment variable.LangchainCallbackHandler,LlamaIndexInstrumentor,OpenAIintegration).This description was created by
for 8fd01cd. It will automatically update as commits are pushed.
Greptile Summary
Disclaimer: Experimental PR review
Added native environment support to the Langfuse Python SDK, allowing users to specify environments for better organization of telemetry data across different deployment contexts.
environmentfield to core models (Observation, Trace, BaseScore, ScoreBody) with validation for lowercase alphanumeric strings with hyphens/underscoresLangfuseclient constructor with support for setting viaLANGFUSE_TRACING_ENVIRONMENTenvironment variable