Skip to content

Commit 68b22ac

Browse files
thampiotrwildumkorniltsevmattdurhamtpaschalis
authored
Prep v1.7.2 in release branch (#2942)
* fix running otelcol.exporter.awss3 with sumo_ic marshaler (#2865) * pyroscope.java: update jfr-parser to 0.9.3 (#2894) * fix targets from_json encoding (#2911) * fix targets from_json encoding * fix targets from_json encoding * fix targets from_json encoding * fix targets from_json encoding # Conflicts: # CHANGELOG.md # Conflicts: # CHANGELOG.md * fix targets indexing and field access (#2914) * fix targets indexing and field access * fix targets indexing and field access * fix targets indexing and field access * fix targets indexing and field access * fix targets indexing and field access * fix targets indexing and field access * fix more stdlib functions working with targets (#2917) * fix more stdlib functions working with targets * fix more stdlib functions working with targets * fix more stdlib functions working with targets * update walqueue (#2923) * remotecfg: fix metric reporting load success (#2926) Signed-off-by: Paschalis Tsilias <[email protected]> * fix-changelog * Set signal types according to encoding in otel kafka exporter (#2943) * set signal types according to encoding in kafka exporter * add test --------- Signed-off-by: Paschalis Tsilias <[email protected]> Co-authored-by: William Dumont <[email protected]> Co-authored-by: Tolya Korniltsev <[email protected]> Co-authored-by: mattdurham <[email protected]> Co-authored-by: Paschalis Tsilias <[email protected]>
1 parent c715642 commit 68b22ac

File tree

20 files changed

+574
-86
lines changed

20 files changed

+574
-86
lines changed

CHANGELOG.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,26 @@ This document contains a historical list of changes between releases. Only
77
changes that impact end-user behavior are listed; changes to documentation or
88
internal API changes are not present.
99

10+
v1.7.2
11+
-----------------
12+
13+
### Bugfixes
14+
15+
- Fixed an issue where the `otelcol.exporter.awss3` could not be started with the `sumo_ic` marshaler. (@wildum)
16+
17+
- Update `jfr-parser` dependency to v0.9.3 to fix jfr parsing issues in `pyroscope.java`. (@korniltsev)
18+
19+
- Fixed an issue where passing targets from some standard library functions was failing with `target::ConvertFrom` error. (@thampiotr)
20+
21+
- Fixed an issue where indexing targets as maps (e.g. `target["foo"]`) or objects (e.g. `target.foo`) or using them with
22+
certain standard library functions was resulting in `expected object or array, got capsule` error under some
23+
circumstances. This could also lead to `foreach evaluation failed` errors when using the `foreach` configuration
24+
block. (@thampiotr)
25+
26+
- Update `prometheus.write.queue` to reduce memory fragmentation and increase sent throughput. (@mattdurham)
27+
28+
- Fixed an issue where the `otelcol.exporter.kafka` component would not start if the `encoding` was specific to a signal type. (@wildum)
29+
1030
v1.7.1
1131
-----------------
1232

@@ -15,7 +35,7 @@ v1.7.1
1535
- Fixed an issue where some exporters such as `prometheus.exporter.snmp` couldn't accept targets from other components
1636
with an error `conversion to '*map[string]string' is not supported"`. (@thampiotr)
1737

18-
- Enable batching of calls to the appender in `prometheus.write.queue` to reduce lock contention when scraping, which
38+
- Enable batching of calls to the appender in `prometheus.write.queue` to reduce lock contention when scraping, which
1939
will lead to reduced scrape duration. (@mattdurham)
2040

2141
v1.7.0

go.mod

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ require (
6363
github.com/grafana/cloudflare-go v0.0.0-20230110200409-c627cf6792f2
6464
github.com/grafana/dskit v0.0.0-20250131191929-eab36484cec2
6565
github.com/grafana/go-gelf/v2 v2.0.1
66-
github.com/grafana/jfr-parser/pprof v0.0.3
66+
github.com/grafana/jfr-parser/pprof v0.0.4
6767
github.com/grafana/jsonparser v0.0.0-20240425183733-ea80629e1a32
6868
github.com/grafana/kafka_exporter v0.0.0-20240409084445-5e3488ad9f9a
6969
github.com/grafana/loki/pkg/push v0.0.0-20250218135905-f078e0e3f9b6 // k217-alloy-v1.7-fork branch
@@ -75,7 +75,7 @@ require (
7575
github.com/grafana/snowflake-prometheus-exporter v0.0.0-20240813124544-9995e8354548
7676
github.com/grafana/tail v0.0.0-20230510142333-77b18831edf0
7777
github.com/grafana/vmware_exporter v0.0.5-beta.0.20250218170317-73398ba08329
78-
github.com/grafana/walqueue v0.0.0-20250226140916-7365e13bbede
78+
github.com/grafana/walqueue v0.0.0-20250306192434-b34b4277b995
7979
github.com/hashicorp/consul/api v1.31.0
8080
github.com/hashicorp/go-discover v0.0.0-20230724184603-e89ebd1b2f65
8181
github.com/hashicorp/go-multierror v1.1.1
@@ -484,7 +484,7 @@ require (
484484
github.com/cyphar/filepath-securejoin v0.3.4 // indirect
485485
github.com/danieljoos/wincred v1.2.0 // indirect
486486
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
487-
github.com/deneonet/benc v1.1.2 // indirect
487+
github.com/deneonet/benc v1.1.7 // indirect
488488
github.com/dennwc/btrfs v0.0.0-20230312211831-a1f570bd01a1 // indirect
489489
github.com/dennwc/ioctl v1.0.0 // indirect
490490
github.com/dennwc/varint v1.0.0 // indirect
@@ -573,7 +573,7 @@ require (
573573
github.com/gosnmp/gosnmp v1.38.0 // indirect
574574
github.com/grafana/go-offsets-tracker v0.1.7 // indirect
575575
github.com/grafana/gomemcache v0.0.0-20240229205252-cd6a66d6fb56 // indirect
576-
github.com/grafana/jfr-parser v0.9.2 // indirect
576+
github.com/grafana/jfr-parser v0.9.3 // indirect
577577
github.com/grobie/gomemcache v0.0.0-20230213081705-239240bbc445 // indirect
578578
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 // indirect
579579
github.com/grpc-ecosystem/grpc-gateway/v2 v2.26.0 // indirect
@@ -737,7 +737,6 @@ require (
737737
github.com/outcaste-io/ristretto v0.2.3 // indirect
738738
github.com/ovh/go-ovh v1.6.0 // indirect
739739
github.com/packethost/packngo v0.1.1-0.20180711074735-b9cb5096f54c // indirect
740-
github.com/panjf2000/ants/v2 v2.11.0 // indirect
741740
github.com/patrickmn/go-cache v2.1.0+incompatible // indirect
742741
github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58 // indirect
743742
github.com/pelletier/go-toml v1.9.5 // indirect

go.sum

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -756,8 +756,8 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
756756
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
757757
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
758758
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
759-
github.com/deneonet/benc v1.1.2 h1:JNJSnA53zVLjt4Bz1HwxG4tQg475LP+kd8rgUuV4tc4=
760-
github.com/deneonet/benc v1.1.2/go.mod h1:HbL4lzHT0jkmlYa36bZw0a0Nhj4NsXG7bd/bXRxJYy4=
759+
github.com/deneonet/benc v1.1.7 h1:0XPxTTVJZq/ulxXvMn2Mzjx5XquekVky3wX6eTgA0vA=
760+
github.com/deneonet/benc v1.1.7/go.mod h1:UCfkM5Od0B2huwv/ZItvtUb7QnALFt9YXtX8NXX4Lts=
761761
github.com/denisenkom/go-mssqldb v0.0.0-20180620032804-94c9c97e8c9f/go.mod h1:xN/JuLBIz4bjkxNmByTiV1IbhfnYb6oo99phBn4Eqhc=
762762
github.com/denisenkom/go-mssqldb v0.0.0-20190707035753-2be1aa521ff4/go.mod h1:zAg7JM8CkOJ43xKXIj7eRO9kmWm/TW578qo+oDO6tuM=
763763
github.com/dennwc/btrfs v0.0.0-20230312211831-a1f570bd01a1 h1:ue4Es4Xzz255hWQ7NAWzZxuXG+YOV7URzzusLLSe0zU=
@@ -1265,10 +1265,10 @@ github.com/grafana/go-offsets-tracker v0.1.7/go.mod h1:qcQdu7zlUKIFNUdBJlLyNHuJG
12651265
github.com/grafana/gocql v0.0.0-20200605141915-ba5dc39ece85/go.mod h1:crI9WX6p0IhrqB+DqIUHulRW853PaNFf7o4UprV//3I=
12661266
github.com/grafana/gomemcache v0.0.0-20240229205252-cd6a66d6fb56 h1:X8IKQ0wu40wpvYcKfBcc5T4QnhdQjUhtUtB/1CY89lE=
12671267
github.com/grafana/gomemcache v0.0.0-20240229205252-cd6a66d6fb56/go.mod h1:PGk3RjYHpxMM8HFPhKKo+vve3DdlPUELZLSDEFehPuU=
1268-
github.com/grafana/jfr-parser v0.9.2 h1:Ba6hqld0oWAIcaY06K7c5DopnsVcAwXhRGS2zGbkDM0=
1269-
github.com/grafana/jfr-parser v0.9.2/go.mod h1:KYbwbvXtBoOsYw9b9w8R01dbM5oVfopljq3hA1WDJMQ=
1270-
github.com/grafana/jfr-parser/pprof v0.0.3 h1:GbhF9vVbfSUTpn0TPSdOBnDW8cKFQ3lqgiIH6/5Iyus=
1271-
github.com/grafana/jfr-parser/pprof v0.0.3/go.mod h1:MccKegViSw2NsyXNww1yuIcaQlw6LxP/DT0CHlsfRgw=
1268+
github.com/grafana/jfr-parser v0.9.3 h1:rMrDfV7U5Ycz12/d57sQrN7UHmt1N6Wi6SSuNKi8hyk=
1269+
github.com/grafana/jfr-parser v0.9.3/go.mod h1:KYbwbvXtBoOsYw9b9w8R01dbM5oVfopljq3hA1WDJMQ=
1270+
github.com/grafana/jfr-parser/pprof v0.0.4 h1:QIpA0tTgG17m/l2B6X0tqf8dZu+AN/UY6B3aYLfAFtY=
1271+
github.com/grafana/jfr-parser/pprof v0.0.4/go.mod h1:7aJk80IjMxc2iaUlliRUgA+bq2ZFTgEQfZgjioL4cvg=
12721272
github.com/grafana/jsonparser v0.0.0-20240425183733-ea80629e1a32 h1:NznuPwItog+rwdVg8hAuGKP29ndRSzJAwhxKldkP8oQ=
12731273
github.com/grafana/jsonparser v0.0.0-20240425183733-ea80629e1a32/go.mod h1:796sq+UcONnSlzA3RtlBZ+b/hrerkZXiEmO8oMjyRwY=
12741274
github.com/grafana/kafka_exporter v0.0.0-20240409084445-5e3488ad9f9a h1:jqM4NNdx8LSquKo8bPx+XWn91S2b+sgNvEcFfSJQtHY=
@@ -1303,8 +1303,8 @@ github.com/grafana/tail v0.0.0-20230510142333-77b18831edf0 h1:bjh0PVYSVVFxzINqPF
13031303
github.com/grafana/tail v0.0.0-20230510142333-77b18831edf0/go.mod h1:7t5XR+2IA8P2qggOAHTj/GCZfoLBle3OvNSYh1VkRBU=
13041304
github.com/grafana/vmware_exporter v0.0.5-beta.0.20250218170317-73398ba08329 h1:Rs4H1yv2Abk3xE82qpyhMGGA8rswAOA0HQZde/BYkFo=
13051305
github.com/grafana/vmware_exporter v0.0.5-beta.0.20250218170317-73398ba08329/go.mod h1:Z28219aViNlsLlPvuCnlgHDagRdZBAZ7JOnQg1b3eWg=
1306-
github.com/grafana/walqueue v0.0.0-20250226140916-7365e13bbede h1:9xJHxsGrN7RPwXNPDSwmE6ivdJMRVnTRQITopBtxKik=
1307-
github.com/grafana/walqueue v0.0.0-20250226140916-7365e13bbede/go.mod h1:++oxbVcfnIzbSKHNxpO3WpQJG5ufmnwtBJqh5rvEmVo=
1306+
github.com/grafana/walqueue v0.0.0-20250306192434-b34b4277b995 h1:wempcAiffauW8l3BOEs9pxwma6z1NaEIEIVYyZ9V2so=
1307+
github.com/grafana/walqueue v0.0.0-20250306192434-b34b4277b995/go.mod h1:jlJk5qY9flSeR4FfwPkk/SgdT0dmmW32opzLQD9aiIs=
13081308
github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA=
13091309
github.com/grobie/gomemcache v0.0.0-20230213081705-239240bbc445 h1:FlKQKUYPZ5yDCN248M3R7x8yu2E3yEZ0H7aLomE4EoE=
13101310
github.com/grobie/gomemcache v0.0.0-20230213081705-239240bbc445/go.mod h1:L69/dBlPQlWkcnU76WgcppK5e4rrxzQdi6LhLnK/ytA=
@@ -2195,8 +2195,6 @@ github.com/ovh/go-ovh v1.6.0/go.mod h1:cTVDnl94z4tl8pP1uZ/8jlVxntjSIf09bNcQ5TJSC
21952195
github.com/packethost/packngo v0.1.1-0.20180711074735-b9cb5096f54c h1:vwpFWvAO8DeIZfFeqASzZfsxuWPno9ncAebBEP0N3uE=
21962196
github.com/packethost/packngo v0.1.1-0.20180711074735-b9cb5096f54c/go.mod h1:otzZQXgoO96RTzDB/Hycg0qZcXZsWJGJRSXbmEIJ+4M=
21972197
github.com/pact-foundation/pact-go v1.0.4/go.mod h1:uExwJY4kCzNPcHRj+hCR/HBbOOIwwtUjcrb0b5/5kLM=
2198-
github.com/panjf2000/ants/v2 v2.11.0 h1:sHrqEwTBQTQ2w6PMvbMfvBtVUuhsaYPzUmAYDLYmJPg=
2199-
github.com/panjf2000/ants/v2 v2.11.0/go.mod h1:V9HhTupTWxcaRmIglJvGwvzqXUTnIZW9uO6q4hAfApw=
22002198
github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=
22012199
github.com/pascaldekloe/goe v0.1.0 h1:cBOtyMzM9HTpWjXfbbunk26uA6nG3a8n06Wieeh0MwY=
22022200
github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=

internal/component/discovery/target.go

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package discovery
22

33
import (
44
"fmt"
5+
"reflect"
56
"slices"
67
"strings"
78
"sync"
@@ -221,15 +222,24 @@ func (t *Target) ConvertFrom(src interface{}) error {
221222
}
222223
*t = NewTargetFromLabelSet(labelSet)
223224
return nil
224-
case map[string]string:
225-
labelSet := make(commonlabels.LabelSet, len(src))
226-
for k, v := range src {
227-
labelSet[commonlabels.LabelName(k)] = commonlabels.LabelValue(v)
225+
default: // handle all other types of maps via reflection as Go generics don't support generics in switch/case.
226+
rv := reflect.ValueOf(src)
227+
switch rv.Kind() {
228+
case reflect.Map:
229+
labelSet := make(commonlabels.LabelSet, rv.Len())
230+
for _, key := range rv.MapKeys() {
231+
value := rv.MapIndex(key)
232+
if !value.CanInterface() || !key.CanInterface() {
233+
return fmt.Errorf("target::ConvertFrom: conversion from '%T' is not supported", src)
234+
}
235+
labelSet[commonlabels.LabelName(fmt.Sprintf("%v", key.Interface()))] = commonlabels.LabelValue(fmt.Sprintf("%v", value.Interface()))
236+
}
237+
*t = NewTargetFromLabelSet(labelSet)
238+
return nil
239+
default:
240+
return fmt.Errorf("target::ConvertFrom: conversion from '%T' is not supported", src)
228241
}
229-
*t = NewTargetFromLabelSet(labelSet)
230-
return nil
231242
}
232-
return fmt.Errorf("target::ConvertFrom: conversion from '%T' is not supported", src)
233243
}
234244

235245
func (t Target) String() string {

internal/component/discovery/target_test.go

Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,143 @@ import (
1515
"github.com/stretchr/testify/require"
1616

1717
"github.com/grafana/alloy/internal/runtime/equality"
18+
"github.com/grafana/alloy/syntax"
1819
"github.com/grafana/alloy/syntax/parser"
1920
"github.com/grafana/alloy/syntax/token/builder"
2021
"github.com/grafana/alloy/syntax/vm"
2122
)
2223

24+
func TestUsingTargetCapsule(t *testing.T) {
25+
type testCase struct {
26+
name string
27+
inputTarget map[string]string
28+
expression string
29+
decodeInto interface{}
30+
expectedDecodedString string
31+
expectedEvalError string
32+
}
33+
34+
testCases := []testCase{
35+
{
36+
name: "target to map of string -> string",
37+
inputTarget: map[string]string{"a1a": "beachfront avenue", "ice": "ice"},
38+
expression: "t",
39+
decodeInto: map[string]string{},
40+
expectedDecodedString: `{"a1a"="beachfront avenue", "ice"="ice"}`,
41+
},
42+
{
43+
name: "target to map of string -> any",
44+
inputTarget: map[string]string{"a1a": "beachfront avenue", "ice": "ice"},
45+
expression: "t",
46+
decodeInto: map[string]any{},
47+
expectedDecodedString: `{"a1a"="beachfront avenue", "ice"="ice"}`,
48+
},
49+
{
50+
name: "target to map of any -> any",
51+
inputTarget: map[string]string{"a1a": "beachfront avenue", "ice": "ice"},
52+
expression: "t",
53+
decodeInto: map[any]any{},
54+
expectedDecodedString: `{"a1a"="beachfront avenue", "ice"="ice"}`,
55+
},
56+
{
57+
name: "target to map of string -> syntax.Value",
58+
inputTarget: map[string]string{"a1a": "beachfront avenue"},
59+
expression: "t",
60+
decodeInto: map[string]syntax.Value{},
61+
expectedDecodedString: `{"a1a"="beachfront avenue"}`,
62+
},
63+
{
64+
name: "target indexing a string value",
65+
inputTarget: map[string]string{"a1a": "beachfront avenue", "hip": "hop"},
66+
expression: `t["hip"]`,
67+
decodeInto: "",
68+
expectedDecodedString: `hop`,
69+
},
70+
{
71+
name: "target indexing a non-existing string value",
72+
inputTarget: map[string]string{"a1a": "beachfront avenue", "hip": "hop"},
73+
expression: `t["boom"]`,
74+
decodeInto: "",
75+
expectedDecodedString: "<nil>",
76+
},
77+
{
78+
name: "target indexing a value like an object field",
79+
inputTarget: map[string]string{"a1a": "beachfront avenue", "hip": "hop"},
80+
expression: `t.boom`,
81+
decodeInto: "",
82+
expectedEvalError: `field "boom" does not exist`,
83+
},
84+
{
85+
name: "targets passed to concat",
86+
inputTarget: map[string]string{"boom": "bap", "hip": "hop"},
87+
expression: `array.concat([t], [t])`,
88+
decodeInto: []Target{},
89+
expectedDecodedString: `[{"boom"="bap", "hip"="hop"} {"boom"="bap", "hip"="hop"}]`,
90+
},
91+
{
92+
name: "coalesce an empty target",
93+
inputTarget: map[string]string{},
94+
expression: `coalesce(t, [], t, {}, t, 123, t)`,
95+
decodeInto: []Target{},
96+
expectedDecodedString: `123`,
97+
},
98+
{
99+
name: "coalesce a non-empty target",
100+
inputTarget: map[string]string{"big": "bang"},
101+
expression: `coalesce([], {}, "", t, 321, [])`,
102+
decodeInto: []Target{},
103+
expectedDecodedString: `{"big"="bang"}`,
104+
},
105+
{
106+
name: "array.combine_maps with targets",
107+
inputTarget: map[string]string{"a": "a1", "b": "b1"},
108+
expression: `array.combine_maps([t, t], [{"a" = "a1", "c" = "c1"}, {"a" = "a2", "c" = "c2"}], ["a"])`,
109+
decodeInto: []Target{},
110+
expectedDecodedString: `[map[a:a1 b:b1 c:c1] map[a:a1 b:b1 c:c1]]`,
111+
},
112+
}
113+
for _, tc := range testCases {
114+
t.Run(tc.name, func(t *testing.T) {
115+
target := NewTargetFromMap(tc.inputTarget)
116+
scope := vm.NewScope(map[string]interface{}{"t": target})
117+
expr, err := parser.ParseExpression(tc.expression)
118+
require.NoError(t, err)
119+
eval := vm.New(expr)
120+
evalError := eval.Evaluate(scope, &tc.decodeInto)
121+
if tc.expectedEvalError != "" {
122+
require.ErrorContains(t, evalError, tc.expectedEvalError)
123+
} else {
124+
require.NoError(t, evalError)
125+
}
126+
require.Equal(t, tc.expectedDecodedString, fmt.Sprintf("%v", tc.decodeInto))
127+
})
128+
}
129+
}
130+
131+
func TestNestedIndexing(t *testing.T) {
132+
targets := []Target{
133+
NewTargetFromMap(map[string]string{"foo": "bar", "boom": "bap"}),
134+
NewTargetFromMap(map[string]string{"hip": "hop", "dont": "stop"}),
135+
}
136+
scope := vm.NewScope(map[string]interface{}{"targets": targets})
137+
138+
expr, err := parser.ParseExpression(`targets[1]["dont"]`)
139+
require.NoError(t, err)
140+
eval := vm.New(expr)
141+
actual := ""
142+
err = eval.Evaluate(scope, &actual)
143+
require.NoError(t, err)
144+
require.Equal(t, "stop", actual)
145+
146+
expr, err = parser.ParseExpression(`targets[0].boom`)
147+
require.NoError(t, err)
148+
eval = vm.New(expr)
149+
actual = ""
150+
err = eval.Evaluate(scope, &actual)
151+
require.NoError(t, err)
152+
require.Equal(t, "bap", actual)
153+
}
154+
23155
func TestDecodeMap(t *testing.T) {
24156
type testCase struct {
25157
name string
@@ -68,6 +200,11 @@ func TestDecodeMap(t *testing.T) {
68200
input: `{ "b" = string.format("%x", 31337), "a" = string.join(["2", "0"], ".") }`,
69201
expected: map[string]string{"a": "2.0", "b": "7a69"},
70202
},
203+
{
204+
name: "decode with encoding.from_json function",
205+
input: "encoding.from_json(`{ \"__address__\": \"localhost:8080\", \"x\": 123 }`)",
206+
expected: map[string]string{"__address__": "localhost:8080", "x": "123"},
207+
},
71208
}
72209

73210
for _, tc := range tests {
@@ -298,6 +435,40 @@ func TestDecode_TargetArrays(t *testing.T) {
298435
{"e": "5", "f": "10"},
299436
},
300437
},
438+
{
439+
name: "from_json",
440+
input: "encoding.from_json(`[ { \"__address__\": \"localhost:8080\", \"foo\": 123 }, {}, {\"bap\": \"boom\"} ]`)",
441+
expected: []map[string]string{
442+
{"__address__": "localhost:8080", "foo": "123"},
443+
{},
444+
{"bap": "boom"},
445+
},
446+
},
447+
{
448+
name: "from_json one by one",
449+
input: "[encoding.from_json(`{ \"__address__\": \"localhost:8080\", \"foo\": 123 }`), encoding.from_json(`{ \"boom\": \"bap\", \"foo\": 321 }`)]",
450+
expected: []map[string]string{
451+
{"__address__": "localhost:8080", "foo": "123"},
452+
{"boom": "bap", "foo": "321"},
453+
},
454+
},
455+
{
456+
name: "from_yaml",
457+
input: "encoding.from_yaml(`[ { __address__: localhost:8080, foo: 123 }, {}, {bap: boom} ]`)",
458+
expected: []map[string]string{
459+
{"__address__": "localhost:8080", "foo": "123"},
460+
{},
461+
{"bap": "boom"},
462+
},
463+
},
464+
{
465+
name: "combine_maps",
466+
input: `array.combine_maps([{"a" = "a1", "b" = "b1"}, {"a" = "a1", "b" = "b1"}], [{"a" = "a1", "c" = "c1"}], ["a"])`,
467+
expected: []map[string]string{
468+
{"a": "a1", "b": "b1", "c": "c1"},
469+
{"a": "a1", "b": "b1", "c": "c1"},
470+
},
471+
},
301472
}
302473

303474
for _, tc := range tests {

internal/component/otelcol/exporter/awss3/awss3.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,17 @@ func init() {
2222

2323
Build: func(opts component.Options, args component.Arguments) (component.Component, error) {
2424
fact := awss3exporter.NewFactory()
25-
return exporter.New(opts, fact, args.(Arguments), exporter.TypeSignalConstFunc(exporter.TypeAll))
25+
26+
typeSignalFunc := func(opts component.Options, args component.Arguments) exporter.TypeSignal {
27+
switch args.(Arguments).MarshalerName.Type {
28+
case "sumo_ic":
29+
return exporter.TypeLogs
30+
default:
31+
return exporter.TypeAll
32+
}
33+
}
34+
35+
return exporter.New(opts, fact, args.(Arguments), typeSignalFunc)
2636
},
2737
})
2838
}

0 commit comments

Comments
 (0)