You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by pc...@apache.org on 2024/08/14 08:02:58 UTC

(camel-k) branch main updated: chore(traits): remove tracing

This is an automated email from the ASF dual-hosted git repository.

pcongiusti pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-k.git


The following commit(s) were added to refs/heads/main by this push:
     new 94d9a9a62 chore(traits): remove tracing
94d9a9a62 is described below

commit 94d9a9a62e9710d1ca629cba789acd69908bdd06
Author: Pasquale Congiusti <pa...@gmail.com>
AuthorDate: Tue Aug 13 15:03:27 2024 +0200

    chore(traits): remove tracing
---
 addons/register_opentracing.go         |  27 ------
 addons/tracing/discovery/jaeger.go     |  73 ----------------
 addons/tracing/discovery/locator.go    |  34 --------
 addons/tracing/test_support.go         |  21 -----
 addons/tracing/tracing.go              | 153 ---------------------------------
 addons/tracing/tracing_test.go         |  76 ----------------
 addons/tracing/zz_desc_generated.go    |   1 -
 addons/tracing/zz_generated_doc.go     |   1 -
 docs/modules/ROOT/nav.adoc             |   1 -
 docs/modules/traits/pages/tracing.adoc |  61 -------------
 10 files changed, 448 deletions(-)

diff --git a/addons/register_opentracing.go b/addons/register_opentracing.go
deleted file mode 100644
index 6b28d49ee..000000000
--- a/addons/register_opentracing.go
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
-Licensed to the Apache Software Foundation (ASF) under one or more
-contributor license agreements.  See the NOTICE file distributed with
-this work for additional information regarding copyright ownership.
-The ASF 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 addons
-
-import (
-	"github.com/apache/camel-k/v2/addons/tracing"
-	"github.com/apache/camel-k/v2/pkg/trait"
-)
-
-func init() {
-	trait.AddToTraits(tracing.NewTracingTrait)
-}
diff --git a/addons/tracing/discovery/jaeger.go b/addons/tracing/discovery/jaeger.go
deleted file mode 100644
index 27d822a2b..000000000
--- a/addons/tracing/discovery/jaeger.go
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
-Licensed to the Apache Software Foundation (ASF) under one or more
-contributor license agreements.  See the NOTICE file distributed with
-this work for additional information regarding copyright ownership.
-The ASF 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 discovery
-
-import (
-	"context"
-	"fmt"
-	"sort"
-	"strings"
-
-	"github.com/apache/camel-k/v2/pkg/client"
-	"github.com/apache/camel-k/v2/pkg/trait"
-	"github.com/apache/camel-k/v2/pkg/util/log"
-	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
-)
-
-type JaegerTracingLocator struct {
-	allowHeadless bool
-}
-
-const (
-	jaegerPortName = "http-c-binary-trft"
-)
-
-func (loc *JaegerTracingLocator) FindEndpoint(ctx context.Context, c client.Client, l log.Logger, e *trait.Environment) (string, error) {
-	opts := metav1.ListOptions{
-		LabelSelector: "app.kubernetes.io/part-of=jaeger,app.kubernetes.io/component=service-collector",
-	}
-	lst, err := c.CoreV1().Services(e.Integration.Namespace).List(ctx, opts)
-	if err != nil {
-		return "", err
-	}
-	var candidates []string
-	for _, svc := range lst.Items {
-		if !loc.allowHeadless && strings.HasSuffix(svc.Name, "-headless") {
-			continue
-		}
-
-		for _, port := range svc.Spec.Ports {
-			if port.Name == jaegerPortName && port.Port > 0 {
-				candidates = append(candidates, fmt.Sprintf("http://%s.%s.svc.cluster.local:%d/api/traces", svc.Name, svc.Namespace, port.Port))
-			}
-		}
-	}
-	sort.Strings(candidates)
-	if len(candidates) > 0 {
-		for _, endpoint := range candidates {
-			l.Infof("Detected Jaeger endpoint at: %s", endpoint)
-		}
-		return candidates[0], nil
-	}
-	return "", nil
-}
-
-// registering the locator.
-func init() {
-	TracingLocators = append(TracingLocators, &JaegerTracingLocator{}, &JaegerTracingLocator{allowHeadless: true})
-}
diff --git a/addons/tracing/discovery/locator.go b/addons/tracing/discovery/locator.go
deleted file mode 100644
index 023cf3b04..000000000
--- a/addons/tracing/discovery/locator.go
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
-Licensed to the Apache Software Foundation (ASF) under one or more
-contributor license agreements.  See the NOTICE file distributed with
-this work for additional information regarding copyright ownership.
-The ASF 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 discovery
-
-import (
-	"context"
-
-	"github.com/apache/camel-k/v2/pkg/client"
-	"github.com/apache/camel-k/v2/pkg/trait"
-	"github.com/apache/camel-k/v2/pkg/util/log"
-)
-
-// TracingLocators contains available tracing locators.
-var TracingLocators []TracingLocator
-
-// TracingLocator is able to find the address of an available tracing endpoint.
-type TracingLocator interface {
-	FindEndpoint(ctx context.Context, c client.Client, logger log.Logger, env *trait.Environment) (string, error)
-}
diff --git a/addons/tracing/test_support.go b/addons/tracing/test_support.go
deleted file mode 100644
index 90ba65bac..000000000
--- a/addons/tracing/test_support.go
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
-Licensed to the Apache Software Foundation (ASF) under one or more
-contributor license agreements.  See the NOTICE file distributed with
-this work for additional information regarding copyright ownership.
-The ASF 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 tracing
-
-// Expose tracingTrait type for testing.
-type TestTracingTrait = tracingTrait
diff --git a/addons/tracing/tracing.go b/addons/tracing/tracing.go
deleted file mode 100644
index 80a302be4..000000000
--- a/addons/tracing/tracing.go
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
-Licensed to the Apache Software Foundation (ASF) under one or more
-contributor license agreements.  See the NOTICE file distributed with
-this work for additional information regarding copyright ownership.
-The ASF 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 tracing
-
-import (
-	"github.com/apache/camel-k/v2/addons/tracing/discovery"
-	v1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1"
-	traitv1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1/trait"
-	"github.com/apache/camel-k/v2/pkg/trait"
-	"github.com/apache/camel-k/v2/pkg/util"
-	"k8s.io/utils/ptr"
-)
-
-// WARNING: The Tracing trait has been **deprecated** in favor of the xref:traits:telemetry.adoc[Telemetry] trait.
-//
-// The Tracing trait can be used to automatically publish tracing information to an OpenTracing compatible collector.
-//
-// The trait is able to automatically discover the tracing endpoint available in the namespace (supports **Jaeger**).
-//
-// The Tracing trait is disabled by default.
-//
-// WARNING: The Tracing trait can't be enabled at the same time as the Telemetry trait.
-//
-// +camel-k:trait=tracing.
-// +camel-k:deprecated=1.12.0.
-type Trait struct {
-	traitv1.Trait `property:",squash" json:",inline"`
-	// Enables automatic configuration of the trait, including automatic discovery of the tracing endpoint.
-	Auto *bool `property:"auto" json:"auto,omitempty"`
-	// The name of the service that publishes tracing data (defaults to the integration name)
-	ServiceName string `property:"service-name" json:"serviceName,omitempty"`
-	// The target endpoint of the OpenTracing service (automatically discovered by default)
-	Endpoint string `property:"endpoint" json:"endpoint,omitempty"`
-	// The sampler type (default "const")
-	SamplerType *string `property:"sampler-type" json:"samplerType,omitempty"`
-	// The sampler specific param (default "1")
-	SamplerParam *string `property:"sampler-param" json:"samplerParam,omitempty"`
-}
-
-type tracingTrait struct {
-	trait.BaseTrait
-	Trait `property:",squash"`
-}
-
-const (
-	propEnabled      = "propEnabled"
-	propEndpoint     = "propEndpoint"
-	propServiceName  = "propServiceName"
-	propSamplerType  = "propSamplerType"
-	propSamplerParam = "propSamplerParam"
-)
-
-var (
-	tracingProperties = map[v1.RuntimeProvider]map[string]string{
-		v1.RuntimeProviderQuarkus: {
-			propEndpoint:     "quarkus.jaeger.endpoint",
-			propServiceName:  "quarkus.jaeger.service-name",
-			propSamplerType:  "quarkus.jaeger.sampler-type",
-			propSamplerParam: "quarkus.jaeger.sampler-param",
-		},
-	}
-
-	defaultSamplerType  = "const"
-	defaultSamplerParam = "1"
-)
-
-// NewTracingTrait --.
-func NewTracingTrait() trait.Trait {
-	return &tracingTrait{
-		BaseTrait: trait.NewBaseTrait("tracing", trait.TraitOrderBeforeControllerCreation),
-	}
-}
-
-func (t *tracingTrait) Configure(e *trait.Environment) (bool, *trait.TraitCondition, error) {
-	if e.Integration == nil || !ptr.Deref(t.Enabled, false) {
-		return false, nil, nil
-	}
-	if e.CamelCatalog == nil {
-		return false, trait.NewIntegrationConditionPlatformDisabledCatalogMissing(), nil
-	}
-
-	if !ptr.Deref(t.Auto, true) {
-		return true, nil, nil
-	}
-
-	if t.Endpoint == "" {
-		for _, locator := range discovery.TracingLocators {
-			endpoint, err := locator.FindEndpoint(e.Ctx, t.Client, t.L, e)
-			if err != nil {
-				return false, nil, err
-			}
-			if endpoint != "" {
-				t.L.Infof("Using tracing endpoint: %s", endpoint)
-				t.Endpoint = endpoint
-				break
-			}
-		}
-	}
-
-	if t.ServiceName == "" {
-		t.ServiceName = e.Integration.Name
-	}
-
-	if t.SamplerType == nil {
-		t.SamplerType = &defaultSamplerType
-	}
-
-	if t.SamplerParam == nil {
-		t.SamplerParam = &defaultSamplerParam
-	}
-
-	return true, nil, nil
-}
-
-func (t *tracingTrait) Apply(e *trait.Environment) error {
-	util.StringSliceUniqueAdd(&e.Integration.Status.Capabilities, v1.CapabilityTracing)
-
-	provider := e.CamelCatalog.CamelCatalogSpec.Runtime.Provider
-	properties := tracingProperties[provider]
-
-	if appPropEnabled := properties[propEnabled]; appPropEnabled != "" {
-		e.ApplicationProperties[appPropEnabled] = "true"
-	}
-	if appPropEndpoint := properties[propEndpoint]; appPropEndpoint != "" && t.Endpoint != "" {
-		e.ApplicationProperties[appPropEndpoint] = t.Endpoint
-	}
-	if appPropServiceName := properties[propServiceName]; appPropServiceName != "" && t.ServiceName != "" {
-		e.ApplicationProperties[appPropServiceName] = t.ServiceName
-	}
-	if appPropSamplerType := properties[propSamplerType]; appPropSamplerType != "" && t.SamplerType != nil {
-		e.ApplicationProperties[appPropSamplerType] = *t.SamplerType
-	}
-	if appPropSamplerParam := properties[propSamplerParam]; appPropSamplerParam != "" && t.SamplerParam != nil {
-		e.ApplicationProperties[appPropSamplerParam] = *t.SamplerParam
-	}
-
-	return nil
-}
diff --git a/addons/tracing/tracing_test.go b/addons/tracing/tracing_test.go
deleted file mode 100644
index f5bc525ce..000000000
--- a/addons/tracing/tracing_test.go
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
-Licensed to the Apache Software Foundation (ASF) under one or more
-contributor license agreements.  See the NOTICE file distributed with
-this work for additional information regarding copyright ownership.
-The ASF 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 tracing
-
-import (
-	"testing"
-
-	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
-	"k8s.io/utils/ptr"
-
-	v1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1"
-	"github.com/apache/camel-k/v2/pkg/trait"
-	"github.com/apache/camel-k/v2/pkg/util/camel"
-
-	"github.com/stretchr/testify/assert"
-	"github.com/stretchr/testify/require"
-)
-
-func TestTracingTraitOnQuarkus(t *testing.T) {
-	e := createEnvironment(t, camel.QuarkusCatalog)
-	tracing := NewTracingTrait()
-	tt, _ := tracing.(*tracingTrait)
-	tt.Enabled = ptr.To(true)
-	tt.Endpoint = "http://endpoint3"
-	ok, condition, err := tracing.Configure(e)
-	require.NoError(t, err)
-	assert.True(t, ok)
-	assert.Nil(t, condition)
-
-	err = tracing.Apply(e)
-	require.NoError(t, err)
-
-	assert.Empty(t, e.ApplicationProperties["quarkus.jaeger.enabled"])
-	assert.Equal(t, "http://endpoint3", e.ApplicationProperties["quarkus.jaeger.endpoint"])
-	assert.Equal(t, "test", e.ApplicationProperties["quarkus.jaeger.service-name"])
-	assert.Equal(t, "const", e.ApplicationProperties["quarkus.jaeger.sampler-type"])
-	assert.Equal(t, "1", e.ApplicationProperties["quarkus.jaeger.sampler-param"])
-}
-
-func createEnvironment(t *testing.T, catalogGen func() (*camel.RuntimeCatalog, error)) *trait.Environment {
-	t.Helper()
-
-	catalog, err := catalogGen()
-	require.NoError(t, err)
-
-	e := trait.Environment{
-		CamelCatalog:          catalog,
-		ApplicationProperties: make(map[string]string),
-	}
-
-	it := v1.Integration{
-		ObjectMeta: metav1.ObjectMeta{
-			Name: "test",
-		},
-		Status: v1.IntegrationStatus{
-			Phase: v1.IntegrationPhaseDeploying,
-		},
-	}
-	e.Integration = &it
-	return &e
-}
diff --git a/addons/tracing/zz_desc_generated.go b/addons/tracing/zz_desc_generated.go
deleted file mode 100644
index 5881eae3c..000000000
--- a/addons/tracing/zz_desc_generated.go
+++ /dev/null
@@ -1 +0,0 @@
-package tracing
diff --git a/addons/tracing/zz_generated_doc.go b/addons/tracing/zz_generated_doc.go
deleted file mode 100644
index 5881eae3c..000000000
--- a/addons/tracing/zz_generated_doc.go
+++ /dev/null
@@ -1 +0,0 @@
-package tracing
diff --git a/docs/modules/ROOT/nav.adoc b/docs/modules/ROOT/nav.adoc
index 9f5c42ec3..d6cf49ee6 100644
--- a/docs/modules/ROOT/nav.adoc
+++ b/docs/modules/ROOT/nav.adoc
@@ -90,7 +90,6 @@
 ** xref:traits:service.adoc[Service]
 ** xref:traits:telemetry.adoc[Telemetry]
 ** xref:traits:toleration.adoc[Toleration]
