Skip to content

Commit

Permalink
Merge branch 'main' into es-roll-bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Manik2708 authored Feb 13, 2025
2 parents 5951744 + 4b884bb commit d61ccd0
Show file tree
Hide file tree
Showing 19 changed files with 97 additions and 60 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci-build-binaries.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: Build binaries

on:
merge_group:
push:
branches: [main]

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ci-crossdock.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: CIT Crossdock

on:
merge_group:
push:
branches: [main]

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ci-docker-all-in-one.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: Build all-in-one

on:
merge_group:
push:
branches: [main]

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ci-docker-build.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: Build docker images

on:
merge_group:
push:
branches: [main]

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ci-docker-hotrod.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: CIT Hotrod

on:
merge_group:
push:
branches: [main]

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ci-e2e-all.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: E2E Tests

on:
merge_group:
push:
branches: [main]

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ci-e2e-spm.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: Test SPM

on:
merge_group:
push:
branches: [main]

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ci-e2e-tailsampling-processor.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: Test Tail Sampling Processor

on:
merge_group:
push:
branches: [main]

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ci-lint-checks.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: Lint Checks

on:
merge_group:
push:
branches: [main]

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ci-lint-dependabot-config.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: dependabot validate

on:
merge_group:
pull_request:
paths:
- '.github/dependabot.yml'
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ci-unit-tests-go-tip.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: Unit Tests on Go Tip

on:
merge_group:
push:
branches: [main]

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ci-unit-tests.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: Unit Tests

on:
merge_group:
push:
branches: [main]

Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: "CodeQL"

on:
merge_group:
push:
branches: [main]

Expand All @@ -20,6 +21,8 @@ permissions: # added using https://github.com/step-security/secure-workflows

jobs:
codeql-analyze:
# Run only on pull requests, see https://github.com/github/codeql-action/issues/1537
if: ${{ github.event_name == 'pull_request' }}
name: CodeQL Analyze
runs-on: ubuntu-latest

Expand Down
14 changes: 14 additions & 0 deletions .github/workflows/dco_merge_group.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Fake "DCO check" workflow inspired by https://github.com/onnx/onnx/pull/5398/files.
# The regular DCO check is required, but it does not run from a merge queue and there is
# no way to configure it to run.
name: DCO
on:
merge_group:

permissions:
contents: read
jobs:
DCO:
runs-on: ubuntu-latest
steps:
- run: echo "Fake DCO check to avoid blocking the merge queue"
1 change: 1 addition & 0 deletions .github/workflows/fossa.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: FOSSA

on:
merge_group:
push:
branches: [main]

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/label-check.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: Verify PR Label

