Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use OpenTelemetry Instrumenter #1678

Merged
merged 2 commits into from
Jan 9, 2023
Merged

Conversation

radcortez
Copy link
Member

@radcortez radcortez commented Mar 21, 2022

@radcortez
Copy link
Member Author

This is not totally done yet, but I wanted to get some feedback before moving forward.

I've tried to only replace the current existing code with the OTel APIs. It seems to work for Kafka and AMQP, but the RabbitMQ one is lacking tests, so no way to verify them at the moment (I'll need to add them).

What I don't like is the Tracing code is all over the place. And each connector is handling it in different ways. I'm wondering if we should introduce a SPI (like Vert.x did for tracing stuff) and make this well defined (it can also be used for gathering Metrics).

On a separate topic, I was wondering if we could inject the TracingMetadata automatically, so the user doesn't have to do that. We may require to adjust the Message to add the OTel Context as a Metadata automatically if exists. The tricky part may be to extract the Context back again and add it to the right place from a Uni.

@cescoffier @ozangunalp any thoughts?

@codecov-commenter
Copy link

codecov-commenter commented Mar 21, 2022

Codecov Report

Merging #1678 (11f89b3) into main (46e36d3) will increase coverage by 0.30%.
The diff coverage is 86.80%.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##               main    #1678      +/-   ##
============================================
+ Coverage     77.25%   77.56%   +0.30%     
- Complexity     3466     3472       +6     
============================================
  Files           294      298       +4     
  Lines         11652    11658       +6     
  Branches       1487     1479       -8     
============================================
+ Hits           9002     9042      +40     
+ Misses         1954     1925      -29     
+ Partials        696      691       -5     
Impacted Files Coverage Δ
...o/smallrye/reactive/messaging/TracingMetadata.java 0.00% <0.00%> (ø)
.../reactive/messaging/kafka/IncomingKafkaRecord.java 97.50% <ø> (+1.75%) ⬆️
...active/messaging/kafka/impl/KafkaRecordHelper.java 78.57% <ø> (-1.99%) ⬇️
...messaging/kafka/impl/ce/KafkaCloudEventHelper.java 82.43% <ø> (-0.32%) ⬇️
...ssaging/amqp/tracing/AmqpMessageTextMapGetter.java 50.00% <50.00%> (ø)
...llrye/reactive/messaging/kafka/KafkaConnector.java 88.54% <50.00%> (-0.94%) ⬇️
...e/messaging/rabbitmq/RabbitMQMessageConverter.java 42.59% <50.00%> (ø)
...ssaging/kafka/tracing/KafkaTraceTextMapGetter.java 53.33% <53.33%> (ø)
...g/rabbitmq/tracing/RabbitMQTraceTextMapGetter.java 53.84% <53.84%> (ø)
...ssaging/amqp/tracing/AmqpMessageTextMapSetter.java 66.66% <66.66%> (ø)
... and 28 more

@radcortez radcortez force-pushed the otel-instrumenter branch 4 times, most recently from cf6cd07 to 2847cb8 Compare November 3, 2022 18:41
@radcortez radcortez marked this pull request as ready for review November 3, 2022 18:42
@ozangunalp
Copy link
Collaborator

@radcortez I've not finished reviewing the code but TracingAppToAmqpTest.testFromAppToAmqp is failing

@radcortez
Copy link
Member Author

It seems to be the same issue reported in #1268.

From what I can tell, the 10 messages are produced correctly, but only 9 reach the consumer. I don't think this is related to any of our code, but I also find it strange if the broker is not able to handle this properly.

Do you have any ideas?

@ozangunalp
Copy link
Collaborator

ozangunalp commented Nov 8, 2022

@radcortez I looked at the changes again. I noticed that we are doing the same sequence of operations on the instrumenter.

I separated that code into a common module which also imports the otel apis. Here is my test PR : ozangunalp#12

Along the way I think I fixed that flaky test in AMQP connector.
There is something wrong with the RabbitMQ connector tracing config: the tracing.attribute-headers is never taken into account. As we discussed I think the decorator is not needed as it is a connector-specific code and can be added directly to the incoming channel stream.

Tell me what do you think.

@radcortez
Copy link
Member Author

@radcortez I looked at the changes again. I noticed that we are doing the same sequence of operations on the instrument.

Yes, my plan was to refactor this later. Thanks for doing it :)

I separated that code into a common module which also imports the otel apis. Here is my test PR : ozangunalp#12

+1

Along the way I think I fixed that flaky test in AMQP connector. There is something wrong with the RabbitMQ connector tracing config: the tracing.attribute-headers is never taken into account. As we discussed I think the decorator is not needed as it is a connector-specific code and can be added directly to the incoming channel stream.

The tracing.attribute-headers were used in the old implementation, but I think they don't make sense. These allowed to record in the span a configurable set of message headers, but these could clash with the OTel-defined span names, so I think we should remove them.

Tell me what do you think.

+1 Good to go!

@ozangunalp ozangunalp force-pushed the otel-instrumenter branch 2 times, most recently from 53be093 to 36ad496 Compare November 24, 2022 10:44
@ozangunalp ozangunalp force-pushed the otel-instrumenter branch 2 times, most recently from 877bb69 to d28a67f Compare January 4, 2023 08:16
@ozangunalp ozangunalp added this to the 3.23.0 milestone Jan 9, 2023
@ozangunalp
Copy link
Collaborator

@cescoffier I am willing to take this in for 3.23. Could you take a look ?

Copy link
Contributor

@cescoffier cescoffier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Refactor OTel integration to use the Instrumenter API
5 participants