-
Notifications
You must be signed in to change notification settings - Fork 0
comments #7
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
base: main
Are you sure you want to change the base?
comments #7
Conversation
|
|
||
| # Global config | ||
| REDIS_PREFIX = "metric:" | ||
| REDIS_PREFIX = "metric:" #ENV VAR!? |
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.
done
| 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... |
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.
done via env var
|
|
||
| def _parse_ttl(labels: Dict[str, str]) -> int: | ||
| ttl_label = "pushgw_ttl" | ||
| ttl_label = "pushgw_ttl" #NAMING CONSITENCY pushgw vs pushgateway |
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.
done with backward compatibility
| @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 |
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.
done
|
|
||
| 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? |
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.
done, there is no such option as redis.STRING
| metrics_by_name[name].append((labels, value)) | ||
| type_by_name[name] = mtype | ||
| except Exception: | ||
| # log execetion every time, now it makes you blind |
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.
done
| 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 |
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.
done
|
|
||
| return PlainTextResponse(internal_metrics + redis_metrics, media_type="text/plain") | ||
|
|
||
| #LOGGING IN BETWEEN WITH DEBUG LEVEL |
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.
done
No description provided.