The following commands were run to prepare this release:
- make chlog-update VERSION=v1.20.0/v0.114.0
- make prepare-release PREVIOUS_VERSION=1[.]19[.]0
RELEASE_CANDIDATE=1.20.0 MODSET=stable
- make prepare-release PREVIOUS_VERSION=0[.]113[.]0
RELEASE_CANDIDATE=0.114.0 MODSET=beta
---------
Signed-off-by: Alex Boten <223565+codeboten@users.noreply.github.com>
Co-authored-by: Alex Boten <223565+codeboten@users.noreply.github.com>
The following commands were run to prepare this release:
- make chlog-update VERSION=v1.19.0/v0.113.0
- make prepare-release PREVIOUS_VERSION=1[.]18[.]0
RELEASE_CANDIDATE=1.19.0 MODSET=stable
- make prepare-release PREVIOUS_VERSION=0[.]112[.]0
RELEASE_CANDIDATE=0.113.0 MODSET=beta
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### Description
This adds profiles support in fanoutconsumer. That is required to be
able to handle profiles in the service graph.
As this is only changing internal modules, I am marking it as chore (and
skipping changelog entry).
<!-- Issue number if applicable -->
#### Link to tracking issue
https://github.com/open-telemetry/opentelemetry-collector/pull/10375
cc @mx-psi
This reduces dependencies from the consumer package while making
testdata available across repos. It will allow us to remove duplicated
code and its a fairly small surface area.
Fixes
https://github.com/open-telemetry/opentelemetry-collector/issues/9886
---------
Signed-off-by: Alex Boten <223565+codeboten@users.noreply.github.com>
**Description:**
It was suggested that we add the [goleak
package](https://pkg.go.dev/go.uber.org/goleak) to every test in core.
This change adds `goleak` to every package that is succeeds with goleak.
There a number that are not successful, the full list of which I've
posted in the bug.
I generated these files using a shell script to copy a template
`main_test.go` file into each package, then modified the package name.
I'm sure there was a better way to automate this, but it worked well
enough at this point. Here's the script:
```
cp ./main_test.go $1
PACKAGE_NAME=$(basename $1)
sed -i '' -e "s|package component|package $PACKAGE_NAME|g"
$1/main_test.go
pushd . && cd $1 && go mod tidy
go test -v .
```
Usage example:
```
$ ./add_leak_test reciever/scrapererror
```
**Link to tracking Issue:**
#9165
**Testing:**
All added tests are passing, but there are a number failing. Note that there's no sign of `goleak` running until it fails.
This fixes two closely related problems.
1. While fanoutconsumers do not themselves mutate data, they should
expose whether or not they are handing data off to consumers which may
do so. Otherwise, the service cannot correctly determine how to fan out
after a receiver. e.g. a receiver shared between two pipelines, one of
which contains an exporter or connector which mutates data.
2. Connectors can themselves mutate data but we were not taking this
into account when building the graph.
A follow-up optimization after merging
https://github.com/open-telemetry/opentelemetry-collector/pull/8634.
There is no need to create a fanout consumer for only one read-only
consumer. This introduces a behavior that closely resembles its previous
state, before the introduction of the readonly/mutable states.
This change enables the runtime assertions to catch unintentional pdata
mutations in components claiming as non-mutating pdata. Without these
assertions, runtime errors may still occur, but thrown by unrelated
components, making it very difficult to troubleshoot.
This required introducing extra API to get the pdata mutability state:
- p[metric|trace|log].[Metrics|Traces|Logs].IsReadOnly()
Resolves:
https://github.com/open-telemetry/opentelemetry-collector/issues/6794
This PR adds helpers to `connectortest` to aid the construction of
`connector.*Router`s for testing connectors. This was implemented based
on @djaglowski's [comment
here](https://github.com/open-telemetry/opentelemetry-collector-contrib/pull/21498#issuecomment-1542682841),
with some slight modifications. I found it more ergonomic to pass the
sink into the `WithTracesSink` (and similar) options. You usually want a
handle on the sink after creating the router. While it's possible to get
the sink out of the router after the fact, it's a little cumbersome.
These helpers will be useful for
https://github.com/open-telemetry/opentelemetry-collector-contrib/pull/21498
and future connectors that need use of routers.
For example, here is a test with the consumer passed in:
```go
func TestFanoutTracesWithSink(t *testing.T) {
var sink0, sink1 consumertest.TracesSink
tr, err := NewTracesRouterSink(
WithTracesSink(component.NewIDWithName(component.DataTypeTraces, "0"), &sink0),
WithTracesSink(component.NewIDWithName(component.DataTypeTraces, "1"), &sink1),
)
require.NoError(t, err)
require.Equal(t, 0, sink0.SpanCount())
require.Equal(t, 0, sink1.SpanCount())
td := testdata.GenerateTraces(1)
err = tr.(consumer.Traces).ConsumeTraces(context.Background(), td)
require.NoError(t, err)
require.Equal(t, 1, sink0.SpanCount())
require.Equal(t, 1, sink1.SpanCount())
}
```
The same test having to extract the consumer out after the fact:
```go
func TestFanoutTracesWithSink(t *testing.T) {
traces0 := component.NewIDWithName(component.DataTypeTraces, "0")
traces1 := component.NewIDWithName(component.DataTypeTraces, "1")
tr, err := NewTracesRouterSink(
WithTracesSink(traces0),
WithTracesSink(traces1),
)
require.NoError(t, err)
cons0, _ := tr.Consumer(traces0)
sink0 := cons0.(*consumertest.TracesSink)
cons1, _ := tr.Consumer(traces1)
sink1 := cons1.(*consumertest.TracesSink)
require.Equal(t, 0, sink0.SpanCount())
require.Equal(t, 0, sink1.SpanCount())
td := testdata.GenerateTraces(1)
err = tr.(consumer.Traces).ConsumeTraces(context.Background(), td)
require.NoError(t, err)
require.Equal(t, 1, sink0.SpanCount())
require.Equal(t, 1, sink1.SpanCount())}
}
```
**Link to tracking Issue:**
#7672
**Testing:**
Unit tests
**Documentation:**
Source code comments
---------
Co-authored-by: Daniel Jaglowski <jaglows3@gmail.com>