MCPcopy Create free account
hub / github.com/docker/compose / ContainerOptions

Function ContainerOptions

internal/tracing/attributes.go:146–160  ·  view source on GitHub ↗

ContainerOptions returns common attributes from a Moby container. For convenience, it's returned as a SpanOptions object to allow it to be passed directly to the wrapping helper methods in this package such as SpanWrapFunc.

(ctr container.Summary)

Source from the content-addressed store, hash-verified

144// passed directly to the wrapping helper methods in this package such as
145// SpanWrapFunc.
146func ContainerOptions(ctr container.Summary) SpanOptions {
147 attrs := []attribute.KeyValue{
148 attribute.String("container.id", ctr.ID),
149 attribute.String("container.image", ctr.Image),
150 unixTimeAttr("container.created_at", ctr.Created),
151 }
152
153 if len(ctr.Names) != 0 {
154 attrs = append(attrs, attribute.String("container.name", strings.TrimPrefix(ctr.Names[0], "/")))
155 }
156
157 return []trace.SpanStartEventOption{
158 trace.WithAttributes(attrs...),
159 }
160}
161
162func keys[T any](m map[string]T) []string {
163 out := make([]string, 0, len(m))

Callers

nothing calls this directly

Calls 2

unixTimeAttrFunction · 0.85
StringMethod · 0.45

Tested by

no test coverage detected