Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated extract to handle http receiver metadata #2

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .chloggen/ottl-improve-parsing-errors.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Use this changelog template to create an entry for release notes.
# If your change doesn't affect end users, such as a test fix or a tooling change,
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.

# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: enhancement

# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
component: pkg/ottl

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Improve error reporting for errors during statement parsing

# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
issues: [23840]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext: |
- Failures are now printed for all statements within a context, and the statements are printed next to the errors.
- Erroneous values found during parsing are now quoted in error logs.
17 changes: 17 additions & 0 deletions .chloggen/support-client-info-metadata.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: enhancement

# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
component: routingprocessor

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Enables processor to extract metadata from client.Info

# One or more tracking issues related to the change
issues: [20913]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext:
Enables processor to perform context based routing for payloads on the http server of otlp receiver
2 changes: 1 addition & 1 deletion .github/workflows/build-and-test-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
run: Install-WindowsFeature -name Web-Server -IncludeManagementTools
- uses: actions/setup-go@v4
with:
go-version: ~1.19.10
go-version: ~1.19.11
cache: false
- name: Cache Go
id: go-mod-cache
Expand Down
18 changes: 9 additions & 9 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: 1.19
go-version: ~1.19.11
cache: false
- name: Cache Go
id: go-cache
Expand Down Expand Up @@ -78,7 +78,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: "1.20"
go-version: "~1.20.6"
cache: false
- name: Cache Go
id: go-cache
Expand Down Expand Up @@ -138,7 +138,7 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: ~1.19.10
go-version: ~1.19.11
cache: false
- name: Cache Go
id: go-cache
Expand All @@ -160,7 +160,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: 1.19
go-version: ~1.19.11
cache: false
- name: Cache Go
id: go-cache
Expand Down Expand Up @@ -308,7 +308,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: 1.19
go-version: ~1.19.11
cache: false
- name: Cache Go
id: go-cache
Expand All @@ -328,7 +328,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: 1.19
go-version: ~1.19.11
cache: false
- name: Cache Go
id: go-cache
Expand All @@ -353,7 +353,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: 1.19
go-version: ~1.19.11
cache: false
- name: Cache Go
id: go-cache
Expand Down Expand Up @@ -416,7 +416,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: 1.19
go-version: ~1.19.11
cache: false
- name: Cache Go
id: go-cache
Expand Down Expand Up @@ -547,7 +547,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: 1.19
go-version: ~1.19.11
cache: false
- name: Mkdir bin and dist
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
fetch-depth: 0
- uses: actions/setup-go@v4
with:
go-version: ~1.19.10
go-version: ~1.19.11
cache: false
- name: Cache Go
id: go-cache
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: ~1.19.10
go-version: ~1.19.11
cache: false

# Initializes the CodeQL tools for scanning.
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/create-dependabot-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
run: sudo apt-get update; sudo apt-get install zsh
- uses: actions/setup-go@v4
with:
go-version: ~1.19.10
go-version: ~1.19.11
cache: false
- name: Run dependabot-pr.sh
run: ./.github/workflows/scripts/dependabot-pr.sh
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: 1.19
go-version: ~1.19.11
cache: false
- name: Cache Go
id: go-cache
Expand Down Expand Up @@ -52,7 +52,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: 1.19
go-version: ~1.19.11
cache: false
- name: Cache Go
id: go-cache
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/load-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: 1.19
go-version: ~1.19.11
cache: false
- name: Cache Go
id: go-cache
Expand Down Expand Up @@ -64,7 +64,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: 1.19
go-version: ~1.19.11
cache: false
- name: Cache Go
id: go-cache
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/prepare-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
path: opentelemetry-collector-contrib
- uses: actions/setup-go@v4
with:
go-version: ~1.19.10
go-version: ~1.19.11
cache: false
- name: Prepare release for contrib
working-directory: opentelemetry-collector-contrib
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/prometheus-compliance-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
path: opentelemetry-collector-contrib
- uses: actions/setup-go@v4
with:
go-version: ~1.19.10
go-version: ~1.19.11
cache: false
- name: Cache Go
id: go-cache
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tidy-dependencies.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
token: ${{ secrets.OPENTELEMETRYBOT_GITHUB_TOKEN }}
- uses: actions/setup-go@v4
with:
go-version: 1.19
go-version: ~1.19.11
cache: false
- name: Cache Go
id: go-cache
Expand Down
3 changes: 0 additions & 3 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,6 @@ issues:
- path: deltatorateprocessor
linters:
- exhaustive
- path: groupbyattrsprocessor
linters:
- exhaustive
- path: filterprocessor
linters:
- exhaustive
Expand Down
4 changes: 2 additions & 2 deletions cmd/opampsupervisor/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ require (
github.com/knadh/koanf v1.5.0
github.com/oklog/ulid/v2 v2.1.0
github.com/open-telemetry/opamp-go v0.6.0
go.opentelemetry.io/collector/config/configtls v0.80.1-0.20230629144634-c3f70bd1f8ea
go.opentelemetry.io/collector/config/configtls v0.81.0
go.uber.org/zap v1.24.0
)

