diff --git a/internal/pkg/otel/Makefile b/internal/pkg/otel/Makefile new file mode 100644 index 00000000000..5301d96bf90 --- /dev/null +++ b/internal/pkg/otel/Makefile @@ -0,0 +1,6 @@ +.PHONY: all + +all: + go run go.opentelemetry.io/collector/cmd/builder@v0.107.0 --skip-compilation --skip-get-modules --config builder-config.yaml + @rm main.go main_others.go main_windows.go go.mod + sed -i 's/package main/\/\/go:build \!windows\npackage otel/g' components.go diff --git a/internal/pkg/otel/builder-config.yaml b/internal/pkg/otel/builder-config.yaml new file mode 100644 index 00000000000..b97177bca75 --- /dev/null +++ b/internal/pkg/otel/builder-config.yaml @@ -0,0 +1,43 @@ +dist: + name: otelcol + description: Elastic Distribution of OpenTelemetry Collector + module: otel + output_path: . + +extensions: + - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/extension/healthcheckextension v0.107.0 + - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/extension/storage/filestorage v0.107.0 + - gomod: go.opentelemetry.io/collector/extension/memorylimiterextension v0.107.0 + +exporters: + - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/exporter/elasticsearchexporter v0.107.0 + - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/exporter/fileexporter v0.107.0 + - gomod: go.opentelemetry.io/collector/exporter/debugexporter v0.107.0 + - gomod: go.opentelemetry.io/collector/exporter/otlpexporter v0.107.0 + - gomod: go.opentelemetry.io/collector/exporter/otlphttpexporter v0.107.0 + +processors: + - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/processor/attributesprocessor v0.107.0 + - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/processor/filterprocessor v0.107.0 + - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/processor/k8sattributesprocessor v0.107.0 + - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/processor/resourcedetectionprocessor v0.107.0 + - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/processor/resourceprocessor v0.107.0 + - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/processor/transformprocessor v0.107.0 + - gomod: go.opentelemetry.io/collector/processor/batchprocessor v0.107.0 + - gomod: go.opentelemetry.io/collector/processor/memorylimiterprocessor v0.107.0 + - gomod: github.com/elastic/opentelemetry-collector-components/processor/elasticinframetricsprocessor v0.9.0 + +receivers: + - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/receiver/filelogreceiver v0.107.0 + - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/receiver/hostmetricsreceiver v0.107.0 + - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/receiver/httpcheckreceiver v0.107.0 + - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/receiver/jaegerreceiver v0.107.0 + - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/receiver/k8sclusterreceiver v0.107.0 + - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/receiver/k8sobjectsreceiver v0.107.0 + - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/receiver/kubeletstatsreceiver v0.107.0 + - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/receiver/prometheusreceiver v0.107.0 + - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/receiver/zipkinreceiver v0.107.0 + - gomod: go.opentelemetry.io/collector/receiver/otlpreceiver v0.107.0 + +connectors: + - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/connector/spanmetricsconnector v0.107.0 diff --git a/internal/pkg/otel/components.go b/internal/pkg/otel/components.go index f44006d799e..d4280658c70 100644 --- a/internal/pkg/otel/components.go +++ b/internal/pkg/otel/components.go @@ -1,21 +1,35 @@ -// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one -// or more contributor license agreements. Licensed under the Elastic License; -// you may not use this file except in compliance with the Elastic License. +// Code generated by "go.opentelemetry.io/collector/cmd/builder". DO NOT EDIT. //go:build !windows - package otel import ( + "go.opentelemetry.io/collector/component" "go.opentelemetry.io/collector/connector" "go.opentelemetry.io/collector/exporter" "go.opentelemetry.io/collector/extension" "go.opentelemetry.io/collector/otelcol" "go.opentelemetry.io/collector/processor" "go.opentelemetry.io/collector/receiver" - - // Receivers: - filelogreceiver "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/filelogreceiver" // for collecting log files + spanmetricsconnector "github.com/open-telemetry/opentelemetry-collector-contrib/connector/spanmetricsconnector" + elasticsearchexporter "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/elasticsearchexporter" + fileexporter "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/fileexporter" + debugexporter "go.opentelemetry.io/collector/exporter/debugexporter" + otlpexporter "go.opentelemetry.io/collector/exporter/otlpexporter" + otlphttpexporter "go.opentelemetry.io/collector/exporter/otlphttpexporter" + healthcheckextension "github.com/open-telemetry/opentelemetry-collector-contrib/extension/healthcheckextension" + filestorage "github.com/open-telemetry/opentelemetry-collector-contrib/extension/storage/filestorage" + memorylimiterextension "go.opentelemetry.io/collector/extension/memorylimiterextension" + attributesprocessor "github.com/open-telemetry/opentelemetry-collector-contrib/processor/attributesprocessor" + filterprocessor "github.com/open-telemetry/opentelemetry-collector-contrib/processor/filterprocessor" + k8sattributesprocessor "github.com/open-telemetry/opentelemetry-collector-contrib/processor/k8sattributesprocessor" + resourcedetectionprocessor "github.com/open-telemetry/opentelemetry-collector-contrib/processor/resourcedetectionprocessor" + resourceprocessor "github.com/open-telemetry/opentelemetry-collector-contrib/processor/resourceprocessor" + transformprocessor "github.com/open-telemetry/opentelemetry-collector-contrib/processor/transformprocessor" + batchprocessor "go.opentelemetry.io/collector/processor/batchprocessor" + memorylimiterprocessor "go.opentelemetry.io/collector/processor/memorylimiterprocessor" + elasticinframetricsprocessor "github.com/elastic/opentelemetry-collector-components/processor/elasticinframetricsprocessor" + filelogreceiver "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/filelogreceiver" hostmetricsreceiver "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/hostmetricsreceiver" httpcheckreceiver "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/httpcheckreceiver" jaegerreceiver "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/jaegerreceiver" @@ -25,99 +39,102 @@ import ( prometheusreceiver "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/prometheusreceiver" zipkinreceiver "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/zipkinreceiver" otlpreceiver "go.opentelemetry.io/collector/receiver/otlpreceiver" - - // Processors: - attributesprocessor "github.com/open-telemetry/opentelemetry-collector-contrib/processor/attributesprocessor" // for modifying signal attributes - "github.com/open-telemetry/opentelemetry-collector-contrib/processor/filterprocessor" - k8sattributesprocessor "github.com/open-telemetry/opentelemetry-collector-contrib/processor/k8sattributesprocessor" // for adding k8s metadata - "github.com/open-telemetry/opentelemetry-collector-contrib/processor/resourcedetectionprocessor" - resourceprocessor "github.com/open-telemetry/opentelemetry-collector-contrib/processor/resourceprocessor" // for modifying resource attributes - transformprocessor "github.com/open-telemetry/opentelemetry-collector-contrib/processor/transformprocessor" // for OTTL processing on logs - "go.opentelemetry.io/collector/processor/batchprocessor" // for batching events - "go.opentelemetry.io/collector/processor/memorylimiterprocessor" - - "github.com/elastic/opentelemetry-collector-components/processor/elasticinframetricsprocessor" - - // Exporters: - "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/elasticsearchexporter" - fileexporter "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/fileexporter" // for e2e tests - debugexporter "go.opentelemetry.io/collector/exporter/debugexporter" // for dev - "go.opentelemetry.io/collector/exporter/otlpexporter" - otlphttpexporter "go.opentelemetry.io/collector/exporter/otlphttpexporter" - - // Extensions - "github.com/open-telemetry/opentelemetry-collector-contrib/extension/healthcheckextension" - filestorage "github.com/open-telemetry/opentelemetry-collector-contrib/extension/storage/filestorage" - "go.opentelemetry.io/collector/extension/memorylimiterextension" // for putting backpressure when approach a memory limit - - // Connectors - spanmetricsconnector "github.com/open-telemetry/opentelemetry-collector-contrib/connector/spanmetricsconnector" ) func components() (otelcol.Factories, error) { var err error factories := otelcol.Factories{} - // Receivers + factories.Extensions, err = extension.MakeFactoryMap( + healthcheckextension.NewFactory(), + filestorage.NewFactory(), + memorylimiterextension.NewFactory(), + ) + if err != nil { + return otelcol.Factories{}, err + } + factories.ExtensionModules = make(map[component.Type]string, len(factories.Extensions)) + factories.ExtensionModules[healthcheckextension.NewFactory().Type()] = "github.com/open-telemetry/opentelemetry-collector-contrib/extension/healthcheckextension v0.107.0" + factories.ExtensionModules[filestorage.NewFactory().Type()] = "github.com/open-telemetry/opentelemetry-collector-contrib/extension/storage/filestorage v0.107.0" + factories.ExtensionModules[memorylimiterextension.NewFactory().Type()] = "go.opentelemetry.io/collector/extension/memorylimiterextension v0.107.0" + factories.Receivers, err = receiver.MakeFactoryMap( - otlpreceiver.NewFactory(), filelogreceiver.NewFactory(), - kubeletstatsreceiver.NewFactory(), - k8sclusterreceiver.NewFactory(), hostmetricsreceiver.NewFactory(), httpcheckreceiver.NewFactory(), + jaegerreceiver.NewFactory(), + k8sclusterreceiver.NewFactory(), k8sobjectsreceiver.NewFactory(), + kubeletstatsreceiver.NewFactory(), prometheusreceiver.NewFactory(), - jaegerreceiver.NewFactory(), zipkinreceiver.NewFactory(), + otlpreceiver.NewFactory(), ) if err != nil { return otelcol.Factories{}, err } + factories.ReceiverModules = make(map[component.Type]string, len(factories.Receivers)) + factories.ReceiverModules[filelogreceiver.NewFactory().Type()] = "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/filelogreceiver v0.107.0" + factories.ReceiverModules[hostmetricsreceiver.NewFactory().Type()] = "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/hostmetricsreceiver v0.107.0" + factories.ReceiverModules[httpcheckreceiver.NewFactory().Type()] = "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/httpcheckreceiver v0.107.0" + factories.ReceiverModules[jaegerreceiver.NewFactory().Type()] = "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/jaegerreceiver v0.107.0" + factories.ReceiverModules[k8sclusterreceiver.NewFactory().Type()] = "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/k8sclusterreceiver v0.107.0" + factories.ReceiverModules[k8sobjectsreceiver.NewFactory().Type()] = "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/k8sobjectsreceiver v0.107.0" + factories.ReceiverModules[kubeletstatsreceiver.NewFactory().Type()] = "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/kubeletstatsreceiver v0.107.0" + factories.ReceiverModules[prometheusreceiver.NewFactory().Type()] = "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/prometheusreceiver v0.107.0" + factories.ReceiverModules[zipkinreceiver.NewFactory().Type()] = "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/zipkinreceiver v0.107.0" + factories.ReceiverModules[otlpreceiver.NewFactory().Type()] = "go.opentelemetry.io/collector/receiver/otlpreceiver v0.107.0" - // Processors - factories.Processors, err = processor.MakeFactoryMap( - batchprocessor.NewFactory(), - resourceprocessor.NewFactory(), - attributesprocessor.NewFactory(), - transformprocessor.NewFactory(), - filterprocessor.NewFactory(), - k8sattributesprocessor.NewFactory(), - elasticinframetricsprocessor.NewFactory(), - resourcedetectionprocessor.NewFactory(), - memorylimiterprocessor.NewFactory(), - ) - if err != nil { - return otelcol.Factories{}, err - } - - // Exporters factories.Exporters, err = exporter.MakeFactoryMap( - otlpexporter.NewFactory(), - debugexporter.NewFactory(), - fileexporter.NewFactory(), elasticsearchexporter.NewFactory(), + fileexporter.NewFactory(), + debugexporter.NewFactory(), + otlpexporter.NewFactory(), otlphttpexporter.NewFactory(), ) if err != nil { return otelcol.Factories{}, err } + factories.ExporterModules = make(map[component.Type]string, len(factories.Exporters)) + factories.ExporterModules[elasticsearchexporter.NewFactory().Type()] = "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/elasticsearchexporter v0.107.0" + factories.ExporterModules[fileexporter.NewFactory().Type()] = "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/fileexporter v0.107.0" + factories.ExporterModules[debugexporter.NewFactory().Type()] = "go.opentelemetry.io/collector/exporter/debugexporter v0.107.0" + factories.ExporterModules[otlpexporter.NewFactory().Type()] = "go.opentelemetry.io/collector/exporter/otlpexporter v0.107.0" + factories.ExporterModules[otlphttpexporter.NewFactory().Type()] = "go.opentelemetry.io/collector/exporter/otlphttpexporter v0.107.0" - factories.Connectors, err = connector.MakeFactoryMap( - spanmetricsconnector.NewFactory(), + factories.Processors, err = processor.MakeFactoryMap( + attributesprocessor.NewFactory(), + filterprocessor.NewFactory(), + k8sattributesprocessor.NewFactory(), + resourcedetectionprocessor.NewFactory(), + resourceprocessor.NewFactory(), + transformprocessor.NewFactory(), + batchprocessor.NewFactory(), + memorylimiterprocessor.NewFactory(), + elasticinframetricsprocessor.NewFactory(), ) if err != nil { return otelcol.Factories{}, err } + factories.ProcessorModules = make(map[component.Type]string, len(factories.Processors)) + factories.ProcessorModules[attributesprocessor.NewFactory().Type()] = "github.com/open-telemetry/opentelemetry-collector-contrib/processor/attributesprocessor v0.107.0" + factories.ProcessorModules[filterprocessor.NewFactory().Type()] = "github.com/open-telemetry/opentelemetry-collector-contrib/processor/filterprocessor v0.107.0" + factories.ProcessorModules[k8sattributesprocessor.NewFactory().Type()] = "github.com/open-telemetry/opentelemetry-collector-contrib/processor/k8sattributesprocessor v0.107.0" + factories.ProcessorModules[resourcedetectionprocessor.NewFactory().Type()] = "github.com/open-telemetry/opentelemetry-collector-contrib/processor/resourcedetectionprocessor v0.107.0" + factories.ProcessorModules[resourceprocessor.NewFactory().Type()] = "github.com/open-telemetry/opentelemetry-collector-contrib/processor/resourceprocessor v0.107.0" + factories.ProcessorModules[transformprocessor.NewFactory().Type()] = "github.com/open-telemetry/opentelemetry-collector-contrib/processor/transformprocessor v0.107.0" + factories.ProcessorModules[batchprocessor.NewFactory().Type()] = "go.opentelemetry.io/collector/processor/batchprocessor v0.107.0" + factories.ProcessorModules[memorylimiterprocessor.NewFactory().Type()] = "go.opentelemetry.io/collector/processor/memorylimiterprocessor v0.107.0" + factories.ProcessorModules[elasticinframetricsprocessor.NewFactory().Type()] = "github.com/elastic/opentelemetry-collector-components/processor/elasticinframetricsprocessor v0.9.0" - factories.Extensions, err = extension.MakeFactoryMap( - memorylimiterextension.NewFactory(), - filestorage.NewFactory(), - healthcheckextension.NewFactory(), + factories.Connectors, err = connector.MakeFactoryMap( + spanmetricsconnector.NewFactory(), ) if err != nil { return otelcol.Factories{}, err } + factories.ConnectorModules = make(map[component.Type]string, len(factories.Connectors)) + factories.ConnectorModules[spanmetricsconnector.NewFactory().Type()] = "github.com/open-telemetry/opentelemetry-collector-contrib/connector/spanmetricsconnector v0.107.0" - return factories, err + return factories, nil }