mirror of https://github.com/docker/compose.git
otel: add `include` to project up span
Flatten the list of included files and add as a slice attribute. Signed-off-by: Milas Bowman <milas.bowman@docker.com>
This commit is contained in:
parent
3b294bfdda
commit
c79f67fead
|
@ -20,6 +20,8 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/docker/compose/v2/pkg/utils"
|
||||||
|
|
||||||
"github.com/compose-spec/compose-go/types"
|
"github.com/compose-spec/compose-go/types"
|
||||||
moby "github.com/docker/docker/api/types"
|
moby "github.com/docker/docker/api/types"
|
||||||
"go.opentelemetry.io/otel/attribute"
|
"go.opentelemetry.io/otel/attribute"
|
||||||
|
@ -73,6 +75,7 @@ func ProjectOptions(proj *types.Project) SpanOptions {
|
||||||
attribute.StringSlice("project.secrets", proj.SecretNames()),
|
attribute.StringSlice("project.secrets", proj.SecretNames()),
|
||||||
attribute.StringSlice("project.configs", proj.ConfigNames()),
|
attribute.StringSlice("project.configs", proj.ConfigNames()),
|
||||||
attribute.StringSlice("project.extensions", keys(proj.Extensions)),
|
attribute.StringSlice("project.extensions", keys(proj.Extensions)),
|
||||||
|
attribute.StringSlice("project.includes", flattenIncludeReferences(proj.IncludeReferences)),
|
||||||
}
|
}
|
||||||
return []trace.SpanStartEventOption{
|
return []trace.SpanStartEventOption{
|
||||||
trace.WithAttributes(attrs...),
|
trace.WithAttributes(attrs...),
|
||||||
|
@ -150,3 +153,13 @@ func timeAttr(key string, value time.Time) attribute.KeyValue {
|
||||||
func unixTimeAttr(key string, value int64) attribute.KeyValue {
|
func unixTimeAttr(key string, value int64) attribute.KeyValue {
|
||||||
return timeAttr(key, time.Unix(value, 0).UTC())
|
return timeAttr(key, time.Unix(value, 0).UTC())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func flattenIncludeReferences(includeRefs map[string][]types.IncludeConfig) []string {
|
||||||
|
ret := utils.NewSet[string]()
|
||||||
|
for _, included := range includeRefs {
|
||||||
|
for i := range included {
|
||||||
|
ret.AddAll(included[i].Path...)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret.Elements()
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue