Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[chore] Fix "Device or resource busy" error when running CI on Windows #26

Closed
27 changes: 27 additions & 0 deletions .chloggen/cpu_stepping_fg_stable.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. filelogreceiver)
component: resourcedetectionprocessor

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Move `processor.resourcedetection.hostCPUSteppingAsString` feature gate to stable.

# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
issues: [31136]

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

# If your change doesn't affect end users or the exported elements of any package,
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
# 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: []
13 changes: 13 additions & 0 deletions .chloggen/munir_add-option-to-avoid-remapping.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
change_type: enhancement

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

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: "Adds exporter.datadogexporter.metricremappingdisabled featuregate which disables renaming OpenTelemetry metrics to match Datadog semantics. This feature gate is only for internal use."

# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
issues: [35025]

# Optional: A list of users who contributed to the change. This is used to generate the list of contributors in the changelog.
change_logs: []
29 changes: 29 additions & 0 deletions .chloggen/otlp_logs.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: enhancement

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

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: "Add support for `otlp_json` encoding to Kafka receiver. The payload is deserialized into OpenTelemetry traces using JSON format."

# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
issues: [33627]

# (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: |
This encoding allows the Kafka receiver to handle trace data in JSON format,
enabling integration with systems that export traces as JSON-encoded data.

# If your change doesn't affect end users or the exported elements of any package,
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
# 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]
27 changes: 27 additions & 0 deletions .chloggen/remove_host_cpu_model_family_fg.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. filelogreceiver)
component: resourcedetectionprocessor

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Remove `processor.resourcedetection.hostCPUModelAndFamilyAsString` feature gate.

# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
issues: [29025]

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

# If your change doesn't affect end users or the exported elements of any package,
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
# 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: []
5 changes: 5 additions & 0 deletions .github/workflows/build-and-test-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ jobs:
- name: Ensure required ports in the dynamic range are available
run: |
& ${{ github.workspace }}\.github\workflows\scripts\win-required-ports.ps1
- name: Build shared test tools
# If component tests share Makefile targets they need to be added here to avoid
# concurrent component tests clashing when building such targets. This applies
# specifically to Windows, see https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/34691
run: make "$(${PWD} -replace '\\', '/')/.tools/gotestsum"
- name: Run Unit tests
run: make -j2 gotest GROUP=${{ matrix.group }}
windows-unittest:
Expand Down
1 change: 0 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ linters-settings:
disable:
- float-compare
- formatter
- go-require
- require-error
- suite-subtest-run
- useless-assert
Expand Down
2 changes: 1 addition & 1 deletion Makefile.Common
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ GOTESTSUM := $(TOOLS_BIN_DIR)/gotestsum
TESTIFYLINT := $(TOOLS_BIN_DIR)/testifylint

GOTESTSUM_OPT?= --rerun-fails=1
TESTIFYLINT_OPT?= --enable-all --disable=float-compare,formatter,go-require,require-error,suite-subtest-run,useless-assert
TESTIFYLINT_OPT?= --enable-all --disable=float-compare,formatter,require-error,suite-subtest-run,useless-assert

