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

Add Exemplars to metrics generated in aggregate processor #3165

Merged
merged 3 commits into from
Aug 17, 2023

Conversation

kkondaka
Copy link
Collaborator

@kkondaka kkondaka commented Aug 15, 2023

Description

Add Exemplars to metrics generated in aggregate processor

Resolves #3164

Issues Resolved

Resolves #3164

Check List

  • [X ] New functionality includes testing.
  • New functionality has a documentation issue. Please link to it in this PR.
    • New functionality has javadoc added
  • [X ] Commits are signed with a real name per the DCO

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

Signed-off-by: Krishna Kondaka <[email protected]>
@@ -98,7 +98,7 @@ While not necessary, a great way to set up the Aggregate Processor [identificati
The values in a list are merely appended, so there can be duplicates.

### <a name="count"></a>
* `count`: Count Events belonging to the same group and generate a new event with values of the identification keys and the count, indicating the number of events. All Events that make up the combined Event will be dropped.
* `count`: Count Events belonging to the same group and generate a new event with values of the identification keys and the count, indicating the number of events. All Events that make up the combined Event will be dropped. One of the events is added as exemplar. If the aggregation is done on traces, then traceId and spanId are included in the exemplar, otherwise, spanId and traceId would be null.
Copy link
Member

Choose a reason for hiding this comment

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

GitHub appears to be reporting some sort of formatting error. Is the Markdown correct?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't know. When you view it in "RichText Format", it seems to be fine to me.

return new DefaultExemplar(
OTelProtoCodec.convertUnixNanosToISO8601(curTimeNanos),
1.0,
event.get("spanId", String.class), // maybe null
Copy link
Member

Choose a reason for hiding this comment

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

This value should only be found when this is a SpanEvent. It may be better to check if this is a span and then handle as necessary.

e.g.

if(event instanceof SpanEvent) {
  SpanEvent spanEvent = (SpanEvent) event;
  String spanId = spanEvent.getSpanId();
  String traceId = spanEvent.getTraceId();
}

return new DefaultExemplar(
  OTelProtoCodec.convertUnixNanosToISO8601(curTimeNanos),
  1.0,
  spanId,
  traceId,
  attributes);

@@ -56,13 +61,25 @@ private long getTimeNanos(Instant time) {
return currentTimeNanos;
}

public Exemplar createExemplar(final Event event) {
long curTimeNanos = getTimeNanos(Instant.now());
Map<String, Object> attributes = event.toMap();
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure this is exactly what the attributes is meant to convey. In the model these are filtered_attributes.

And the current code in Data Prepper for metric exemplars uses only the provided filtered_attributes.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah. I do not know why SAP folks called it Attributes in the DataPrepper implementation

long curTimeNanos = getTimeNanos(Instant.now());
Map<String, Object> attributes = event.toMap();
if (Objects.nonNull(id)) {
attributes.put("exemplar_id", id);
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 the right naming convention? Does this work with the OpenSearch schemas?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I changed it to exemplarId

Signed-off-by: Krishna Kondaka <[email protected]>
@kkondaka kkondaka merged commit 11c6f46 into opensearch-project:main Aug 17, 2023
24 checks passed
@kkondaka kkondaka deleted the aggr-exemplar branch May 13, 2024 05:52
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.

Add Exemplars to metrics generated in aggregate processor
3 participants