Skip to content

add capability for keyed paths#39

Merged
LarsxGitHub merged 1 commit intoopenconfig:mainfrom
LarsxGitHub:main
Mar 10, 2026
Merged

add capability for keyed paths#39
LarsxGitHub merged 1 commit intoopenconfig:mainfrom
LarsxGitHub:main

Conversation

@LarsxGitHub
Copy link
Contributor

@LarsxGitHub LarsxGitHub commented Mar 10, 2026

This PR extends CLIO with support for keyed gNMI paths. The idea is to leverage the Metric attributes to encode the keys in PathElem maps as <PathElemName><attrSep><PathElemMapKey>, e.g., interface.name and then copy over the respective value.

On the telemetry-generating side this looks as follows:

// Inside a function where you record a metric
counter, _ := meter.Int64Counter("interfaces.interface.afisafis.afisafi.value")

// Key-value pairs describing this specific metric event
metricAttributes := []attribute.KeyValue{
    attribute.String("interface.name", "Ethernet1/1/1"),
    attribute.String("interface.speed", "100Mbps"),
    attribute.String("afisafi.name", "IPV4_UNICAST"),
    attribute.String("yolo-I-can't-be-matched", "ever")
}

counter.Add(ctx, bytesReceived, metric.WithAttributes(metricAttributes...))

which translates to the following gNMI path:

[]*gpb.PathElem{
    {Name: "interfaces"},
    {Name: "interface", Key:  map[string]string{"name": "Ethernet1/1/1", "speed": "100Mbps"}},
    {Name: "afisafis"}, 
    {Name: "afisafi", Key:  map[string]string{"name": "IPV4_UNICAST"}}, 
    {Name: "value", Key:  map[string]string{"yolo-I-can't-be-matched": "ever"}},
}

Notably, to stay consistent with the existing code the following two caveats apply:
(1) if the update path starts with "container", that PathElem is skipped (as "container" is assumed to be in the prefix)
(2) If an attribute can not be matched, it is assigned to the last PathElem

@LarsxGitHub LarsxGitHub requested a review from alshabib March 10, 2026 20:07
@LarsxGitHub LarsxGitHub merged commit 0b12e66 into openconfig:main Mar 10, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants