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

Add basicauth extension #3413

Merged
merged 3 commits into from
Jul 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

- (Splunk) Discovery mode: Ensure all successful observers are used in resulting receiver creator instance ([#3391](https://github.com/signalfx/splunk-otel-collector/pull/3391))

### 💡 Enhancements 💡

- Add support for basicauth extension ([#3413](https://github.com/signalfx/splunk-otel-collector/pull/3413))
## v0.81.0

This Splunk OpenTelemetry Collector release includes changes from the [opentelemetry-collector v0.81.0](https://github.com/open-telemetry/opentelemetry-collector/releases/tag/v0.81.0) and the [opentelemetry-collector-contrib v0.81.0](https://github.com/open-telemetry/opentelemetry-collector-contrib/releases/tag/v0.81.0) releases where appropriate.
Expand Down
29 changes: 15 additions & 14 deletions docs/components.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,20 +97,21 @@ The distribution offers support for the following components.

<div>

| Extensions | Stability |
|:------------------------------------------------------------------------------------------------------------------------------------|:----------|
| [docker_observer](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/extension/observer/dockerobserver) | [beta] |
| [ecs_observer](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/extension/observer/ecsobserver) | [beta] |
| [ecs_task_observer](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/extension/observer/ecstaskobserver) | [beta] |
| [healthcheck](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/extension/healthcheckextension) | [beta] |
| [httpforwarder](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/extension/httpforwarder) | [beta] |
| [host_observer](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/extension/observer/hostobserver) | [beta] |
| [k8s_observer](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/extension/observer/k8sobserver) | [beta] |
| [pprof](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/extension/pprofextension) | [beta] |
| [smartagent](../pkg/extension/smartagentextension) | [beta] |
| [zpages](https://github.com/open-telemetry/opentelemetry-collector/tree/main/extension/zpagesextension) | [beta] |
| [file_storage](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/extension/storage/filestorage) | [beta] |
| [ballast](https://github.com/open-telemetry/opentelemetry-collector/tree/main/extension/ballastextension) | [beta] |
| Extensions | Stability |
|:------------------------------------------------------------------------------------------------------------------------------------|:-----------|
| [basicauth](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/extension/basicauthextension) | [beta] |
| [docker_observer](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/extension/observer/dockerobserver) | [beta] |
| [ecs_observer](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/extension/observer/ecsobserver) | [beta] |
| [ecs_task_observer](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/extension/observer/ecstaskobserver) | [beta] |
| [healthcheck](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/extension/healthcheckextension) | [beta] |
| [httpforwarder](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/extension/httpforwarder) | [beta] |
| [host_observer](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/extension/observer/hostobserver) | [beta] |
| [k8s_observer](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/extension/observer/k8sobserver) | [beta] |
| [pprof](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/extension/pprofextension) | [beta] |
| [smartagent](../pkg/extension/smartagentextension) | [beta] |
| [zpages](https://github.com/open-telemetry/opentelemetry-collector/tree/main/extension/zpagesextension) | [beta] |
| [file_storage](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/extension/storage/filestorage) | [beta] |
| [ballast](https://github.com/open-telemetry/opentelemetry-collector/tree/main/extension/ballastextension) | [beta] |

</div>

Expand Down
3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ require (
github.com/open-telemetry/opentelemetry-collector-contrib/exporter/sapmexporter v0.81.0
github.com/open-telemetry/opentelemetry-collector-contrib/exporter/signalfxexporter v0.81.0
github.com/open-telemetry/opentelemetry-collector-contrib/exporter/splunkhecexporter v0.81.0
github.com/open-telemetry/opentelemetry-collector-contrib/extension/basicauthextension v0.81.0
github.com/open-telemetry/opentelemetry-collector-contrib/extension/healthcheckextension v0.81.0
github.com/open-telemetry/opentelemetry-collector-contrib/extension/httpforwarder v0.81.0
github.com/open-telemetry/opentelemetry-collector-contrib/extension/observer v0.81.0
Expand Down Expand Up @@ -133,6 +134,7 @@ require (
github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0 // indirect
github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.0.0 // indirect
github.com/AzureAD/microsoft-authentication-library-for-go v1.0.0 // indirect
github.com/GehirnInc/crypt v0.0.0-20200316065508-bb7000b8a962 // indirect
github.com/JohnCGriffin/overflow v0.0.0-20211019200055-46fa312c352c // indirect
github.com/andybalholm/brotli v1.0.4 // indirect
github.com/apache/arrow/go/v12 v12.0.0 // indirect
Expand Down Expand Up @@ -165,6 +167,7 @@ require (
github.com/relvacode/iso8601 v1.3.0 // indirect
github.com/shirou/gopsutil v3.21.11+incompatible // indirect
github.com/shoenig/go-m1cpu v0.1.6 // indirect
github.com/tg123/go-htpasswd v1.2.1 // indirect
github.com/tilinna/clock v1.1.0 // indirect
github.com/zeebo/xxh3 v1.0.2 // indirect
go.opentelemetry.io/collector/config/configauth v0.81.0 // indirect
Expand Down
6 changes: 6 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ github.com/DataDog/datadog-go v3.2.0+incompatible h1:qSG2N4FghB1He/r2mFrWKCaL7dX
github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ=
github.com/DataDog/zstd v1.5.0 h1:+K/VEwIAaPcHiMtQvpLD4lqW7f0Gk3xdYZmI1hD+CXo=
github.com/DataDog/zstd v1.5.0/go.mod h1:g4AWEaM3yOg3HYfnJ3YIawPnVdXJh9QME85blwSAmyw=
github.com/GehirnInc/crypt v0.0.0-20200316065508-bb7000b8a962 h1:KeNholpO2xKjgaaSyd+DyQRrsQjhbSeS7qe4nEw8aQw=
github.com/GehirnInc/crypt v0.0.0-20200316065508-bb7000b8a962/go.mod h1:kC29dT1vFpj7py2OvG1khBdQpo3kInWP+6QipLbdngo=
github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.15.2 h1:9VwVugD2NuPr6/IjrNJLpzaX7j+P6EJIup7cpNwcYhw=
github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.15.2/go.mod h1:Xx0VKh7GJ4si3rmElbh19Mejxz68ibWg/J30ZOMrqzU=
github.com/HdrHistogram/hdrhistogram-go v1.1.0/go.mod h1:yDgFjdqOqDEKOvasDdhWNXYg9BVp4O+o5f6V/ehm6Oo=
Expand Down Expand Up @@ -1138,6 +1140,8 @@ github.com/open-telemetry/opentelemetry-collector-contrib/exporter/signalfxexpor
github.com/open-telemetry/opentelemetry-collector-contrib/exporter/signalfxexporter v0.81.0/go.mod h1:WAQrgajoWC4x9BkCaiRSortkUK4OKjbN8aw4coXsuJM=
github.com/open-telemetry/opentelemetry-collector-contrib/exporter/splunkhecexporter v0.81.0 h1:xsRmOPWyAWNFnEnuK2d3JtD+RaO0JR6/BIKw0eSjNy8=
github.com/open-telemetry/opentelemetry-collector-contrib/exporter/splunkhecexporter v0.81.0/go.mod h1:jlILI9syx/7cbTRKvP0pzr2I7wv5vnz1q+OYM76escw=
github.com/open-telemetry/opentelemetry-collector-contrib/extension/basicauthextension v0.81.0 h1:5rnbwxwn9+PF6hMpRYoz8fI8n/Oyj6uFTi+nCqXcITo=
github.com/open-telemetry/opentelemetry-collector-contrib/extension/basicauthextension v0.81.0/go.mod h1:RFbrR6/CmOHkuJIlGoi3xfUpkSZ15EubW0qcpAAHUC8=
github.com/open-telemetry/opentelemetry-collector-contrib/extension/healthcheckextension v0.81.0 h1:ZqX6htxXlPr5GrAj/zpGjYGvhBIRkosyzV4VjGYLvKg=
github.com/open-telemetry/opentelemetry-collector-contrib/extension/healthcheckextension v0.81.0/go.mod h1:Kd2693zrJXP/BoRA59N/obF1Fjx+LPSB7L1nmR6pSz4=
github.com/open-telemetry/opentelemetry-collector-contrib/extension/httpforwarder v0.81.0 h1:52o4B6JzTn3lghhCPZk0/4rzUaCEMjLVEMKhck7Gb6c=
Expand Down Expand Up @@ -1541,6 +1545,8 @@ github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635/go.mod h1:hkRG
github.com/tencentcloud/tencentcloud-sdk-go v1.0.162 h1:8fDzz4GuVg4skjY2B0nMN7h6uN61EDVkuLyI2+qGHhI=
github.com/testcontainers/testcontainers-go v0.21.0 h1:syePAxdeTzfkap+RrJaQZpJQ/s/fsUgn11xIvHrOE9U=
github.com/testcontainers/testcontainers-go v0.21.0/go.mod h1:c1ez3WVRHq7T/Aj+X3TIipFBwkBaNT5iNCY8+1b83Ng=
github.com/tg123/go-htpasswd v1.2.1 h1:i4wfsX1KvvkyoMiHZzjS0VzbAPWfxzI8INcZAKtutoU=
github.com/tg123/go-htpasswd v1.2.1/go.mod h1:erHp1B86KXdwQf1X5ZrLb7erXZnWueEQezb2dql4q58=
github.com/tidwall/gjson v1.10.2 h1:APbLGOM0rrEkd8WBw9C24nllro4ajFuJu0Sc9hRz8Bo=
github.com/tidwall/gjson v1.10.2/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA=
Expand Down
6 changes: 4 additions & 2 deletions internal/components/components.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"github.com/open-telemetry/opentelemetry-collector-contrib/exporter/sapmexporter"
"github.com/open-telemetry/opentelemetry-collector-contrib/exporter/signalfxexporter"
"github.com/open-telemetry/opentelemetry-collector-contrib/exporter/splunkhecexporter"
"github.com/open-telemetry/opentelemetry-collector-contrib/extension/basicauthextension"
"github.com/open-telemetry/opentelemetry-collector-contrib/extension/healthcheckextension"
"github.com/open-telemetry/opentelemetry-collector-contrib/extension/httpforwarder"
"github.com/open-telemetry/opentelemetry-collector-contrib/extension/observer/dockerobserver"
Expand Down Expand Up @@ -112,18 +113,19 @@ import (
func Get() (otelcol.Factories, error) {
var errs []error
extensions, err := extension.MakeFactoryMap(
ballastextension.NewFactory(),
basicauthextension.NewFactory(),
ecsobserver.NewFactory(),
ecstaskobserver.NewFactory(),
dockerobserver.NewFactory(),
healthcheckextension.NewFactory(),
filestorage.NewFactory(),
healthcheckextension.NewFactory(),
hostobserver.NewFactory(),
httpforwarder.NewFactory(),
k8sobserver.NewFactory(),
pprofextension.NewFactory(),
smartagentextension.NewFactory(),
zpagesextension.NewFactory(),
ballastextension.NewFactory(),
)
if err != nil {
errs = append(errs, err)
Expand Down
1 change: 1 addition & 0 deletions internal/components/components_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (

func TestDefaultComponents(t *testing.T) {
expectedExtensions := []component.Type{
"basicauth",
"ecs_observer",
"ecs_task_observer",
"docker_observer",
Expand Down
9 changes: 9 additions & 0 deletions tests/receivers/lightprometheus/internal_prometheus_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,23 @@
package tests

import (
"path"
"testing"

"github.com/signalfx/splunk-otel-collector/tests/testutils"
)

var httpd = []testutils.Container{testutils.NewContainer().WithContext(
path.Join(".", "testdata", "server"),
).WithName("httpd").WithExposedPorts("8000:80").WillWaitForLogs("httpd -D FOREGROUND")}

func TestInternalPrometheusMetrics(t *testing.T) {
testutils.SkipIfNotContainerTest(t) // TODO: enhance internal metric settings detection for process config
testutils.AssertAllMetricsReceived(
t, "internal.yaml", "internal_metrics_config.yaml", nil, nil,
)
}

func TestHttpdBasicAuth(t *testing.T) {
testutils.AssertAllMetricsReceived(t, "basic_auth_metrics.yaml", "httpd_basic_auth.yaml", httpd, nil)
}
23 changes: 23 additions & 0 deletions tests/receivers/lightprometheus/testdata/httpd_basic_auth.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
receivers:
lightprometheus/myjob:
auth:
authenticator: basicauth
collection_interval: 1s
endpoint: "http://localhost:8000/metrics"
exporters:
otlp:
endpoint: "${OTLP_ENDPOINT}"
tls:
insecure: true
extensions:
basicauth:
client_auth:
username: foo
password: bar

service:
extensions: [ basicauth ]
pipelines:
metrics:
receivers: [ lightprometheus/myjob ]
exporters: [ otlp ]
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
resource_metrics:
- attributes:
service.instance.id: localhost:8000
service.name: myjob
scope_metrics:
- instrumentation_scope:
attributes: { }
metrics:
- attributes:
application: my-own-app
area: nonheap
id: CodeHeap 'non-profiled nmethods'
description: The amount of foo going well with bar
name: foo_bar
type: DoubleGauge
- attributes:
application: my-own-app
area: heap
id: G1 Eden Space
description: The amount of foo going well with bar
name: foo_bar
type: DoubleGauge
- attributes:
application: my-own-app
area: nonheap
id: Metaspace
description: The amount of foo going well with bar
name: foo_bar
type: DoubleGauge
- attributes:
application: my-own-app
area: heap
id: G1 Survivor Space
description: The amount of foo going well with bar
name: foo_bar
type: DoubleGauge
- attributes:
application: my-own-app
area: nonheap
id: CodeHeap 'non-nmethods'
description: The amount of foo going well with bar
name: foo_bar
type: DoubleGauge
- attributes:
application: my-own-app
area: nonheap
id: CodeHeap 'profiled nmethods'
description: The amount of foo going well with bar
name: foo_bar
type: DoubleGauge
- attributes:
application: my-own-app
area: nonheap
id: Compressed Class Space
description: The amount of foo going well with bar
name: foo_bar
type: DoubleGauge
- attributes:
application: my-own-app
area: heap
id: G1 Old Gen
description: The amount of foo going well with bar
name: foo_bar
type: DoubleGauge
4 changes: 4 additions & 0 deletions tests/receivers/lightprometheus/testdata/server/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FROM httpd:2.4
COPY htpasswd /etc/httpd/.htpasswd
COPY content /usr/local/apache2/htdocs
COPY httpd.conf /usr/local/apache2/conf/httpd.conf
10 changes: 10 additions & 0 deletions tests/receivers/lightprometheus/testdata/server/content/metrics
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# HELP foo_bar The amount of foo going well with bar
# TYPE foo_bar gauge
foo_bar{application="my-own-app",area="nonheap",id="CodeHeap 'non-profiled nmethods'",} 13732552.0
foo_bar{application="my-own-app",area="heap",id="G1 Eden Space",} 17.9641776E7
foo_bar{application="my-own-app",area="nonheap",id="Metaspace",} 13.72735E7
foo_bar{application="my-own-app",area="heap",id="G1 Survivor Space",} 12097152.0
foo_bar{application="my-own-app",area="nonheap",id="CodeHeap 'non-nmethods'",} 12544904.0
foo_bar{application="my-own-app",area="nonheap",id="CodeHeap 'profiled nmethods'",} 11.0555296E7
foo_bar{application="my-own-app",area="nonheap",id="Compressed Class Space",} 14325676.0
foo_bar{application="my-own-app",area="heap",id="G1 Old Gen",} 15.0331678E7
1 change: 1 addition & 0 deletions tests/receivers/lightprometheus/testdata/server/htpasswd
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
foo:$apr1$ciDFVh2r$9Wc.6ZZkxST37BIxT3f9Y.
Loading