Skip to content

Feature/xray otlp config #5583

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

Closed
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add X-Ray OTLP Sink plugin skeleton
Signed-off-by: huy pham <huyp@amazon.com>
huypham612 committed Apr 3, 2025
commit 323e03e455cc10e980725bf7fc8ca702495c6885
20 changes: 20 additions & 0 deletions data-prepper-plugins/xray-otlp-sink/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# X-Ray OTLP Sink

The `xray_otlp_sink` plugin sends span data to [AWS X-Ray](https://docs.aws.amazon.com/xray/) using the OTLP (OpenTelemetry Protocol) format.

## Usage

For information on usage, see the forthcoming documentation in the [Data Prepper Sink Plugins section](https://opensearch.org/docs/latest/data-prepper/pipelines/configuration/sinks/).

A sample pipeline configuration will be added once the plugin is ready for testing.

## Developer Guide

See the [CONTRIBUTING](https://github.com/opensearch-project/data-prepper/blob/main/CONTRIBUTING.md) guide for general information on contributions.

The integration tests for this plugin do not run as part of the main Data Prepper build.

To run unit tests for this plugin locally:

```bash
./gradlew :data-prepper-plugins:xray-otlp-sink:test
20 changes: 20 additions & 0 deletions data-prepper-plugins/xray-otlp-sink/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

plugins {
id 'java-library'
}

dependencies {
implementation project(':data-prepper-api')
implementation 'com.fasterxml.jackson.core:jackson-databind'

testImplementation 'org.junit.jupiter:junit-jupiter-api:5.9.1'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.9.1'
}

test {
useJUnitPlatform()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/
package org.opensearch.dataprepper.plugins.sink.xrayotlp;

import org.opensearch.dataprepper.model.annotations.DataPrepperPlugin;
import org.opensearch.dataprepper.model.record.Record;
import org.opensearch.dataprepper.model.sink.Sink;

import java.util.Collection;

/**
* A Data Prepper Sink plugin that forwards traces to AWS X-Ray's OTLP endpoint.
*/
@DataPrepperPlugin(
name = "otlp_xray_sink",
pluginType = Sink.class
)
public class XRayOTLPSink implements Sink<Record<String>> {

/**
* Constructs the OTLP X-Ray Sink.
* Configuration loading will be added in a later iteration.
*/
public XRayOTLPSink() {
// TODO: Inject config or plugin setting.
}

/**
* Lifecycle hook invoked during pipeline startup.
* Initialize AWS clients or other resources here.
*/
@Override
public void initialize() {
// TODO: Initialize AWS X-Ray client
}

/**
* Called each time a batch of records is emitted to the sink.
* This method is responsible for handling delivery to AWS X-Ray.
*
* @param records Collection of OTLP log records to process.
*/
@Override
public void output(final Collection<Record<String>> records) {
// TODO: Process records
}

/**
* Indicates whether this sink is ready to receive data.
*
* @return true if the sink is ready
*/
@Override
public boolean isReady() {
// TODO: Implement readiness logic
return true;
}

/**
* Hook called during pipeline shutdown.
*/
@Override
public void shutdown() {
// TODO: Clean up resources
}

/**
* Updates internal latency metrics using the received records.
*
* @param events Collection of records used for latency tracking.
*/
@Override
public void updateLatencyMetrics(final Collection<Record<String>> events) {
// TODO: Implement latency tracking with PluginMetrics
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

package org.opensearch.dataprepper.plugins.sink.xrayotlp;


import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.opensearch.dataprepper.model.record.Record;

import java.util.Collections;

import static org.junit.jupiter.api.Assertions.*;

class XRayOTLPSinkTest {
private XRayOTLPSink sink;

@BeforeEach
void setUp() {
sink = new XRayOTLPSink();
}

@Test
void testInitialize_doesNotThrow() {
assertDoesNotThrow(() -> sink.initialize());
}

@Test
void testOutput_printsRecordData() {
Record<String> record = new Record<>("mock-otlp-span");
assertDoesNotThrow(() -> sink.output(Collections.singletonList(record)));
}

@Test
void testIsReady_returnsTrue() {
assertTrue(sink.isReady());
}

@Test
void testShutdown_doesNotThrow() {
assertDoesNotThrow(() -> sink.shutdown());
}
}
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
@@ -193,4 +193,4 @@ include 'data-prepper-plugins:saas-source-plugins:source-crawler'
include 'data-prepper-plugins:saas-source-plugins:jira-source'
include 'data-prepper-plugins:saas-source-plugins:confluence-source'
include 'data-prepper-plugins:saas-source-plugins:atlassian-commons'

include 'data-prepper-plugins:xray-otlp-sink'