on:
merge_group:
pull_request:
types:
- opened
Expand Down
14 changes: 5 additions & 9 deletions cmd/query/app/apiv3/grpc_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,21 +131,17 @@ func receiveTraces(
seq iter.Seq2[[]ptrace.Traces, error],
sendFn func(*api_v3.TracesData) error,
) error {
var capturedErr error
seq(func(traces []ptrace.Traces, err error) bool {
for traces, err := range seq {
if err != nil {
capturedErr = err
return false
return err
}
for _, trace := range traces {
tracesData := api_v3.TracesData(trace)
if err := sendFn(&tracesData); err != nil {
capturedErr = status.Error(codes.Internal,
return status.Error(codes.Internal,
fmt.Sprintf("failed to send response stream chunk to client: %v", err))
return false
}
}
return true
})
return capturedErr
}
return nil
}
24 changes: 6 additions & 18 deletions internal/jiter/iter.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,34 +10,22 @@ import (

func CollectWithErrors[V any](seq iter.Seq2[V, error]) ([]V, error) {
var result []V
var err error
seq(func(v V, e error) bool {
if e != nil {
err = e
return false
for v, err := range seq {
if err != nil {
return nil, err
}
result = append(result, v)
return true
})
if err != nil {
return nil, err
}
return result, nil
}

func FlattenWithErrors[V any](seq iter.Seq2[[]V, error]) ([]V, error) {
var result []V
var err error
seq(func(v []V, e error) bool {
if e != nil {
err = e
return false
for v, err := range seq {
if err != nil {
return nil, err
}
result = append(result, v...)
return true
})
if err != nil {
return nil, err
}
return result, nil
}
88 changes: 55 additions & 33 deletions internal/jiter/iter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,60 +4,71 @@
package jiter

import (
"iter"
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

func TestCollectWithErrors(t *testing.T) {
type item struct {
str string
err error
}
tests := []struct {
name string
seq iter.Seq2[string, error]
items []item
expected []string
err error
}{
{
name: "no errors",
seq: func(yield func(string, error) bool) {
yield("a", nil)
yield("b", nil)
yield("c", nil)
items: []item{
{str: "a", err: nil},
{str: "b", err: nil},
{str: "c", err: nil},
},
expected: []string{"a", "b", "c"},
},
{
name: "first error",
seq: func(yield func(string, error) bool) {
yield("a", nil)
yield("b", nil)
yield("c", assert.AnError)
items: []item{
{str: "a", err: nil},
{str: "b", err: nil},
{str: "c", err: assert.AnError},
},
err: assert.AnError,
},
{
name: "second error",
seq: func(yield func(string, error) bool) {
yield("a", nil)
yield("b", assert.AnError)
yield("c", nil)
items: []item{
{str: "a", err: nil},
{str: "b", err: assert.AnError},
{str: "c", err: nil},
},
err: assert.AnError,
},
{
name: "third error",
seq: func(yield func(string, error) bool) {
yield("a", nil)
yield("b", nil)
yield("c", assert.AnError)
items: []item{
{str: "a", err: nil},
{str: "b", err: nil},
{str: "c", err: assert.AnError},
},

err: assert.AnError,
},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
result, err := CollectWithErrors(test.seq)
seq := func(yield func(string, error) bool) {
for _, item := range test.items {
if !yield(item.str, item.err) {
return
}
}
}
result, err := CollectWithErrors(seq)
if test.err != nil {
require.ErrorIs(t, err, test.err)
} else {
Expand All @@ -69,43 +80,54 @@ func TestCollectWithErrors(t *testing.T) {
}

func TestFlattenWithErrors(t *testing.T) {
type item struct {
strs []string
err error
}
tests := []struct {
name string
seq iter.Seq2[[]string, error]
items []item
expected []string
err error
}{
{
name: "no errors",
seq: func(yield func([]string, error) bool) {
yield([]string{"a", "b", "c"}, nil)
yield([]string{"d", "e", "f"}, nil)
yield([]string{"g", "h", "i"}, nil)
items: []item{
{strs: []string{"a", "b", "c"}, err: nil},
{strs: []string{"d", "e", "f"}, err: nil},
{strs: []string{"g", "h", "i"}, err: nil},
},
expected: []string{"a", "b", "c", "d", "e", "f", "g", "h", "i"},
},
{
name: "first error",
seq: func(yield func([]string, error) bool) {
yield([]string{"a", "b", "c"}, nil)
yield([]string{"d", "e", "f"}, assert.AnError)
yield([]string{"g", "h", "i"}, nil)
items: []item{
{strs: []string{"a", "b", "c"}, err: nil},
{strs: []string{"d", "e", "f"}, err: assert.AnError},
{strs: []string{"g", "h", "i"}, err: nil},
},
err: assert.AnError,
},
{
name: "second error",
seq: func(yield func([]string, error) bool) {
yield([]string{"a", "b", "c"}, nil)
yield([]string{"d", "e", "f"}, nil)
yield([]string{"g", "h", "i"}, assert.AnError)
items: []item{
{strs: []string{"a", "b", "c"}, err: nil},
{strs: []string{"d", "e", "f"}, err: nil},
{strs: []string{"g", "h", "i"}, err: assert.AnError},
},
err: assert.AnError,
},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
result, err := FlattenWithErrors(test.seq)
seq := func(yield func([]string, error) bool) {
for _, item := range test.items {
if !yield(item.strs, item.err) {
return
}
}
}
result, err := FlattenWithErrors(seq)
if test.err != nil {
require.ErrorIs(t, err, test.err)
} else {
Expand Down

0 comments on commit d61ccd0

Please sign in to comment.