Skip to content

Commit

Permalink
Merge branch 'main' into bug/10952
Browse files Browse the repository at this point in the history
  • Loading branch information
iblancasa authored Sep 30, 2024
2 parents 9a2a893 + 52e11ec commit 6bb2a59
Show file tree
Hide file tree
Showing 74 changed files with 1,327 additions and 1,428 deletions.
29 changes: 29 additions & 0 deletions .chloggen/configgrpc-option-refactor.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Use this changelog template to create an entry for release notes.

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

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

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Replace ToClientConn and ToServer with ToClientConnWithOptions and ToServerWithOptions.

# One or more tracking issues or pull requests related to the change
issues: [11271, 9480]

# (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: |
`ClientConfig.ToClientConn` and `ServerConfig.ToServer` were deprecated in v0.110.0 in favor of
`ClientConfig.ToClientConnWithOptions` and `ServerConfig.ToServerWithOptions` which use a more
flexible option type. The original functions are now removed, and the new ones are renamed to the
old names. The `WithOptions` names are kept as deprecated aliases for now.
# 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]
25 changes: 25 additions & 0 deletions .chloggen/dep-processorhelper.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: deprecation

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

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Deprecate unused and empty struct processorhelper.ObsReport

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

# (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]
25 changes: 25 additions & 0 deletions .chloggen/jackgopack4_add-ocb-docker-images.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: ocb

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: create docker images for OCB, per https://github.com/open-telemetry/opentelemetry-collector-releases/pull/671

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

# (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: Adds standard Docker images for OCB to Dockerhub and GitHub, see hub.docker.com/r/otel/opentelemetry-collector-builder

# 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: [ user ]
25 changes: 25 additions & 0 deletions .chloggen/remove-scraper-with-component-type.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: breaking

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

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Remove deprecated function `NewScraperWithComponentType`.

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

# (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]
27 changes: 27 additions & 0 deletions .chloggen/rm-deprecated-func.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Use this changelog template to create an entry for release notes.

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

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

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Remove deprecated funcs form processorhelper.ObsReport

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

# (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: The "otelcol_processor_dropped_log_records", "otelcol_processor_dropped_log_records" |
and "otelcol_processor_dropped_spans" metrics are complete removed, before they were always record with 0 values.


# 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]
29 changes: 26 additions & 3 deletions cmd/builder/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,34 @@ $ /tmp/dist/otelcol-custom --config=/tmp/otelcol.yaml

## Installation

There are two supported ways to install the builder: via the official releases (recommended) and through `go install`.
There are three supported ways to install the builder:
1. Via official release Docker images (recommended)
2. Via official release binaries (recommended)
3. Through `go install` (not recommended)

### Official releases
### Official release Docker image

