Skip to content

Commit

Permalink
Merge branch 'main' into fix-contrib-mdatagen-test
Browse files Browse the repository at this point in the history
  • Loading branch information
PrateekKumar1709 authored Sep 22, 2024
2 parents ceb4f92 + d17559b commit 39acea4
Show file tree
Hide file tree
Showing 29 changed files with 727 additions and 202 deletions.
25 changes: 25 additions & 0 deletions .chloggen/add-pipeline-module.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: new_component

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

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Adds new `pipeline` module to house the concept of pipeline ID and Signal.

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

# (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]
20 changes: 20 additions & 0 deletions .chloggen/consumertest-profiles-samplecount.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# 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: consumertest

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Introduce SampleCount method in ProfilesSink struct.

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

# 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]
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -304,11 +304,13 @@ check-contrib:
-replace go.opentelemetry.io/collector/extension/zpagesextension=$(CURDIR)/extension/zpagesextension \
-replace go.opentelemetry.io/collector/featuregate=$(CURDIR)/featuregate \
-replace go.opentelemetry.io/collector/internal/globalgates=$(CURDIR)/internal/globalgates \
-replace go.opentelemetry.io/collector/internal/globalsignal=$(CURDIR)/internal/globalsignal \
-replace go.opentelemetry.io/collector/otelcol=$(CURDIR)/otelcol \
-replace go.opentelemetry.io/collector/otelcol/otelcoltest=$(CURDIR)/otelcol/otelcoltest \
-replace go.opentelemetry.io/collector/pdata=$(CURDIR)/pdata \
-replace go.opentelemetry.io/collector/pdata/testdata=$(CURDIR)/pdata/testdata \
-replace go.opentelemetry.io/collector/pdata/pprofile=$(CURDIR)/pdata/pprofile \
-replace go.opentelemetry.io/collector/pipeline=$(CURDIR)/pipeline \
-replace go.opentelemetry.io/collector/processor=$(CURDIR)/processor \
-replace go.opentelemetry.io/collector/processor/batchprocessor=$(CURDIR)/processor/batchprocessor \
-replace go.opentelemetry.io/collector/processor/memorylimiterprocessor=$(CURDIR)/processor/memorylimiterprocessor \
Expand Down Expand Up @@ -371,11 +373,13 @@ restore-contrib:
-dropreplace go.opentelemetry.io/collector/extension/zpagesextension \
-dropreplace go.opentelemetry.io/collector/featuregate \
-dropreplace go.opentelemetry.io/collector/internal/globalgates \
-dropreplace go.opentelemetry.io/collector/internal/globalsignal \
-dropreplace go.opentelemetry.io/collector/otelcol \
-dropreplace go.opentelemetry.io/collector/otelcol/otelcoltest \
-dropreplace go.opentelemetry.io/collector/pdata \
-dropreplace go.opentelemetry.io/collector/pdata/testdata \
-dropreplace go.opentelemetry.io/collector/pdata/pprofile \
-dropreplace go.opentelemetry.io/collector/pipeline \
-dropreplace go.opentelemetry.io/collector/processor \
-dropreplace go.opentelemetry.io/collector/processor/batchprocessor \
-dropreplace go.opentelemetry.io/collector/processor/memorylimiterprocessor \
Expand Down
9 changes: 0 additions & 9 deletions Makefile.Common
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ MULTIMOD := $(TOOLS_BIN_DIR)/multimod
PORTO := $(TOOLS_BIN_DIR)/porto
SEMCONVGEN := $(TOOLS_BIN_DIR)/semconvgen
SEMCONVKIT := $(TOOLS_BIN_DIR)/semconvkit
TESTIFYLINT := $(TOOLS_BIN_DIR)/testifylint

TESTIFYLINT_OPT?= --enable-all

.PHONY: install-tools
install-tools: $(TOOLS_BIN_NAMES)
Expand Down Expand Up @@ -91,9 +88,3 @@ impi: $(IMPI)
.PHONY: moddownload
moddownload:
$(GOCMD) mod download

.PHONY: testifylint-fix
testifylint-fix:$(TESTIFYLINT)
@echo "running $(TESTIFYLINT)"
@$(TESTIFYLINT) $(TESTIFYLINT_OPT) -fix ./...

50 changes: 43 additions & 7 deletions VERSIONING.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,42 @@
# Versioning
# Versioning and stability

