Files
a46b19a87d confighttp: add support for binding unix sockets (#14248)
#### Description

Embed `confignet.AddrConfig` in `confighttp.ServerConfig`, replacing the
`Endpoint` field. This introduces the "transport" config attribute,
which can be set to "unix" for binding a Unix domain socket.

#### Link to tracking issue

Fixes #8752
Fixes #14187

#### Testing

```bash
$ ./bin/otelcorecol_linux_amd64 \
    --config examples/local/otel-config.yaml \
    --set receivers::otlp::protocols::http::transport=unix \
    --set receivers::otlp::protocols::http::endpoint=\"@otlphttp\"
```

```bash
$ curl --abstract-unix-socket otlphttp http://testing.invalid:1234/v1/traces
405 method not allowed, supported: [POST]
```

#### Documentation

Updated README.md

---------

Co-authored-by: Antoine Toulme <[email protected]>
2026-01-14 11:54:55 +00:00

41 lines
1.1 KiB
Go

// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
package zpagesextension
import (
"path/filepath"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.opentelemetry.io/collector/config/confighttp"
"go.opentelemetry.io/collector/confmap"
"go.opentelemetry.io/collector/confmap/confmaptest"
)
func TestUnmarshalDefaultConfig(t *testing.T) {
factory := NewFactory()
cfg := factory.CreateDefaultConfig()
require.NoError(t, confmap.New().Unmarshal(&cfg))
assert.Equal(t, factory.CreateDefaultConfig(), cfg)
}
func TestInvalidConfig(t *testing.T) {
assert.Error(t, (&Config{}).Validate())
}
func TestUnmarshalConfig(t *testing.T) {
cm, err := confmaptest.LoadConf(filepath.Join("testdata", "config.yaml"))
require.NoError(t, err)
factory := NewFactory()
cfg := factory.CreateDefaultConfig()
require.NoError(t, cm.Unmarshal(&cfg))
expectedServerConfig := confighttp.NewDefaultServerConfig()
expectedServerConfig.NetAddr.Endpoint = "localhost:56888"
assert.Equal(t, &Config{ServerConfig: expectedServerConfig}, cfg)
}