Skip to content

Implementation for the latest Messaging Semantic conventions. #13192

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

Open
wants to merge 18 commits into
base: main
Choose a base branch
from

Conversation

cbos
Copy link

@cbos cbos commented Feb 4, 2025

Update Messaging span with the latest semantic conventions.
https://github.com/open-telemetry/semantic-conventions/blob/v1.30.0/docs/messaging/messaging-spans.md

By default nothing changes, it adheres to this:

  • SHOULD introduce an environment variable OTEL_SEMCONV_STABILITY_OPT_IN
    in the existing major version which is a comma-separated list of values.
    The list of values includes:
    • messaging - emit the new, stable messaging conventions,
      and stop emitting the old experimental messaging conventions
      that the instrumentation emitted previously.
    • messaging/dup - emit both the old and the stable messaging conventions,
      allowing for a seamless transition.
    • The default behavior (in the absence of one of these values) is to continue
      emitting whatever version of the old experimental messaging conventions
      the instrumentation was emitting previously.
    • Note: messaging/dup has higher precedence than messaging in case both values are present

@cbos cbos requested a review from a team as a code owner February 4, 2025 15:23
Copy link

linux-foundation-easycla bot commented Feb 4, 2025

CLA Signed


The committers listed above are authorized under a signed CLA.

@laurit laurit mentioned this pull request Mar 24, 2025
@laurit
Copy link
Contributor

laurit commented Mar 24, 2025

@cbos are you doing this for fun or do you intend to get this merged?

@cbos
Copy link
Author

cbos commented Mar 31, 2025

@laurit
Thanks for reaching out.
My intent is to get the merged, but I had difficulties to find out how the CLA should be handled. That took an awful lot of time to get that sorted out in the organisation I am currently active, but that is arranged now. I signed the CLA.

@cbos
Copy link
Author

cbos commented Mar 31, 2025

@laurit
Thanks for reaching out.
My intent is to get the merged, but I had difficulties to find out how the CLA should be handled. That took an awefull lot of time to get that sorted out in the organisation I am currently active, but that is arranged now. I signed the CLA.

Copy link
Contributor

@laurit laurit left a comment

Choose a reason for hiding this comment

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

Eventually it would be nice if we also had tests running with the stable semconvs. For db tests we use

tasks {
  val testStableSemconv by registering(Test::class) {
    jvmArgs("-Dotel.semconv-stability.opt-in=database")
  }

  check {
    dependsOn(testStableSemconv)
  }
}

I guess the tests can be added a bit later once the other parts of the PR are finished.

@@ -13,16 +13,33 @@
* that may be used in a messaging system.
*/
public enum MessageOperation {
Copy link
Contributor

Choose a reason for hiding this comment

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

*/
@Deprecated
String operationName() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Since this is a package private method it is not part of the public api and can be renamed without preserving the original method. If you wish to keep the original method then it would be better to make the old method class the new one.

Comment on lines +176 to +178
internalSet(attributes, MESSAGING_MESSAGE_BODY_SIZE, getter.getMessageBodySize(request));
internalSet(
attributes, MESSAGING_MESSAGE_ENVELOPE_SIZE, getter.getMessageEnvelopeSize(request));
Copy link
Contributor

Choose a reason for hiding this comment

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

why did you move these from start to end?

Comment on lines -26 to +27
String getDestination(REQUEST request);
default Long getBatchMessageCount(REQUEST request, @Nullable RESPONSE response) {
return null;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Rearranging methods like that complicates the review. It is hard to tell what methods have been added and what was just moved.

import io.opentelemetry.instrumentation.api.instrumenter.InstrumenterBuilder;
import javax.annotation.Nullable;

public final class MessagingNetworkAttributesExtractor<REQUEST, RESPONSE>
Copy link
Contributor

Choose a reason for hiding this comment

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

We already have ServerAttributesExtractor and NetworkAttributesExtractor are you sure we should add a new messaging specific extractor?

* This class is internal and is hence not for public use. Its APIs are unstable and can change at
* any time.
*/
public class PropagatorBasedBaggageExtractor<REQUEST> implements ContextCustomizer<REQUEST> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this required by the specification? If I understand correctly what this is supposed to do it seems to have a limited usefulness. Perhaps it would be better to introduce it in a separate PR?

MessageOperation operation = MessageOperation.PUBLISH;
MessageOperation operation =
emitStableMessagingSemconv() ? MessageOperation.SEND : MessageOperation.PUBLISH;
;
Copy link
Contributor

Choose a reason for hiding this comment

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

this line can be deleted

enum SqsAttributesGetter
implements
MessagingAttributesGetter<Request<?>, Response<?>>,
MessagingNetworkAttributesGetter<Request<?>, Response<?>> {
Copy link
Contributor

Choose a reason for hiding this comment

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

not much point in adding the network attributes interface when no methods are implemented

SpanKindExtractor.alwaysConsumer(),
toSqsRequestExtractors(attributesExtractors()),
singletonList(messagingAttributeExtractor),
messagingReceiveInstrumentationEnabled);
messagingReceiveInstrumentationEnabled || SemconvStability.emitStableMessagingSemconv());
Copy link
Contributor

Choose a reason for hiding this comment

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

My advice would be to do the attribute changes in one PR and leave any potential changes to trace structure for followup PRs. Changes to trace structure will most likely require new tests and will make your PR much larger. Also as far as I can tell https://opentelemetry.io/docs/specs/semconv/messaging/messaging-spans/#message-creation-context-as-parent-of-process-span hints that having the process span as child of publish span is still allowed. Having these in one trace seems to be preferred by users.

public static Timer onEnter() {
public static Timer onEnter(@Advice.This MessageConsumer consumer) {

if (JmsConfig.EXPERIMENTAL_CONSUMER_PROCESS_TELEMETRY_ENABLED) {
Copy link
Contributor

Choose a reason for hiding this comment

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

If this change is not related to the semantic conventions consider submitting it as a separate PR.

@cbos
Copy link
Author

cbos commented Apr 4, 2025

@laurit
Thanks for the review, next week I will go through all details and update the PR

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.

2 participants