Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/pcp2openmetrics/pcp2openmetrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,10 @@ def openmetrics_labels(inst, name, desc, labels):
if self.url:
auth = None
if self.http_user and self.http_pass:
if not self.url.lower().startswith("https://"):
raise ValueError(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could break existing setups - should this just be a warning not an error?

"HTTP Basic Authentication requires an HTTPS connection to prevent leaking credentials."
)
auth = requests.auth.HTTPBasicAuth(self.http_user, self.http_pass)
try:
timeout = self.http_timeout
Expand Down
13 changes: 10 additions & 3 deletions src/pcp2opentelemetry/pcp2opentelemetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -531,14 +531,16 @@ def UCUM_count_prefix(scale):
if units.dimSpace != 1:
ucum_string += "%d" % units.dimSpace
first_unit = 0
elif units.dimTime:

if units.dimTime:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do these changes impact on tests? If not, why not? :)

if not first_unit:
ucum_string += "."
first_unit = 0
ucum_string += "%s" % UCUM_time_prefix(units.scaleTime)
if units.dimTime != 1:
ucum_string += "%d" % units.dimTime
elif units.dimCount:

if units.dimCount:
if not first_unit:
ucum_string += "."
first_unit = 0
Expand All @@ -549,7 +551,8 @@ def UCUM_count_prefix(scale):
ucum_string += "%s{count}" % prefix
if units.dimCount != 1:
ucum_string += "%d" % units.scaleCount
else:

if first_unit:
ucum_string = "1" # dimensionless

return ucum_string
Expand Down Expand Up @@ -678,6 +681,10 @@ def scope_metric_function(results):
if self.url:
auth = None
if self.http_user and self.http_pass:
if not self.url.lower().startswith("https://"):
raise ValueError(
"HTTP Basic Authentication requires an HTTPS connection to prevent leaking credentials."
)
auth = requests.auth.HTTPBasicAuth(self.http_user, self.http_pass)
try:
timeout = self.http_timeout
Expand Down
Loading