Skip to content

Commit

Permalink
STAC-21205: drop properties, labels
Browse files Browse the repository at this point in the history
  • Loading branch information
fvlankvelt committed Apr 26, 2024
1 parent 2a22f99 commit dfa1a35
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 21 deletions.
2 changes: 1 addition & 1 deletion exporter/ststopologyexporter/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func newTopologyExporter(logger *zap.Logger, cfg component.Config) (*topologyExp
return nil, fmt.Errorf("invalid config passed to stackstateexporter: %T", cfg)
}
httpClient := http.Client{
Timeout: 5 * time.Second, // TODO configure timeout
Timeout: 5 * time.Second,
}

return &topologyExporter{logger: logger, httpClient: httpClient, cfg: stsCfg}, nil
Expand Down
33 changes: 15 additions & 18 deletions exporter/ststopologyexporter/internal/topology.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func (c *ComponentsCollection) AddResource(attrs *pcommon.Map) bool {
withEnvironment(attrs).
withName(attrs, "service.name").
withVersion(attrs, "service.version").
withTags(attrs, "telemetry.sdk"),
withTag(attrs, "service.namespace"),
})
c.serviceInstances = append(c.serviceInstances, &Component{
fmt.Sprintf("urn:opentelemetry:namespace/%s:service/%s:serviceInstance/%s", serviceNamespace.AsString(), serviceName.AsString(), serviceInstanceId.AsString()),
Expand All @@ -71,9 +71,8 @@ func (c *ComponentsCollection) AddResource(attrs *pcommon.Map) bool {
withEnvironment(attrs).
withName(attrs, "service.instance.id").
withVersion(attrs, "service.version").
withTags(attrs, "telemetry.sdk").
withTags(attrs, "telemetry.distro").
withProperties(attrs),
withTag(attrs, "service.namespace").
withTags(attrs),
})
return true
}
Expand Down Expand Up @@ -103,9 +102,7 @@ func newData() *ComponentData {
Layer: "",
Domain: "",
Environment: "",
Labels: []string{},
Tags: map[string]string{},
Properties: map[string]string{},
}
}

Expand All @@ -122,6 +119,14 @@ func (c *ComponentData) withName(attrs *pcommon.Map, key string) *ComponentData
return c
}

func (c *ComponentData) withTag(attrs *pcommon.Map, key string) *ComponentData {
value, ok := attrs.Get(key)
if ok {
c.Tags[key] = value.AsString()
}
return c
}

func (c *ComponentData) withVersion(attrs *pcommon.Map, key string) *ComponentData {
value, ok := attrs.Get(key)
if ok {
Expand All @@ -134,25 +139,17 @@ func (c *ComponentData) withEnvironment(attrs *pcommon.Map) *ComponentData {
value, ok := attrs.Get("deployment.environment")
if ok {
c.Environment = value.AsString()
c.Tags["deployment.environment"] = value.AsString()
}
return c
}
func (c *ComponentData) withTags(attrs *pcommon.Map, prefix string) *ComponentData {

func (c *ComponentData) withTags(attrs *pcommon.Map) *ComponentData {
attrs.Range(func(k string, v pcommon.Value) bool {
if len(k) >= len(prefix) && k[:len(prefix)] == prefix {
if _, ok := c.Tags[k]; !ok {
c.Tags[k] = v.AsString()
}
return true
})
return c
}

func (c *ComponentData) withProperties(attrs *pcommon.Map) *ComponentData {
m := make(map[string]string, attrs.Len())
attrs.Range(func(k string, v pcommon.Value) bool {
m[k] = v.AsString()
return true
})
c.Properties = m
return c
}
2 changes: 0 additions & 2 deletions exporter/ststopologyexporter/internal/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ type ComponentData struct {
Layer string `json:"layer"`
Domain string `json:"domain"`
Environment string `json:"environment"`
Labels []string `json:"labels"`
Tags map[string]string `json:"tags"`
Properties map[string]string `json:"properties"`
}

type Component struct {
Expand Down

0 comments on commit dfa1a35

Please sign in to comment.