@@ -50,24 +50,26 @@ func (c *count) ConsumeTraces(ctx context.Context, td ptrace.Traces) error {
5050 countMetrics .ResourceMetrics ().EnsureCapacity (td .ResourceSpans ().Len ())
5151 for i := 0 ; i < td .ResourceSpans ().Len (); i ++ {
5252 resourceSpan := td .ResourceSpans ().At (i )
53+ resourceAttrs := resourceSpan .Resource ().Attributes ()
5354 spansCounter := newCounter [ottlspan.TransformContext ](c .spansMetricDefs )
5455 spanEventsCounter := newCounter [ottlspanevent.TransformContext ](c .spanEventsMetricDefs )
5556
5657 for j := 0 ; j < resourceSpan .ScopeSpans ().Len (); j ++ {
5758 scopeSpan := resourceSpan .ScopeSpans ().At (j )
59+ scopeAttrs := scopeSpan .Scope ().Attributes ()
5860
5961 for k := 0 ; k < scopeSpan .Spans ().Len (); k ++ {
6062 span := scopeSpan .Spans ().At (k )
6163 spansCounter .updateTimestamp (span .StartTimestamp ())
6264 spansCounter .updateTimestamp (span .EndTimestamp ())
6365 sCtx := ottlspan .NewTransformContext (span , scopeSpan .Scope (), resourceSpan .Resource (), scopeSpan , resourceSpan )
64- multiError = errors .Join (multiError , spansCounter .update (ctx , span .Attributes (), sCtx ))
66+ multiError = errors .Join (multiError , spansCounter .update (ctx , span .Attributes (), scopeAttrs , resourceAttrs , sCtx ))
6567
6668 for l := 0 ; l < span .Events ().Len (); l ++ {
6769 event := span .Events ().At (l )
6870 spanEventsCounter .updateTimestamp (event .Timestamp ())
6971 eCtx := ottlspanevent .NewTransformContext (event , span , scopeSpan .Scope (), resourceSpan .Resource (), scopeSpan , resourceSpan )
70- multiError = errors .Join (multiError , spanEventsCounter .update (ctx , event .Attributes (), eCtx ))
72+ multiError = errors .Join (multiError , spanEventsCounter .update (ctx , event .Attributes (), scopeAttrs , resourceAttrs , eCtx ))
7173 }
7274 }
7375 }
@@ -98,16 +100,18 @@ func (c *count) ConsumeMetrics(ctx context.Context, md pmetric.Metrics) error {
98100 countMetrics .ResourceMetrics ().EnsureCapacity (md .ResourceMetrics ().Len ())
99101 for i := 0 ; i < md .ResourceMetrics ().Len (); i ++ {
100102 resourceMetric := md .ResourceMetrics ().At (i )
103+ resourceAttrs := resourceMetric .Resource ().Attributes ()
101104 metricsCounter := newCounter [ottlmetric.TransformContext ](c .metricsMetricDefs )
102105 dataPointsCounter := newCounter [ottldatapoint.TransformContext ](c .dataPointsMetricDefs )
103106
104107 for j := 0 ; j < resourceMetric .ScopeMetrics ().Len (); j ++ {
105108 scopeMetrics := resourceMetric .ScopeMetrics ().At (j )
109+ scopeAttrs := scopeMetrics .Scope ().Attributes ()
106110
107111 for k := 0 ; k < scopeMetrics .Metrics ().Len (); k ++ {
108112 metric := scopeMetrics .Metrics ().At (k )
109113 mCtx := ottlmetric .NewTransformContext (metric , scopeMetrics .Metrics (), scopeMetrics .Scope (), resourceMetric .Resource (), scopeMetrics , resourceMetric )
110- multiError = errors .Join (multiError , metricsCounter .update (ctx , pcommon .NewMap (), mCtx ))
114+ multiError = errors .Join (multiError , metricsCounter .update (ctx , pcommon .NewMap (), scopeAttrs , resourceAttrs , mCtx ))
111115
112116 //exhaustive:enforce
113117 switch metric .Type () {
@@ -117,39 +121,39 @@ func (c *count) ConsumeMetrics(ctx context.Context, md pmetric.Metrics) error {
117121 dp := dps .At (i )
118122 dataPointsCounter .updateTimestamp (dp .Timestamp ())
119123 dCtx := ottldatapoint .NewTransformContext (dp , metric , scopeMetrics .Metrics (), scopeMetrics .Scope (), resourceMetric .Resource (), scopeMetrics , resourceMetric )
120- multiError = errors .Join (multiError , dataPointsCounter .update (ctx , dp .Attributes (), dCtx ))
124+ multiError = errors .Join (multiError , dataPointsCounter .update (ctx , dp .Attributes (), scopeAttrs , resourceAttrs , dCtx ))
121125 }
122126 case pmetric .MetricTypeSum :
123127 dps := metric .Sum ().DataPoints ()
124128 for i := 0 ; i < dps .Len (); i ++ {
125129 dp := dps .At (i )
126130 dataPointsCounter .updateTimestamp (dp .Timestamp ())
127131 dCtx := ottldatapoint .NewTransformContext (dp , metric , scopeMetrics .Metrics (), scopeMetrics .Scope (), resourceMetric .Resource (), scopeMetrics , resourceMetric )
128- multiError = errors .Join (multiError , dataPointsCounter .update (ctx , dp .Attributes (), dCtx ))
132+ multiError = errors .Join (multiError , dataPointsCounter .update (ctx , dp .Attributes (), scopeAttrs , resourceAttrs , dCtx ))
129133 }
130134 case pmetric .MetricTypeSummary :
131135 dps := metric .Summary ().DataPoints ()
132136 for i := 0 ; i < dps .Len (); i ++ {
133137 dp := dps .At (i )
134138 dataPointsCounter .updateTimestamp (dp .Timestamp ())
135139 dCtx := ottldatapoint .NewTransformContext (dp , metric , scopeMetrics .Metrics (), scopeMetrics .Scope (), resourceMetric .Resource (), scopeMetrics , resourceMetric )
136- multiError = errors .Join (multiError , dataPointsCounter .update (ctx , dp .Attributes (), dCtx ))
140+ multiError = errors .Join (multiError , dataPointsCounter .update (ctx , dp .Attributes (), scopeAttrs , resourceAttrs , dCtx ))
137141 }
138142 case pmetric .MetricTypeHistogram :
139143 dps := metric .Histogram ().DataPoints ()
140144 for i := 0 ; i < dps .Len (); i ++ {
141145 dp := dps .At (i )
142146 dataPointsCounter .updateTimestamp (dp .Timestamp ())
143147 dCtx := ottldatapoint .NewTransformContext (dp , metric , scopeMetrics .Metrics (), scopeMetrics .Scope (), resourceMetric .Resource (), scopeMetrics , resourceMetric )
144- multiError = errors .Join (multiError , dataPointsCounter .update (ctx , dp .Attributes (), dCtx ))
148+ multiError = errors .Join (multiError , dataPointsCounter .update (ctx , dp .Attributes (), scopeAttrs , resourceAttrs , dCtx ))
145149 }
146150 case pmetric .MetricTypeExponentialHistogram :
147151 dps := metric .ExponentialHistogram ().DataPoints ()
148152 for i := 0 ; i < dps .Len (); i ++ {
149153 dp := dps .At (i )
150154 dataPointsCounter .updateTimestamp (dp .Timestamp ())
151155 dCtx := ottldatapoint .NewTransformContext (dp , metric , scopeMetrics .Metrics (), scopeMetrics .Scope (), resourceMetric .Resource (), scopeMetrics , resourceMetric )
152- multiError = errors .Join (multiError , dataPointsCounter .update (ctx , dp .Attributes (), dCtx ))
156+ multiError = errors .Join (multiError , dataPointsCounter .update (ctx , dp .Attributes (), scopeAttrs , resourceAttrs , dCtx ))
153157 }
154158 case pmetric .MetricTypeEmpty :
155159 multiError = errors .Join (multiError , fmt .Errorf ("metric %q: invalid metric type: %v" , metric .Name (), metric .Type ()))
@@ -183,16 +187,18 @@ func (c *count) ConsumeLogs(ctx context.Context, ld plog.Logs) error {
183187 countMetrics .ResourceMetrics ().EnsureCapacity (ld .ResourceLogs ().Len ())
184188 for i := 0 ; i < ld .ResourceLogs ().Len (); i ++ {
185189 resourceLog := ld .ResourceLogs ().At (i )
190+ resourceAttrs := resourceLog .Resource ().Attributes ()
186191 counter := newCounter [ottllog.TransformContext ](c .logsMetricDefs )
187192
188193 for j := 0 ; j < resourceLog .ScopeLogs ().Len (); j ++ {
189194 scopeLogs := resourceLog .ScopeLogs ().At (j )
195+ scopeAttrs := scopeLogs .Scope ().Attributes ()
190196
191197 for k := 0 ; k < scopeLogs .LogRecords ().Len (); k ++ {
192198 logRecord := scopeLogs .LogRecords ().At (k )
193199 counter .updateTimestamp (logRecord .Timestamp ())
194200 lCtx := ottllog .NewTransformContext (logRecord , scopeLogs .Scope (), resourceLog .Resource (), scopeLogs , resourceLog )
195- multiError = errors .Join (multiError , counter .update (ctx , logRecord .Attributes (), lCtx ))
201+ multiError = errors .Join (multiError , counter .update (ctx , logRecord .Attributes (), scopeAttrs , resourceAttrs , lCtx ))
196202 }
197203 }
198204
@@ -221,17 +227,19 @@ func (c *count) ConsumeProfiles(ctx context.Context, ld pprofile.Profiles) error
221227 countMetrics .ResourceMetrics ().EnsureCapacity (ld .ResourceProfiles ().Len ())
222228 for i := 0 ; i < ld .ResourceProfiles ().Len (); i ++ {
223229 resourceProfile := ld .ResourceProfiles ().At (i )
230+ resourceAttrs := resourceProfile .Resource ().Attributes ()
224231 counter := newCounter [ottlprofile.TransformContext ](c .profilesMetricDefs )
225232
226233 for j := 0 ; j < resourceProfile .ScopeProfiles ().Len (); j ++ {
227234 scopeProfile := resourceProfile .ScopeProfiles ().At (j )
235+ scopeAttrs := scopeProfile .Scope ().Attributes ()
228236
229237 for k := 0 ; k < scopeProfile .Profiles ().Len (); k ++ {
230238 profile := scopeProfile .Profiles ().At (k )
231239 counter .updateTimestamp (profile .Time ())
232240 pCtx := ottlprofile .NewTransformContext (profile , ld .Dictionary (), scopeProfile .Scope (), resourceProfile .Resource (), scopeProfile , resourceProfile )
233241 attributes := pprofile .FromAttributeIndices (ld .Dictionary ().AttributeTable (), profile , ld .Dictionary ())
234- multiError = errors .Join (multiError , counter .update (ctx , attributes , pCtx ))
242+ multiError = errors .Join (multiError , counter .update (ctx , attributes , scopeAttrs , resourceAttrs , pCtx ))
235243 }
236244 }
237245
0 commit comments