Add Prometheus Remote Write Exporter (3/6)#207
Conversation
a6732c4 to
ed1f7d8
Compare
ed1f7d8 to
e9e348d
Compare
ocelotl
left a comment
There was a problem hiding this comment.
Please take a look at the comments and check what can be refactored from the test cases. 👍
e9e348d to
b9cb195
Compare
07893f4 to
f971041
Compare
970212c to
51d4ca5
Compare
|
|
||
| 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.
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.
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.
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.
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.
f537701 to
96d22ae
Compare
|
All comments have been addressed @lzchen. |
96d22ae to
86d48f1
Compare
| "%s aggregator is not supported, record dropped", | ||
| aggregator_type, | ||
| ) | ||
| return None |
There was a problem hiding this comment.
I don't think we want to return here? We just want to skip the record.
There was a problem hiding this comment.
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.
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
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?
TestValidationintest_prometheus_remote_write_exporter.pyDoes This PR Require a Core Repo Change?
Checklist:
cc- @AzfaarQureshi , @alolita