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

Observation otel IT #297

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

Conversation

brunobat
Copy link
Contributor

No description provided.

@brunobat brunobat changed the title Observation otel Observation otel IT Feb 25, 2024
@radcortez radcortez force-pushed the main branch 4 times, most recently from df73490 to 58c8a10 Compare September 25, 2024 18:26
@brunobat brunobat force-pushed the observation-otel branch 2 times, most recently from d81b882 to f4d5752 Compare November 28, 2024 18:05
@brunobat brunobat marked this pull request as ready for review December 4, 2024 18:40
@brunobat brunobat requested a review from radcortez December 4, 2024 18:40
@brunobat
Copy link
Contributor Author

brunobat commented Dec 4, 2024

Need to make the tests more resilient.

Comment on lines +42 to +49
new OpenTelemetryObservationHandler(tracer)))
// todo duplicate the tracer strategy for baggage, adding a condition to bypass when no baggage is present
// todo just implement the receiver and sender handlers
// todo. Alternatively we can split in 2 the tracing handlers, one to create spans (in the current .observationHandler(new ObservationHandler.FirstMatchingCompositeObservationHandler )
// todo. A new .observationHandler bloc to process the baggage on the receiver side.
// todo. Another to propagate the context in a new .observationHandler )
// todo. We assume on the receiver side we open and close the baggage once because it should have just 1 scope app wide and the
// todo. user will use the baggage api itself. We are just making sure we don't break the propagation to the user.
Copy link
Member

Choose a reason for hiding this comment

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

Is this ok?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It means it doesn't provide baggage propagation through the Observation API. The OTel API can be used instead...
Implementing this is not trivial and the comment explains the possible approach.

@@ -56,6 +56,7 @@ public String get(C carrier, String key) {
return getter.get(carrier, key);
}
});
// extracted.makeCurrent(); // this actually fixes the baggage test
Copy link
Member

Choose a reason for hiding this comment

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

Is this ok?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Basically, if you uncomment, baggage propagation will be fixed, is there for reference... We can remove these comments but I will need to document these things somewhere, maybe on a README... What do you think?

final Attributes highCardAttributes = context.get(HIGH_CARD_ATTRIBUTES);
setOtelAttributes(span, highCardAttributes);

final Attributes lowCardAttributes = context.get(LOW_CARD_ATTRIBUTES);
Copy link
Member

Choose a reason for hiding this comment

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

Are these always set, no matter what?

Copy link
Contributor Author

@brunobat brunobat Dec 16, 2024

Choose a reason for hiding this comment

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

The low cardinality ones, yes.
The high cardinality are only used in traces.
This is there to go around a limitation of the Observation API... Currently, It only supports storage of Strings. Will file a feature request there.


final Attributes lowCardAttributes = context.get(LOW_CARD_ATTRIBUTES);
setOtelAttributes(span, lowCardAttributes);

for (KeyValue keyValue : context.getAllKeyValues()) {
Copy link
Member

Choose a reason for hiding this comment

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

Can it contain keys from HIGH_CARD_ATTRIBUTESand LOW_CARD_ATTRIBUTES?

Copy link
Contributor Author

@brunobat brunobat Dec 16, 2024

Choose a reason for hiding this comment

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

yes, but originally stored in 2 different structures.


@Override
public KeyName[] getHighCardinalityKeyNames() {
return KeyName.merge(HighCardinalityValues.values(), ServerHighCardinalityValues.values());
Copy link
Member

Choose a reason for hiding this comment

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

Probably cache the merge?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

They are session scoped


@Override
public KeyName[] getHighCardinalityKeyNames() {
return KeyName.merge(HighCardinalityValues.values(), ClientHighCardinalityValues.values());
Copy link
Member

Choose a reason for hiding this comment

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

Probably cache the merge?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

They are session scoped

}
};

public enum LowCardinalityValues implements KeyName {
Copy link
Member

Choose a reason for hiding this comment

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

Do the names come from some spec or it is our feeling?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

From the OTel semconv, yes. I followed the latest versions

Comment on lines +85 to +87
builder.put(HTTP_ROUTE.getKey(), request.getUri().getPath().toString());// Fixme must contain a template /users/:userID?

builder.put(HTTP_REQUEST_METHOD, request.getMethod());// FIXME semantic conventions
Copy link
Member

Choose a reason for hiding this comment

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

Is this ok?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This needs updating. Will fix

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