Add Prometheus Remote Write Exporter (4/6)#212
Conversation
09fe5a2 to
ac5f46f
Compare
ocelotl
left a comment
There was a problem hiding this comment.
Some test case result interpretations can be affected by the current implementation, please take a look.
9c932ae to
f5499ce
Compare
ocelotl
left a comment
There was a problem hiding this comment.
Well done! Just a request to remove unnecessary Mocks.
f5499ce to
dcf02ef
Compare
b6251fb to
f249cc9
Compare
f199064 to
0dad10e
Compare
| response.reason, | ||
| str(response.content), | ||
| ) | ||
| return MetricsExportResult.FAILURE |
There was a problem hiding this comment.
Are we going to be handling retries? Timeouts?, etc?
There was a problem hiding this comment.
The timeout can be adjusted, but if a request fails (timeout or otherwise), we just report failure instead of retrying to avoid requests getting clogged due to records being exported continuously. If we set a timeout, but then retried multiple times, the timeout would no longer limit the time spent attempting to export one set of records. Our reasoning was that missing data is not as bad as delayed data especially in cases of cumulative data where missing data can be interpolated or cases where data is exported on a very short interval. Does not retrying failed requests sound reasonable for this use case?
There was a problem hiding this comment.
Depends on how robust we want the functionality of this exporter. We can handle it in a different PR in the future if is needed.
b1e6880 to
5da9eb2
Compare
codeboten
left a comment
There was a problem hiding this comment.
A couple of questions I'd like to have answered before approving.
| import re | ||
| from typing import Dict, Sequence | ||
|
|
||
| import requests |
There was a problem hiding this comment.
should dependencies be added for python-snappy and requests?
There was a problem hiding this comment.
One issue that I am running into is that I cannot add python-snappy to the setup.cfg because it depends on the snappy library in C which I had to brew install to get. Is there a way to add a C dependency that a module requires? If not I might have to specify to first manually install snappy library and module before using exporter in README.
There was a problem hiding this comment.
Excluded python-snappy from install-requires for now.
| data=message, | ||
| headers=headers, | ||
| auth=auth, | ||
| timeout=self.timeout, |
There was a problem hiding this comment.
would be good to add the default timeout value to the class documentation
There was a problem hiding this comment.
Added, will also add to README
| self.tls_config["cert_file"], | ||
| self.tls_config["key_file"], | ||
| ) | ||
| response = requests.post( |
There was a problem hiding this comment.
should this be wrapped in a try block?
There was a problem hiding this comment.
I did not consider that requests.post could throw exceptions in addition to returning HTTPErrors inside the response. Modified to use a try/except block which handles all request exceptions. (now raises HTTPErrors to be logged as well) This guarantees calling export() will never throw an exception.
5395f9f to
c79a4c9
Compare
| install_requires = | ||
| protobuf >= 3.13.0 | ||
| requests == 2.25.0 | ||
| opentelemetry-api == 0.16.dev0 |
There was a problem hiding this comment.
Could you update these dependencies to 0.17.dev0 as well as the current version? It's causing some build failures.
4847d6a to
f9c341e
Compare
codeboten
left a comment
There was a problem hiding this comment.
Thanks for responding to all my comments.
7fea46a to
9c036e1
Compare
9c036e1 to
8e93659
Compare
Description
This is PR 3/6 of adding a Prometheus Remote Write Exporter in Python SDK and address Issue open-telemetry/opentelemetry-python#1302
Part 1/6
Part 2/6
Part 3/6
👉 Part 4/6
Part 5/6
Part 6/6
Type of change
How Has This Been Tested?
TestValidationintest_prometheus_remote_write_exporter.pyDoes This PR Require a Core Repo Change?
Checklist:
cc- @AzfaarQureshi , @alolita