-
Notifications
You must be signed in to change notification settings - Fork 624
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
Add Prometheus Remote Write Exporter (4/6) #212
Add Prometheus Remote Write Exporter (4/6) #212
Conversation
09fe5a2
to
ac5f46f
Compare
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.
Some test case result interpretations can be affected by the current implementation, please take a look.
...orter-prometheus-remote-write/src/opentelemetry/exporter/prometheus_remote_write/__init__.py
Outdated
Show resolved
Hide resolved
...pentelemetry-exporter-prometheus-remote-write/tests/test_prometheus_remote_write_exporter.py
Outdated
Show resolved
Hide resolved
...pentelemetry-exporter-prometheus-remote-write/tests/test_prometheus_remote_write_exporter.py
Outdated
Show resolved
Hide resolved
...pentelemetry-exporter-prometheus-remote-write/tests/test_prometheus_remote_write_exporter.py
Outdated
Show resolved
Hide resolved
9c932ae
to
f5499ce
Compare
...pentelemetry-exporter-prometheus-remote-write/tests/test_prometheus_remote_write_exporter.py
Outdated
Show resolved
Hide resolved
...pentelemetry-exporter-prometheus-remote-write/tests/test_prometheus_remote_write_exporter.py
Outdated
Show resolved
Hide resolved
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.
Well done! Just a request to remove unnecessary Mock
s.
f5499ce
to
dcf02ef
Compare
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.
Great job!
b6251fb
to
f249cc9
Compare
f199064
to
0dad10e
Compare
...orter-prometheus-remote-write/src/opentelemetry/exporter/prometheus_remote_write/__init__.py
Show resolved
Hide resolved
...orter-prometheus-remote-write/src/opentelemetry/exporter/prometheus_remote_write/__init__.py
Outdated
Show resolved
Hide resolved
...orter-prometheus-remote-write/src/opentelemetry/exporter/prometheus_remote_write/__init__.py
Outdated
Show resolved
Hide resolved
response.reason, | ||
str(response.content), | ||
) | ||
return MetricsExportResult.FAILURE |
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.
Are we going to be handling retries? Timeouts?, etc?
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
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.
A couple of questions I'd like to have answered before approving.
@@ -16,6 +16,9 @@ | |||
import re | |||
from typing import Dict, Sequence | |||
|
|||
import requests |
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.
should dependencies be added for python-snappy and requests?
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excluded python-snappy from install-requires for now.
data=message, | ||
headers=headers, | ||
auth=auth, | ||
timeout=self.timeout, |
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.
would be good to add the default timeout value to the class documentation
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this be wrapped in a try block?
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.
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
@@ -39,6 +39,8 @@ package_dir= | |||
=src | |||
packages=find_namespace: | |||
install_requires = | |||
protobuf >= 3.13.0 | |||
requests == 2.25.0 | |||
opentelemetry-api == 0.16.dev0 |
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.
Could you update these dependencies to 0.17.dev0 as well as the current version? It's causing some build failures.
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.
Updated
4847d6a
to
f9c341e
Compare
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.
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?
TestValidation
intest_prometheus_remote_write_exporter.py
Does This PR Require a Core Repo Change?
Checklist:
cc- @AzfaarQureshi , @alolita