-
Notifications
You must be signed in to change notification settings - Fork 78
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
fix: support custom exporters #235
fix: support custom exporters #235
Conversation
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
|
99fff91
to
c13cbbd
Compare
@lvaylet could you please review this MR, let me know if you have any concerns. |
Hi @pradeepbbl, and thanks a lot for contributing to SLO Generator! Just so I understand more what you are trying to fix here, can you provide us with an example of a custom exporter that fails to load due to capitalization? Also, regarding the pylint comment you removed, I am struggling to understand how it is related to this issue. Finally, @ocervell could you take a quick look when you are back from vacation early next week? I do not want to miss anything critical. |
Hi @lvaylet, thanks for the reply :) I'm trying to use a custom exporter to send metrics data for POC am using the below sample code #!/usr/bin/env python3
"""
Custom Exporter
"""
import logging
from logging import Logger
from slo_generator.exporters.base import MetricsExporter
class SloExporter(MetricsExporter):
"""Custom exporter for metrics."""
logger: Logger = logging.getLogger(__name__)
def export_metric(self, data):
"""Export data to custom destination.
Args:
data (dict): Metric data.
Returns:
object: Custom destination response.
"""
self.logger.info(f"[SloExporter.export_metric] exporting slo metrics: {data}")
return {"status": "ok", "code": 200} #!/usr/bin/env python3
"""
Custom SLO provider
"""
import logging
from logging import Logger
class SloProvider:
logger: Logger = logging.getLogger(__name__)
def __init__(self, client=None, **kwargs) -> None:
pass
def test_slo(self, timestamp, window, slo_config) -> tuple:
"""
return sample data
"""
self.logger.info(f"[SloProvider.test_slo] getting slo data for epoch: {timestamp} window: {window} config: {slo_config}")
return (10, 1) while running the
and regarding the Ref: https://github.com/google/slo-generator/runs/6982515317?check_suite_focus=true
|
Thanks a lot @pradeepbbl for these comprehensive details. Is it OK on your side to wait a few extra days for Olivier's return early next week? I just took over after him on the maintenance part and I do not feel comfortable approving this PR on my own. There might be side effects that I am not aware of. In the meantime, feel free to move forward with your development version. Regarding the pylint warning, let me fix this in a separate PR. I'd rather keep small PRs that only do one thing, in case we ever need to revert any of them "surgically". |
sure, no worries take your time and will push a revert of |
9f7ee83
to
c13cbbd
Compare
c13cbbd
to
1a350fe
Compare
Hi @pradeepbbl, just wanted to let you know that we are not overlooking this PR. I removed the pylint warning in a separate PR so all checks pass on this one. I just need an extra pair of eyes from @ocervell before approving. |
Hi @pradeepbbl, sorry for the delay here ... |
currently custom exporter are failing to load due to `capitalize`, this will add the same logic to `get_exporters` used in `get_backend`.
1a350fe
to
fd4ef7c
Compare
Thanks @pradeepbbl and @ocervell. I just rebased this branch with the latest changes from I also edited the name of the PR so it matches our semantic commit message policy. |
Custom exporters are failing to load due to `capitalize`. This PR propagates the `get_backend()` logic to `get_exporters()`.
currently, custom exporters are failing to load due to
capitalize
, thiswill add the same logic (avoid capitalize custom class name) to
get_exporters
used inget_backend
.