Skip to content

Commit

Permalink
Merge branch 'main' into add-logs-scraper-in-factory
Browse files Browse the repository at this point in the history
  • Loading branch information
sincejune authored Jan 4, 2025
2 parents f13709c + 3e87d0d commit 42fb906
Show file tree
Hide file tree
Showing 36 changed files with 629 additions and 268 deletions.
25 changes: 25 additions & 0 deletions .chloggen/add-scrapertest.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Use this changelog template to create an entry for release notes.

# 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. otlpreceiver)
component: scrapertest

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Add scrapertest package in a separate module

# One or more tracking issues or pull requests related to the change
issues: [11988]

# (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:

# Optional: The change log or logs in which this entry should be included.
# e.g. '[user]' or '[user, api]'
# Include 'user' if the change is relevant to end users.
# Include 'api' if there is a change to a library API.
# Default: '[user]'
change_logs: [api]
58 changes: 41 additions & 17 deletions .github/workflows/prepare-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@ on:
current-beta:
required: true
description: Current version (beta, like 0.95.1). Don't include `v`.

permissions: read-all

jobs:
#validate-version format
validate-versions:
validate-versions-format:
runs-on: ubuntu-latest

steps:
Expand Down Expand Up @@ -58,10 +60,9 @@ jobs:
exit 1
fi
# Releasing opentelemetry-collector
prepare-release:
check-blockers:
needs:
- validate-versions
- validate-versions-format
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
Expand Down Expand Up @@ -91,6 +92,41 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPO: open-telemetry/opentelemetry-collector-contrib
run: ./.github/workflows/scripts/release-check-build-status.sh

create-release-issue:
needs:
- check-blockers
runs-on: ubuntu-latest
permissions:
issues: write
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0
# To keep track of the progress, it might be helpful to create a tracking issue similar to #6067. You are responsible
# for all of the steps under the "Performed by collector release manager" heading. Once the issue is created, you can
# create the individual ones by hovering them and clicking the "Convert to issue" button on the right hand side.
- name: Create issue for tracking release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CANDIDATE_BETA: ${{ inputs.candidate-beta }}
CANDIDATE_STABLE: ${{ inputs.candidate-stable }}
CURRENT_BETA: ${{ inputs.current-beta }}
CURRENT_STABLE: ${{ inputs.current-stable }}
REPO: open-telemetry/opentelemetry-collector
run: ./.github/workflows/scripts/release-create-tracking-issue.sh

