Skip to content

Commit e049f19

Browse files
committed
fix count and signaltometrics connectors
1 parent 1e2b677 commit e049f19

File tree

4 files changed

+50
-144
lines changed

4 files changed

+50
-144
lines changed

connector/countconnector/connector.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,8 +216,8 @@ func (c *count) ConsumeProfiles(ctx context.Context, ld pprofile.Profiles) error
216216
for k := 0; k < scopeProfile.Profiles().Len(); k++ {
217217
profile := scopeProfile.Profiles().At(k)
218218

219-
pCtx := ottlprofile.NewTransformContext(profile, scopeProfile.Scope(), resourceProfile.Resource(), scopeProfile, resourceProfile)
220-
attributes := pprofile.FromAttributeIndices(profile.AttributeTable(), profile)
219+
pCtx := ottlprofile.NewTransformContext(profile, ld.ProfilesDictionary(), scopeProfile.Scope(), resourceProfile.Resource(), scopeProfile, resourceProfile)
220+
attributes := pprofile.FromAttributeIndices(ld.ProfilesDictionary().AttributeTable(), profile)
221221
multiError = errors.Join(multiError, counter.update(ctx, attributes, pCtx))
222222
}
223223
}

connector/countconnector/testdata/profiles/input.yaml

Lines changed: 24 additions & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -10,58 +10,31 @@ resourceProfiles:
1010
scopeProfiles:
1111
- profiles:
1212
- attributeIndices: [0, 1]
13-
attributeTable:
14-
- key: profile.required
15-
value:
16-
stringValue: foo
17-
- key: profile.optional
18-
value:
19-
stringValue: bar
2013
sample:
2114
- locationsLength: 0
2215
timestampsUnixNano: ["0"]
2316
sampleType:
2417
- unitStrindex: 0
25-
stringTable:
26-
- count
2718
duration: 10000
28-
- attributeIndices: [0, 1]
29-
attributeTable:
30-
- key: profile.required
31-
value:
32-
stringValue: foo
33-
- key: profile.optional
34-
value:
35-
stringValue: notbar
19+
- attributeIndices: [0, 2]
3620
sample:
3721
- locationsLength: 0
3822
timestampsUnixNano: ["0"]
3923
sampleType:
4024
- unitStrindex: 0
41-
stringTable:
42-
- count
4325
duration: 10000
44-
- attributeIndices: [0]
45-
attributeTable:
46-
- key: profile.required
47-
value:
48-
stringValue: notfoo
26+
- attributeIndices: [3]
4927
sample:
5028
- locationsLength: 0
5129
timestampsUnixNano: ["0"]
5230
sampleType:
5331
- unitStrindex: 0
54-
stringTable:
55-
- count
5632
- attributeIndices: []
57-
attributeTable: []
5833
sample:
5934
- locationsLength: 0
6035
timestampsUnixNano: ["0"]
6136
sampleType:
6237
- unitStrindex: 0
63-
stringTable:
64-
- count
6538
duration: 100
6639
scope: {}
6740

@@ -76,58 +49,31 @@ resourceProfiles:
7649
scopeProfiles:
7750
- profiles:
7851
- attributeIndices: [0, 1]
79-
attributeTable:
80-
- key: profile.required
81-
value:
82-
stringValue: foo
83-
- key: profile.optional
84-
value:
85-
stringValue: bar
8652
sample:
8753
- locationsLength: 0
8854
timestampsUnixNano: ["0"]
8955
sampleType:
9056
- unitStrindex: 0
91-
stringTable:
92-
- count
9357
duration: 10000
94-
- attributeIndices: [0, 1]
95-
attributeTable:
96-
- key: profile.required
97-
value:
98-
stringValue: foo
99-
- key: profile.optional
100-
value:
101-
stringValue: notbar
58+
- attributeIndices: [0, 2]
10259
sample:
10360
- locationsLength: 0
10461
timestampsUnixNano: ["0"]
10562
sampleType:
10663
- unitStrindex: 0
107-
stringTable:
108-
- count
10964
duration: 10000
110-
- attributeIndices: [0]
111-
attributeTable:
112-
- key: profile.required
113-
value:
114-
stringValue: notfoo
65+
- attributeIndices: [3]
11566
sample:
11667
- locationsLength: 0
11768
timestampsUnixNano: ["0"]
11869
sampleType:
11970
- unitStrindex: 0
120-
stringTable:
121-
- count
12271
- attributeIndices: []
123-
attributeTable: []
12472
sample:
12573
- locationsLength: 0
12674
timestampsUnixNano: ["0"]
12775
sampleType:
12876
- unitStrindex: 0
129-
stringTable:
130-
- count
13177
duration: 100
13278
scope: {}
13379

