WithNamespace adds containerd namespace attribute to spans when available. It is best-effort: if namespace is not present in the context, it does nothing.
(ctx context.Context)
| 26 | // WithNamespace adds containerd namespace attribute to spans when available. |
| 27 | // It is best-effort: if namespace is not present in the context, it does nothing. |
| 28 | func WithNamespace(ctx context.Context) SpanOpt { |
| 29 | return func(config *StartConfig) { |
| 30 | ns, err := namespaces.NamespaceRequired(ctx) |
| 31 | if err != nil { |
| 32 | return |
| 33 | } |
| 34 | config.spanOpts = append(config.spanOpts, |
| 35 | trace.WithAttributes(Attribute("namespace", ns)), |
| 36 | ) |
| 37 | } |
| 38 | } |
no test coverage detected
searching dependent graphs…