(batches []*v1.ResourceSpans, cfg *LogSpansConfig, logger log.Logger)
| 866 | } |
| 867 | |
| 868 | func logSpans(batches []*v1.ResourceSpans, cfg *LogSpansConfig, logger log.Logger) { |
| 869 | for _, b := range batches { |
| 870 | loggerWithAtts := logger |
| 871 | |
| 872 | if cfg.IncludeAllAttributes { |
| 873 | for _, a := range b.Resource.GetAttributes() { |
| 874 | loggerWithAtts = log.With( |
| 875 | loggerWithAtts, |
| 876 | "span_"+strutil.SanitizeLabelName(a.GetKey()), |
| 877 | util.StringifyAnyValue(a.GetValue())) |
| 878 | } |
| 879 | } |
| 880 | |
| 881 | for _, ils := range b.ScopeSpans { |
| 882 | for _, s := range ils.Spans { |
| 883 | if cfg.FilterByStatusError && s.Status.Code != v1.Status_STATUS_CODE_ERROR { |
| 884 | continue |
| 885 | } |
| 886 | |
| 887 | logSpan(s, cfg.IncludeAllAttributes, loggerWithAtts) |
| 888 | } |
| 889 | } |
| 890 | } |
| 891 | } |
| 892 | |
| 893 | func logSpan(s *v1.Span, allAttributes bool, logger log.Logger) { |
| 894 | if allAttributes { |
no test coverage detected