-
Notifications
You must be signed in to change notification settings - Fork 119
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
Elasticsearch report backend #58
Conversation
Very interesting! It'll take me bit to fully review but meanwhile some question regarding the Also, |
@ionelmc Thanks for fast response. I can squash that information to
|
To be honest I'd rather have a single option for the backends, eg: Can you specify doctype without index? |
Ok we can do that. But I would not like to invent new protocols like You usually call Index and doctype are lower case strings that don't start with underscore and dot. elastic/elasticsearch#6736. |
Well is either inventing an URI protocol or inventing 5 more command line options. There are way too many options, I'm just trying to keep the option list under control. What if someone else comes with a different backend? Does elasticsearch support just http? Or https too? Is there support for other protocols? |
In hindsight, Unfortunately the URI parser in python doesn't support well the |
Elasticsearch can be accessed via |
I removed those |
One more thing that I was wondering about is what if there would be some package holding the report backends, eg: There are two issues I think:
Also, the |
|
On Fri, Sep 9, 2016 at 5:53 PM, Petr Šebek notifications@github.com wrote:
Could we integrate that into the storage URI? Also, out of curiosity, |
I've refactored report backends so there is no duplicated code. Therefore, I don't understand how we should integrate project name to storage URI. We can live without it and just use function Yes you can add more options to Elasticsearch connection, e.g. |
|
||
@staticmethod | ||
def _benchmark_from_es_record(source_es_record): | ||
result = {} |
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.
Does the ES record have stuff we don't need?
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.
You can see how single record looks in es in the bottom. I had to split benchmarks of each run to single record and therefore put common information (e.g. machine_info
, datetime
) to each record. Function _benchmark_from_es_record
selects only keys that belongs to single benchmark, while _run_info_from_es_record
selects data that are common among these benchmarks.
{ "_index": "benchmark", "_type": "benchmark", "_id": "ukuran_6eac319724dbd9beebf21aafd52d00ece31f61a4_20160912_080154_tests/test_performance.py::test_pedantic", "_score": null, "_source": { "version": "3.0.0", "options": { "timer": "perf_counter", "warmup": false, "disable_gc": false, "max_time": 1, "min_rounds": 5, "min_time": 0.000005 }, "commit_info": { "project": "ukuran", "id": "6eac319724dbd9beebf21aafd52d00ece31f61a4", "dirty": false }, "stats": { "stddev": 0.0000033206052045174887, "q1": 0.005085450800015679, "stddev_outliers": 2, "q3": 0.005090232499969716, "rounds": 10, "median": 0.005088654999963182, "max": 0.0050920920999487865, "iqr": 0.000004781699954037148, "outliers": "2;0", "min": 0.005080863300008787, "iqr_outliers": 0, "ld15iqr": 0.005080863300008787, "mean": 0.005087793719976617, "iterations": 10, "hd15iqr": 0.0050920920999487865 }, "machine_info": { "node": "ubuntu", "processor": "x86_64", "machine": "x86_64", "system": "Linux", "release": "4.4.0-36-generic", "python_implementation": "CPython", "python_build": [ "default", "Jul 5 2016 12:43:10" ], "python_implementation_version": "3.5.2", "python_compiler": "GCC 5.4.0 20160609", "python_version": "3.5.2" }, "group": null, "fullname": "tests/test_performance.py::test_pedantic", "name": "test_pedantic", "datetime": "2016-09-12T08:01:57.865021", "param": null, "params": null }, "sort": [ 1473667317865 ] }
About the project name, could the scheme be |
I think that adding |
@ionelmc Hi, so what do you think about those two PRs? Will you eventually merge it? Is there some problem? What's your plan with it? |
Yes they will be merged. I was a bit busy last week. |
Regarding |
( |
Current coverage is 56.71% (diff: 42.91%)@@ master #58 diff @@
==========================================
Files 15 20 +5
Lines 1423 1564 +141
Methods 0 0
Messages 0 0
Branches 260 271 +11
==========================================
+ Hits 867 887 +20
- Misses 507 631 +124
+ Partials 49 46 -3
|
Ok, I added |
@@ -11,7 +32,7 @@ def __init__(self, elasticsearch_hosts, elasticsearch_index, elasticsearch_docty | |||
self._elasticsearch_hosts = elasticsearch_hosts | |||
self._elasticsearch_index = elasticsearch_index | |||
self._elasticsearch_doctype = elasticsearch_doctype | |||
self._elasticsearch = elasticsearch.Elasticsearch(self._elasticsearch_hosts) | |||
self._elasticsearch = elasticsearch.Elasticsearch(self._elasticsearch_hosts, serializer=SaveElasticsearchJSONSerializer()) |
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.
Note that this will create an error at runtime if elasticsearch could not be imported (None
is not callable).
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 elasticsearch could not be imported it raises ImportError
before we get to this point. The control is at start of ElasticsearchStorage.__init__
method.
@ionelmc So is there something more I could do with this pull request? Can you merge it now? |
config.option.__dict__["benchmark_project_name"] = project_name | ||
config.option.__dict__["benchmark_autosave"] = get_tag(project_name) | ||
return ElasticReportBackend(config) | ||
else: |
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.
Regarding #58 (comment), can we also support legacy-style paths (auto-convert them to file://<value>
if value doesn't contain ://
)? Tests are failing anyway because of this :)
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.
@ionelmc Done, thanks for the fast reply.
@Artimi I think that's the last nit there, getting pretty close now. |
Don't worry about the conflicts, I can do the rebasing. |
Ok so I've played with this a bit, what I've found:
Another strange thing in the CLI is that it don't use any machine_id (it has access to all the runs, regardless of what machine_id). What I'm proposing here:
For purpose of speeding this up a bit I did the rebasing and refactoring in this branch https://github.com/ionelmc/pytest-benchmark/tree/es-storage-cli-support (refactoring commit: 7d38c66). I probably broke something in there (waiting on tests, don't consider it something final). So (how) would it be possible to support the machine_id namespacing in the ES storage? I can explain more if not clear, or feel free to argue if you disagree :-) |
Thanks for your suggestions. I removed ReportBackend classes and returned |
@Artimi hmmm, it would be easier if you'd work new changes on top of https://github.com/ionelmc/pytest-benchmark/tree/es-storage-cli-support no? |
Ah ok, I thought we will talk about it here. I will cherry pick tomorrow. |
@ionelmc I've pushed requested changes to our organization repo https://github.com/qntln/pytest-benchmark/tree/es-storage-cli-supportt. It seems that I don't have permissions to write to your branch https://github.com/ionelmc/pytest-benchmark/tree/es-storage-cli-support. |
@Artimi it seems it's a private org. You can either |
3cb4230
to
264d645
Compare
@ionelmc I force pushed it here. |
def get_tag(project_name=None): | ||
info = get_commit_info(project_name) | ||
parts = [] | ||
if info['project']: |
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.
@Artimi I plan to remove the project part (to get back the old "brief" naming style from 3.0) in the next release (alpha2). Let me know if you have objections or not.
Hello,
we found your plugin very useful. I wrote this PR so we can be able to store information about benchmarks in elasticsearch. As we have plenty of services and we want to track them in CI this is more suitable option for us than files. We can also then generate reports in Kibana as this:
I put saving to files to
FileReportBackend
and created new oneElasticsearchReportBackend
. Packageelasticsearch
is only optional. I hope I kept spirit of your awesome plugin and did not bend it too much.