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

POC of integration receiver and processor #96

Draft
wants to merge 23 commits into
base: main
Choose a base branch
from
Draft
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
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,4 @@ builddocker:
else \
IMAGE_NAME=elastic-collector-components:$(TAG); \
fi; \
docker build -t $$IMAGE_NAME -f distributions/elastic-components/Dockerfile .
docker build -t $$IMAGE_NAME -f distributions/elastic-components/Dockerfile .
30 changes: 20 additions & 10 deletions distributions/elastic-components/manifest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ dist:
output_path: ./_build

extensions:
- gomod: github.com/elastic/opentelemetry-collector-components/extension/configintegrationextension v0.0.0
- gomod: github.com/elastic/opentelemetry-collector-components/extension/fileintegrationextension v0.0.0
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/extension/healthcheckextension v0.114.0
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/extension/pprofextension v0.114.0
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/extension/storage/filestorage v0.114.0
Expand All @@ -17,36 +19,38 @@ connectors:
converters:

receivers:
- gomod: go.opentelemetry.io/collector/receiver/nopreceiver v0.114.0
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/receiver/jaegerreceiver v0.114.0
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/receiver/prometheusreceiver v0.114.0
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/receiver/zipkinreceiver v0.114.0
- gomod: github.com/elastic/opentelemetry-collector-components/receiver/integrationreceiver v0.0.0
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/receiver/filelogreceiver v0.114.0
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/receiver/hostmetricsreceiver v0.114.0
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/receiver/httpcheckreceiver v0.114.0
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/receiver/jaegerreceiver v0.114.0
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/receiver/k8sclusterreceiver v0.114.0
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/receiver/k8sobjectsreceiver v0.114.0
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/receiver/kubeletstatsreceiver v0.114.0
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/receiver/prometheusreceiver v0.114.0
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/receiver/zipkinreceiver v0.114.0
- gomod: go.opentelemetry.io/collector/receiver/nopreceiver v0.114.0
- gomod: go.opentelemetry.io/collector/receiver/otlpreceiver v0.114.0

processors:
- gomod: go.opentelemetry.io/collector/processor/memorylimiterprocessor v0.114.0
- gomod: github.com/elastic/opentelemetry-collector-components/processor/elasticinframetricsprocessor v0.0.0
- gomod: github.com/elastic/opentelemetry-collector-components/processor/elastictraceprocessor v0.0.0
- gomod: github.com/elastic/opentelemetry-collector-components/processor/integrationprocessor v0.0.0
- gomod: github.com/elastic/opentelemetry-collector-components/processor/lsmintervalprocessor v0.0.0
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/processor/attributesprocessor v0.114.0
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/processor/filterprocessor v0.114.0
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/processor/k8sattributesprocessor v0.114.0
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/processor/resourcedetectionprocessor v0.114.0
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/processor/resourceprocessor v0.114.0
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/processor/transformprocessor v0.114.0
- gomod: go.opentelemetry.io/collector/processor/batchprocessor v0.114.0
- gomod: github.com/elastic/opentelemetry-collector-components/processor/elasticinframetricsprocessor v0.0.0
- gomod: github.com/elastic/opentelemetry-collector-components/processor/elastictraceprocessor v0.0.0
- gomod: github.com/elastic/opentelemetry-collector-components/processor/lsmintervalprocessor v0.0.0
- gomod: go.opentelemetry.io/collector/processor/memorylimiterprocessor v0.114.0

exporters:
- gomod: go.opentelemetry.io/collector/exporter/nopexporter v0.114.0
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/exporter/elasticsearchexporter v0.114.0
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/exporter/fileexporter v0.114.0
- gomod: go.opentelemetry.io/collector/exporter/debugexporter v0.114.0
- gomod: go.opentelemetry.io/collector/exporter/nopexporter v0.114.0
- gomod: go.opentelemetry.io/collector/exporter/otlpexporter v0.114.0
- gomod: go.opentelemetry.io/collector/exporter/otlphttpexporter v0.114.0

Expand All @@ -59,7 +63,13 @@ providers:
- gomod: go.opentelemetry.io/collector/confmap/provider/yamlprovider v1.20.0