@@ -139,116 +85,78 @@ resourceProfiles:
13985
scopeProfiles:
14086
- profiles:
14187
- attributeIndices: [0, 1]
142-
attributeTable:
143-
- key: profile.required
144-
value:
145-
stringValue: foo
146-
- key: profile.optional
147-
value:
148-
stringValue: bar
14988
sample:
15089
- locationsLength: 0
15190
timestampsUnixNano: ["0"]
15291
sampleType:
15392
- unitStrindex: 0
154-
stringTable:
155-
- count
15693
duration: 10000
157-
- attributeIndices: [0, 1]
158-
attributeTable:
159-
- key: profile.required
160-
value:
161-
stringValue: foo
162-
- key: profile.optional
163-
value:
164-
stringValue: notbar
94+
- attributeIndices: [0, 2]
16595
sample:
16696
- locationsLength: 0
16797
timestampsUnixNano: ["0"]
16898
sampleType:
16999
- unitStrindex: 0
170-
stringTable:
171-
- count
172100
duration: 10000
173-
- attributeIndices: [0]
174-
attributeTable:
175-
- key: profile.required
176-
value:
177-
stringValue: notfoo
101+
- attributeIndices: [3]
178102
sample:
179103
- locationsLength: 0
180104
timestampsUnixNano: ["0"]
181105
sampleType:
182106
- unitStrindex: 0
183-
stringTable:
184-
- count
185107
- attributeIndices: []
186-
attributeTable: []
187108
sample:
188109
- locationsLength: 0
189110
timestampsUnixNano: ["0"]
190111
sampleType:
191112
- unitStrindex: 0
192-
stringTable:
193-
- count
194113
duration: 100
195114
scope: {}
196115

197116
- resource: {}
198117
scopeProfiles:
199118
- profiles:
200119
- attributeIndices: [0, 1]
201-
attributeTable:
202-
- key: profile.required
203-
value:
204-
stringValue: foo
205-
- key: profile.optional
206-
value:
207-
stringValue: bar
208120
sample:
209121
- locationsLength: 0
210122
timestampsUnixNano: ["0"]
211123
sampleType:
212124
- unitStrindex: 0
213-
stringTable:
214-
- count
215125
duration: 10000
216-
- attributeIndices: [0, 1]
217-
attributeTable:
218-
- key: profile.required
219-
value:
220-
stringValue: foo
221-
- key: profile.optional
222-
value:
223-
stringValue: notbar
126+
- attributeIndices: [0, 2]
224127
sample:
225128
- locationsLength: 0
226129
timestampsUnixNano: ["0"]
227130
sampleType:
228131
- unitStrindex: 0
229-
stringTable:
230-
- count
231132
duration: 10000
232-
- attributeIndices: [0]
233-
attributeTable:
234-
- key: profile.required
235-
value:
236-
stringValue: notfoo
133+
- attributeIndices: [3]
237134
sample:
238135
- locationsLength: 0
239136
timestampsUnixNano: ["0"]
240137
sampleType:
241138
- unitStrindex: 0
242-
stringTable:
243-
- count
244139
- attributeIndices: []
245-
attributeTable: []
246140
sample:
247141
- locationsLength: 0
248142
timestampsUnixNano: ["0"]
249143
sampleType:
250144
- unitStrindex: 0
251-
stringTable:
252-
- count
253145
duration: 100
254146
scope: {}
147+
dictionary:
148+
attributeTable:
149+
- key: profile.required
150+
value:
151+
stringValue: foo
152+
- key: profile.optional
153+
value:
154+
stringValue: bar
155+
- key: profile.optional
156+
value:
157+
stringValue: notbar
158+
- key: profile.required
159+
value:
160+
stringValue: notfoo
161+
stringTable:
162+
- count

