Skip to content

Commit

Permalink
Merge branch 'main' into remove_top_level_block
Browse files Browse the repository at this point in the history
  • Loading branch information
codeboten authored May 3, 2024
2 parents 33b6fa5 + ff7a485 commit 3958649
Show file tree
Hide file tree
Showing 22 changed files with 5,554 additions and 34 deletions.
25 changes: 25 additions & 0 deletions .chloggen/codeboten_10072.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: semconv

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Add support for v1.25.0 semantic convention

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

# (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: []
20 changes: 20 additions & 0 deletions .chloggen/expose-err-queue-full.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: exporterqueue

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Expose ErrQueueIsFull so upstream components can retry or apply backpressure.

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

# 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]
3 changes: 3 additions & 0 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,9 @@ jobs:
strategy:
matrix:
runner: [ubuntu-latest, actuated-arm64-4cpu-4gb]
exclude:
- go-version: "~1.21.9"
runner: actuated-arm64-4cpu-4gb
go-version: ["~1.22", "~1.21.9"] # 1.20 needs quotes otherwise it's interpreted as 1.2
runs-on: ${{ matrix.runner }}
needs: [setup-environment]
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/check-links.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
fetch-depth: 0

- name: Install markdown-link-check
run: npm install -g markdown-link-check
run: npm install -g markdown-link-check@3.11.2

- name: Run markdown-link-check
run: |
Expand Down
13 changes: 13 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,19 @@ that each of the following steps is done in a separate version:
1. On `v0.N+2`, we change `func GetFoo() Foo` to `func GetFoo(context.Context) Foo` if desired or remove it entirely if
needed.

#### Exceptions

For changes to modules that do not have a version of `v1` or higher, we may skip the deprecation process described above
for the following situations. Note that these changes should still be recorded as breaking changes in the changelog.

* **Variadic arguments.** Functions that are not already variadic may have a variadic parameter added as a method of
supporting optional parameters, particularly through the functional options pattern. If a variadic parameter is
added to a function with no change in functionality when no variadic arguments are passed, the deprecation process
may be skipped. Calls to updated functions without the new argument will continue to work before, but users who depend
on the exact function signature as a type, for example as an argument to another function, will experience a
breaking change. For this reason, the deprecation process should only be skipped when it is not expected that
the function is commonly passed as a value.

#### Configuration changes

##### Alpha components
Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ gensemconv: $(SEMCONVGEN) $(SEMCONVKIT)
$(SEMCONVGEN) -o semconv/${SPECTAG} -t semconv/template.j2 -s ${SPECTAG} -i ${SPECPATH}/model/. --only=resource -p conventionType=resource -f generated_resource.go
$(SEMCONVGEN) -o semconv/${SPECTAG} -t semconv/template.j2 -s ${SPECTAG} -i ${SPECPATH}/model/. --only=event -p conventionType=event -f generated_event.go
$(SEMCONVGEN) -o semconv/${SPECTAG} -t semconv/template.j2 -s ${SPECTAG} -i ${SPECPATH}/model/. --only=span -p conventionType=trace -f generated_trace.go
$(SEMCONVGEN) -o semconv/${SPECTAG} -t semconv/template.j2 -s ${SPECTAG} -i ${SPECPATH}/model/. --only=attribute_group -p conventionType=attribute_group -f generated_attribute_group.go
$(SEMCONVKIT) -output "semconv/$(SPECTAG)" -tag "$(SPECTAG)"

# Checks that the HEAD of the contrib repo checked out in CONTRIB_PATH compiles
Expand Down
14 changes: 14 additions & 0 deletions cmd/builder/internal/builder/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"os/exec"
"path/filepath"
"strings"
"time"

"github.com/hashicorp/go-version"
"go.uber.org/multierr"
Expand Down Expand Up @@ -41,6 +42,8 @@ type Config struct {
Providers *[]Module `mapstructure:"providers"`
Replaces []string `mapstructure:"replaces"`
Excludes []string `mapstructure:"excludes"`

downloadModules retry `mapstructure:"-"`
}

// Distribution holds the parameters for the final binary
Expand All @@ -66,6 +69,11 @@ type Module struct {
Path string `mapstructure:"path"` // an optional path to the local version of this module
}