Expand All @@ -20,7 +20,7 @@ require (
github.com/mitchellh/reflectwalk v1.0.2 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/stretchr/testify v1.8.4 // indirect
go.opentelemetry.io/collector/config/configopaque v0.80.1-0.20230629144634-c3f70bd1f8ea // indirect
go.opentelemetry.io/collector/config/configopaque v0.81.0 // indirect
go.uber.org/atomic v1.7.0 // indirect
go.uber.org/multierr v1.6.0 // indirect
golang.org/x/sys v0.10.0 // indirect
Expand Down
8 changes: 4 additions & 4 deletions cmd/opampsupervisor/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions extension/observer/dockerobserver/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ func (h *testHost) ReportFatalError(err error) {
var _ component.Host = (*testHost)(nil)

func TestObserverEmitsEndpointsIntegration(t *testing.T) {
t.Skip("See https://github.com/testcontainers/testcontainers-go/issues/1359")
image := "docker.io/library/nginx"
tag := "1.17"

Expand Down Expand Up @@ -82,6 +83,7 @@ func TestObserverEmitsEndpointsIntegration(t *testing.T) {
}

func TestObserverUpdatesEndpointsIntegration(t *testing.T) {
t.Skip("See https://github.com/testcontainers/testcontainers-go/issues/1359")
image := "docker.io/library/nginx"
tag := "1.17"

Expand Down Expand Up @@ -143,6 +145,7 @@ func TestObserverUpdatesEndpointsIntegration(t *testing.T) {
}

func TestObserverRemovesEndpointsIntegration(t *testing.T) {
t.Skip("See https://github.com/testcontainers/testcontainers-go/issues/1359")
image := "docker.io/library/nginx"
tag := "1.17"

Expand Down Expand Up @@ -185,6 +188,7 @@ func TestObserverRemovesEndpointsIntegration(t *testing.T) {
}

func TestObserverExcludesImagesIntegration(t *testing.T) {
t.Skip("See https://github.com/testcontainers/testcontainers-go/issues/1359")
ctx := context.Background()
req := testcontainers.ContainerRequest{
Image: "docker.io/library/nginx:1.17",
Expand Down
2 changes: 2 additions & 0 deletions internal/coreinternal/scraperinttest/scraperint.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ func (it *IntegrationTest) Run(t *testing.T) {
}

func (it *IntegrationTest) createNetwork(t *testing.T) testcontainers.Network {
t.Skip("See https://github.com/testcontainers/testcontainers-go/issues/1359")
var errs error

var network testcontainers.Network
Expand All @@ -163,6 +164,7 @@ func (it *IntegrationTest) createNetwork(t *testing.T) testcontainers.Network {
}

func (it *IntegrationTest) createContainers(t *testing.T) *ContainerInfo {
t.Skip("See https://github.com/testcontainers/testcontainers-go/issues/1359")
var wg sync.WaitGroup
ci := &ContainerInfo{
containers: make(map[string]testcontainers.Container, len(it.containerRequests)),
Expand Down
14 changes: 7 additions & 7 deletions pkg/ottl/functions.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type Enum int64
func (p *Parser[K]) newFunctionCall(ed editor) (Expr[K], error) {
f, ok := p.functions[ed.Function]
if !ok {
return Expr[K]{}, fmt.Errorf("undefined function %v", ed.Function)
return Expr[K]{}, fmt.Errorf("undefined function %q", ed.Function)
}
args := f.CreateDefaultArguments()

Expand All @@ -30,12 +30,12 @@ func (p *Parser[K]) newFunctionCall(ed editor) (Expr[K], error) {
// settability requirements. Non-pointer values are not
// modifiable through reflection.
if reflect.TypeOf(args).Kind() != reflect.Pointer {
return Expr[K]{}, fmt.Errorf("factory for %s must return a pointer to an Arguments value in its CreateDefaultArguments method", ed.Function)
return Expr[K]{}, fmt.Errorf("factory for %q must return a pointer to an Arguments value in its CreateDefaultArguments method", ed.Function)
}

err := p.buildArgs(ed, reflect.ValueOf(args).Elem())
if err != nil {
return Expr[K]{}, fmt.Errorf("error while parsing arguments for call to '%v': %w", ed.Function, err)
return Expr[K]{}, fmt.Errorf("error while parsing arguments for call to %q: %w", ed.Function, err)
}
}

Expand All @@ -61,17 +61,17 @@ func (p *Parser[K]) buildArgs(ed editor, argsVal reflect.Value) error {
fieldTag, ok := argsType.Field(i).Tag.Lookup("ottlarg")

if !ok {
return fmt.Errorf("no `ottlarg` struct tag on Arguments field '%s'", argsType.Field(i).Name)
return fmt.Errorf("no `ottlarg` struct tag on Arguments field %q", argsType.Field(i).Name)
}

argNum, err := strconv.Atoi(fieldTag)

if err != nil {
return fmt.Errorf("ottlarg struct tag on field '%s' is not a valid integer: %w", argsType.Field(i).Name, err)
return fmt.Errorf("ottlarg struct tag on field %q is not a valid integer: %w", argsType.Field(i).Name, err)
}

if argNum < 0 || argNum >= len(ed.Arguments) {
return fmt.Errorf("ottlarg struct tag on field '%s' has value %d, but must be between 0 and %d", argsType.Field(i).Name, argNum, len(ed.Arguments))
return fmt.Errorf("ottlarg struct tag on field %q has value %d, but must be between 0 and %d", argsType.Field(i).Name, argNum, len(ed.Arguments))
}

argVal := ed.Arguments[argNum]
Expand Down Expand Up @@ -167,7 +167,7 @@ func (p *Parser[K]) buildSliceArg(argVal value, argType reflect.Type) (any, erro
}
return arg, nil
default:
return nil, fmt.Errorf("unsupported slice type '%s' for function", argType.Elem().Name())
return nil, fmt.Errorf("unsupported slice type %q for function", argType.Elem().Name())
}
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/ottl/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ require (
go.opentelemetry.io/collector/component v0.81.0
go.opentelemetry.io/collector/pdata v1.0.0-rcv0013
go.opentelemetry.io/otel/trace v1.16.0
go.uber.org/multierr v1.11.0
go.uber.org/zap v1.24.0
golang.org/x/exp v0.0.0-20230510235704-dd950f8aeaea
)
Expand All @@ -35,7 +36,6 @@ require (
go.opentelemetry.io/otel v1.16.0 // indirect
go.opentelemetry.io/otel/metric v1.16.0 // indirect
go.uber.org/atomic v1.10.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/net v0.12.0 // indirect
golang.org/x/sys v0.10.0 // indirect
golang.org/x/text v0.11.0 // indirect
Expand Down
Loading