# Releasing opentelemetry-collector
prepare-release:
needs:
- check-blockers
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0
- name: Setup Go
uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0
with:
Expand All @@ -108,15 +144,3 @@ jobs:
CURRENT_BETA: ${{ inputs.current-beta }}
CURRENT_STABLE: ${{ inputs.current-stable }}
run: ./.github/workflows/scripts/release-prepare-release.sh
# To keep track of the progress, it might be helpful to create a tracking issue similar to #6067. You are responsible
# for all of the steps under the "Performed by collector release manager" heading. Once the issue is created, you can
# create the individual ones by hovering them and clicking the "Convert to issue" button on the right hand side.
- name: Create issue for tracking release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CANDIDATE_BETA: ${{ inputs.candidate-beta }}
CANDIDATE_STABLE: ${{ inputs.candidate-stable }}
CURRENT_BETA: ${{ inputs.current-beta }}
CURRENT_STABLE: ${{ inputs.current-stable }}
REPO: open-telemetry/opentelemetry-collector
run: ./.github/workflows/scripts/release-create-tracking-issue.sh
43 changes: 43 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,50 @@ linters-settings:
# minimal confidence for issues, default is 0.8
min-confidence: 0.8
rules:
# Blank import should be only in a main or test package, or have a comment justifying it.
- name: blank-imports
# context.Context() should be the first parameter of a function when provided as argument.
- name: context-as-argument
# Basic types should not be used as a key in `context.WithValue`
- name: context-keys-type
# Importing with `.` makes the programs much harder to understand
- name: dot-imports
# Empty blocks make code less readable and could be a symptom of a bug or unfinished refactoring.
- name: empty-block
# for better readability, variables of type `error` must be named with the prefix `err`.
- name: error-naming
# for better readability, the errors should be last in the list of returned values by a function.
- name: error-return
# for better readability, error messages should not be capitalized or end with punctuation or a newline.
- name: error-strings
# report when replacing `errors.New(fmt.Sprintf())` with `fmt.Errorf()` is possible
- name: errorf
# incrementing an integer variable by 1 is recommended to be done using the `++` operator
- name: increment-decrement
# highlights redundant else-blocks that can be eliminated from the code
- name: indent-error-flow
# This rule suggests a shorter way of writing ranges that do not use the second value.
- name: range
# receiver names in a method should reflect the struct name (p for Person, for example)
- name: receiver-naming
# redefining built in names (true, false, append, make) can lead to bugs very difficult to detect.
- name: redefines-builtin-id
# redundant else-blocks that can be eliminated from the code.
- name: superfluous-else
# prevent confusing name for variables when using `time` package
- name: time-naming
# warns when an exported function or method returns a value of an un-exported type.
- name: unexported-return
# spots and proposes to remove unreachable code. also helps to spot errors
- name: unreachable-code
# Functions or methods with unused parameters can be a symptom of an unfinished refactoring or a bug.
- name: unused-parameter
# Since Go 1.18, interface{} has an alias: any. This rule proposes to replace instances of interface{} with any.
- name: use-any
# report when a variable declaration can be simplified
- name: var-declaration
# warns when initialism, variable or package naming conventions are not followed.
- name: var-naming

