Skip to content
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

Do not use the NS peer as a label #6344

Merged
merged 1 commit into from
Jun 29, 2023
Merged
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
2 changes: 1 addition & 1 deletion pkg/applicationserver/applicationserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,7 @@ func (as *ApplicationServer) downlinkQueueOp(ctx context.Context, ids *ttnpb.End
if err != nil {
as.registerDropDownlinks(ctx, ids, decrypted, err)
} else {
as.registerForwardDownlinks(ctx, ids, decrypted, encrypted, peer.Name())
as.registerForwardDownlinks(ctx, ids, decrypted, encrypted)
}
},
})
Expand Down
26 changes: 11 additions & 15 deletions pkg/applicationserver/observability.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (
"go.thethings.network/lorawan-stack/v3/pkg/log"
"go.thethings.network/lorawan-stack/v3/pkg/metrics"
"go.thethings.network/lorawan-stack/v3/pkg/ttnpb"
"google.golang.org/grpc/peer"
)

const (
Expand Down Expand Up @@ -149,9 +148,8 @@ var (
)

const (
subsystem = "as"
unknown = "unknown"
networkServer = "network_server"
subsystem = "as"
unknown = "unknown"
)

var asMetrics = &messageMetrics{
Expand All @@ -161,7 +159,7 @@ var asMetrics = &messageMetrics{
Name: "uplink_received_total",
Help: "Total number of received uplinks (join-accepts and data)",
},
[]string{networkServer},
[]string{},
),
uplinkForwarded: metrics.NewContextualCounterVec(
prometheus.CounterOpts{
Expand Down Expand Up @@ -211,7 +209,7 @@ var asMetrics = &messageMetrics{
Name: "downlink_forwarded_total",
Help: "Total number of forwarded downlinks",
},
[]string{networkServer},
[]string{},
),
downlinkDropped: metrics.NewContextualCounterVec(
prometheus.CounterOpts{
Expand Down Expand Up @@ -261,10 +259,6 @@ func (m messageMetrics) Collect(ch chan<- prometheus.Metric) {
}

func registerReceiveUp(ctx context.Context, msg *ttnpb.ApplicationUp) {
ns := "application"
if p, ok := peer.FromContext(ctx); ok {
ns = p.Addr.String()
}
switch msg.Up.(type) {
case *ttnpb.ApplicationUp_JoinAccept:
events.Publish(evtReceiveJoinAccept.NewWithIdentifiersAndData(ctx, msg.EndDeviceIds, nil))
Expand All @@ -273,7 +267,7 @@ func registerReceiveUp(ctx context.Context, msg *ttnpb.ApplicationUp) {
default:
return
}
asMetrics.uplinkReceived.WithLabelValues(ctx, ns).Inc()
asMetrics.uplinkReceived.WithLabelValues(ctx).Inc()
}

func registerForwardUp(ctx context.Context, msg *ttnpb.ApplicationUp) {
Expand Down Expand Up @@ -330,9 +324,9 @@ func registerReceiveDownlinks(ctx context.Context, ids *ttnpb.EndDeviceIdentifie
}
}

func registerForwardDownlink(ctx context.Context, ids *ttnpb.EndDeviceIdentifiers, msg *ttnpb.ApplicationDownlink, ns string) {
func registerForwardDownlink(ctx context.Context, ids *ttnpb.EndDeviceIdentifiers, msg *ttnpb.ApplicationDownlink) {
events.Publish(evtForwardDataDown.NewWithIdentifiersAndData(ctx, ids, msg))
asMetrics.downlinkForwarded.WithLabelValues(ctx, ns).Inc()
asMetrics.downlinkForwarded.WithLabelValues(ctx).Inc()
}

func registerDropDownlink(ctx context.Context, ids *ttnpb.EndDeviceIdentifiers, msg *ttnpb.ApplicationDownlink, err error) {
Expand Down Expand Up @@ -369,7 +363,9 @@ func (as *ApplicationServer) registerDropDownlinks(ctx context.Context, ids *ttn
}
}

func (as *ApplicationServer) registerForwardDownlinks(ctx context.Context, ids *ttnpb.EndDeviceIdentifiers, decrypted, encrypted []*ttnpb.ApplicationDownlink, peerName string) {
func (as *ApplicationServer) registerForwardDownlinks(
ctx context.Context, ids *ttnpb.EndDeviceIdentifiers, decrypted, encrypted []*ttnpb.ApplicationDownlink,
) {
for _, item := range decrypted {
if err := as.publishUp(ctx, &ttnpb.ApplicationUp{
EndDeviceIds: ids,
Expand All @@ -382,6 +378,6 @@ func (as *ApplicationServer) registerForwardDownlinks(ctx context.Context, ids *
}
}
for _, item := range encrypted {
registerForwardDownlink(ctx, ids, item, peerName)
registerForwardDownlink(ctx, ids, item)
}
}
Loading