-
Notifications
You must be signed in to change notification settings - Fork 621
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 (3/6) #207
Add Prometheus Remote Write Exporter (3/6) #207
Conversation
a6732c4
to
ed1f7d8
Compare
ed1f7d8
to
e9e348d
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.
Please take a look at the comments and check what can be refactored from the test cases. 👍
...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
...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
...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
...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
e9e348d
to
b9cb195
Compare
07893f4
to
f971041
Compare
970212c
to
51d4ca5
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
...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
Show resolved
Hide resolved
...orter-prometheus-remote-write/src/opentelemetry/exporter/prometheus_remote_write/__init__.py
Show resolved
Hide resolved
|
||
def add_label(label_name, label_value): | ||
# Label name must contain only alphanumeric characters and underscores | ||
label_name = re.sub("[^\\w_]", "_", label_name) |
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'm wondering if we might get labels that are supposed to be unique but will be dropped due to removal of these characters. Is the alphanumeric + underscores limitation of the labels specific for Prometheus?
e.g.
testing
and ${testing}
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 limitation is specific to the TimeSeries type https://prometheus.io/docs/concepts/data_model/ . You bring up a valid point. Since the non-alphanumeric characters are replaced with underscores: '$testing' and '_testing' will be considered the same label which would be an issue. Also, a label_name cannot start with two underscores. Would it be better to validate label names (raise Error) or add more complex sanitizing? I am not quite sure how to prevent duplicates when addressing label names that contain non-alphanumeric characters.
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 the limitation is Prometheus specific, I am okay with the current implementation. The only problem was if it were a limitation we imposed on the OT side, then Prometheus users would have unexpected behaviour. But if it's on the Prometheus side, then user's should EXPECT this behaviour.
I wonder in this case if we should DROP labels that defy the TimeSeries
definition (and maybe log a warning), instead of only dropping the duplicate.
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.
In the rare case this occurs, I think whoever is misusing the exporter will value the label with the non-ascii characters as much as the valid one, so I suggest dropping the duplicate but logging a warning that after sanitizing, a duplicate label had to be dropped.
...orter-prometheus-remote-write/src/opentelemetry/exporter/prometheus_remote_write/__init__.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.
Some comments.
f537701
to
96d22ae
Compare
All comments have been addressed @lzchen. |
...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
96d22ae
to
86d48f1
Compare
"%s aggregator is not supported, record dropped", | ||
aggregator_type, | ||
) | ||
return None |
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 don't think we want to return here? We just want to skip the record.
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 thought to skip the record, I would need to return both here and in the calling "export" method. I was planning on adding this to the export method:
if timeseries is None:
return
Is there a better way to skip the record from an inner method?
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 misunderstood it as skip the batch. I fixed this to only skip the record and log a warning. I will add an additional check to not send empty requests in the subsequent PR.
7e6ae1b
to
fd8bb30
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.
Nice!
fd8bb30
to
8750f9d
Compare
8750f9d
to
3dce1b6
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