depguard:
rules:
Expand Down
2 changes: 1 addition & 1 deletion client/doc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (

func Example_receiver() {
// Your receiver get a next consumer when it's constructed
next, err := consumer.NewTraces(func(ctx context.Context, td ptrace.Traces) error {
next, err := consumer.NewTraces(func(_ context.Context, _ ptrace.Traces) error {
return nil
})
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion cmd/otelcorecol/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ require (
github.com/prometheus/common v0.61.0 // indirect
github.com/prometheus/procfs v0.15.1 // indirect
github.com/rs/cors v1.11.1 // indirect
github.com/shirou/gopsutil/v4 v4.24.11 // indirect
github.com/shirou/gopsutil/v4 v4.24.12 // indirect
github.com/spf13/cobra v1.8.1 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/stretchr/testify v1.10.0 // indirect
Expand Down
4 changes: 2 additions & 2 deletions cmd/otelcorecol/go.sum

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

20 changes: 11 additions & 9 deletions docs/release.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,30 +107,32 @@ Before the release, make sure there are no open release blockers in [core](https

The last step of the release process creates artifacts for the new version of the collector and publishes images to Dockerhub. The steps in this portion of the release are done in the [opentelemetry-collector-releases](https://github.com/open-telemetry/opentelemetry-collector-releases) repo.

1. Update the `./distributions/**/manifest.yaml` files to include the new release version.
1. As of https://github.com/open-telemetry/opentelemetry-collector-releases/pull/684, sub-steps 1-4 below are now automated. Manually run GitHub Action workflow "Update Version in Distributions and Prepare PR" which will update the minor version automatically (e.g. v0.116.0 -> v0.117.0) or manually provide a new version if releasing a bugfix or skipping a version. Select "create pr" option to commit the changes and allow GitHub bot to create a draft PR with changes from sub-steps 1-3 included. Alternatively, you can run the ['bump-versions.sh' script locally in the opentelemetry-collector-releases repo](https://github.com/open-telemetry/opentelemetry-collector-releases/blob/main/.github/workflows/scripts/bump-versions.sh) with optional arguments for next version number(s) and whether to commit changes and create PR with GitHub CLI.

2. Update the builder version in `OTELCOL_BUILDER_VERSION` to the new release in the `Makefile`. While this might not be strictly necessary for every release, this is a good practice.
1. Update the `./distributions/**/manifest.yaml` files to include the new release version.

3. Run `make chlog-update VERSION="${RELEASE_VERSION}"` with the version of the artifacts.
2. Update the builder version in `OTELCOL_BUILDER_VERSION` to the new release in the `Makefile`. While this might not be strictly necessary for every release, this is a good practice.

4. Create a pull request with the change and ensure the build completes successfully. See [example](https://github.com/open-telemetry/opentelemetry-collector-releases/pull/71).
3. Run `make chlog-update VERSION="${RELEASE_VERSION}"` with the version of the artifacts.

4. Create a pull request with the change and ensure the build completes successfully. See [example](https://github.com/open-telemetry/opentelemetry-collector-releases/pull/71).
- 🛑 **Do not move forward until this PR is merged.** 🛑

5. Check out main and ensure it has the "Prepare release" commit in your local
2. Check out main and ensure it has the "Prepare release" commit in your local
copy by pulling in the latest from
`open-telemetry/opentelemetry-collector-releases`. Assuming your upstream
remote is named `upstream`, you can try running:
- `git checkout main && git fetch upstream && git rebase upstream/main`

6. Create a tag for the new release version by running:
3. Create a tag for the new release version by running:

⚠️ If you set your remote using `https` you need to include `REMOTE=https://github.com/open-telemetry/opentelemetry-collector-contrib.git` in each command. ⚠️

- `make push-tags TAG=v0.85.0`

7. Wait for the new tag build to pass successfully.
4. Wait for the new tag build to pass successfully.

8. Ensure the "Release Core", "Release Contrib", "Release k8s", and "Builder - Release" actions pass, this will
5. Ensure the "Release Core", "Release Contrib", "Release k8s", and "Builder - Release" actions pass, this will

1. push new container images to `https://hub.docker.com/repository/docker/otel/opentelemetry-collector`, `https://hub.docker.com/repository/docker/otel/opentelemetry-collector-contrib` and `https://hub.docker.com/repository/docker/otel/opentelemetry-collector-k8s`

Expand All @@ -140,7 +142,7 @@ The last step of the release process creates artifacts for the new version of th

4. build and push ocb Docker images to `https://hub.docker.com/r/otel/opentelemetry-collector-builder` and the GitHub Container Registry within the releases repository

9. Update the release notes with the CHANGELOG.md updates.
6. Update the release notes with the CHANGELOG.md updates.

## Post-release steps

Expand Down
13 changes: 1 addition & 12 deletions exporter/exporterhelper/internal/base_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ type BaseExporter struct {
component.StartFunc
component.ShutdownFunc

Signal pipeline.Signal

Marshaler exporterqueue.Marshaler[internal.Request]
Unmarshaler exporterqueue.Unmarshaler[internal.Request]

Expand Down Expand Up @@ -75,8 +73,6 @@ func NewBaseExporter(set exporter.Settings, signal pipeline.Signal, osf ObsrepSe
}

be := &BaseExporter{
Signal: signal,

BatchSender: &BaseRequestSender{},
QueueSender: &BaseRequestSender{},
ObsrepSender: osf(obsReport),
Expand All @@ -98,14 +94,11 @@ func NewBaseExporter(set exporter.Settings, signal pipeline.Signal, osf ObsrepSe
q := be.queueFactory(
context.Background(),
exporterqueue.Settings{
Signal: be.Signal,
Signal: signal,
ExporterSettings: be.Set,
},
be.queueCfg)
be.QueueSender = NewQueueSender(q, be.Set, be.queueCfg.NumConsumers, be.ExportFailureMessage, be.Obsrep, be.BatcherCfg)
for _, op := range options {
err = multierr.Append(err, op(be))
}
}

if !usePullingBasedExporterQueueBatcher.IsEnabled() && be.BatcherCfg.Enabled ||
Expand All @@ -114,10 +107,6 @@ func NewBaseExporter(set exporter.Settings, signal pipeline.Signal, osf ObsrepSe
be.BatchSender = bs
}

if err != nil {
return nil, err
}

be.connectSenders()

if bs, ok := be.BatchSender.(*BatchSender); ok {
Expand Down
17 changes: 11 additions & 6 deletions exporter/exporterhelper/logs_batch.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,24 @@ func (req *logsRequest) Merge(_ context.Context, r2 Request) (Request, error) {
// MergeSplit splits and/or merges the provided logs request and the current request into one or more requests
// conforming with the MaxSizeConfig.
func (req *logsRequest) MergeSplit(_ context.Context, cfg exporterbatcher.MaxSizeConfig, r2 Request) ([]Request, error) {
var req2 *logsRequest
if r2 != nil {
var ok bool
req2, ok = r2.(*logsRequest)
if !ok {
return nil, errors.New("invalid input type")
}
}

var (
res []Request
destReq *logsRequest
capacityLeft = cfg.MaxSizeItems
)
for _, req := range []Request{req, r2} {
if req == nil {
for _, srcReq := range []*logsRequest{req, req2} {
if srcReq == nil {
continue
}
srcReq, ok := req.(*logsRequest)
if !ok {
return nil, errors.New("invalid input type")
}
if srcReq.ld.LogRecordCount() <= capacityLeft {
if destReq == nil {
destReq = srcReq
Expand Down
12 changes: 10 additions & 2 deletions exporter/exporterhelper/logs_batch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func TestMergeLogsInvalidInput(t *testing.T) {
lr1 := &tracesRequest{td: testdata.GenerateTraces(2)}
lr2 := &logsRequest{ld: testdata.GenerateLogs(3)}
_, err := lr1.Merge(context.Background(), lr2)
assert.Error(t, err)
require.Error(t, err)
}

func TestMergeSplitLogs(t *testing.T) {
Expand Down Expand Up @@ -129,11 +129,19 @@ func TestMergeSplitLogs(t *testing.T) {
}
}

func TestMergeSplitLogsInputNotModifiedIfErrorReturned(t *testing.T) {
r1 := &logsRequest{ld: testdata.GenerateLogs(18)}
r2 := &tracesRequest{td: testdata.GenerateTraces(3)}
_, err := r1.MergeSplit(context.Background(), exporterbatcher.MaxSizeConfig{MaxSizeItems: 10}, r2)
require.Error(t, err)
assert.Equal(t, 18, r1.ItemsCount())
}

func TestMergeSplitLogsInvalidInput(t *testing.T) {
r1 := &tracesRequest{td: testdata.GenerateTraces(2)}
r2 := &logsRequest{ld: testdata.GenerateLogs(3)}
_, err := r1.MergeSplit(context.Background(), exporterbatcher.MaxSizeConfig{}, r2)
assert.Error(t, err)
require.Error(t, err)
}

func TestExtractLogs(t *testing.T) {
Expand Down
17 changes: 11 additions & 6 deletions exporter/exporterhelper/metrics_batch.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,24 @@ func (req *metricsRequest) Merge(_ context.Context, r2 Request) (Request, error)
// MergeSplit splits and/or merges the provided metrics request and the current request into one or more requests
// conforming with the MaxSizeConfig.
func (req *metricsRequest) MergeSplit(_ context.Context, cfg exporterbatcher.MaxSizeConfig, r2 Request) ([]Request, error) {
var req2 *metricsRequest
if r2 != nil {
var ok bool
req2, ok = r2.(*metricsRequest)
if !ok {
return nil, errors.New("invalid input type")
}
}

var (
res []Request
destReq *metricsRequest
capacityLeft = cfg.MaxSizeItems
)
for _, req := range []Request{req, r2} {
if req == nil {
for _, srcReq := range []*metricsRequest{req, req2} {
if srcReq == nil {
continue
}
srcReq, ok := req.(*metricsRequest)
if !ok {
return nil, errors.New("invalid input type")
}
if srcReq.md.DataPointCount() <= capacityLeft {
if destReq == nil {
destReq = srcReq
Expand Down
Loading

0 comments on commit 42fb906

Please sign in to comment.