Skip to content

Commit

Permalink
Merge branch 'main' into codeboten/may-9
Browse files Browse the repository at this point in the history
  • Loading branch information
bogdandrutu authored May 10, 2022
2 parents adf4c3d + 10b308e commit 8cb2081
Show file tree
Hide file tree
Showing 5 changed files with 136 additions and 146 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ jobs:
docker run otel/opentelemetry-collector-contrib-dev:$GITHUB_SHA --version
docker run otel/opentelemetry-collector-contrib-dev:latest --version
- name: Login to Docker Hub
uses: docker/login-action@v1
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/tracegen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
- name: Checkout Repo
uses: actions/checkout@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
Expand All @@ -52,7 +52,7 @@ jobs:
id: github_tag
run: ./.github/workflows/scripts/set_release_tag.sh
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
- `filelogreceiver`: Update Kubernetes examples to fix native OTel logs collection issue where 0 length logs cause errors (#9754)
- `logstransformprocessor`: Resolve node ordering to fix intermittent failures (#9761)
- `awsinsightreceiver`: Migrate from `ConfigMapsResourceLock` to `ConfigMapsLeasesResourceLock` as per https://github.com/kubernetes/client-go/commit/276ea3ed979947d7cdd4b3d708862245ddcd8883 (#9885)
- `filelog`, `journald`, `syslog`, `tcplog`, `udplog`: Add support for []string type for converting log record entries (#9887)

## v0.50.0

Expand Down
260 changes: 117 additions & 143 deletions exporter/prometheusremotewriteexporter/exporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -421,192 +421,162 @@ func Test_PushMetrics(t *testing.T) {

tests := []struct {
name string
md *pmetric.Metrics
metrics *pmetric.Metrics
reqTestFunc func(t *testing.T, r *http.Request, expected int, isStaleMarker bool)
expectedTimeSeries int
httpResponseCode int
returnErr bool
isStaleMarker bool
skipForWAL bool
}{
{
"invalid_type_case",
&invalidTypeBatch,
nil,
0,
http.StatusAccepted,
true,
false,
name: "invalid_type_case",
metrics: &invalidTypeBatch,
httpResponseCode: http.StatusAccepted,
returnErr: true,
},
{
"intSum_case",
&intSumBatch,
checkFunc,
3,
http.StatusAccepted,
false,
false,
name: "intSum_case",
metrics: &intSumBatch,
reqTestFunc: checkFunc,
expectedTimeSeries: 3,
httpResponseCode: http.StatusAccepted,
},
{
"doubleSum_case",
&sumBatch,
checkFunc,
2,
http.StatusAccepted,
false,
false,
name: "doubleSum_case",
metrics: &sumBatch,
reqTestFunc: checkFunc,
expectedTimeSeries: 2,
httpResponseCode: http.StatusAccepted,
},
{
"doubleGauge_case",
&doubleGaugeBatch,
checkFunc,
2,
http.StatusAccepted,
false,
false,
name: "doubleGauge_case",
metrics: &doubleGaugeBatch,
reqTestFunc: checkFunc,
expectedTimeSeries: 2,
httpResponseCode: http.StatusAccepted,
},
{
"intGauge_case",
&intGaugeBatch,
checkFunc,
2,
http.StatusAccepted,
false,
false,
name: "intGauge_case",
metrics: &intGaugeBatch,
reqTestFunc: checkFunc,
expectedTimeSeries: 2,
httpResponseCode: http.StatusAccepted,
},
{
"histogram_case",
&histogramBatch,
checkFunc,
12,
http.StatusAccepted,
false,
false,
name: "histogram_case",
metrics: &histogramBatch,
reqTestFunc: checkFunc,
expectedTimeSeries: 12,
httpResponseCode: http.StatusAccepted,
},
{
"summary_case",
&summaryBatch,
checkFunc,
10,
http.StatusAccepted,
false,
false,
name: "summary_case",
metrics: &summaryBatch,
reqTestFunc: checkFunc,
expectedTimeSeries: 10,
httpResponseCode: http.StatusAccepted,
},
{
"unmatchedBoundBucketHist_case",
&unmatchedBoundBucketHistBatch,
checkFunc,
5,
http.StatusAccepted,
false,
false,
name: "unmatchedBoundBucketHist_case",
metrics: &unmatchedBoundBucketHistBatch,
reqTestFunc: checkFunc,
expectedTimeSeries: 5,
httpResponseCode: http.StatusAccepted,
},
{
"5xx_case",
&unmatchedBoundBucketHistBatch,
checkFunc,
5,
http.StatusServiceUnavailable,
true,
false,
name: "5xx_case",
metrics: &unmatchedBoundBucketHistBatch,
reqTestFunc: checkFunc,
expectedTimeSeries: 5,
httpResponseCode: http.StatusServiceUnavailable,
returnErr: true,
// When using the WAL, it returns success once the data is persisted to the WAL
skipForWAL: true,
},
{
"emptyGauge_case",
&emptyDoubleGaugeBatch,
checkFunc,
0,
http.StatusAccepted,
true,
false,
name: "emptyGauge_case",
metrics: &emptyDoubleGaugeBatch,
reqTestFunc: checkFunc,
httpResponseCode: http.StatusAccepted,
returnErr: true,
},
{
"emptyCumulativeSum_case",
&emptyCumulativeSumBatch,
checkFunc,
0,
http.StatusAccepted,
true,
false,
name: "emptyCumulativeSum_case",
metrics: &emptyCumulativeSumBatch,
reqTestFunc: checkFunc,
httpResponseCode: http.StatusAccepted,
returnErr: true,
},
{
"emptyCumulativeHistogram_case",
&emptyCumulativeHistogramBatch,
checkFunc,
0,
http.StatusAccepted,
true,
false,
name: "emptyCumulativeHistogram_case",
metrics: &emptyCumulativeHistogramBatch,
reqTestFunc: checkFunc,
httpResponseCode: http.StatusAccepted,
returnErr: true,
},
{
"emptySummary_case",
&emptySummaryBatch,
checkFunc,
0,
http.StatusAccepted,
true,
false,
name: "emptySummary_case",
metrics: &emptySummaryBatch,
reqTestFunc: checkFunc,
httpResponseCode: http.StatusAccepted,
returnErr: true,
},
{
"staleNaNIntGauge_case",
&staleNaNIntGaugeBatch,
checkFunc,
1,
http.StatusAccepted,
false,
true,
name: "staleNaNIntGauge_case",
metrics: &staleNaNIntGaugeBatch,
reqTestFunc: checkFunc,
expectedTimeSeries: 1,
httpResponseCode: http.StatusAccepted,
isStaleMarker: true,
},
{
"staleNaNDoubleGauge_case",
&staleNaNDoubleGaugeBatch,
checkFunc,
1,
http.StatusAccepted,
false,
true,
name: "staleNaNDoubleGauge_case",
metrics: &staleNaNDoubleGaugeBatch,
reqTestFunc: checkFunc,
expectedTimeSeries: 1,
httpResponseCode: http.StatusAccepted,
isStaleMarker: true,
},
{
"staleNaNIntSum_case",
&staleNaNIntSumBatch,
checkFunc,
1,
http.StatusAccepted,
false,
true,
name: "staleNaNIntSum_case",
metrics: &staleNaNIntSumBatch,
reqTestFunc: checkFunc,
expectedTimeSeries: 1,
httpResponseCode: http.StatusAccepted,
isStaleMarker: true,
},
{
"staleNaNSum_case",
&staleNaNSumBatch,
checkFunc,
1,
http.StatusAccepted,
false,
true,
name: "staleNaNSum_case",
metrics: &staleNaNSumBatch,
reqTestFunc: checkFunc,
expectedTimeSeries: 1,
httpResponseCode: http.StatusAccepted,
isStaleMarker: true,
},
{
"staleNaNHistogram_case",
&staleNaNHistogramBatch,
checkFunc,
6,
http.StatusAccepted,
false,
true,
name: "staleNaNHistogram_case",
metrics: &staleNaNHistogramBatch,
reqTestFunc: checkFunc,
expectedTimeSeries: 6,
httpResponseCode: http.StatusAccepted,
isStaleMarker: true,
},
{
"staleNaNEmptyHistogram_case",
&staleNaNEmptyHistogramBatch,
checkFunc,
3,
http.StatusAccepted,
false,
true,
name: "staleNaNEmptyHistogram_case",
metrics: &staleNaNEmptyHistogramBatch,
reqTestFunc: checkFunc,
expectedTimeSeries: 3,
httpResponseCode: http.StatusAccepted,
isStaleMarker: true,
},
{
"staleNaNSummary_case",
&staleNaNSummaryBatch,
checkFunc,
5,
http.StatusAccepted,
false,
true,
name: "staleNaNSummary_case",
metrics: &staleNaNSummaryBatch,
reqTestFunc: checkFunc,
expectedTimeSeries: 5,
httpResponseCode: http.StatusAccepted,
isStaleMarker: true,
},
}

Expand All @@ -619,7 +589,11 @@ func Test_PushMetrics(t *testing.T) {
if useWAL {
t.Skip("Flaky test, see https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/9124")
}
for _, tt := range tests {
for _, ttt := range tests {
tt := ttt
if useWAL && tt.skipForWAL {
t.Skip("test not supported when using WAL")
}
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
Expand Down Expand Up @@ -664,7 +638,7 @@ func Test_PushMetrics(t *testing.T) {
defer func() {
require.NoError(t, prwe.Shutdown(ctx))
}()
err := prwe.PushMetrics(ctx, *tt.md)
err := prwe.PushMetrics(ctx, *tt.metrics)
if tt.returnErr {
assert.Error(t, err)
return
Expand Down
15 changes: 15 additions & 0 deletions internal/stanza/converter.go
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,8 @@ func insertToAttributeVal(value interface{}, dest pcommon.Value) {
dest.SetBoolVal(t)
case string:
dest.SetStringVal(t)
case []string:
toStringArray(t).CopyTo(dest)
case []byte:
dest.SetBytesVal(t)
case int64:
Expand Down Expand Up @@ -420,6 +422,9 @@ func insertToAttributeMap(obsMap map[string]interface{}, dest pcommon.Map) {
dest.InsertBool(k, t)
case string:
dest.InsertString(k, t)
case []string:
arr := toStringArray(t)
dest.Insert(k, arr)
case []byte:
dest.InsertBytes(k, t)
case int64:
Expand Down Expand Up @@ -468,6 +473,16 @@ func toAttributeArray(obsArr []interface{}) pcommon.Value {
return arrVal
}

func toStringArray(strArr []string) pcommon.Value {
arrVal := pcommon.NewValueSlice()
arr := arrVal.SliceVal()
arr.EnsureCapacity(len(strArr))
for _, v := range strArr {
insertToAttributeVal(v, arr.AppendEmpty())
}
return arrVal
}

var sevMap = map[entry.Severity]plog.SeverityNumber{
entry.Default: plog.SeverityNumberUNDEFINED,
entry.Trace: plog.SeverityNumberTRACE,
Expand Down

0 comments on commit 8cb2081

Please sign in to comment.