Open
Conversation
maso7
reviewed
Aug 19, 2025
|
|
||
| # Global config | ||
| REDIS_PREFIX = "metric:" | ||
| REDIS_PREFIX = "metric:" #ENV VAR!? |
maso7
reviewed
Aug 19, 2025
| DEFAULT_TTL = int(os.getenv("DEFAULT_TTL", "7200")) # 2 hours | ||
|
|
||
| logging.basicConfig(level=logging.INFO) | ||
| logging.basicConfig(level=logging.INFO) # LOGLEVEL SET VIA ENV VAR?! OR -v -vv -vvv... |
maso7
reviewed
Aug 19, 2025
|
|
||
| def _parse_ttl(labels: Dict[str, str]) -> int: | ||
| ttl_label = "pushgw_ttl" | ||
| ttl_label = "pushgw_ttl" #NAMING CONSITENCY pushgw vs pushgateway |
Contributor
There was a problem hiding this comment.
done with backward compatibility
maso7
reviewed
Aug 19, 2025
| @asynccontextmanager | ||
| async def lifespan(app: FastAPI) -> AsyncIterator[None]: | ||
| global redis_client | ||
| global redis_client # must be global var? cannot be passed as param to this async func? global client is ok, but not global variable |
maso7
reviewed
Aug 19, 2025
|
|
||
| for key in keys: | ||
| if await redis_client.type(key) != "string": | ||
| if await redis_client.type(key) != "string": # type checking via string? is there somthing like redis.STRING to compare with? |
Contributor
There was a problem hiding this comment.
done, there is no such option as redis.STRING
maso7
reviewed
Aug 19, 2025
| metrics_by_name[name].append((labels, value)) | ||
| type_by_name[name] = mtype | ||
| except Exception: | ||
| # log execetion every time, now it makes you blind |
maso7
reviewed
Aug 20, 2025
| filtered = {k: labels.get(k, "") for k in label_keys} | ||
| g.labels(**filtered).set(value) | ||
| except ValueError: | ||
| # log execetion every time, now it makes you blind, but less then case before, because it was generic exception |
maso7
reviewed
Aug 20, 2025
|
|
||
| return PlainTextResponse(internal_metrics + redis_metrics, media_type="text/plain") | ||
|
|
||
| #LOGGING IN BETWEEN WITH DEBUG LEVEL |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.