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 new OTEL Metrics source that creates events #4183

Merged
merged 4 commits into from
Feb 25, 2024

Conversation

kkondaka
Copy link
Collaborator

Description

Add new OTEL Metrics source that creates events

Added a new OTEL source that creates DataPrepper Events before putting them into buffer.

Issues Resolved

Resolves #[Issue number to be closed when this PR is merged]

Check List

  • 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 <krishkdk@dev-dsk-krishkdk-2c-bd29c437.us-west-2.amazon.com>
…ew events are created in the source

Signed-off-by: Krishna Kondaka <krishkdk@dev-dsk-krishkdk-2c-bd29c437.us-west-2.amazon.com>
engechas
engechas previously approved these changes Feb 24, 2024
Copy link
Collaborator

@engechas engechas left a comment

Choose a reason for hiding this comment

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

Some minor comments. Can fix later if needed

Comment on lines 102 to 103
final int bufferWriteTimeoutInMillis =
(int) (oTelMetricsSourceConfig.getRequestTimeoutInMillis() * 0.8);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Doesn't look like this is used anywhere

Collection<Record<? extends Metric>> metrics;
AtomicInteger droppedCounter = new AtomicInteger(0);

OTelProtoCodec.OTelProtoDecoder oTelProtoDecoder = new OTelProtoCodec.OTelProtoDecoder();
Copy link
Collaborator

Choose a reason for hiding this comment

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

It looks like the decoder is passed through the constructor in the other sources. We could do the same in this class to avoid instantiating a new one for each request: https://github.com/opensearch-project/data-prepper/blob/main/data-prepper-plugins/otel-trace-source/src/main/java/org/opensearch/dataprepper/plugins/source/oteltrace/OTelTraceGrpcService.java#L57

@@ -81,7 +78,12 @@ private void processRequest(final ExportMetricsServiceRequest request, final Str
if (buffer.isByteBuffer()) {
buffer.writeBytes(request.toByteArray(), null, bufferWriteTimeoutInMillis);
} else {
buffer.write(new Record<>(request), bufferWriteTimeoutInMillis);
Collection<Record<? extends Metric>> metrics;
AtomicInteger droppedCounter = new AtomicInteger(0);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we be emitting a metric for this or does the decoder already handle that?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added metrics.

graytaylor0
graytaylor0 previously approved these changes Feb 24, 2024
@@ -935,12 +942,13 @@ void gRPC_with_auth_request_writes_to_buffer_with_successful_response() throws E
final ExportMetricsServiceResponse exportResponse = client.export(createExportMetricsRequest());
assertThat(exportResponse, notNullValue());

final ArgumentCaptor<Record<ExportMetricsServiceRequest>> bufferWriteArgumentCaptor = ArgumentCaptor.forClass(Record.class);
verify(buffer).write(bufferWriteArgumentCaptor.capture(), anyInt());
//final ArgumentCaptor<Record<ExportMetricsServiceRequest>> bufferWriteArgumentCaptor = ArgumentCaptor.forClass(Record.class);
Copy link
Member

Choose a reason for hiding this comment

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

Extra comment here

@@ -40,7 +46,7 @@ public class OTelMetricsGrpcService extends MetricsServiceGrpc.MetricsServiceImp


public OTelMetricsGrpcService(int bufferWriteTimeoutInMillis,
Buffer<Record<ExportMetricsServiceRequest>> buffer,
Copy link
Member

Choose a reason for hiding this comment

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

Please be sure to verify that the original source that uses ExportMetricsServiceRequest is not affected by this change

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Original source is not there any more. We are replacing original source with this new behavior.

Signed-off-by: Krishna Kondaka <krishkdk@dev-dsk-krishkdk-2c-bd29c437.us-west-2.amazon.com>
@kkondaka kkondaka dismissed stale reviews from graytaylor0 and engechas via f00afb2 February 24, 2024 22:12
graytaylor0
graytaylor0 previously approved these changes Feb 24, 2024
engechas
engechas previously approved these changes Feb 25, 2024
Signed-off-by: Krishna Kondaka <krishkdk@dev-dsk-krishkdk-2c-bd29c437.us-west-2.amazon.com>
@kkondaka kkondaka dismissed stale reviews from engechas and graytaylor0 via 37e1664 February 25, 2024 02:47
@kkondaka kkondaka merged commit 0fa5550 into opensearch-project:main Feb 25, 2024
47 checks passed
@kkondaka kkondaka deleted the otel-metrics 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.

None yet

3 participants