-** xref:traits:tracing.adoc[Tracing]
 // End of autogenerated code - DO NOT EDIT! (trait-nav)
 * xref:pipeline/pipeline.adoc[Pipelines]
 ** xref:pipeline/tekton.adoc[Tekton]
diff --git a/docs/modules/traits/pages/tracing.adoc b/docs/modules/traits/pages/tracing.adoc
deleted file mode 100644
index 26d638f8e..000000000
--- a/docs/modules/traits/pages/tracing.adoc
+++ /dev/null
@@ -1,61 +0,0 @@
-= Tracing Trait
-
-// Start of autogenerated code - DO NOT EDIT! (badges)
-image:https://img.shields.io/badge/1.12.0-white?label=Deprecated&labelColor=C40C0C&color=gray[Deprecated Badge]
-// End of autogenerated code - DO NOT EDIT! (badges)
-// Start of autogenerated code - DO NOT EDIT! (description)
-WARNING: The Tracing trait has been **deprecated** in favor of the xref:traits:telemetry.adoc[Telemetry] trait.
-
-The Tracing trait can be used to automatically publish tracing information to an OpenTracing compatible collector.
-
-The trait is able to automatically discover the tracing endpoint available in the namespace (supports **Jaeger**).
-
-The Tracing trait is disabled by default.
-
-WARNING: The Tracing trait can't be enabled at the same time as the Telemetry trait.
-
-
-This trait is available in the following profiles: **Kubernetes, Knative, OpenShift**.
-
-// End of autogenerated code - DO NOT EDIT! (description)
-// Start of autogenerated code - DO NOT EDIT! (configuration)
-== Configuration
-
-Trait properties can be specified when running any integration with the CLI:
-[source,console]
-----
-$ kamel run --trait tracing.[key]=[value] --trait tracing.[key2]=[value2] integration.yaml
-----
-The following configuration options are available:
-
-[cols="2m,1m,5a"]
-|===
-|Property | Type | Description
-
-| tracing.enabled
-| bool
-| Can be used to enable or disable a trait. All traits share this common property.
-
-| tracing.auto
-| bool
-| Enables automatic configuration of the trait, including automatic discovery of the tracing endpoint.
-
-| tracing.service-name
-| string
-| The name of the service that publishes tracing data (defaults to the integration name)
-
-| tracing.endpoint
-| string
-| The target endpoint of the OpenTracing service (automatically discovered by default)
-
-| tracing.sampler-type
-| string
-| The sampler type (default "const")
-
-| tracing.sampler-param
-| string
-| The sampler specific param (default "1")
-
-|===
-
-// End of autogenerated code - DO NOT EDIT! (configuration)