This is the recommended installation method. Download the binary for your respective platform from the ["Releases"](https://github.com/open-telemetry/opentelemetry-collector-releases/releases?q=cmd/builder) page.
You will find the official docker images at [DockerHub](https://hub.docker.com/r/otel/opentelemetry-collector-builder).

Pull the image via tagged version number (e.g. v0.110.0) or 'latest'. You may also specify platform, although Docker will handle this automatically as it is a multi-platform build.

```
docker pull otel/opentelemetry-collector-builder:latest
```

The included builder configuration file/manifest should be replaced by mounting a file from your local filesystem to the docker container; the default location is `/build/builder-config.yaml`. If you mount a file at a different location inside the container, your `builder.config.yaml` must be specified as a command line argument to ocb. Additionally, the output folder must also be mounted from your local system to the docker container. This output directory must be specified in your `builder-config.yaml` file as it cannot be set via the command-line arguments.

Assuming you are running this image in your working directory, have a `builder-config.yaml` file located in this folder, the `dist.output_path` item inside your `builder-config.yaml` is set to `./otelcol-dev`, and you wish to output the binary/go module files to a folder named `output`, the command would look as follows:

```
docker run -v "$(pwd)/builder-config.yaml:/build/builder-config.yaml" -v "$(pwd)/output:/build/otelcol-dev" otel/opentelemetry-collector-builder:latest
```

Additional arguments may be passed to ocb on the command line as specified below, but if you wish to do this, you must make sure to pass the `--config` argument, as this is specified as an additional `CMD`, not an entrypoint.

### Official release binaries

This is the recommended installation method for the binary. Download the binary for your respective platform from the ["Releases"](https://github.com/open-telemetry/opentelemetry-collector-releases/releases?q=cmd/builder) page.

### `go install`

Expand Down
3 changes: 1 addition & 2 deletions cmd/builder/internal/builder/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,7 @@ func TestGenerateInvalidOutputPath(t *testing.T) {
cfg := newInitializedConfig(t)
cfg.Distribution.OutputPath = ":/invalid"
err := Generate(cfg)
require.Error(t, err)
require.Contains(t, err.Error(), "failed to create output path")
require.ErrorContains(t, err, "failed to create output path")
}

func TestVersioning(t *testing.T) {
Expand Down
25 changes: 10 additions & 15 deletions component/componenttest/obsreporttest.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ const (
scraperTag = "scraper"
transportTag = "transport"
exporterTag = "exporter"
processorTag = "processor"
)

type TestTelemetry struct {
Expand Down Expand Up @@ -72,27 +71,23 @@ func (tts *TestTelemetry) CheckExporterLogs(sentLogRecords, sendFailedLogRecords
}

func (tts *TestTelemetry) CheckExporterMetricGauge(metric string, val int64, extraAttrs ...attribute.KeyValue) error {
attrs := attributesForExporterMetrics(tts.id)
attrs = append(attrs, extraAttrs...)
attrs := attributesForExporterMetrics(tts.id, extraAttrs...)
return checkIntGauge(tts.reader, metric, val, attrs)
}

// CheckProcessorTraces checks that for the current exported values for trace exporter metrics match given values.
// Note: SetupTelemetry must be called before this function.
func (tts *TestTelemetry) CheckProcessorTraces(acceptedSpans, refusedSpans, droppedSpans int64) error {
return checkProcessorTraces(tts.reader, tts.id, acceptedSpans, refusedSpans, droppedSpans)
// Deprecated: [v0.111.0] deleted metrics, no-op.
func (tts *TestTelemetry) CheckProcessorTraces(_, _, _ int64) error {
return nil
}

// CheckProcessorMetrics checks that for the current exported values for metrics exporter metrics match given values.
// Note: SetupTelemetry must be called before this function.
func (tts *TestTelemetry) CheckProcessorMetrics(acceptedMetricPoints, refusedMetricPoints, droppedMetricPoints int64) error {
return checkProcessorMetrics(tts.reader, tts.id, acceptedMetricPoints, refusedMetricPoints, droppedMetricPoints)
// Deprecated: [v0.111.0] deleted metrics, no-op.
func (tts *TestTelemetry) CheckProcessorMetrics(_, _, _ int64) error {
return nil
}

// CheckProcessorLogs checks that for the current exported values for logs exporter metrics match given values.
// Note: SetupTelemetry must be called before this function.
func (tts *TestTelemetry) CheckProcessorLogs(acceptedLogRecords, refusedLogRecords, droppedLogRecords int64) error {
return checkProcessorLogs(tts.reader, tts.id, acceptedLogRecords, refusedLogRecords, droppedLogRecords)
// Deprecated: [v0.111.0] deleted metrics, no-op.
func (tts *TestTelemetry) CheckProcessorLogs(_, _, _ int64) error {
return nil
}

// CheckReceiverTraces checks that for the current exported values for trace receiver metrics match given values.
Expand Down
62 changes: 19 additions & 43 deletions component/componenttest/otelchecker.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,27 +41,6 @@ func checkReceiver(reader *sdkmetric.ManualReader, receiver component.ID, dataty
checkIntSum(reader, fmt.Sprintf("otelcol_receiver_refused_%s", datatype), droppedMetricPoints, receiverAttrs))
}

func checkProcessorTraces(reader *sdkmetric.ManualReader, processor component.ID, accepted, refused, dropped int64) error {
return checkProcessor(reader, processor, "spans", accepted, refused, dropped)
}

func checkProcessorMetrics(reader *sdkmetric.ManualReader, processor component.ID, accepted, refused, dropped int64) error {
return checkProcessor(reader, processor, "metric_points", accepted, refused, dropped)
}

func checkProcessorLogs(reader *sdkmetric.ManualReader, processor component.ID, accepted, refused, dropped int64) error {
return checkProcessor(reader, processor, "log_records", accepted, refused, dropped)
}

func checkProcessor(reader *sdkmetric.ManualReader, processor component.ID, datatype string, accepted, refused, dropped int64) error {
processorAttrs := attributesForProcessorMetrics(processor)
return multierr.Combine(
checkIntSum(reader, fmt.Sprintf("otelcol_processor_accepted_%s", datatype), accepted, processorAttrs),
checkIntSum(reader, fmt.Sprintf("otelcol_processor_refused_%s", datatype), refused, processorAttrs),
checkIntSum(reader, fmt.Sprintf("otelcol_processor_dropped_%s", datatype), dropped, processorAttrs),
)
}

func checkExporterTraces(reader *sdkmetric.ManualReader, exporter component.ID, sent, sendFailed int64) error {
return checkExporter(reader, exporter, "spans", sent, sendFailed)
}
Expand Down Expand Up @@ -92,8 +71,8 @@ func checkExporterEnqueueFailed(reader *sdkmetric.ManualReader, exporter compone
return checkIntSum(reader, fmt.Sprintf("otelcol_exporter_enqueue_failed_%s", datatype), enqueueFailed, exporterAttrs)
}

func checkIntGauge(reader *sdkmetric.ManualReader, metric string, expected int64, attrs []attribute.KeyValue) error {
dp, err := getGaugeDataPoint[int64](reader, metric, attrs)
func checkIntGauge(reader *sdkmetric.ManualReader, metric string, expected int64, expectedAttrs attribute.Set) error {
dp, err := getGaugeDataPoint[int64](reader, metric, expectedAttrs)
if err != nil {
return err
}
Expand All @@ -105,8 +84,8 @@ func checkIntGauge(reader *sdkmetric.ManualReader, metric string, expected int64
return nil
}

func checkIntSum(reader *sdkmetric.ManualReader, expectedMetric string, expected int64, attrs []attribute.KeyValue) error {
dp, err := getSumDataPoint[int64](reader, expectedMetric, attrs)
func checkIntSum(reader *sdkmetric.ManualReader, expectedMetric string, expected int64, expectedAttrs attribute.Set) error {
dp, err := getSumDataPoint[int64](reader, expectedMetric, expectedAttrs)
if err != nil {
return err
}
Expand All @@ -118,7 +97,7 @@ func checkIntSum(reader *sdkmetric.ManualReader, expectedMetric string, expected
return nil
}

func getSumDataPoint[N int64 | float64](reader *sdkmetric.ManualReader, expectedName string, expectedAttrs []attribute.KeyValue) (metricdata.DataPoint[N], error) {
func getSumDataPoint[N int64 | float64](reader *sdkmetric.ManualReader, expectedName string, expectedAttrs attribute.Set) (metricdata.DataPoint[N], error) {
m, err := getMetric(reader, expectedName)
if err != nil {
return metricdata.DataPoint[N]{}, err
Expand All @@ -132,7 +111,7 @@ func getSumDataPoint[N int64 | float64](reader *sdkmetric.ManualReader, expected
}
}

func getGaugeDataPoint[N int64 | float64](reader *sdkmetric.ManualReader, expectedName string, expectedAttrs []attribute.KeyValue) (metricdata.DataPoint[N], error) {
func getGaugeDataPoint[N int64 | float64](reader *sdkmetric.ManualReader, expectedName string, expectedAttrs attribute.Set) (metricdata.DataPoint[N], error) {
m, err := getMetric(reader, expectedName)
if err != nil {
return metricdata.DataPoint[N]{}, err
Expand All @@ -146,14 +125,13 @@ func getGaugeDataPoint[N int64 | float64](reader *sdkmetric.ManualReader, expect
}
}

func getDataPoint[N int64 | float64](dps []metricdata.DataPoint[N], expectedName string, expectedAttrs []attribute.KeyValue) (metricdata.DataPoint[N], error) {
expectedSet := attribute.NewSet(expectedAttrs...)
func getDataPoint[N int64 | float64](dps []metricdata.DataPoint[N], expectedName string, expectedAttrs attribute.Set) (metricdata.DataPoint[N], error) {
for _, dp := range dps {
if expectedSet.Equals(&dp.Attributes) {
if expectedAttrs.Equals(&dp.Attributes) {
return dp, nil
}
}
return metricdata.DataPoint[N]{}, fmt.Errorf("metric '%s' doesn't have a data point with the given attributes: %s", expectedName, expectedSet.Encoded(attribute.DefaultEncoder()))
return metricdata.DataPoint[N]{}, fmt.Errorf("metric '%s' doesn't have a data point with the given attributes: %s", expectedName, expectedAttrs.Encoded(attribute.DefaultEncoder()))
}

func getMetric(reader *sdkmetric.ManualReader, expectedName string) (metricdata.Metrics, error) {
Expand All @@ -172,26 +150,24 @@ func getMetric(reader *sdkmetric.ManualReader, expectedName string) (metricdata.
return metricdata.Metrics{}, fmt.Errorf("metric '%s' not found", expectedName)
}

func attributesForScraperMetrics(receiver component.ID, scraper component.ID) []attribute.KeyValue {
return []attribute.KeyValue{
func attributesForScraperMetrics(receiver component.ID, scraper component.ID) attribute.Set {
return attribute.NewSet(
attribute.String(receiverTag, receiver.String()),
attribute.String(scraperTag, scraper.String()),
}
)
}

// attributesForReceiverMetrics returns the attributes that are needed for the receiver metrics.
func attributesForReceiverMetrics(receiver component.ID, transport string) []attribute.KeyValue {
return []attribute.KeyValue{
func attributesForReceiverMetrics(receiver component.ID, transport string) attribute.Set {
return attribute.NewSet(
attribute.String(receiverTag, receiver.String()),
attribute.String(transportTag, transport),
}
}

func attributesForProcessorMetrics(processor component.ID) []attribute.KeyValue {
return []attribute.KeyValue{attribute.String(processorTag, processor.String())}
)
}

// attributesForExporterMetrics returns the attributes that are needed for the receiver metrics.
func attributesForExporterMetrics(exporter component.ID) []attribute.KeyValue {
return []attribute.KeyValue{attribute.String(exporterTag, exporter.String())}
func attributesForExporterMetrics(exporter component.ID, extraAttrs ...attribute.KeyValue) attribute.Set {
attrs := []attribute.KeyValue{attribute.String(exporterTag, exporter.String())}
attrs = append(attrs, extraAttrs...)
return attribute.NewSet(attrs...)
}
Loading

0 comments on commit 6bb2a59

Please sign in to comment.