This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push: new ff96cecae23 CAMEL-16364: camel-tracing - Add more decorators ff96cecae23 is described below commit ff96cecae23315dbffc394a64414c0886fdbeba4 Author: Claus Ibsen <claus.ib...@gmail.com> AuthorDate: Tue Jun 18 09:01:00 2024 +0200 CAMEL-16364: camel-tracing - Add more decorators --- .../org/apache/camel/tracing/TagConstants.java | 3 ++ .../tracing/decorators/FileSpanDecorator.java | 14 ++++--- .../tracing/decorators/QuartzSpanDecorator.java | 45 ---------------------- 3 files changed, 11 insertions(+), 51 deletions(-) diff --git a/components/camel-tracing/src/main/java/org/apache/camel/tracing/TagConstants.java b/components/camel-tracing/src/main/java/org/apache/camel/tracing/TagConstants.java index cf9b51aa3da..d8a0b40a104 100644 --- a/components/camel-tracing/src/main/java/org/apache/camel/tracing/TagConstants.java +++ b/components/camel-tracing/src/main/java/org/apache/camel/tracing/TagConstants.java @@ -42,6 +42,9 @@ public class TagConstants { public static final String MESSAGE_BUS_DESTINATION = "messaging.destination.name"; public static final String MESSAGE_ID = "messaging.message.id"; + // File attributes + public static final String FILE_NAME = "file.name"; + // Database attributes public static final String DB_SYSTEM = "db.system"; public static final String DB_NAME = "db.name"; diff --git a/components/camel-tracing/src/main/java/org/apache/camel/tracing/decorators/FileSpanDecorator.java b/components/camel-tracing/src/main/java/org/apache/camel/tracing/decorators/FileSpanDecorator.java index 44031121b5f..ec8dadb9848 100644 --- a/components/camel-tracing/src/main/java/org/apache/camel/tracing/decorators/FileSpanDecorator.java +++ b/components/camel-tracing/src/main/java/org/apache/camel/tracing/decorators/FileSpanDecorator.java @@ -18,6 +18,8 @@ package org.apache.camel.tracing.decorators; import org.apache.camel.Endpoint; import org.apache.camel.Exchange; +import org.apache.camel.tracing.SpanAdapter; +import org.apache.camel.tracing.TagConstants; public class FileSpanDecorator extends AbstractSpanDecorator { @@ -32,13 +34,13 @@ public class FileSpanDecorator extends AbstractSpanDecorator { } @Override - public String getOperationName(Exchange exchange, Endpoint endpoint) { - Object name = exchange.getMessage().getHeader(Exchange.FILE_NAME); - if (name instanceof String) { - return (String) name; - } + public void pre(SpanAdapter span, Exchange exchange, Endpoint endpoint) { + super.pre(span, exchange, endpoint); - return super.getOperationName(exchange, endpoint); + String name = exchange.getMessage().getHeader(Exchange.FILE_NAME, String.class); + if (name != null) { + span.setTag(TagConstants.FILE_NAME, name); + } } } diff --git a/components/camel-tracing/src/main/java/org/apache/camel/tracing/decorators/QuartzSpanDecorator.java b/components/camel-tracing/src/main/java/org/apache/camel/tracing/decorators/QuartzSpanDecorator.java deleted file mode 100644 index a231a0c4d7f..00000000000 --- a/components/camel-tracing/src/main/java/org/apache/camel/tracing/decorators/QuartzSpanDecorator.java +++ /dev/null @@ -1,45 +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 org.apache.camel.tracing.decorators; - -import org.apache.camel.Endpoint; -import org.apache.camel.Exchange; - -public class QuartzSpanDecorator extends AbstractSpanDecorator { - - @Override - public String getComponent() { - return "quartz"; - } - - @Override - public String getComponentClassName() { - return "org.apache.camel.component.quartz.QuartzComponent"; - } - - @Override - public String getOperationName(Exchange exchange, Endpoint endpoint) { - String group = exchange.getMessage().getHeader("triggerGroup", String.class); - String name = exchange.getMessage().getHeader("triggerName", String.class); - if (group != null && name != null) { - return group + "/" + name; - } - - return super.getOperationName(exchange, endpoint); - } - -}