diff --git a/generic-examples/README.md b/generic-examples/README.md index d990676..ba9e840 100644 --- a/generic-examples/README.md +++ b/generic-examples/README.md @@ -1,10 +1,11 @@ # Camel K Examples -This folder contains various examples of `Camel K` integrations. You can use them to learn more about the capabilities of Camel K or to inspire your integration development. +This folder contains various examples of `Camel K` integrations. You can use them to learn more about the capabilities +of Camel K or to inspire your integration development. ## Basic usage examples -In this section you will find the most basic examples. Useful to start learning about Camel K and how to run. +In this section you will find the most basic examples. Useful to start learning about Camel K and how to run. You can use many supported languages and learn about the most basic features: | Type | Description | Link | @@ -22,7 +23,9 @@ You can use many supported languages and learn about the most basic features: ## Component usage examples -In this section you can find a few examples of certain [`Camel` components](https://camel.apache.org/components/latest/index.html). This is a limited number of the wide variety of components supported by Apache Camel. +In this section you can find a few examples of certain [ +`Camel` components](https://camel.apache.org/components/latest/index.html). This is a limited number of the wide variety +of components supported by Apache Camel. You can also find useful examples [in this repository](https://github.com/apache/camel-k-examples). | Type | Description | Link | @@ -37,7 +40,8 @@ You can also find useful examples [in this repository](https://github.com/apache ## Advanced usage examples -When you feel comfortable with basic stuff, you may want to try the more advanced features offered by Camel K. Here a few examples: +When you feel comfortable with basic stuff, you may want to try the more advanced features offered by Camel K. Here a +few examples: | Type | Description | Link | |----------|---------------------------------------------------------------------------------------|-----------------------------| @@ -52,9 +56,11 @@ When you feel comfortable with basic stuff, you may want to try the more advance Traits configuration will be very helpful to fine tune your `Integration`. Here a few examples: -| Type | Description | Link | -|-----------------------|-----------------------------------------|-------------------------------------| -| Container | How to customize with `container` trait | [see examples](./traits/container/) | -| Health | How to customize with `health` trait | [see examples](./traits/health/) | -| JVM | How to use `jvm` trait | [see examples](./traits/jvm/) | -| Tracing (opentracing) | How to use `tracing` trait | [see examples](./traits/tracing/) | \ No newline at end of file +| Type | Description | Link | +|------------|-----------------------------------------|--------------------------------------| +| Container | How to customize with `container` trait | [see examples](./traits/container/) | +| Health | How to customize with `health` trait | [see examples](./traits/health/) | +| JVM | How to use `jvm` trait | [see examples](./traits/jvm/) | +| Prometheus | How to use `prometheus` trait | [see examples](./traits/prometheus/) | +| Service | How to use `service` trait | [see examples](./traits/service/) | +| Telemetry | How to use `telemetry` trait | [see examples](./traits/telemetry/) | diff --git a/generic-examples/languages/routes.yaml b/generic-examples/languages/routes.yaml index fe3eb83..7c0e0a4 100644 --- a/generic-examples/languages/routes.yaml +++ b/generic-examples/languages/routes.yaml @@ -21,9 +21,10 @@ uri: "timer:tick" parameters: period: "5000" + includeMetadata: true steps: - set-body: - constant: "Hello Yaml !!!" + simple: "Hello Yaml #${header.CamelTimerCounter}" - transform: simple: "${body.toUpperCase()}" - to: "log:info" diff --git a/generic-examples/traits/container/README.md b/generic-examples/traits/container/README.md index a1b51de..52553f1 100644 --- a/generic-examples/traits/container/README.md +++ b/generic-examples/traits/container/README.md @@ -1,8 +1,8 @@ # Camel K Container Trait -In this section you will find examples about fine tuning your `Integration` using **Container** `trait` capability. +In this section you will find examples about fine-tuning your `Integration` using **Container** `trait` capability. -The Container trait is a platform trait, it is **enabled** by default. +The Container trait is a platform trait, it is **enabled** by default. ## Before you begin @@ -25,9 +25,8 @@ kamel run \ --trait container.limit-memory=500Mi ``` - - When you check the values declared by the pod spec + ```sh kubectl get pods --selector="camel.apache.org/integration"="container" -o yaml ``` @@ -37,7 +36,6 @@ You should get a result with the values you defined ```yaml ... "imagePullPolicy": "Always", - ... "resources": { "limits": { @@ -48,13 +46,13 @@ You should get a result with the values you defined "cpu": "5m", "memory": "100Mi" } - }, + } ... ``` ## Advanced usages -The container and service port configuration needs needs the presence of a service, else it will be ignored. +The container and service port configuration needs the presence of a service, else it will be ignored. For these example, we use an example route exposing some rest endpoint. This will enable the service and expose the container port by default. @@ -76,7 +74,7 @@ kamel run --name restcontainer \ When you check the values declared by the service spec ```sh -kubectl get service restcontainer -o jsonpath='{.spec.ports}' +kubectl get service restcontainer -o jsonpath='{.spec.ports}' ``` You should get a result with the values you defined @@ -101,8 +99,7 @@ kamel run \ ``` ```sh -kubectl get pods --selector="camel.apache.org/integration"="restcontainer" \ - -o jsonpath= -o jsonpath='{.items[*].spec.containers[*].ports}' +kubectl get pods --selector="camel.apache.org/integration"="restcontainer" -o jsonpath='{.items[*].spec.containers[*].ports}' ``` You should get a result with the values you defined diff --git a/generic-examples/traits/health/README.md b/generic-examples/traits/health/README.md index 6bc0b6f..41af9a0 100644 --- a/generic-examples/traits/health/README.md +++ b/generic-examples/traits/health/README.md @@ -1,6 +1,6 @@ # Camel K Health Trait -In this section you will find examples about fine tuning your `Integration` using **Health** `trait` capability. +In this section you will find examples about fine-tuning your `Integration` using **Health** `trait` capability. The Health trait can be used to activate and configure the Health Probes on the integration container. @@ -12,7 +12,7 @@ Make sure you've read the [installation instructions](https://camel.apache.org/c ## Basic usage -By default the trait is disabled so it needs to be activated. +By default, the trait is disabled so it needs to be activated. To activate the trait and configure the liveness Probes, run the integration @@ -29,13 +29,14 @@ kamel run \ --trait health.liveness-timeout=2 ``` - When you check the values declared by the pod spec + ```sh kubectl get pods --selector="camel.apache.org/integration"="health" -o jsonpath='{.items[*].spec.containers[*].livenessProbe}' ``` You should get a result with the values you defined + ```json {"failureThreshold":5,"httpGet":{"path":"/q/health/live","port":8080,"scheme":"HTTP"},"initialDelaySeconds":30,"periodSeconds":10,"successThreshold":1,"timeoutSeconds":2} ``` @@ -68,7 +69,6 @@ Run the integration --trait health.readiness-scheme=HTTPS ``` - When you check the values declared by the pod spec for the readinessProbe ```sh kubectl get pods --selector="camel.apache.org/integration"="health" -o jsonpath='{.items[*].spec.containers[*].readinessProbe}' diff --git a/generic-examples/traits/jvm/Classpath.java b/generic-examples/traits/jvm/Classpath.java index 40d76cd..a405eea 100644 --- a/generic-examples/traits/jvm/Classpath.java +++ b/generic-examples/traits/jvm/Classpath.java @@ -15,11 +15,6 @@ * limitations under the License. */ -// Create a configmap holding a jar in order to simulate the presence of a dependency on the runtime image -// kubectl create configmap my-dep --from-file=sample-1.0.jar - -//kamel run --resource configmap:my-dep -t jvm.classpath=/etc/camel/resources/my-dep/sample-1.0.jar Classpath.java --dev - import org.apache.camel.builder.RouteBuilder; import org.apache.camel.example.MyClass; diff --git a/generic-examples/traits/jvm/README.md b/generic-examples/traits/jvm/README.md index f7a2896..38eca4c 100644 --- a/generic-examples/traits/jvm/README.md +++ b/generic-examples/traits/jvm/README.md @@ -1,3 +1,18 @@ # Camel K JVM Trait -In this section you will find examples about fine tuning your `Integration` using **JVM** `trait` capability. \ No newline at end of file +In this section you will find examples about fine-tuning your `Integration` using **JVM** `trait` capability. + +Create a configmap holding a jar in order to simulate the presence of a dependency on the runtime image + +```shell +kubectl create configmap my-dep --from-file=sample-1.0.jar +``` + +Run the integration +```shell +kamel run --dev --resource configmap:my-dep --trait jvm.classpath=/etc/camel/resources/my-dep/sample-1.0.jar Classpath.java + +[1] 2024-06-07 09:17:06,422 INFO [route1] (Camel (camel-1) thread #1 - timer://tick) Hello World! +[1] 2024-06-07 09:17:07,410 INFO [route1] (Camel (camel-1) thread #1 - timer://tick) Hello World! +[1] 2024-06-07 09:17:08,410 INFO [route1] (Camel (camel-1) thread #1 - timer://tick) Hello World! +``` diff --git a/generic-examples/traits/prometheus/MyIntegration.java b/generic-examples/traits/prometheus/MyIntegration.java index 5b4ee4c..5f5c05d 100644 --- a/generic-examples/traits/prometheus/MyIntegration.java +++ b/generic-examples/traits/prometheus/MyIntegration.java @@ -15,17 +15,10 @@ * limitations under the License. */ -/* - -To execute this example, run: -kamel run -t prometheus.enabled=true MyIntegration.java - -*/ import org.apache.camel.Exchange; import org.apache.camel.LoggingLevel; import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.component.microprofile.metrics.MicroProfileMetricsConstants; public class MyIntegration extends RouteBuilder { @@ -39,12 +32,10 @@ public void configure() { .log(LoggingLevel.ERROR, "Failed processing ${body}") .to("log:exception"); - from("timer:foo?period=1000") + from("timer:foo?includeMetadata=true") .routeId("unreliable-service") .setBody(header(Exchange.TIMER_COUNTER).prepend("event #")) - .log("Processing ${body}...") - .bean("service", "process") .log("Successfully processed ${body}") - .to("microprofile-metrics:meter:success"); + .to("micrometer:counter:success"); } } diff --git a/generic-examples/traits/prometheus/README.md b/generic-examples/traits/prometheus/README.md index ef6d157..8364571 100644 --- a/generic-examples/traits/prometheus/README.md +++ b/generic-examples/traits/prometheus/README.md @@ -1,27 +1,34 @@ # Camel K Prometheus Trait -In this section you will find examples about fine tuning your `Integration` using **Prometheus** `trait` capability. +In this section you will find examples about fine-tuning your `Integration` using **Prometheus** `trait` capability. - -A Prometheus-compatible endpoint is configured with the Prometheus trait. When utilising the Prometheus operator, it also generates a PodMonitor resource, which allows the endpoint to be scraped automatically. +A Prometheus-compatible endpoint is configured with the Prometheus trait. +When utilising the Prometheus operator, it also generates a PodMonitor resource, which allows the endpoint to be scraped automatically. To get statistics about the number of events successfully handled by the `Integration`,execute the `MyIntegration.java` route via: - $ kamel run -t prometheus.enabled=true MyIntegration.java +In case the prometheus operator is not installed in your cluster, run: + +```shell +kamel run --dev --trait prometheus.enabled=true --trait prometheus.pod-monitor=false MyIntegration.java +``` - In case the prometheus operator is not installed in your cluster, run: - - $ kamel run -t prometheus.enabled=true pod-monitor=false MyIntegration.java +Alternatively, you can quickly deploy the Prometheus operator and then run: -You should be able to see the new integration running after a while via: +```shell +kubectl create -f https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/main/bundle.yaml - $ kamel get +kamel run --dev --trait prometheus.enabled=true MyIntegration.java +``` The metrics can be retrieved by port-forwarding this service, e.g.: - $ kubectl port-forward svc/metrics-prometheus 8080:8080 +```shell +kubectl port-forward svc/prometheus-operator 8080:8080 - $ curl http://localhost:8080/metrics +curl http://localhost:8080/metrics +``` -Similarly other use cases can be to retrieve information on unprocessed events, number of retries made to process an event, etc. For more information on Integration monitoring refer to the [Camel K Integration Monitoring](https://camel.apache.org/camel-k/next/observability/monitoring/integration.html) documentation. +Similarly other use cases can be to retrieve information on unprocessed events, number of retries made to process an event, etc. +For more information on Integration monitoring refer to the [Camel K Integration Monitoring](https://camel.apache.org/camel-k/next/observability/monitoring/integration.html) documentation. diff --git a/generic-examples/traits/service/README.md b/generic-examples/traits/service/README.md index 61434d8..a54a778 100644 --- a/generic-examples/traits/service/README.md +++ b/generic-examples/traits/service/README.md @@ -1,7 +1,19 @@ # SERVICE EXAMPLE -This folder contains examples of how to use a `trait service`. You can use them to learn more about how to enable services for integrations deployed on the cluster. +This folder contains examples of how to use a trait `service`. You can use them to learn more about how to enable services for integrations deployed on the cluster. To access integration outside the cluster you can enable a nodePort when you deploy integration. An example is `./RestDSL.java.` -You can also optionally decide to just go with the default clusterIP if you do not want your integration to be directly exposed to the outside world. An example of this use case is `./RestDSL2.java` \ No newline at end of file +To run this integrations use: +```shell +kamel run --dev --trait service.enabled=true --trait service.node-port=true RestDSL.java + +kubectl port-forward svc/rest-dsl 8080:80 +curl http://localhost:8080/hello +``` + +You can also optionally decide to just go with the default clusterIP if you do not want your integration to be directly exposed to the outside world. + +```shell +kamel run --dev --trait service.enabled=true rest-dsl.yaml +``` \ No newline at end of file diff --git a/generic-examples/traits/service/RestDSL.java b/generic-examples/traits/service/RestDSL.java index fcd1bc3..63b3aa2 100644 --- a/generic-examples/traits/service/RestDSL.java +++ b/generic-examples/traits/service/RestDSL.java @@ -15,11 +15,6 @@ * limitations under the License. */ -// -// To run this integrations use: -// kamel run RestDSL.java --trait service.enabled=true\ -// --trait service.node-port=true -// import org.apache.camel.Exchange; public class RestDSL extends org.apache.camel.builder.RouteBuilder { diff --git a/generic-examples/traits/service/RestDSL2.java b/generic-examples/traits/service/RestDSL2.java deleted file mode 100644 index 71d9f6c..0000000 --- a/generic-examples/traits/service/RestDSL2.java +++ /dev/null @@ -1,35 +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. - */ - -// -// To run this integrations use: -// kamel run RestDSL2.java --trait service.enabled=true -// -import org.apache.camel.Exchange; - -public class RestDSL2 extends org.apache.camel.builder.RouteBuilder { - @Override - public void configure() throws Exception { - rest() - .get("/hello") - .to("direct:hello"); - - from("direct:hello") - .setHeader(Exchange.CONTENT_TYPE, constant("text/plain")) - .transform().simple("Hello World"); - } -} diff --git a/generic-examples/traits/service/rest-dsl.yaml b/generic-examples/traits/service/rest-dsl.yaml new file mode 100644 index 0000000..81b42a3 --- /dev/null +++ b/generic-examples/traits/service/rest-dsl.yaml @@ -0,0 +1,24 @@ +# camel-k: language=yaml + +# --------------------------------------------------------------------------- +# 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. +# --------------------------------------------------------------------------- + +- from: + uri: "rest:get:/hello" + steps: + - setBody: + simple: "Hello World" diff --git a/generic-examples/traits/telemetry/README.md b/generic-examples/traits/telemetry/README.md index 4770e71..9492d0b 100644 --- a/generic-examples/traits/telemetry/README.md +++ b/generic-examples/traits/telemetry/README.md @@ -1,6 +1,6 @@ # Camel K Telemetry Trait -In this section you will find examples about fine tuning your `Integration` using **Telemetry** `trait` capability. +In this section you will find examples about fine-tuning your `Integration` using **Telemetry** `trait` capability. The Telemetry trait can be used to automatically publish tracing information of interactions to an OTLP compatible collector. @@ -8,7 +8,6 @@ The Telemetry trait can be used to automatically publish tracing information of You can choose which distributed tracing tool you want to use as long as it offers a OTLP compatible collector. - ### Configure and Setup Jaeger Telemetry is compatible with Jaeger version 1.35+. diff --git a/generic-examples/traits/tracing/InventoryService.java b/generic-examples/traits/tracing/InventoryService.java deleted file mode 100644 index be194fc..0000000 --- a/generic-examples/traits/tracing/InventoryService.java +++ /dev/null @@ -1,113 +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. - */ - - -/* - -kamel run InventoryService.java --name inventory -d camel-opentracing -d mvn:io.jaegertracing:jaeger-client:1.2.0 -d rest-api -d camel-jackson --property-file application.properties - -*/ - -import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.model.rest.RestBindingMode; -import org.apache.camel.component.jackson.JacksonDataFormat; -import java.text.SimpleDateFormat; -import org.apache.camel.Exchange; -import java.util.Date; -import java.util.Map; - - -public class InventoryService extends RouteBuilder { - - - @Override - public void configure() throws Exception { - restConfiguration() - .enableCORS(true) - .bindingMode(RestBindingMode.json); - - rest() - .post("/notify/order/place") - .to("direct:notify"); - - - JacksonDataFormat invDataFormat = new JacksonDataFormat(); - invDataFormat.setUnmarshalType(InventoryNotification.class); - - from("direct:notify") - .log("notifyorder--> ${body}") - .setHeader(Exchange.CONTENT_TYPE, constant("application/json")) - .bean(InventoryNotification.class, "getInventoryNotification(${body['orderId']},${body['itemId']},${body['quantity']} )") - .marshal(invDataFormat) - .log("Inventory Notified ${body}") - .convertBodyTo(String.class) - ; - } - - private static class InventoryNotification { - private Integer orderId; - private Integer itemId; - private Integer quantity; - private String department; - private Date datetime; - - public static InventoryNotification getInventoryNotification(Integer orderId, Integer itemId, Integer quantity ){ - InventoryNotification invenNotification = new InventoryNotification(); - invenNotification.setOrderId(orderId); - invenNotification.setItemId(itemId); - invenNotification.setQuantity(quantity); - invenNotification.setDepartment("inventory"); - SimpleDateFormat formatter= new SimpleDateFormat("yyyy-MM-dd 'at' HH:mm:ss z"); - invenNotification.setDatetime(new Date(System.currentTimeMillis())); - return invenNotification; - } - - - public void setOrderId(Integer orderId){ - this.orderId=orderId; - } - public void setItemId(Integer itemId){ - this.itemId=itemId; - } - public void setQuantity(Integer quantity){ - this.quantity=quantity; - } - public Integer getOrderId(){ - return this.orderId; - } - public Integer getItemId(){ - return this.itemId; - } - public Integer getQuantity(){ - return this.quantity; - } - public String getDepartment() { - return department; - } - public void setDepartment(String department) { - this.department = department; - } - public Date getDatetime() { - return datetime; - } - - public void setDatetime(Date datetime) { - this.datetime = datetime; - } - } - -} \ No newline at end of file diff --git a/generic-examples/traits/tracing/OrderService.java b/generic-examples/traits/tracing/OrderService.java deleted file mode 100644 index f706927..0000000 --- a/generic-examples/traits/tracing/OrderService.java +++ /dev/null @@ -1,107 +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. - */ - - -/* - -kamel run --name=order-service-api -d camel-swagger-java -d camel-jackson -d camel-undertow OrderService.java --dev - -*/ - -import java.util.HashMap; -import org.apache.camel.Processor; -import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.model.rest.RestBindingMode; -import org.apache.camel.Exchange; -import org.apache.camel.component.jackson.JacksonDataFormat; -import org.apache.camel.processor.aggregate.GroupedBodyAggregationStrategy; - -public class OrderService extends RouteBuilder { - - @Override - public void configure() throws Exception { - - restConfiguration() - .enableCORS(true) - .bindingMode(RestBindingMode.json); - - rest() - .post("/place") - .to("direct:placeorder"); - - JacksonDataFormat jacksonDataFormat = new JacksonDataFormat(); - jacksonDataFormat.setUnmarshalType(Order.class); - - from("direct:placeorder") - .log("-----IN ${headers}") - .marshal(jacksonDataFormat) - .log("inputBody --> ${body}") - .to("http://inventory/notify/order?bridgeEndpoint=true") - .removeHeaders("*") - .log("responseBody from inventory --> ${body}") - .setHeader(Exchange.CONTENT_TYPE, constant("application/json")) - .setBody(simple("{\"inventory\":${body}}")) - .unmarshal().json() - ; - } - - private static class Order implements java.io.Serializable{ - private static final long serialVersionUID = 1L; - - private Integer orderId; - private Integer itemId; - private Integer quantity; - - private String orderItemName; - private Integer price; - - public void setOrderId(Integer orderId){ - this.orderId=orderId; - } - public void setItemId(Integer itemId){ - this.itemId=itemId; - } - public void setQuantity(Integer quantity){ - this.quantity=quantity; - } - - public void setOrderItemName(String orderItemName){ - this.orderItemName=orderItemName; - } - public void setPrice(Integer price){ - this.price=price; - } - - public Integer getOrderId(){ - return this.orderId; - } - public Integer getItemId(){ - return this.itemId; - } - public Integer getQuantity(){ - return this.quantity; - } - - public String getOrderItemName(){ - return this.orderItemName; - } - public Integer getPrice(){ - return this.price; - } - - } -} \ No newline at end of file diff --git a/generic-examples/traits/tracing/README.md b/generic-examples/traits/tracing/README.md deleted file mode 100644 index 27e3875..0000000 --- a/generic-examples/traits/tracing/README.md +++ /dev/null @@ -1,91 +0,0 @@ -# Camel K Tracing Trait - -> **Warning** -> The Tracing Trait the trait has been deprecated in favor of the Telemetry Trait in camel-k 1.12+. - -In this section you will find examples about fine tuning your `Integration` using **Tracing** `trait` capability. - -The Tracing trait can be used to automatically publish tracing information of interactions to an OpenTracing compatible collector. - -## Configure and Setup Jaeger - -1. Enable Ingress addon in Minikube - -```sh -$ minikube addons enable ingress -``` - -2. Add Minikube IP to /etc/hosts: - -```sh -$ echo "$(minikube ip) example.com" | sudo tee -a /etc/hosts -``` - -3. Make sure Jaeger operator is available (see https://www.jaegertracing.io/docs for installation details) - -4. To use Jaeger, you can install the AllInOne image: - -```sh -$ kubetcl apply -f instance.yaml -``` - -5. Check the presence of the Jaeger instance - -```sh -$ kubectl get jaeger -NAME STATUS VERSION STRATEGY STORAGE AGE -instances Running 1.40.0 allinone memory 9m16s -``` - -## Enable OpenTracing and trace a REST API call in Camel K Route - -Tracing is an important approach for controlling and monitoring the experience of users. We  will be creating two distributed services: `Order` which is a rest service, and `Inventory` which is also a rest service. - -Quarkus OpenTracing extension in Camel automatically creates a Camel OpenTracingTracer and binds it to the Camel registry. Simply declare the traits to enable open tracing. - - -```sh -kamel run InventoryService.java --name inventory \ - -d camel-jackson \ - -t tracing.enabled=true \ - -t tracing.sampler-type=const \ - -t tracing.sampler-param=1 -``` - -This will : -* enable tracing -* automaticly discover of jaeger tracing endpoint -* sample all traces - -To specify the endpoint use the following trait configuration `-t tracing.endpoint=http://instance-collector:14268/api/traces` - -Let's inject the Opentracing Tracer to the camel OrderService.java application. Let's start the inventory service. - -```sh -kamel run OrderService.java --name order \ - -d camel-jackson \ - -t tracing.enabled=true \ - -t tracing.sampler-type=const \ - -t tracing.sampler-param=1 -``` - -## View the Jaeger UI - -If you installed the Jaeger Operator as describred, you should be able to access Jaeger interface on minikube : http://example.com. - -In the Jaeger interface we can see the details as: - -![Jeager Tracing Interface](interface/jaegerInterface.png) - -You can make a few requests the REST Service with custom transaction values defined by curl, provided you made the `order` and `inventory` services available (using the **Service** trait is an easy way). - -```sh -curl http:///place -d ' -{ - "orderId":58, - "itemId":12, - "quantity":1, - "orderItemName":"awesome item", - "price":99 -}' -v -H "Content-Type: application/json" -``` diff --git a/generic-examples/traits/tracing/instance.yaml b/generic-examples/traits/tracing/instance.yaml deleted file mode 100644 index 9b1eab9..0000000 --- a/generic-examples/traits/tracing/instance.yaml +++ /dev/null @@ -1,4 +0,0 @@ -apiVersion: jaegertracing.io/v1 -kind: Jaeger -metadata: - name: instances \ No newline at end of file diff --git a/generic-examples/traits/tracing/interface/jaegerInterface.png b/generic-examples/traits/tracing/interface/jaegerInterface.png deleted file mode 100644 index 1dbdbff..0000000 Binary files a/generic-examples/traits/tracing/interface/jaegerInterface.png and /dev/null differ