[ 
https://issues.apache.org/jira/browse/CAMEL-21858?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Luis Sergio Faria Carneiro updated CAMEL-21858:
-----------------------------------------------
    Description: 
Consider the following integration created with the yaml dsl:
{code:java}
- from: 
    uri: rest:get:/demo 
    steps: 
    - setBody: 
        expression: 
           constant: '{"hello": "world"}'
    - toD: 
        uri: "https://webhook.site/0148d971-4a63-4c61-8845-efd62b7242de";
        parameters: 
          bridgeEndpoint: true 
          httpMethod: POST 
          throwExceptionOnFailure: false{code}
and that open telemetry tracing is enabled.

When a request to /demo is performed, we can see that the code performs a POST 
request to [https://webhook.site/0148d971-4a63-4c61-8845-efd62b7242de,] as it 
should, but the corresponding trace span reports the http.method as GET instead.

This happens because the rest consumer sets the CamelHttpMethod header to GET 
and this header is used by the tracing component do build the span. I expected 
it to use give priority to the httpMethod endpoint parameter, as the http 
component does.

similar scenario happens in this case:

 
{code:java}
- from:    
    uri: rest:post:/demo    
    steps:      
    - removeHeaders:          
        pattern: "*" 
   - setBody: 
        expression: 
          constant: '{"hello": "world"}'     
    - toD:          
        uri: "https://webhook.site/0148d971-4a63-4c61-8845-efd62b7242de";
        parameters:            
          bridgeEndpoint: true            
          httpMethod: POST            
          throwExceptionOnFailure: false {code}
Here we have the rest consumer defined with POST, but we remove the headers.

And the [span 
decorator|https://github.com/apache/camel/blob/main/components/camel-tracing/src/main/java/org/apache/camel/tracing/decorators/AbstractHttpSpanDecorator.java#L47]
 decides it is a GET because the endpoint has query parameters. The endpoint in 
this case is 
[https://webhook.site/0148d971-4a63-4c61-8845-efd62b7242de?bridgeEndpoint=true&httpMethod=POST&throwExceptionOnFailure=false|https://webhook.site/0148d971-4a63-4c61-8845-efd62b7242de?httMethod=true&httpMethod=POST&throwExceptionOnFailure=false]

 

 

 

 

 

  was:
Consider the following integration created with the yaml dsl:
{code:java}
- from: 
    uri: rest:get:/demo 
    steps: 
    - setBody: 
        expression: 
           constant: '{"hello": "world"}'
    - toD: 
        uri: "https://webhook.site/0148d971-4a63-4c61-8845-efd62b7242de";
        parameters: 
          bridgeEndpoint: true 
          httpMethod: POST 
          throwExceptionOnFailure: false{code}
and that open telemetry tracing is enabled.

When a request to /demo is performed, we can see that the code performs a POST 
request to [https://webhook.site/0148d971-4a63-4c61-8845-efd62b7242de,] as it 
should, but the corresponding trace span reports the http.method as GET instead.

This happens because the rest consumer sets the CamelHttpMethod header to GET 
and this header is used by the tracing component do build the span. I expected 
it to use give priority to the httpMethod endpoint parameter, as the http 
component does.

similar scenario happens in this case:

 
{code:java}
- from:    
    uri: rest:post:/demo    
    steps:      
    - removeHeaders:          
        pattern: "*" 
   - setBody: 
        expression: 
          constant: '{"hello": "world"}'     
    - toD:          
        uri: "https://webhook.site/0148d971-4a63-4c61-8845-efd62b7242de";
        parameters:            
          bridgeEndpoint: true            
          httpMethod: POST            
          throwExceptionOnFailure: false {code}
Here we have the rest consumer defined with POST, but we remove the headers.

And the [span 
decorator|https://github.com/apache/camel/blob/main/components/camel-tracing/src/main/java/org/apache/camel/tracing/decorators/AbstractHttpSpanDecorator.java#L47]
 decides it is a GET because the endpoint has query parameters. The endpoint in 
this case is 
[https://webhook.site/0148d971-4a63-4c61-8845-efd62b7242de?httMethod=true&httpMethod=POST&throwExceptionOnFailure=false]

 

 

 

 

 


> camel-tracing: Incorrect http method on trace record
> ----------------------------------------------------
>
>                 Key: CAMEL-21858
>                 URL: https://issues.apache.org/jira/browse/CAMEL-21858
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-tracing
>            Reporter: Luis Sergio Faria Carneiro
>            Priority: Minor
>
> Consider the following integration created with the yaml dsl:
> {code:java}
> - from: 
>     uri: rest:get:/demo 
>     steps: 
>     - setBody: 
>         expression: 
>            constant: '{"hello": "world"}'
>     - toD: 
>         uri: "https://webhook.site/0148d971-4a63-4c61-8845-efd62b7242de";
>         parameters: 
>           bridgeEndpoint: true 
>           httpMethod: POST 
>           throwExceptionOnFailure: false{code}
> and that open telemetry tracing is enabled.
> When a request to /demo is performed, we can see that the code performs a 
> POST request to [https://webhook.site/0148d971-4a63-4c61-8845-efd62b7242de,] 
> as it should, but the corresponding trace span reports the http.method as GET 
> instead.
> This happens because the rest consumer sets the CamelHttpMethod header to GET 
> and this header is used by the tracing component do build the span. I 
> expected it to use give priority to the httpMethod endpoint parameter, as the 
> http component does.
> similar scenario happens in this case:
>  
> {code:java}
> - from:    
>     uri: rest:post:/demo    
>     steps:      
>     - removeHeaders:          
>         pattern: "*" 
>    - setBody: 
>         expression: 
>           constant: '{"hello": "world"}'     
>     - toD:          
>         uri: "https://webhook.site/0148d971-4a63-4c61-8845-efd62b7242de";
>         parameters:            
>           bridgeEndpoint: true            
>           httpMethod: POST            
>           throwExceptionOnFailure: false {code}
> Here we have the rest consumer defined with POST, but we remove the headers.
> And the [span 
> decorator|https://github.com/apache/camel/blob/main/components/camel-tracing/src/main/java/org/apache/camel/tracing/decorators/AbstractHttpSpanDecorator.java#L47]
>  decides it is a GET because the endpoint has query parameters. The endpoint 
> in this case is 
> [https://webhook.site/0148d971-4a63-4c61-8845-efd62b7242de?bridgeEndpoint=true&httpMethod=POST&throwExceptionOnFailure=false|https://webhook.site/0148d971-4a63-4c61-8845-efd62b7242de?httMethod=true&httpMethod=POST&throwExceptionOnFailure=false]
>  
>  
>  
>  
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to