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

MAINT: add OTelTraceGroupProcessor from trace ingestion migration branch #1224

Conversation

chenqi0805
Copy link
Collaborator

@chenqi0805 chenqi0805 commented Mar 18, 2022

Signed-off-by: Qi Chen [email protected]

Description

This PR adds in otel-trace-group-processor which is otel-trace-group-prepper in https://github.com/opensearch-project/data-prepper/tree/maint/546-migrate-trace-analytics-to-event-model.

Beside renaming plugins, some cleanups are essential:

  • README: prepper -> processor
  • package name in new modules: prepper -> processor
  • implement interface: prepper -> processor

Issues Resolved

Contributes to #1158

Check List

  • New functionality includes testing.
  • New functionality has been documented.
    • New functionality has javadoc added
  • 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.

@chenqi0805 chenqi0805 requested a review from a team as a code owner March 18, 2022 18:39
Signed-off-by: Qi Chen <[email protected]>
@codecov-commenter
Copy link

codecov-commenter commented Mar 18, 2022

Codecov Report

Merging #1224 (fd73be7) into main (c684f7c) will not change coverage.
The diff coverage is n/a.

@@            Coverage Diff            @@
##               main    #1224   +/-   ##
=========================================
  Coverage     93.79%   93.79%           
  Complexity     1104     1104           
=========================================
  Files           153      153           
  Lines          3064     3064           
  Branches        257      257           
=========================================
  Hits           2874     2874           
  Misses          138      138           
  Partials         52       52           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c684f7c...fd73be7. Read the comment docs.

Copy link
Contributor

@cmanning09 cmanning09 left a comment

Choose a reason for hiding this comment

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

Thanks for migrating to the processor interface. I have a comment for updating the documentation.

@@ -0,0 +1,67 @@
# OTel Trace Group Processor

This is a processor that fills in the missing trace group related fields in the collection of [Span](../../data-prepper-api/src/main/java/com/amazon/dataprepper/model/trace/Span.java) records output by [otel-trace-raw-processor](../otel-trace-raw-processor) and then convert them back into a new collection of string records.
Copy link
Contributor

Choose a reason for hiding this comment

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

... and then convert them back into a new collection of string records. <- This is no longer accurate and we should be able to remove it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Great catch!

try (MockedStatic<ConnectionConfiguration> connectionConfigurationMockedStatic = Mockito.mockStatic(ConnectionConfiguration.class)) {
connectionConfigurationMockedStatic.when(() -> ConnectionConfiguration.readConnectionConfiguration(any(PluginSetting.class)))
.thenReturn(connectionConfigurationMock);
PluginSetting testPluginSetting = new PluginSetting("otel_trace_group_prepper", new HashMap<>());
Copy link
Contributor

Choose a reason for hiding this comment

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

Please update this to new PluginSetting("otel_trace_group_processor",, new HashMap<>());

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Great catch!


@Test
public void testTraceGroupFillFailDueToFailedRequest() throws IOException {
// Arrange
Copy link
Contributor

Choose a reason for hiding this comment

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

I like how you've separated the functionality within each test case!

cmanning09
cmanning09 previously approved these changes Mar 28, 2022
pipeline:
...
processor:
- otel-trace-group-processor:
Copy link
Member

Choose a reason for hiding this comment

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

This should be using underscores, right?

pipeline:
...
processor:
- otel-trace-group:
Copy link
Member

Choose a reason for hiding this comment

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

This should be using underscores, right?

pipeline:
...
processor:
- otel-trace-group-processor:
Copy link
Member

Choose a reason for hiding this comment

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

Also, there is no _processor suffix, right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks for the catch.

@@ -0,0 +1,67 @@
# OTel Trace Group Processor

This is a processor that fills in the missing trace group related fields in the collection of [Span](../../data-prepper-api/src/main/java/com/amazon/dataprepper/model/trace/Span.java) records output by [otel-trace-raw-processor](../otel-trace-raw-processor).
Copy link
Member

Choose a reason for hiding this comment

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

The name here also should use underscores.

final String traceId = traceIdDocField.getValue();
final String traceGroupName = traceGroupNameDocField.getValue();
// Restore trailing zeros for thousand, e.g. 2020-08-20T05:40:46.0895568Z -> 2020-08-20T05:40:46.089556800Z
final String traceGroupEndTime = Instant.parse(traceGroupEndTimeDocField.getValue()).toString();
Copy link
Member

Choose a reason for hiding this comment

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

Rather than add an inline comment (which is prone to being lost over time), I suggest you make this a function.

Perhaps:

/**
 * Restores trailing zeros for thousand, e.g. 2020-08-20T05:40:46.0895568Z -> 2020-08-20T05:40:46.089556800Z
 */ 
private String normalizeDateTime(String dateTimeString) {
  return Instant.parse(dateTimeString).toString();
}

Signed-off-by: Qi Chen <[email protected]>
@chenqi0805 chenqi0805 requested review from dlvenable and removed request for dlvenable March 30, 2022 20:47
@chenqi0805 chenqi0805 merged commit 46b205a into opensearch-project:main Mar 30, 2022
@chenqi0805 chenqi0805 deleted the maint/add-otel-trace-group-processor branch March 30, 2022 22:17
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.

5 participants