replaces:
- github.com/elastic/opentelemetry-collector-components/connector/signaltometricsconnector => ../connector/signaltometricsconnector
- github.com/elastic/opentelemetry-collector-components/connector/spanmetricsconnectorv2 => ../connector/spanmetricsconnectorv2
- github.com/elastic/opentelemetry-collector-components/extension/configintegrationextension => ../extension/configintegrationextension
- github.com/elastic/opentelemetry-collector-components/extension/fileintegrationextension => ../extension/fileintegrationextension
- github.com/elastic/opentelemetry-collector-components/internal/integrations => ../internal/integrations
- github.com/elastic/opentelemetry-collector-components/processor/elasticinframetricsprocessor => ../processor/elasticinframetricsprocessor
- github.com/elastic/opentelemetry-collector-components/processor/elastictraceprocessor => ../processor/elastictraceprocessor
- github.com/elastic/opentelemetry-collector-components/processor/integrationprocessor => ../processor/integrationprocessor
- github.com/elastic/opentelemetry-collector-components/processor/lsmintervalprocessor => ../processor/lsmintervalprocessor
- github.com/elastic/opentelemetry-collector-components/connector/signaltometricsconnector => ../connector/signaltometricsconnector
- github.com/elastic/opentelemetry-collector-components/receiver/integrationreceiver => ../receiver/integrationreceiver
1 change: 1 addition & 0 deletions extension/configintegrationextension/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include ../../Makefile.Common
26 changes: 26 additions & 0 deletions extension/configintegrationextension/config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Licensed to Elasticsearch B.V. under one or more contributor
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
// ownership. Elasticsearch B.V. licenses this file to you under
// the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

package configintegrationextension // import "github.com/elastic/opentelemetry-collector-components/extension/configintegrationextension"

type Config struct {
Integrations map[string]string `mapstructure:"integrations"`
}

func (c *Config) Validate() error {
return nil
}
21 changes: 21 additions & 0 deletions extension/configintegrationextension/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Licensed to Elasticsearch B.V. under one or more contributor
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
// ownership. Elasticsearch B.V. licenses this file to you under
// the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

//go:generate mdatagen metadata.yaml

// Package configintegrationextension provides a source of integrations that obtain them from a local directory.
package configintegrationextension // import "github.com/elastic/opentelemetry-collector-components/extension/configintegrationextension"
89 changes: 89 additions & 0 deletions extension/configintegrationextension/extension.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
// Licensed to Elasticsearch B.V. under one or more contributor
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
// ownership. Elasticsearch B.V. licenses this file to you under
// the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

package configintegrationextension // import "github.com/elastic/opentelemetry-collector-components/extension/configintegrationextension"

import (
"context"
"strings"

"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/confmap"

"github.com/elastic/opentelemetry-collector-components/internal/integrations"
)

type configTemplateExtension struct {
config *Config
}

var _ integrations.TemplateFinder = &configTemplateExtension{}

func newConfigTemplateExtension(config *Config) *configTemplateExtension {
return &configTemplateExtension{
config: config,
}
}

func (e *configTemplateExtension) FindTemplate(ctx context.Context, name, version string) (integrations.Template, error) {
integration, found := e.config.Integrations[name]
if !found {
return nil, integrations.ErrNotFound
}

return &integrationConfig{
name: name,
integration: strings.ReplaceAll(integration, `$$`, `$`),
}, nil
}

func (*configTemplateExtension) Start(context.Context, component.Host) error {
return nil
}

func (*configTemplateExtension) Shutdown(context.Context) error {
return nil
}

type integrationConfig struct {
name string
integration string
}

func (t *integrationConfig) URI() string {
return t.Scheme() + ":" + t.name
}

func (t *integrationConfig) ProviderFactory() confmap.ProviderFactory {
return t
}

func (t *integrationConfig) Create(_ confmap.ProviderSettings) confmap.Provider {
return t
}

func (t *integrationConfig) Retrieve(ctx context.Context, _ string, _ confmap.WatcherFunc) (*confmap.Retrieved, error) {
return confmap.NewRetrievedFromYAML([]byte(t.integration))
}

func (t *integrationConfig) Scheme() string {
return "config"
}

func (t *integrationConfig) Shutdown(ctx context.Context) error {
return nil
}
45 changes: 45 additions & 0 deletions extension/configintegrationextension/factory.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// Licensed to Elasticsearch B.V. under one or more contributor
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
// ownership. Elasticsearch B.V. licenses this file to you under
// the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

package configintegrationextension // import "github.com/elastic/opentelemetry-collector-components/extension/configintegrationextension"

import (
"context"

"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/extension"

"github.com/elastic/opentelemetry-collector-components/extension/configintegrationextension/internal/metadata"
)

// NewFactory creates a factory for ack extension.
func NewFactory() extension.Factory {
return extension.NewFactory(
metadata.Type,
createDefaultConfig,
createExtension,
metadata.ExtensionStability,
)
}

func createDefaultConfig() component.Config {
return &Config{}
}

func createExtension(_ context.Context, _ extension.Settings, cfg component.Config) (extension.Extension, error) {
return newConfigTemplateExtension(cfg.(*Config)), nil
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 29 additions & 0 deletions extension/configintegrationextension/generated_package_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading