Addition of pcp2opentelemetry tool
Supports translation of pcp metrics into opentelemetry format. Supports opentelemetry protocol http json.
Updated relevent qa tests; added one new one (1977) to test pcp2opentelemetry http functionality.
Added man page and makefile. Includes updates and changes from review.
@lmchilton this is failing in the CI build because the new pcp2opentelemetry tool subdir is missing from the src/GNUmakefile - this patch should fix it:
$ git diff
src/GNUmakefile
--- /tmp/git-blob-wXFv0g/GNUmakefile 2025-06-12 10:07:23.480332266 +1000
+++ src/GNUmakefile 2025-06-12 09:55:30.834563600 +1000
@@ -65,6 +65,7 @@ OTHER_SUBDIRS += \
pcp2influxdb \
pcp2json \
pcp2openmetrics \
+ pcp2opentelemetry \
pcp2spark \
pcp2xlsx \
pcp2xml \
Need an entry in qa/groups for the new test 1977. Without the entry the the 1977 test doesn't get installed. When looking through the test qa/1131.out wondering why the change adding "age:" {...} on the pcp2openmetrics?
The "age": .... stuff doesn't look like it should be there in qa/1131.out
qa/group needs entry for pcp2openmetrics.
Need to have a entry in qa/group for 1977, something like:
1977 pcp2openmetrics python pcp2xxx local
Should test 1977 also check that -s option with an option greater than 1 works and doesn't hang (like the recent issue with qa/1131, PR#2243).
There be some substitutions in qa/1977.out:
- for the "server.address" to replace the 54322 in "http://localhost:54322/receive". PROXYPORT?
- "groupid" 4209557 should have generic string replacing it. GID?
- "userid" 4209557 should have a generic string replacing it. UID?
Looking over the pcp2opentelemetry.py file based on the pcp2openmetric
Issues with the PM_DEBUG_APPL1 in pcp2opentelemetry.py:
$ pcp2opentelemetry
Traceback (most recent call last):
File "/usr/sbin/pcp2opentelemetry", line 33, in <module>
from cpmapi import PM_CONTEXT_ARCHIVE, PM_INDOM_NULL, PM_DEBUG_APPL1, PM_TIME_SEC
ImportError: cannot import name 'PM_DEBUG_APPL1' from 'cpmapi' (/usr/lib64/python3.13/site-packages/cpmapi.cpython-313-x86_64-linux-gnu.so)
The PCP QA tests just compare the output to "GOOD" output. Is there tooling somewhere that will check that output generated is valide opentelemetry JSON output?
Is the following function printing the correct thing for num >= 2 || num < 0?
def dimCount_units(num):
if num == 0:
return "count"
elif num == 1:
return "count x 10"
else:
return "count x 10%d" % num
The PCP QA tests just compare the output to "GOOD" output.
They also check the test return code FWIW.
Is there tooling somewhere that will check that output generated is valid opentelemetry JSON output?
I don't think so, from a search and putting the question to a current AI.
Is the following function printing the correct thing for num >= 2 || num < 0?
AIUI OpenTelemetry units must be in UCUM format - I think that whole function needs a rethink, from my understanding of the standard everything its producing is NQR. I have some pmUnits->UCUM C code I'll put into a PR shortly that may provide a starting point for new python code.