connector/signaltometricsconnector/connector.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ func (sm *signalToMetrics) ConsumeProfiles(ctx context.Context, profiles pprofil
264264

265265
for k := 0; k < scopeProfile.Profiles().Len(); k++ {
266266
profile := scopeProfile.Profiles().At(k)
267-
profileAttrs := pprofile.FromAttributeIndices(profile.AttributeTable(), profile)
267+
profileAttrs := pprofile.FromAttributeIndices(profiles.ProfilesDictionary().AttributeTable(), profile)
268268

269269
for _, md := range sm.profileMetricDefs {
270270
filteredProfileAttrs, ok := md.FilterAttributes(profileAttrs)
@@ -274,7 +274,7 @@ func (sm *signalToMetrics) ConsumeProfiles(ctx context.Context, profiles pprofil
274274

275275
// The transform context is created from original attributes so that the
276276
// OTTL expressions are also applied on the original attributes.
277-
tCtx := ottlprofile.NewTransformContext(profile, scopeProfile.Scope(), resourceProfile.Resource(), scopeProfile, resourceProfile)
277+
tCtx := ottlprofile.NewTransformContext(profile, profiles.ProfilesDictionary(), scopeProfile.Scope(), resourceProfile.Resource(), scopeProfile, resourceProfile)
278278
if md.Conditions != nil {
279279
match, err := md.Conditions.Eval(ctx, tCtx)
280280
if err != nil {

connector/signaltometricsconnector/testdata/profiles/profiles.yaml

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -10,29 +10,13 @@ resourceProfiles:
1010
scopeProfiles:
1111
- profiles:
1212
- attributeIndices: [0, 1]
13-
attributeTable:
14-
- key: profile.foo
15-
value:
16-
stringValue: foo
17-
- key: profile.bar
18-
value:
19-
stringValue: bar
2013
sample:
2114
- locationsLength: 0
2215
timestampsUnixNano: ["0"]
2316
sampleType:
2417
- unitStrindex: 0
25-
stringTable:
26-
- count
2718
duration: 10000
28-
- attributeIndices: [0, 1]
29-
attributeTable:
30-
- key: profile.required
31-
value:
32-
stringValue: foo
33-
- key: profile.optional
34-
value:
35-
stringValue: notbar
19+
- attributeIndices: [2, 3]
3620
sample:
3721
- locationsLength: 0
3822
timestampsUnixNano: ["0"]
@@ -41,16 +25,30 @@ resourceProfiles:
4125
stringTable:
4226
- count
4327
duration: 10000
44-
- attributeIndices: [0]
45-
attributeTable:
46-
- key: profile.required
47-
value:
48-
stringValue: notfoo
28+
- attributeIndices: [5]
4929
sample:
5030
- locationsLength: 0
5131
timestampsUnixNano: ["0"]
5232
sampleType:
5333
- unitStrindex: 0
54-
stringTable:
55-
- count
5634
scope: {}
35+
dictionary:
36+
attributeTable:
37+
- key: profile.foo
38+
value:
39+
stringValue: foo
40+
- key: profile.bar
41+
value:
42+
stringValue: bar
43+
- key: profile.required
44+
value:
45+
stringValue: foo
46+
- key: profile.optional
47+
value:
48+
stringValue: notbar
49+
- key: profile.optional
50+
value:
51+
stringValue: notbar
52+
- key: profile.required
53+
value:
54+
stringValue: notfoo

0 commit comments

Comments
 (0)