Skip to content

Commit

Permalink
STAC-21209: report client and server side separately
Browse files Browse the repository at this point in the history
  • Loading branch information
fvlankvelt committed Apr 26, 2024
1 parent 7bd8d0c commit 478c404
Showing 1 changed file with 29 additions and 8 deletions.
37 changes: 29 additions & 8 deletions exporter/ststopologyexporter/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (

"github.com/stackvista/sts-opentelemetry-collector/exporter/ststopologyexporter/internal"
"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/pdata/pcommon"
"go.opentelemetry.io/collector/pdata/pmetric"
"go.uber.org/zap"
)
Expand Down Expand Up @@ -82,17 +83,37 @@ func (t *topologyExporter) ConsumeMetrics(ctx context.Context, md pmetric.Metric
continue
}
connAttrs := m.Sum().DataPoints().At(0).Attributes()
sts_api_key_value, key_exists := connAttrs.Get("client_sts_api_key")
if !key_exists {
log.Error("Configuration error - no sts_api_key available on servicegraph metric")
return errInternal
client_api_key_value, client_key_exists := connAttrs.Get("client_sts_api_key")
var client_api_key string
if client_key_exists {
client_api_key = client_api_key_value.AsString()
}
server_api_key_value, server_key_exists := connAttrs.Get("server_sts_api_key")
var server_api_key string
if server_key_exists {
server_api_key = server_api_key_value.AsString()
}
if !client_key_exists && !server_key_exists {
log.Warn("No sts_api_key attributes, found:")
connAttrs.Range(func(k string, v pcommon.Value) bool {
log.Warn(" attr", zap.String(k, v.AsString()))
return true
})
continue
}
sts_api_key := sts_api_key_value.AsString()
connAttrs.Remove("client_sts_api_key")
connAttrs.Remove("server_sts_api_key")
collection := getOrDefault(componentsByApiKey, sts_api_key)
if !collection.AddConnection(&connAttrs) {
log.Warn("Unable to add connection from servicegraphconnector")
if client_key_exists {
collection := getOrDefault(componentsByApiKey, client_api_key)
if !collection.AddConnection(&connAttrs) {
log.Warn("Unable to add connection from servicegraphconnector to client")
}
}
if server_key_exists {
collection := getOrDefault(componentsByApiKey, server_api_key)
if !collection.AddConnection(&connAttrs) {
log.Warn("Unable to add connection from servicegraphconnector to server")
}
}
}
break
Expand Down

0 comments on commit 478c404

Please sign in to comment.