# BUILD_TYPE should be one of (dev, release).
BUILD_TYPE?=release
Expand Down
3 changes: 2 additions & 1 deletion cmd/telemetrygen/internal/e2etest/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"testing"
"time"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.opentelemetry.io/collector/component/componenttest"
"go.opentelemetry.io/collector/consumer/consumertest"
Expand Down Expand Up @@ -53,7 +54,7 @@ func TestGenerateTraces(t *testing.T) {
}
go func() {
err = traces.Start(cfg)
require.NoError(t, err)
assert.NoError(t, err)
}()
require.Eventually(t, func() bool {
return len(sink.AllTraces()) > 0
Expand Down
2 changes: 1 addition & 1 deletion connector/spanmetricsconnector/connector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,7 @@ func TestConcurrentShutdown(t *testing.T) {
for i := 0; i < concurrency; i++ {
go func() {
err := p.Shutdown(ctx)
require.NoError(t, err)
assert.NoError(t, err)
wg.Done()
}()
}
Expand Down
8 changes: 4 additions & 4 deletions exporter/carbonexporter/exporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ func TestConsumeMetrics(t *testing.T) {
defer writersWG.Done()
<-startCh
for j := 0; j < tt.writesPerProducer; j++ {
require.NoError(t, exp.ConsumeMetrics(context.Background(), tt.md))
assert.NoError(t, exp.ConsumeMetrics(context.Background(), tt.md))
}
}()
}
Expand Down Expand Up @@ -332,10 +332,10 @@ func (cs *carbonServer) start(t *testing.T, numExpectedReq int) {
// Close is expected to cause error.
return
}
require.NoError(t, err)
assert.NoError(t, err)
go func(conn net.Conn) {
defer func() {
require.NoError(t, conn.Close())
assert.NoError(t, conn.Close())
}()

reader := bufio.NewReader(conn)
Expand All @@ -344,7 +344,7 @@ func (cs *carbonServer) start(t *testing.T, numExpectedReq int) {
if errors.Is(err, io.EOF) {
return
}
require.NoError(t, err)
assert.NoError(t, err)

if cs.expectedContainsValue != "" {
assert.Contains(t, string(buf), cs.expectedContainsValue)
Expand Down
12 changes: 12 additions & 0 deletions exporter/datadogexporter/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ var metricExportNativeClientFeatureGate = featuregate.GlobalRegistry().MustRegis
featuregate.WithRegisterDescription("When enabled, metric export in datadogexporter uses native Datadog client APIs instead of Zorkian APIs."),
)

var metricRemappingDisableddFeatureGate = featuregate.GlobalRegistry().MustRegister(
"exporter.datadogexporter.metricremappingdisabled",
featuregate.StageAlpha,
featuregate.WithRegisterDescription("When enabled the Datadog Exporter remaps OpenTelemetry semantic conventions to Datadog semantic conventions. This feature gate is only for internal use."),
featuregate.WithRegisterReferenceURL("https://docs.datadoghq.com/opentelemetry/schema_semantics/metrics_mapping/"),
)

// noAPMStatsFeatureGate causes the trace consumer to skip APM stats computation.
var noAPMStatsFeatureGate = featuregate.GlobalRegistry().MustRegister(
"exporter.datadogexporter.DisableAPMStats",
Expand All @@ -65,6 +72,11 @@ func isMetricExportV2Enabled() bool {
return metricExportNativeClientFeatureGate.IsEnabled()
}

// isMetricRemappingDisabled returns true if the datadogexporter should generate Datadog-compliant metrics from OpenTelemetry metrics
func isMetricRemappingDisabled() bool {
return metricRemappingDisableddFeatureGate.IsEnabled()
}

func isLogsAgentExporterEnabled() bool {
return logsAgentExporterFeatureGate.IsEnabled()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,13 +190,13 @@ func TestPushMetadata(t *testing.T) {
assert.Equal(t, "apikey", r.Header.Get("DD-Api-Key"))
assert.Equal(t, "otelcontribcol/1.0", r.Header.Get("User-Agent"))
reader, err := gzip.NewReader(r.Body)
require.NoError(t, err)
assert.NoError(t, err)
body, err := io.ReadAll(reader)
require.NoError(t, err)
assert.NoError(t, err)

var recvMetadata payload.HostMetadata
err = json.Unmarshal(body, &recvMetadata)
require.NoError(t, err)
assert.NoError(t, err)
assert.Equal(t, mockMetadata, recvMetadata)
})

Expand Down
7 changes: 6 additions & 1 deletion exporter/datadogexporter/metrics_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,12 @@ func translatorFromConfig(set component.TelemetrySettings, cfg *Config, attrsTra
options := []otlpmetrics.TranslatorOption{
otlpmetrics.WithDeltaTTL(cfg.Metrics.DeltaTTL),
otlpmetrics.WithFallbackSourceProvider(sourceProvider),
otlpmetrics.WithRemapping(),
}

if isMetricRemappingDisabled() {
set.Logger.Warn("Metric remapping is disabled in the Datadog exporter. OpenTelemetry metrics must be mapped to Datadog semantics before metrics are exported to Datadog (ex: via a processor).")
} else {
options = append(options, otlpmetrics.WithRemapping())
}

if cfg.Metrics.HistConfig.SendAggregations {
Expand Down
2 changes: 1 addition & 1 deletion exporter/honeycombmarkerexporter/logs_exporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func TestExportMarkers(t *testing.T) {
decodedBody := map[string]any{}
err := json.NewDecoder(req.Body).Decode(&decodedBody)

require.NoError(t, err)
assert.NoError(t, err)

assert.Equal(t, len(tt.attributeMap), len(decodedBody))

Expand Down
2 changes: 1 addition & 1 deletion exporter/loadbalancingexporter/log_exporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ func TestRollingUpdatesWhenConsumeLogs(t *testing.T) {
return
case <-ticker.C:
go func() {
require.NoError(t, p.ConsumeLogs(ctx, randomLogs()))
assert.NoError(t, p.ConsumeLogs(ctx, randomLogs()))
}()
}
}
Expand Down
2 changes: 1 addition & 1 deletion exporter/loadbalancingexporter/metrics_exporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -847,7 +847,7 @@ func TestRollingUpdatesWhenConsumeMetrics(t *testing.T) {
return
case <-ticker.C:
go func() {
require.NoError(t, p.ConsumeMetrics(ctx, randomMetrics(t, 1, 1, 1, 1)))
assert.NoError(t, p.ConsumeMetrics(ctx, randomMetrics(t, 1, 1, 1, 1)))
}()
}
}
Expand Down
2 changes: 1 addition & 1 deletion exporter/loadbalancingexporter/trace_exporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ func TestRollingUpdatesWhenConsumeTraces(t *testing.T) {
return
case <-ticker.C:
go func() {
require.NoError(t, p.ConsumeTraces(ctx, randomTraces()))
assert.NoError(t, p.ConsumeTraces(ctx, randomTraces()))
}()
}
}
Expand Down
12 changes: 6 additions & 6 deletions exporter/lokiexporter/exporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,13 @@ func TestPushLogData(t *testing.T) {
// prepare
ts := httptest.NewServer(http.HandlerFunc(func(_ http.ResponseWriter, r *http.Request) {
encPayload, err := io.ReadAll(r.Body)
require.NoError(t, err)
assert.NoError(t, err)

decPayload, err := snappy.Decode(nil, encPayload)
require.NoError(t, err)
assert.NoError(t, err)

err = proto.Unmarshal(decPayload, actualPushRequest)
require.NoError(t, err)
assert.NoError(t, err)
}))
defer ts.Close()

Expand Down Expand Up @@ -241,14 +241,14 @@ func TestLogsToLokiRequestWithGroupingByTenant(t *testing.T) {
// prepare
ts := httptest.NewServer(http.HandlerFunc(func(_ http.ResponseWriter, r *http.Request) {
encPayload, err := io.ReadAll(r.Body)
require.NoError(t, err)
assert.NoError(t, err)

decPayload, err := snappy.Decode(nil, encPayload)
require.NoError(t, err)
assert.NoError(t, err)

pr := &push.PushRequest{}
err = proto.Unmarshal(decPayload, pr)
require.NoError(t, err)
assert.NoError(t, err)

actualPushRequestPerTenant[r.Header.Get("X-Scope-OrgID")] = pr
}))
Expand Down
9 changes: 5 additions & 4 deletions exporter/opensearchexporter/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"os"
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.opentelemetry.io/collector/component/componenttest"
"go.opentelemetry.io/collector/consumer/consumererror"
Expand Down Expand Up @@ -112,13 +113,13 @@ func TestOpenSearchTraceExporter(t *testing.T) {
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
var err error
docs := getReceivedDocuments(r.Body)
require.LessOrEqualf(t, requestCount, len(tc.RequestHandlers), "Test case generated more requests than it has response for.")
assert.LessOrEqualf(t, requestCount, len(tc.RequestHandlers), "Test case generated more requests than it has response for.")
tc.RequestHandlers[requestCount].ValidateReceivedDocuments(t, requestCount, docs)

w.WriteHeader(200)
response, _ := os.ReadFile(tc.RequestHandlers[requestCount].ResponseJSONPath)
_, err = w.Write(response)
require.NoError(t, err)
assert.NoError(t, err)

requestCount++
}))
Expand Down Expand Up @@ -242,13 +243,13 @@ func TestOpenSearchLogExporter(t *testing.T) {
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
var err error
docs := getReceivedDocuments(r.Body)
require.LessOrEqualf(t, requestCount, len(tc.RequestHandlers), "Test case generated more requests than it has response for.")
assert.LessOrEqualf(t, requestCount, len(tc.RequestHandlers), "Test case generated more requests than it has response for.")
tc.RequestHandlers[requestCount].ValidateReceivedDocuments(t, requestCount, docs)

w.WriteHeader(200)
response, _ := os.ReadFile(tc.RequestHandlers[requestCount].ResponseJSONPath)
_, err = w.Write(response)
require.NoError(t, err)
assert.NoError(t, err)

requestCount++
}))
Expand Down
Loading
Loading