MCPcopy
hub / github.com/docker/compose / ServiceOptions

Function ServiceOptions

internal/tracing/attributes.go:110–139  ·  view source on GitHub ↗

ServiceOptions returns common attributes from a Compose service. 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.

(service types.ServiceConfig)

Source from the content-addressed store, hash-verified

108// passed directly to the wrapping helper methods in this package such as
109// SpanWrapFunc.
110func ServiceOptions(service types.ServiceConfig) SpanOptions {
111 attrs := []attribute.KeyValue{
112 attribute.String("service.name", service.Name),
113 attribute.String("service.image", service.Image),
114 attribute.StringSlice("service.networks", keys(service.Networks)),
115 attribute.StringSlice("service.models", keys(service.Models)),
116 }
117
118 configNames := make([]string, len(service.Configs))
119 for i := range service.Configs {
120 configNames[i] = service.Configs[i].Source
121 }
122 attrs = append(attrs, attribute.StringSlice("service.configs", configNames))
123
124 secretNames := make([]string, len(service.Secrets))
125 for i := range service.Secrets {
126 secretNames[i] = service.Secrets[i].Source
127 }
128 attrs = append(attrs, attribute.StringSlice("service.secrets", secretNames))
129
130 volNames := make([]string, len(service.Volumes))
131 for i := range service.Volumes {
132 volNames[i] = service.Volumes[i].Source
133 }
134 attrs = append(attrs, attribute.StringSlice("service.volumes", volNames))
135
136 return []trace.SpanStartEventOption{
137 trace.WithAttributes(attrs...),
138 }
139}
140
141// ContainerOptions returns common attributes from a Moby container.
142//

Callers

nothing calls this directly

Calls 2

keysFunction · 0.85
StringMethod · 0.45

Tested by

no test coverage detected