-
Notifications
You must be signed in to change notification settings - Fork 66
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
feat: Allow custom prometheus info metric #83
Conversation
614dbe5
to
b8d0567
Compare
Signed-off-by: Rafael Vasquez <[email protected]>
2334e98
to
92a6a7e
Compare
Signed-off-by: Rafael Vasquez <[email protected]>
Signed-off-by: Rafael Vasquez <[email protected]>
Signed-off-by: Rafael Vasquez <[email protected]>
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.
@rafvasq it doesn't look like you addressed my earlier comment about resolving env vars.
String[] labelNames = infoMetricParams.keySet().toArray(new String[0]); | ||
String[] labelValues = infoMetricParams.values().toArray(new String[0]); |
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 it's a great idea to rely on the fact that the passed in hashmap is ordered. For a regular hashmap there's no guarantee these names/values will end up in the same order. Better to create two empty arrays of the correct size prior to the loop above and just populate the names/values in the loop.
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 was using a linkedhashmap here to preserve the order, I made it a bit more obvious now. Interested to know what you think or if the array creation method would still be better.
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.
Yep I did see the LinkedHashMap but I still think it's cleaner not require it as the type. You could do:
String[] labelNames = infoMetricParams.keySet().toArray(String[]::new);
String[] labelValues = Stream.of(labelNames).map(infoMetricParams::get).toArray(String[]::new);
Signed-off-by: Rafael Vasquez <[email protected]>
@njhill thanks for the comments and patience, it's ready for another pass. I believe I'm now resolving the env vars as expected. |
Signed-off-by: Rafael Vasquez <[email protected]>
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.
Thanks @rafvasq I think it's almost there
String[] labelNames = infoMetricParams.keySet().toArray(new String[0]); | ||
String[] labelValues = infoMetricParams.values().toArray(new String[0]); |
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.
Yep I did see the LinkedHashMap but I still think it's cleaner not require it as the type. You could do:
String[] labelNames = infoMetricParams.keySet().toArray(String[]::new);
String[] labelValues = Stream.of(labelNames).map(infoMetricParams::get).toArray(String[]::new);
Signed-off-by: Rafael Vasquez <[email protected]>
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: njhill, rafvasq The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/lgtm |
Motivation
Allow the generation of an "info" metric by way of environment variables captured as
Gauge
metric set up during container startupModifications
MMESH_CUSTOM_ENV_VAR
inModelMeshEnvVars
infoMetricParams
and logic to parse and pass the info to prometheus inModelMesh
Gauge
using the parsed label names and values inMetrics
pom.xml
for testing and related test inModelMeshMetricsTest
Result
<metricname>[;label1=envVarWithValueforLabel1,label2=envVarWithValueforLabel2,...,labelN=envVarWithValueforLabelN,]
if provided.