Skip to content

Commit

Permalink
Merge branch 'main' into rhel-dockerfile-ci
Browse files Browse the repository at this point in the history
  • Loading branch information
damemi authored Feb 17, 2025
2 parents f3c0adb + 90bf334 commit 64147dd
Show file tree
Hide file tree
Showing 141 changed files with 1,657 additions and 1,149 deletions.
1 change: 1 addition & 0 deletions .github/workflows/publish-modules.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ jobs:
git tag procdiscovery/${{ steps.extract_tag.outputs.tag }}
git tag profiles/${{ steps.extract_tag.outputs.tag }}
git tag distros/${{ steps.extract_tag.outputs.tag }}
git tag instrumentor/${{ steps.extract_tag.outputs.tag }}
git push origin --tags
- name: Trigger Release PR in Odigos Enterprise
Expand Down
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"type": "go",
"request": "launch",
"mode": "debug",
"program": "${workspaceFolder}/instrumentor",
"program": "${workspaceFolder}/instrumentor/cmd",
"cwd": "${workspaceFolder}/instrumentor"
},
{
Expand Down
7 changes: 1 addition & 6 deletions agents/python/configurator/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,4 @@

class OdigosPythonConfigurator(sdk_config._BaseConfigurator):
def _configure(self, **kwargs):
trace_exporters, metric_exporters, log_exporters = sdk_config._import_exporters(
['otlp_proto_http'] if sdk_config._get_exporter_names("traces") else [],
[],
[],
)
initialize_components(trace_exporters, metric_exporters, log_exporters)
initialize_components(trace_exporters=True)
2 changes: 1 addition & 1 deletion agents/python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# index_url = 'http://host.docker.internal:8081/packages/odigos_opentelemetry_python-0.1.1-py3-none-any.whl'

install_requires = [
f"odigos-opentelemetry-python @ {index_url}" if index_url else "odigos-opentelemetry-python==1.0.26"
f"odigos-opentelemetry-python @ {index_url}" if index_url else "odigos-opentelemetry-python==1.0.27"
]

setup(
Expand Down
12 changes: 6 additions & 6 deletions autoscaler/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ require (
github.com/odigos-io/opentelemetry-zap-bridge v0.0.5
github.com/stretchr/testify v1.10.0
go.opentelemetry.io/otel v1.34.0
k8s.io/api v0.32.1
k8s.io/apimachinery v0.32.1
k8s.io/client-go v0.32.1
k8s.io/api v0.32.2
k8s.io/apimachinery v0.32.2
k8s.io/client-go v0.32.2
k8s.io/utils v0.0.0-20241210054802-24370beab758
sigs.k8s.io/controller-runtime v0.20.1
sigs.k8s.io/controller-runtime v0.20.2
)

require (
Expand All @@ -27,7 +27,7 @@ require (
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/emicklei/go-restful/v3 v3.12.0 // indirect
github.com/evanphx/json-patch v4.9.0+incompatible // indirect
github.com/evanphx/json-patch/v5 v5.9.0 // indirect
github.com/evanphx/json-patch/v5 v5.9.11 // indirect
github.com/fatih/color v1.16.0 // indirect
github.com/fsnotify/fsnotify v1.8.0 // indirect
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
Expand Down Expand Up @@ -86,7 +86,7 @@ require (
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/apiextensions-apiserver v0.32.0 // indirect
k8s.io/apiextensions-apiserver v0.32.1 // indirect
k8s.io/klog/v2 v2.130.1 // indirect
k8s.io/kube-openapi v0.0.0-20241105132330-32ad38e42d3f // indirect
sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 // indirect
Expand Down
32 changes: 16 additions & 16 deletions autoscaler/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ github.com/emicklei/go-restful/v3 v3.12.0 h1:y2DdzBAURM29NFF94q6RaY4vjIH1rtwDapw
github.com/emicklei/go-restful/v3 v3.12.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc=
github.com/evanphx/json-patch v4.9.0+incompatible h1:kLcOMZeuLAJvL2BPWLMIj5oaZQobrkAqrL+WFZwQses=
github.com/evanphx/json-patch v4.9.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk=
github.com/evanphx/json-patch/v5 v5.9.0 h1:kcBlZQbplgElYIlo/n1hJbls2z/1awpXxpRi0/FOJfg=
github.com/evanphx/json-patch/v5 v5.9.0/go.mod h1:VNkHZ/282BpEyt/tObQO8s5CMPmYYq14uClGH4abBuQ=
github.com/evanphx/json-patch/v5 v5.9.11 h1:/8HVnzMq13/3x9TPvjG08wUGqBTmZBsCWzjTM0wiaDU=
github.com/evanphx/json-patch/v5 v5.9.11/go.mod h1:3j+LviiESTElxA4p3EMKAB9HXj3/XEtnUf6OZxqIQTM=
github.com/fatih/color v1.16.0 h1:zmkK9Ngbjj+K0yRhTVONQh1p/HknKYSlNT+vZCzyokM=
github.com/fatih/color v1.16.0/go.mod h1:fL2Sau1YI5c0pdGEVCbKQbLXB6edEj1ZgiY4NijnWvE=
github.com/fsnotify/fsnotify v1.8.0 h1:dAwr6QBTBZIkG8roQaJjGof0pp0EeF+tNV7YBP3F/8M=
Expand Down Expand Up @@ -101,10 +101,10 @@ github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
github.com/odigos-io/opentelemetry-zap-bridge v0.0.5 h1:UDEKtgab42nGVSvA/F3lLKUYFPETtpl7kpxM9BKBlWk=
github.com/odigos-io/opentelemetry-zap-bridge v0.0.5/go.mod h1:K98wHhktQ6vCTqeFztcpBDtPTe88vxVgZFlbeGobt24=
github.com/onsi/ginkgo/v2 v2.21.0 h1:7rg/4f3rB88pb5obDgNZrNHrQ4e6WpjonchcpuBRnZM=
github.com/onsi/ginkgo/v2 v2.21.0/go.mod h1:7Du3c42kxCUegi0IImZ1wUQzMBVecgIHjR1C+NkhLQo=
github.com/onsi/gomega v1.35.1 h1:Cwbd75ZBPxFSuZ6T+rN/WCb/gOc6YgFBXLlZLhC7Ds4=
github.com/onsi/gomega v1.35.1/go.mod h1:PvZbdDc8J6XJEpDK4HCuRBm8a6Fzp9/DmhC9C7yFlog=
github.com/onsi/ginkgo/v2 v2.22.0 h1:Yed107/8DjTr0lKCNt7Dn8yQ6ybuDRQoMGrNFKzMfHg=
github.com/onsi/ginkgo/v2 v2.22.0/go.mod h1:7Du3c42kxCUegi0IImZ1wUQzMBVecgIHjR1C+NkhLQo=
github.com/onsi/gomega v1.36.1 h1:bJDPBO7ibjxcbHMgSCoo4Yj18UWbKDlLwX1x9sybDcw=
github.com/onsi/gomega v1.36.1/go.mod h1:PvZbdDc8J6XJEpDK4HCuRBm8a6Fzp9/DmhC9C7yFlog=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
Expand Down Expand Up @@ -220,22 +220,22 @@ gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
k8s.io/api v0.32.1 h1:f562zw9cy+GvXzXf0CKlVQ7yHJVYzLfL6JAS4kOAaOc=
k8s.io/api v0.32.1/go.mod h1:/Yi/BqkuueW1BgpoePYBRdDYfjPF5sgTr5+YqDZra5k=
k8s.io/apiextensions-apiserver v0.32.0 h1:S0Xlqt51qzzqjKPxfgX1xh4HBZE+p8KKBq+k2SWNOE0=
k8s.io/apiextensions-apiserver v0.32.0/go.mod h1:86hblMvN5yxMvZrZFX2OhIHAuFIMJIZ19bTvzkP+Fmw=
k8s.io/apimachinery v0.32.1 h1:683ENpaCBjma4CYqsmZyhEzrGz6cjn1MY/X2jB2hkZs=
k8s.io/apimachinery v0.32.1/go.mod h1:GpHVgxoKlTxClKcteaeuF1Ul/lDVb74KpZcxcmLDElE=
k8s.io/client-go v0.32.1 h1:otM0AxdhdBIaQh7l1Q0jQpmo7WOFIk5FFa4bg6YMdUU=
k8s.io/client-go v0.32.1/go.mod h1:aTTKZY7MdxUaJ/KiUs8D+GssR9zJZi77ZqtzcGXIiDg=
k8s.io/api v0.32.2 h1:bZrMLEkgizC24G9eViHGOPbW+aRo9duEISRIJKfdJuw=
k8s.io/api v0.32.2/go.mod h1:hKlhk4x1sJyYnHENsrdCWw31FEmCijNGPJO5WzHiJ6Y=
k8s.io/apiextensions-apiserver v0.32.1 h1:hjkALhRUeCariC8DiVmb5jj0VjIc1N0DREP32+6UXZw=
k8s.io/apiextensions-apiserver v0.32.1/go.mod h1:sxWIGuGiYov7Io1fAS2X06NjMIk5CbRHc2StSmbaQto=
k8s.io/apimachinery v0.32.2 h1:yoQBR9ZGkA6Rgmhbp/yuT9/g+4lxtsGYwW6dR6BDPLQ=
k8s.io/apimachinery v0.32.2/go.mod h1:GpHVgxoKlTxClKcteaeuF1Ul/lDVb74KpZcxcmLDElE=
k8s.io/client-go v0.32.2 h1:4dYCD4Nz+9RApM2b/3BtVvBHw54QjMFUl1OLcJG5yOA=
k8s.io/client-go v0.32.2/go.mod h1:fpZ4oJXclZ3r2nDOv+Ux3XcJutfrwjKTCHz2H3sww94=
k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk=
k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE=
k8s.io/kube-openapi v0.0.0-20241105132330-32ad38e42d3f h1:GA7//TjRY9yWGy1poLzYYJJ4JRdzg3+O6e8I+e+8T5Y=
k8s.io/kube-openapi v0.0.0-20241105132330-32ad38e42d3f/go.mod h1:R/HEjbvWI0qdfb8viZUeVZm0X6IZnxAydC7YU42CMw4=
k8s.io/utils v0.0.0-20241210054802-24370beab758 h1:sdbE21q2nlQtFh65saZY+rRM6x6aJJI8IUa1AmH/qa0=
k8s.io/utils v0.0.0-20241210054802-24370beab758/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
sigs.k8s.io/controller-runtime v0.20.1 h1:JbGMAG/X94NeM3xvjenVUaBjy6Ui4Ogd/J5ZtjZnHaE=
sigs.k8s.io/controller-runtime v0.20.1/go.mod h1:BrP3w158MwvB3ZbNpaAcIKkHQ7YGpYnzpoSTZ8E14WU=
sigs.k8s.io/controller-runtime v0.20.2 h1:/439OZVxoEc02psi1h4QO3bHzTgu49bb347Xp4gW1pc=
sigs.k8s.io/controller-runtime v0.20.2/go.mod h1:xg2XB0K5ShQzAgsoujxuKN4LNXR2LfwwHsPj7Iaw+XY=
sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 h1:/Rv+M11QRah1itp8VhT6HoVx1Ray9eB4DBr+K+/sCJ8=
sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3/go.mod h1:18nIHnGi6636UCz6m8i4DhaJ65T6EruyzmoQqI2BVDo=
sigs.k8s.io/structured-merge-diff/v4 v4.5.0 h1:nbCitCK2hfnhyiKo6uf2HxUPTCodY6Qaf85SbDIaMBk=
Expand Down
8 changes: 4 additions & 4 deletions cli/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ require (
github.com/spf13/cobra v1.8.1
github.com/spf13/pflag v1.0.6
gopkg.in/yaml.v2 v2.4.0
k8s.io/api v0.32.1
k8s.io/apiextensions-apiserver v0.32.1
k8s.io/apimachinery v0.32.1
k8s.io/client-go v0.32.1
k8s.io/api v0.32.2
k8s.io/apiextensions-apiserver v0.32.2
k8s.io/apimachinery v0.32.2
k8s.io/client-go v0.32.2
sigs.k8s.io/yaml v1.4.0
)

Expand Down
16 changes: 8 additions & 8 deletions cli/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -178,14 +178,14 @@ gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
k8s.io/api v0.32.1 h1:f562zw9cy+GvXzXf0CKlVQ7yHJVYzLfL6JAS4kOAaOc=
k8s.io/api v0.32.1/go.mod h1:/Yi/BqkuueW1BgpoePYBRdDYfjPF5sgTr5+YqDZra5k=
k8s.io/apiextensions-apiserver v0.32.1 h1:hjkALhRUeCariC8DiVmb5jj0VjIc1N0DREP32+6UXZw=
k8s.io/apiextensions-apiserver v0.32.1/go.mod h1:sxWIGuGiYov7Io1fAS2X06NjMIk5CbRHc2StSmbaQto=
k8s.io/apimachinery v0.32.1 h1:683ENpaCBjma4CYqsmZyhEzrGz6cjn1MY/X2jB2hkZs=
k8s.io/apimachinery v0.32.1/go.mod h1:GpHVgxoKlTxClKcteaeuF1Ul/lDVb74KpZcxcmLDElE=
k8s.io/client-go v0.32.1 h1:otM0AxdhdBIaQh7l1Q0jQpmo7WOFIk5FFa4bg6YMdUU=
k8s.io/client-go v0.32.1/go.mod h1:aTTKZY7MdxUaJ/KiUs8D+GssR9zJZi77ZqtzcGXIiDg=
k8s.io/api v0.32.2 h1:bZrMLEkgizC24G9eViHGOPbW+aRo9duEISRIJKfdJuw=
k8s.io/api v0.32.2/go.mod h1:hKlhk4x1sJyYnHENsrdCWw31FEmCijNGPJO5WzHiJ6Y=
k8s.io/apiextensions-apiserver v0.32.2 h1:2YMk285jWMk2188V2AERy5yDwBYrjgWYggscghPCvV4=
k8s.io/apiextensions-apiserver v0.32.2/go.mod h1:GPwf8sph7YlJT3H6aKUWtd0E+oyShk/YHWQHf/OOgCA=
k8s.io/apimachinery v0.32.2 h1:yoQBR9ZGkA6Rgmhbp/yuT9/g+4lxtsGYwW6dR6BDPLQ=
k8s.io/apimachinery v0.32.2/go.mod h1:GpHVgxoKlTxClKcteaeuF1Ul/lDVb74KpZcxcmLDElE=
k8s.io/client-go v0.32.2 h1:4dYCD4Nz+9RApM2b/3BtVvBHw54QjMFUl1OLcJG5yOA=
k8s.io/client-go v0.32.2/go.mod h1:fpZ4oJXclZ3r2nDOv+Ux3XcJutfrwjKTCHz2H3sww94=
k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk=
k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE=
k8s.io/kube-openapi v0.0.0-20241105132330-32ad38e42d3f h1:GA7//TjRY9yWGy1poLzYYJJ4JRdzg3+O6e8I+e+8T5Y=
Expand Down
11 changes: 11 additions & 0 deletions common/consts/consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,14 @@ const (
var (
ErrorPodsNotFound = errors.New("could not find a ready pod")
)

// Agents related consts
var (
OtelExporterEndpointEnvName = "OTEL_EXPORTER_OTLP_ENDPOINT"
// Python related ones
OtelPythonConfiguratorEnvName = "OTEL_PYTHON_CONFIGURATOR"
OtelPythonOSSConfiguratorEnvValue = "odigos-python-configurator"
OtelPythonEBPFConfiguratorEnvValue = "ebpf"
OpampServerHostEnvName = "ODIGOS_OPAMP_SERVER_HOST"
OpAMPPort = 4320
)
7 changes: 4 additions & 3 deletions distros/distro/oteldistribution.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ type RuntimeAgent struct {
// For opamp distros, the resource attributes are set in the opamp server.
// We will eventually remove this field once all distros upgrade to dynamic resource attributes.
K8sAttrsViaEnvVars bool `yaml:"k8sAttrsViaEnvVars,omitempty"`

// If mounting of agent directory is achieved via k8s virtual device,
// this field specifies the name of the device to inject into the resources part of the pods container spec.
Device *string `yaml:"device,omitempty"`
}

// OtelDistro (Short for OpenTelemetry Distribution) is a collection of OpenTelemetry components,
Expand Down Expand Up @@ -88,9 +92,6 @@ type OtelDistro struct {
// Free text description of the distribution, what it includes, it's use cases, etc.
Description string `yaml:"description"`

// Specifies the odigos tiers which includes this distribution
Tiers []common.OdigosTier `yaml:"tiers"`

// a list of environment variables that needs to be set in the application runtime
// to enable the distribution.
EnvironmentVariables []EnvironmentVariable `yaml:"environmentVariables,omitempty"`
Expand Down
169 changes: 136 additions & 33 deletions distros/oteldistributions.go
Original file line number Diff line number Diff line change
@@ -1,53 +1,156 @@
package distros

import (
"embed"
"errors"
"fmt"

"github.com/odigos-io/odigos/common"
"github.com/odigos-io/odigos/distros/distro"
"github.com/odigos-io/odigos/distros/yamls"

"gopkg.in/yaml.v3"
)

func GetDefaultDistroNames(tier common.OdigosTier) map[common.ProgrammingLanguage]string {
switch tier {
case common.CommunityOdigosTier:
return map[common.ProgrammingLanguage]string{
common.JavascriptProgrammingLanguage: "nodejs-community",
common.PythonProgrammingLanguage: "python-community",
common.DotNetProgrammingLanguage: "dotnet-community",
common.JavaProgrammingLanguage: "java-community",
common.GoProgrammingLanguage: "golang-community",
type Defaulter interface {
GetDefaultDistroNames() map[common.ProgrammingLanguage]string
}

type communityDefaulter struct{}

var _ Defaulter = &communityDefaulter{}

// TODO: remove/rename this once we have an enterprise instrumentor
func NewCommunityDefaulter() *communityDefaulter {
return &communityDefaulter{}
}

// TODO: remove this once we have an enterprise instrumentor
func NewOnPremDefaulter() *onPremDefaulter {
return &onPremDefaulter{}
}

// TODO: once we split the distros package this should be renamed
func NewGetter() (*Getter, error) {
g := Getter{}

distrosByName, err := getDistrosMap(yamls.GetFS())
if err != nil {
return nil, err
}

g.distrosByName = distrosByName

return &g, nil
}

func (c *communityDefaulter) GetDefaultDistroNames() map[common.ProgrammingLanguage]string {
return map[common.ProgrammingLanguage]string{
common.JavascriptProgrammingLanguage: "nodejs-community",
common.PythonProgrammingLanguage: "python-community",
common.DotNetProgrammingLanguage: "dotnet-community",
common.JavaProgrammingLanguage: "java-community",
common.GoProgrammingLanguage: "golang-community",
}
}

// TODO: remove this once we have an enterprise instrumentor
type onPremDefaulter struct{}

var _ Defaulter = &onPremDefaulter{}

func (o *onPremDefaulter) GetDefaultDistroNames() map[common.ProgrammingLanguage]string {
return map[common.ProgrammingLanguage]string{
common.JavascriptProgrammingLanguage: "nodejs-enterprise",
common.PythonProgrammingLanguage: "python-enterprise",
common.DotNetProgrammingLanguage: "dotnet-community",
common.JavaProgrammingLanguage: "java-enterprise",
common.GoProgrammingLanguage: "golang-enterprise",
common.MySQLProgrammingLanguage: "mysql-enterprise",
}
}

type Getter struct {
distrosByName map[string]*distro.OtelDistro
}

func (g *Getter) GetDistroByName(distroName string) *distro.OtelDistro {
return g.distrosByName[distroName]
}

type Provider struct {
Defaulter
*Getter
}

// NewProvider creates a new distributions provider.
// A provider is a combination of a defaulter and a getter.
// The defaulter is used to get the default distro names for each programming language.
// The getter is used to get the distro object itself from the available distros.
//
// A provider is constructed from a single defaulter and one or more getters.
// The getters are unioned together to create a single getter for the provider.
//
// Each default distribution must be provided by at least one of the getters.
func NewProvider(defaulter Defaulter, getters ...*Getter) (*Provider, error) {
if len(getters) == 0 {
return nil, errors.New("at least one getter must be provided")
}

distros := make(map[string]*distro.OtelDistro)
for _, g := range getters {
for k, v := range g.distrosByName {
distros[k] = v
}
case common.OnPremOdigosTier:
return map[common.ProgrammingLanguage]string{
common.JavascriptProgrammingLanguage: "nodejs-enterprise",
common.PythonProgrammingLanguage: "python-enterprise",
common.DotNetProgrammingLanguage: "dotnet-community",
common.JavaProgrammingLanguage: "java-enterprise",
common.GoProgrammingLanguage: "golang-enterprise",
common.MySQLProgrammingLanguage: "mysql-enterprise",
}

// make sure the default distributions are provided by at least one of the getters
defaultDistroNames := defaulter.GetDefaultDistroNames()
for _, distroName := range defaultDistroNames {
if _, ok := distros[distroName]; !ok {
return nil, fmt.Errorf("default distribution %s not found in any getter", distroName)
}
default:
return nil
}

return &Provider{
Defaulter: defaulter,
Getter: &Getter{
distrosByName: distros,
},
}, nil
}

type distroResource struct {
ApiVersion string `json:"apiVersion"`
Spec distro.OtelDistro `json:"spec"`
}

var allDistros = []distro.OtelDistro{}
func getDistrosMap(fs embed.FS) (map[string]*distro.OtelDistro, error) {
files, err := fs.ReadDir(".")
if err != nil {
return nil, err
}

func init() {
distroNames := yamls.GetAllDistroNames()
for _, distroName := range distroNames {
distro, err := yamls.ReadDistroFromYamlManifest(distroName)
if err != nil {
distrosByName := make(map[string]*distro.OtelDistro)

for _, file := range files {
if file.IsDir() {
continue
}
allDistros = append(allDistros, *distro)
}
}

func GetDistroByName(distroName string) *distro.OtelDistro {
for i := range allDistros {
if allDistros[i].Name == distroName {
return &allDistros[i]
yamlBytes, err := fs.ReadFile(file.Name())
if err != nil {
return nil, err
}

otelDistro := distroResource{}
err = yaml.Unmarshal(yamlBytes, &otelDistro)
if err != nil {
return nil, err
}

distrosByName[otelDistro.Spec.Name] = &otelDistro.Spec
}
return nil

return distrosByName, nil
}
Loading

0 comments on commit 64147dd

Please sign in to comment.