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)
| 144 | // passed directly to the wrapping helper methods in this package such as |
| 145 | // SpanWrapFunc. |
| 146 | func 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 | |
| 162 | func keys[T any](m map[string]T) []string { |
| 163 | out := make([]string, 0, len(m)) |
nothing calls this directly
no test coverage detected