vitalics / playwright-prometheus-remote-write-reporter

Playwright prometheus remote write reporter. Send your metrics to prometheus in realtime.
https://www.npmjs.com/package/playwright-prometheus-remote-write-reporter?activeTab=readme
MIT License
11 stars 3 forks source link

Add external_labels option or static label 'instance' - prevent out of order samples or duplicate samples for timestamp with multiple instances of pw/reporter #9

Closed xTrekStorex closed 3 months ago

xTrekStorex commented 3 months ago

Is your feature request related to a problem? Please describe. When more than one instance of playwright with this reporter are run in parallel, e.g. when tests are spread across multiple instances via sharding, the remote written timeseries clash in prometheus with either out of order samples or duplicate samples for timestamp. This is mainly caused by metrics like pw_tests_pass_count not setting unique labels. For scrape targets this is usually worked around using the instance and job labels. For remote write there usually are external_labels which can be added to each series - e.g. source_prometheus.

Describe the solution you'd like I'd like an extra_labels option for the reporter. These could be done like headers and passed as 'labels' in options/config for prometheus-remote-write just by adding 'labels' to PrometheusOptions & the constructor.

Describe alternatives you've considered A hardcoded label instance=$hostname or similar to identify the instance writing to prometheus. Added here to be inherited by all metrics: https://github.com/vitalics/playwright-prometheus-remote-write-reporter/blob/main/src/helpers.ts#L15

vitalics commented 3 months ago

Hi, thanks for your issue. Could you please add repo with steps, it helps me improve this library

xTrekStorex commented 3 months ago

Hi, thanks for your issue. Could you please add repo with steps, it helps me improve this library

Hi, do you mean #10 ?