This document describes the versioning policy for this repository. This policy
is designed so that the following goal can be achieved:
The OpenTelemetry Collector SIG produces several artifacts for [a variety of audiences](CONTRIBUTING.md#target-audiences). This document describes the versioning and support policy for these artifacts. These policies are designed so that the following goal can be achieved:

**Users are provided a codebase of value that is stable and secure.**
**Users are provided software artifacts of value that are stable and secure.**

## Public API expectations
The policies are divided depending on the artifact's target audience. While an artifact is supported, [critical bugs](docs/release.md#bugfix-release-criteria) and security vulnerabilities MUST be addressed. The main criteria for the length of support for an artifact is how easy it is for an artifact's target audience to adapt to disruptive changes.

The following public API expectations apply to all modules in opentelemetry-collector and opentelemetry-collector-contrib.
These policies reflect the current consensus of the OpenTelemetry Collector SIG. They are subject to change as the project evolves.

## Software artifacts for end users

Software artifacts intended for [end users](CONTRIBUTING.md#end-users) of the OpenTelemetry Collector include
- Binary distributions of the OpenTelemetry Collector.
- Go modules that expose Collector components, such as receivers, processors, connectors, extensions and exporters.

These artifacts are versioned according to the [semantic versioning v2.0.0](https://semver.org/) specification.

### General considerations

Binary distributions produced by the Collector SIG contain components and features with varying [levels of stability](README.md#stability-levels). We abide by the following principles to relate the Collector's version to the stability of its components and features:

* The Collector's core framework behavior MUST be stable in order for a Collector distribution to be v1.0.0 or higher.
* Users can easily understand when they are opting in to use a component or feature that is not stable.
* The Collector MUST be configurable so that unstable components or features can be excluded ensuring that a fully stable configuration is possible.
* The Collector's telemetry (e.g. Collector logs) MUST provide the ability to identify usage of unstable components or features.

### Long-term support after v1

The OpenTelemetry Collector SIG provides long-term support for stable binary distributions of the OpenTelemetry Collector and its components. The following policies apply to long-term support for any major version starting on v1:

* A binary distribution of the OpenTelemetry Collector MUST be supported for a minimum of **one year** after the release of the next major version of said distribution.
* Components MUST be supported for a minimum of **6 months** after the release of the next major version of said component or after the component has been marked as deprecated. If a component has been deprecated for 6 months it MAY be removed from a binary distribution of the OpenTelemetry Collector. This does not imply a major version change in the Collector distribution.

## Go modules

Go modules are intended to be used by [component developers](CONTRIBUTING.md#component-developers) and [Collector library users](CONTRIBUTING.md#collector-library-users) of the OpenTelemetry Collector

Unless otherwise specified, the following public API expectations apply to all modules in opentelemetry-collector and opentelemetry-collector-contrib.
As a general rule, stability guarantees of modules versioned as `v1` or higher are aligned with [Go 1 compatibility promise](https://go.dev/doc/go1compat).

### General Go API considerations
Expand Down Expand Up @@ -54,7 +83,7 @@ structure.
must continue to be valid after a change to the validation rules, except when the configuration struct would cause an error
on its intended usage (e.g. when calling a method or when passed to any method or function in any module under opentelemetry-collector).

## Versioning and module schema
### Module versioning and schema

* Versioning of this project will be idiomatic of a Go project using [Go
modules](https://golang.org/ref/mod#versions).
Expand Down Expand Up @@ -135,3 +164,10 @@ on its intended usage (e.g. when calling a method or when passed to any method o
* Contrib modules will be kept up to date with this project's releases.
* GitHub releases will be made for all releases.
* Go modules will be made available at Go package mirrors.

### Long-term support after v1

The OpenTelemetry Collector SIG provides long-term support for stable Go modules. Support for modules depend on the module's [target audiences](CONTRIBUTING.md#target-audiences). The following policies apply to long-term support for any major version starting on v1:

- Modules intended for **component developers** MUST be supported for a minimum of **1 year** after the release of the next major version of said module or after the module has been marked as deprecated.
- Modules intended for **Collector library users** MUST be supported for a minimum of **6 months** after the release of the next major version of said module or after the module has been marked as deprecated.
14 changes: 12 additions & 2 deletions consumer/consumertest/sink.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,9 @@ func (sle *LogsSink) Reset() {
// stores all profiles and allows querying them for testing.
type ProfilesSink struct {
nonMutatingConsumer
mu sync.Mutex
profiles []pprofile.Profiles
mu sync.Mutex
profiles []pprofile.Profiles
sampleCount int
}

var _ consumerprofiles.Profiles = (*ProfilesSink)(nil)
Expand All @@ -175,6 +176,7 @@ func (ste *ProfilesSink) ConsumeProfiles(_ context.Context, td pprofile.Profiles
defer ste.mu.Unlock()

ste.profiles = append(ste.profiles, td)
ste.sampleCount += td.SampleCount()

return nil
}
Expand All @@ -189,10 +191,18 @@ func (ste *ProfilesSink) AllProfiles() []pprofile.Profiles {
return copyProfiles
}

// ProfileRecordCount returns the number of profiles stored by this sink since last Reset.
func (ste *ProfilesSink) SampleCount() int {
ste.mu.Lock()
defer ste.mu.Unlock()
return ste.sampleCount
}

// Reset deletes any stored data.
func (ste *ProfilesSink) Reset() {
ste.mu.Lock()
defer ste.mu.Unlock()

ste.profiles = nil
ste.sampleCount = 0
}
2 changes: 2 additions & 0 deletions consumer/consumertest/sink_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ func TestProfilesSink(t *testing.T) {
want = append(want, td)
}
assert.Equal(t, want, sink.AllProfiles())
assert.Equal(t, len(want), sink.SampleCount())
sink.Reset()
assert.Empty(t, sink.AllProfiles())
assert.Empty(t, sink.SampleCount())
}
1 change: 1 addition & 0 deletions internal/globalsignal/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include ../../Makefile.Common
11 changes: 11 additions & 0 deletions internal/globalsignal/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module go.opentelemetry.io/collector/internal/globalsignal

go 1.22.0

require github.com/stretchr/testify v1.9.0

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
10 changes: 10 additions & 0 deletions internal/globalsignal/go.sum

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

50 changes: 50 additions & 0 deletions internal/globalsignal/signal.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

package globalsignal // import "go.opentelemetry.io/collector/internal/globalsignal"

import (
"fmt"
"regexp"
)

// Signal represents the signals supported by the collector.
type Signal struct {
name string
}

// String returns the string representation of the signal.
func (s Signal) String() string {
return s.name
}

// MarshalText marshals the Signal.
func (s Signal) MarshalText() (text []byte, err error) {
return []byte(s.name), nil
}

// signalRegex is used to validate the signal.
// A signal must consist of 1 to 62 lowercase ASCII alphabetic characters.
var signalRegex = regexp.MustCompile(`^[a-z]{1,62}$`)

// NewSignal creates a Signal. It returns an error if the Signal is invalid.
// A Signal must consist of 1 to 62 lowercase ASCII alphabetic characters.
func NewSignal(signal string) (Signal, error) {
if len(signal) == 0 {
return Signal{}, fmt.Errorf("signal must not be empty")
}
if !signalRegex.MatchString(signal) {
return Signal{}, fmt.Errorf("invalid character(s) in type %q", signal)
}
return Signal{name: signal}, nil
}

// MustNewSignal creates a Signal. It panics if the Signal is invalid.
// A signal must consist of 1 to 62 lowercase ASCII alphabetic characters.
func MustNewSignal(signal string) Signal {
s, err := NewSignal(signal)
if err != nil {
panic(err)
}
return s
}
41 changes: 41 additions & 0 deletions internal/globalsignal/signal_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

package globalsignal

import (
"testing"

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

func Test_NewSignal(t *testing.T) {
s, err := NewSignal("traces")
require.NoError(t, err)
assert.Equal(t, Signal{name: "traces"}, s)
}

func Test_NewSignal_Invalid(t *testing.T) {
_, err := NewSignal("")
require.Error(t, err)
_, err = NewSignal("TRACES")
require.Error(t, err)
}

func Test_MustNewSignal(t *testing.T) {
s := MustNewSignal("traces")
assert.Equal(t, Signal{name: "traces"}, s)
}

func Test_Signal_String(t *testing.T) {
s := MustNewSignal("traces")
assert.Equal(t, "traces", s.String())
}

func Test_Signal_MarshalText(t *testing.T) {
s := MustNewSignal("traces")
b, err := s.MarshalText()
require.NoError(t, err)
assert.Equal(t, []byte("traces"), b)
}
2 changes: 1 addition & 1 deletion internal/tools/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ go 1.22.1
toolchain go1.22.7

require (
github.com/Antonboom/testifylint v1.4.3
github.com/a8m/envsubst v1.4.2
github.com/client9/misspell v0.3.4
github.com/golangci/golangci-lint v1.60.1
Expand All @@ -30,6 +29,7 @@ require (
github.com/Abirdcfly/dupword v0.0.14 // indirect
github.com/Antonboom/errname v0.1.13 // indirect
github.com/Antonboom/nilnil v0.1.9 // indirect
github.com/Antonboom/testifylint v1.4.3 // indirect
github.com/BurntSushi/toml v1.4.1-0.20240526193622-a339e1f7089c // indirect
github.com/Crocmagnon/fatcontext v0.4.0 // indirect
github.com/Djarvur/go-err113 v0.0.0-20210108212216-aea10b59be24 // indirect
Expand Down
1 change: 0 additions & 1 deletion internal/tools/tools.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ package tools // import "go.opentelemetry.io/collector/internal/tools"
// This ensures that all systems use the same version of tools in addition to regular dependencies.

import (
_ "github.com/Antonboom/testifylint"
_ "github.com/a8m/envsubst/cmd/envsubst"
_ "github.com/client9/misspell/cmd/misspell"
_ "github.com/golangci/golangci-lint/cmd/golangci-lint"
Expand Down
1 change: 1 addition & 0 deletions pipeline/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include ../Makefile.Common
16 changes: 16 additions & 0 deletions pipeline/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module go.opentelemetry.io/collector/pipeline

go 1.22.0

require (
github.com/stretchr/testify v1.9.0
go.opentelemetry.io/collector/internal/globalsignal v0.109.0
)

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

replace go.opentelemetry.io/collector/internal/globalsignal => ../internal/globalsignal
10 changes: 10 additions & 0 deletions pipeline/go.sum

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

Loading

0 comments on commit 39acea4

Please sign in to comment.