Conversation
There was a problem hiding this comment.
Code Review
This pull request centralizes environment variable management by introducing the FirebaseEnv class, which replaces scattered Platform.environment calls and the EmulatorEnvironment class. The feedback identifies a performance concern regarding frequent FirebaseEnv instantiations in hot paths and a robustness issue where the logger might crash if a project ID is missing. Additionally, suggestions were provided to improve code conciseness and further enhance encapsulation by adding specific getters for variables like PORT and K_SERVICE.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces a centralized FirebaseEnv class to manage environment variables and configuration, replacing manual Platform.environment lookups throughout the package. It also refactors the logging system to use Zone keys for propagating project and trace IDs and updates the server runtime to handle trace context headers. Feedback suggests centralizing the FirebaseEnv instance within the Firebase class to improve efficiency and consistency instead of instantiating it repeatedly.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request centralizes environment variable management through a new FirebaseEnv class and refactors the logging system to utilize Zone-based context for project and trace IDs. The changes also include cleaning up internal exports and replacing manual environment lookups across various namespaces. Feedback identifies a bug where the trace ID prefix is duplicated in the server request handler and suggests an improvement to a unit test to properly leverage the new zone keys for better coverage.
Introduced FirebaseEnv to unify emulator configuration and project ID resolution across namespaces, replacing scattered Platform.environment lookups. Also made `projecId` not nullable and moved the `demo-test` logic into a mock setting
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request centralizes environment variable management by introducing the FirebaseEnv class and refactors the logging system to utilize Zone values for project and trace IDs. These changes improve testability and ensure consistent environment handling across the SDK. One review comment identifies a documentation inconsistency in the logger's zone key example that needs to be updated.
- Add robust validation to `extractTraceId` in `server.dart` - Ensure strict 32-character hexadecimal requirement - Add trace parsing unit tests - Defend against empty trace strings in logger assertions
|
/gemini review |
|
|
||
| /// Zone key for propagating trace IDs. | ||
| @internal | ||
| final Object traceIdZoneKey = Object(); |
There was a problem hiding this comment.
Object is better than symbol since it'll never conflict.
Just don't make it const. 😄
There was a problem hiding this comment.
Code Review
This pull request centralizes environment variable management by introducing the FirebaseEnv class and refactoring the codebase to use it. It also improves structured logging by using Zone keys for project and trace ID propagation and adds logic to extract trace IDs from request headers. Feedback was provided regarding the projectId getter to ensure empty environment variables are treated as missing values.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Introduced FirebaseEnv to unify emulator configuration and project ID resolution across namespaces, replacing scattered Platform.environment lookups.
Also made
projecIdnot nullable and moved thedemo-testlogic into a mock setting
I also refactored logging to use
Zoneso we get the trace ID behavior(this was kinda tested, but never completed!)
I did a benchmark to make sure the zone overhead for each request was tiny (like 3% on a no-op request, which I'm not worried about)