type retry struct {
numRetries int
wait time.Duration
}

// NewDefaultConfig creates a new config, with default values
func NewDefaultConfig() Config {
log, err := zap.NewDevelopment()
Expand All @@ -85,6 +93,12 @@ func NewDefaultConfig() Config {
OtelColVersion: defaultOtelColVersion,
Module: "go.opentelemetry.io/collector/cmd/builder",
},
// basic retry if error from go mod command (in case of transient network error).
// retry 3 times with 5 second spacing interval
downloadModules: retry{
numRetries: 3,
wait: 5 * time.Second,
},
}
}

Expand Down
9 changes: 3 additions & 6 deletions cmd/builder/internal/builder/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,15 +189,12 @@ func GetModules(cfg Config) error {

func downloadModules(cfg Config) error {
cfg.Logger.Info("Getting go modules")
// basic retry if error from go mod command (in case of transient network error). This could be improved
// retry 3 times with 5 second spacing interval
retries := 3
failReason := "unknown"
for i := 1; i <= retries; i++ {
for i := 1; i <= cfg.downloadModules.numRetries; i++ {
if _, err := runGoCommand(cfg, "mod", "download"); err != nil {
failReason = err.Error()
cfg.Logger.Info("Failed modules download", zap.String("retry", fmt.Sprintf("%d/%d", i, retries)))
time.Sleep(5 * time.Second)
cfg.Logger.Info("Failed modules download", zap.String("retry", fmt.Sprintf("%d/%d", i, cfg.downloadModules.numRetries)))
time.Sleep(cfg.downloadModules.wait)
continue
}
return nil
Expand Down
33 changes: 20 additions & 13 deletions cmd/builder/internal/builder/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,15 @@ require (
)`)
)

func newInitializedConfig(t *testing.T) Config {
func newTestConfig() Config {
cfg := NewDefaultConfig()
cfg.downloadModules.wait = 0
cfg.downloadModules.numRetries = 1
return cfg
}

func newInitializedConfig(t *testing.T) Config {
cfg := newTestConfig()
// Validate and ParseModules will be called before the config is
// given to Generate.
assert.NoError(t, cfg.Validate())
Expand Down Expand Up @@ -66,7 +73,7 @@ func TestVersioning(t *testing.T) {
{
description: "defaults",
cfgBuilder: func() Config {
cfg := NewDefaultConfig()
cfg := newTestConfig()
cfg.Distribution.Go = "go"
cfg.Replaces = append(cfg.Replaces, replaces...)
return cfg
Expand All @@ -76,7 +83,7 @@ func TestVersioning(t *testing.T) {
{
description: "require otelcol",
cfgBuilder: func() Config {
cfg := NewDefaultConfig()
cfg := newTestConfig()
cfg.Distribution.Go = "go"
cfg.Distribution.RequireOtelColModule = true
cfg.Replaces = append(cfg.Replaces, replaces...)
Expand All @@ -87,7 +94,7 @@ func TestVersioning(t *testing.T) {
{
description: "only gomod file, skip generate",
cfgBuilder: func() Config {
cfg := NewDefaultConfig()
cfg := newTestConfig()
tempDir := t.TempDir()
err := makeModule(tempDir, goModTestFile)
require.NoError(t, err)
Expand All @@ -101,7 +108,7 @@ func TestVersioning(t *testing.T) {
{
description: "old otel version",
cfgBuilder: func() Config {
cfg := NewDefaultConfig()
cfg := newTestConfig()
cfg.Verbose = true
cfg.Distribution.Go = "go"
cfg.Distribution.OtelColVersion = "0.97.0"
Expand Down Expand Up @@ -133,7 +140,7 @@ func TestVersioning(t *testing.T) {
{
description: "old component version",
cfgBuilder: func() Config {
cfg := NewDefaultConfig()
cfg := newTestConfig()
cfg.Distribution.Go = "go"
cfg.Exporters = []Module{
{
Expand All @@ -149,7 +156,7 @@ func TestVersioning(t *testing.T) {
{
description: "old component version without strict mode",
cfgBuilder: func() Config {
cfg := NewDefaultConfig()
cfg := newTestConfig()
cfg.Distribution.Go = "go"
cfg.SkipStrictVersioning = true
cfg.Exporters = []Module{
Expand Down Expand Up @@ -200,7 +207,7 @@ func TestGenerateAndCompile(t *testing.T) {
{
testCase: "Default Configuration Compilation",
cfgBuilder: func(t *testing.T) Config {
cfg := NewDefaultConfig()
cfg := newTestConfig()
cfg.Distribution.OutputPath = t.TempDir()
cfg.Replaces = append(cfg.Replaces, replaces...)
return cfg
Expand All @@ -209,7 +216,7 @@ func TestGenerateAndCompile(t *testing.T) {
{
testCase: "LDFlags Compilation",
cfgBuilder: func(t *testing.T) Config {
cfg := NewDefaultConfig()
cfg := newTestConfig()
cfg.Distribution.OutputPath = t.TempDir()
cfg.Replaces = append(cfg.Replaces, replaces...)
cfg.LDFlags = `-X "test.gitVersion=0743dc6c6411272b98494a9b32a63378e84c34da" -X "test.gitTag=local-testing" -X "test.goVersion=go version go1.20.7 darwin/amd64"`
Expand All @@ -219,7 +226,7 @@ func TestGenerateAndCompile(t *testing.T) {
{
testCase: "Debug Compilation",
cfgBuilder: func(t *testing.T) Config {
cfg := NewDefaultConfig()
cfg := newTestConfig()
cfg.Distribution.OutputPath = t.TempDir()
cfg.Replaces = append(cfg.Replaces, replaces...)
cfg.Logger = zap.NewNop()
Expand All @@ -230,7 +237,7 @@ func TestGenerateAndCompile(t *testing.T) {
{
testCase: "No providers",
cfgBuilder: func(t *testing.T) Config {
cfg := NewDefaultConfig()
cfg := newTestConfig()
cfg.Distribution.OutputPath = t.TempDir()
cfg.Replaces = append(cfg.Replaces, replaces...)
cfg.Providers = &[]Module{}
Expand All @@ -240,7 +247,7 @@ func TestGenerateAndCompile(t *testing.T) {
{
testCase: "Pre-confmap factories",
cfgBuilder: func(t *testing.T) Config {
cfg := NewDefaultConfig()
cfg := newTestConfig()
cfg.Distribution.OutputPath = t.TempDir()
cfg.Replaces = append(cfg.Replaces, replaces...)
cfg.Distribution.OtelColVersion = "0.98.0"
Expand All @@ -251,7 +258,7 @@ func TestGenerateAndCompile(t *testing.T) {
{
testCase: "With confmap factories",
cfgBuilder: func(t *testing.T) Config {
cfg := NewDefaultConfig()
cfg := newTestConfig()
cfg.Distribution.OutputPath = t.TempDir()
cfg.Replaces = append(cfg.Replaces, replaces...)
cfg.Distribution.OtelColVersion = "0.99.0"
Expand Down
23 changes: 14 additions & 9 deletions confmap/confmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,30 +250,35 @@ func expandNilStructPointersHookFunc() mapstructure.DecodeHookFuncValue {
// This is needed in combination with ComponentID, which may produce equal IDs for different strings,
// and an error needs to be returned in that case, otherwise the last equivalent ID overwrites the previous one.
func mapKeyStringToMapKeyTextUnmarshalerHookFunc() mapstructure.DecodeHookFuncType {
return func(f reflect.Type, t reflect.Type, data any) (any, error) {
if f.Kind() != reflect.Map || f.Key().Kind() != reflect.String {
return func(from reflect.Type, to reflect.Type, data any) (any, error) {
if from.Kind() != reflect.Map || from.Key().Kind() != reflect.String {
return data, nil
}

if t.Kind() != reflect.Map {
if to.Kind() != reflect.Map {
return data, nil
}

if _, ok := reflect.New(t.Key()).Interface().(encoding.TextUnmarshaler); !ok {
// Checks that the key type of to implements the TextUnmarshaler interface.
if _, ok := reflect.New(to.Key()).Interface().(encoding.TextUnmarshaler); !ok {
return data, nil
}

m := reflect.MakeMap(reflect.MapOf(t.Key(), reflect.TypeOf(true)))
// Create a map with key value of to's key to bool.
fieldNameSet := reflect.MakeMap(reflect.MapOf(to.Key(), reflect.TypeOf(true)))
for k := range data.(map[string]any) {
tKey := reflect.New(t.Key())
// Create a new value of the to's key type.
tKey := reflect.New(to.Key())

// Use tKey to unmarshal the key of the map.
if err := tKey.Interface().(encoding.TextUnmarshaler).UnmarshalText([]byte(k)); err != nil {
return nil, err
}

if m.MapIndex(reflect.Indirect(tKey)).IsValid() {
// Checks if the key has already been decoded in a previous iteration.
if fieldNameSet.MapIndex(reflect.Indirect(tKey)).IsValid() {
return nil, fmt.Errorf("duplicate name %q after unmarshaling %v", k, tKey)
}
m.SetMapIndex(reflect.Indirect(tKey), reflect.ValueOf(true))
fieldNameSet.SetMapIndex(reflect.Indirect(tKey), reflect.ValueOf(true))
}
return data, nil
}
Expand Down
1 change: 0 additions & 1 deletion confmap/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ func NewResolver(set ResolverSettings) (*Resolver, error) {
}

// Resolve returns the configuration as a Conf, or error otherwise.
//
// Should never be called concurrently with itself, Watch or Shutdown.
func (mr *Resolver) Resolve(ctx context.Context) (*Conf, error) {
// First check if already an active watching, close that if any.
Expand Down
5 changes: 5 additions & 0 deletions exporter/exporterqueue/queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ import (
"go.opentelemetry.io/collector/exporter/internal/queue"
)

// ErrQueueIsFull is the error that Queue returns when full.
// Experimental: This API is at the early stage of development and may change without backward compatibility
// until https://github.com/open-telemetry/opentelemetry-collector/issues/8122 is resolved.
var ErrQueueIsFull = queue.ErrQueueIsFull

// Queue defines a producer-consumer exchange which can be backed by e.g. the memory-based ring buffer queue
// (boundedMemoryQueue) or via a disk-based queue (persistentQueue)
// Experimental: This API is at the early stage of development and may change without backward compatibility
Expand Down
4 changes: 4 additions & 0 deletions otelcol/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ func (col *Collector) setupConfigurationComponents(ctx context.Context) error {
}

col.serviceConfig = &cfg.Service

col.service, err = service.New(ctx, service.Settings{
BuildInfo: col.set.BuildInfo,
CollectorConf: conf,
Expand Down Expand Up @@ -248,6 +249,7 @@ func (col *Collector) DryRun(ctx context.Context) error {

// Run starts the collector according to the given configuration, and waits for it to complete.
// Consecutive calls to Run are not allowed, Run shouldn't be called once a collector is shut down.
// Sets up the control logic for config reloading and shutdown.
func (col *Collector) Run(ctx context.Context) error {
if err := col.setupConfigurationComponents(ctx); err != nil {
col.setCollectorState(StateClosed)
Expand All @@ -263,6 +265,8 @@ func (col *Collector) Run(ctx context.Context) error {
signal.Notify(col.signalsChannel, os.Interrupt, syscall.SIGTERM)
}

// Control loop: selects between channels for various interrupts - when this loop is broken, the collector exits.
// If a configuration reload fails, we return without waiting for graceful shutdown.
LOOP:
for {
select {
Expand Down
1 change: 1 addition & 0 deletions otelcol/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ func NewCommand(set CollectorSettings) *cobra.Command {
return rootCmd
}

// Puts command line flags from flags into the CollectorSettings, to be used during config resolution.
func updateSettingsUsingFlags(set *CollectorSettings, flags *flag.FlagSet) error {
if set.ConfigProvider == nil {
resolverSet := &set.ConfigProviderSettings.ResolverSettings
Expand Down
9 changes: 9 additions & 0 deletions semconv/v1.25.0/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

// Package semconv implements OpenTelemetry semantic conventions.
//
// OpenTelemetry semantic conventions are agreed standardized naming
// patterns for OpenTelemetry things. This package represents the v1.25.0
// version of the OpenTelemetry semantic conventions.
package semconv // import "go.opentelemetry.io/collector/semconv/v1.25.0"
Loading

0 comments on commit 3958649

Please sign in to comment.