Repository navigation
Conversation
json_ietf encodes YANG uint64/int64/decimal64 as JSON strings. The OTLP converter previously treated every string as an enum (value=1 + value attribute), causing wrong Prom values and label cardinality explosion. Prefer numeric datapoints when the string parses, matching prometheus_output.
karimra
left a comment
There was a problem hiding this comment.
Thanks for this. The direction is correct but it needs a small change:
The change bypasses strings-as-attributes. The default for is false, that means string values are dropped. With this change, any string that parses as a number becomes a data point, even when the option is false. So users on the default config will see new metrics that did not exist before.
I think the numeric check should run after the strings-as-attributes gate, or use its own option.
|
Thanks for taking a look. I went back and forth on this one and I think the gate order is actually the whole bug, so I want to lay out why before I change it. The prometheus output doesn't have the gate problem. If the numeric check moves behind the gate, the default config stays broken. It only fixes the people who already turned the flag on, which is the config that also turns every enum into a label. So that version doesn't really fix the thing I hit. You're right that this is a behavior change for defaults though. People on json_ietf with the flag off will start seeing series they don't have today. I'd argue that's the fix rather than a side effect, and it makes OTLP match what prom already does, but I'm happy to call it out as a behavior change in the changelog and docs. If you'd still rather have it behind its own option I can add one, something like One limit worth having on the record either way: once the value has been through json.Unmarshal there's no type left on it, so a YANG string leaf whose text happens to be "100" will become a metric too. Prom has that same collision today and the only real fix is checking the leaf type against a loaded model, which is a different change. Let me know which way you want it and I'll update the PR. |
…rings The review asked for a dedicated option so numeric JSON strings do not bypass strings-as-attributes. The option defaults to true, so json_ietf uint64/int64/decimal64 stay numeric samples on the default config. Set it false to restore the previous drop-or-attribute behavior. Co-authored-by: Cursor <cursoragent@cursor.com>
|
Updated with a dedicated option, Putting the numeric check behind Docs call out the behavior change for existing json_ietf users, and the remaining limit: a YANG string leaf whose text happens to be numeric is also exported as a number, same as the Prometheus output. Distinguishing that needs the leaf type from a loaded model.
|
This change aligns the OTEL output with the way the Prometheus output works.
json_ietf encodes YANG uint64/int64/decimal64 as JSON strings. The OTLP converter previously treated every string as an enum (value=1 + value attribute), causing wrong Prom values and label cardinality explosion. Prefer numeric datapoints when the string parses, matching prometheus_output.