-
Notifications
You must be signed in to change notification settings - Fork 530
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
[INLONG-11013][Sort] A demo of reporting sort logs through OpenTelemetry #11015
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,22 +20,73 @@ | |
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>org.apache.inlong</groupId> | ||
<artifactId>sort-connectors-v1.15</artifactId> | ||
<version>1.14.0-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>sort-connector-mysql-cdc-v1.15</artifactId> | ||
<packaging>jar</packaging> | ||
<name>Apache InLong - Sort-connector-mysql-cdc</name> | ||
|
||
<properties> | ||
<inlong.root.dir>${project.parent.parent.parent.parent.parent.basedir}</inlong.root.dir> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.apache.logging.log4j</groupId> | ||
<artifactId>log4j-core</artifactId> | ||
<version>${log4j2.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.logging.log4j</groupId> | ||
<artifactId>log4j-api</artifactId> | ||
<version>${log4j2.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.opentelemetry</groupId> | ||
<artifactId>opentelemetry-api</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.opentelemetry.instrumentation</groupId> | ||
<artifactId>opentelemetry-instrumentation-api</artifactId> | ||
<version>1.28.0</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.opentelemetry.instrumentation</groupId> | ||
<artifactId>opentelemetry-log4j-appender-2.17</artifactId> | ||
<version>1.28.0-alpha</version> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto |
||
</dependency> | ||
<dependency> | ||
<groupId>io.opentelemetry</groupId> | ||
<artifactId>opentelemetry-sdk-trace</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.opentelemetry</groupId> | ||
<artifactId>opentelemetry-exporter-otlp</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.opentelemetry</groupId> | ||
<artifactId>opentelemetry-sdk</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.opentelemetry</groupId> | ||
<artifactId>opentelemetry-semconv</artifactId> | ||
<version>1.28.0-alpha</version> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto |
||
</dependency> | ||
<dependency> | ||
<groupId>io.opentelemetry</groupId> | ||
<artifactId>opentelemetry-sdk-logs</artifactId> | ||
<version>1.28.0</version> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto |
||
</dependency> | ||
<dependency> | ||
<groupId>com.squareup.okhttp3</groupId> | ||
<artifactId>okhttp</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.squareup.okio</groupId> | ||
<artifactId>okio</artifactId> | ||
<version>1.17.2</version> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto |
||
</dependency> | ||
<!-- Debezium dependencies --> | ||
<dependency> | ||
<groupId>com.ververica</groupId> | ||
|
@@ -78,7 +129,6 @@ | |
<version>${project.version}</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
|
@@ -92,6 +142,7 @@ | |
</goals> | ||
<phase>package</phase> | ||
<configuration> | ||
<createDependencyReducedPom>false</createDependencyReducedPom> | ||
<artifactSet> | ||
<includes> | ||
<include>org.apache.inlong:*</include> | ||
|
@@ -113,6 +164,11 @@ | |
<!-- Include fixed version 18.0-13.0 of flink shaded guava --> | ||
<include>org.apache.flink:flink-shaded-guava</include> | ||
<include>com.google.protobuf:*</include> | ||
<include>io.opentelemetry</include> | ||
<include>io.opentelemetry.*</include> | ||
<include>io.opentelemetry-sdk.*</include> | ||
<include>com.squareup.okhttp3</include> | ||
<include>com.squareup.okio</include> | ||
</includes> | ||
</artifactSet> | ||
<filters> | ||
|
@@ -137,10 +193,6 @@ | |
</filter> | ||
</filters> | ||
<relocations> | ||
<relocation> | ||
<pattern>org.apache.inlong.sort.base</pattern> | ||
<shadedPattern>org.apache.inlong.sort.cdc.mysql.shaded.org.apache.inlong.sort.base</shadedPattern> | ||
</relocation> | ||
<relocation> | ||
<pattern>org.apache.inlong.sort.cdc.base</pattern> | ||
<shadedPattern>org.apache.inlong.sort.cdc.mysql.shaded.org.apache.inlong.sort.cdc.base</shadedPattern> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,6 +47,13 @@ | |
import io.debezium.connector.mysql.MySqlConnection; | ||
import io.debezium.relational.TableId; | ||
import io.debezium.relational.history.TableChanges; | ||
import io.opentelemetry.exporter.otlp.logs.OtlpGrpcLogRecordExporter; | ||
import io.opentelemetry.instrumentation.log4j.appender.v2_17.OpenTelemetryAppender; | ||
import io.opentelemetry.sdk.OpenTelemetrySdk; | ||
import io.opentelemetry.sdk.logs.SdkLoggerProvider; | ||
import io.opentelemetry.sdk.logs.export.BatchLogRecordProcessor; | ||
import io.opentelemetry.sdk.resources.Resource; | ||
import io.opentelemetry.semconv.resource.attributes.ResourceAttributes; | ||
import org.apache.flink.api.connector.source.SourceEvent; | ||
import org.apache.flink.configuration.Configuration; | ||
import org.apache.flink.connector.base.source.reader.RecordEmitter; | ||
|
@@ -88,6 +95,7 @@ public class MySqlSourceReader<T> | |
private final MySqlSourceReaderContext mySqlSourceReaderContext; | ||
private MySqlBinlogSplit suspendedBinlogSplit; | ||
private final DebeziumDeserializationSchema<T> metricSchema; | ||
private OpenTelemetrySdk SDK; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Better to add a configuration to enable or disable opentelemetry There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I found a better way to do this at #11065 . |
||
|
||
public MySqlSourceReader( | ||
FutureCompletingBlockingQueue<RecordsWithSplitIds<SourceRecords>> elementQueue, | ||
|
@@ -113,11 +121,33 @@ public MySqlSourceReader( | |
|
||
@Override | ||
public void start() { | ||
this.SDK = OpenTelemetrySdk.builder() | ||
.setLoggerProvider( | ||
SdkLoggerProvider.builder() | ||
.setResource( | ||
Resource.getDefault().toBuilder() | ||
.put(ResourceAttributes.SERVICE_NAME, "log4j-example") | ||
.build()) | ||
.addLogRecordProcessor( | ||
BatchLogRecordProcessor.builder( | ||
OtlpGrpcLogRecordExporter.builder() | ||
.setEndpoint("http://127.0.0.1:4317") | ||
.build()) | ||
.build()) | ||
.build()) | ||
.build(); | ||
OpenTelemetryAppender.install(SDK); | ||
if (getNumberOfCurrentlyAssignedSplits() == 0) { | ||
context.sendSplitRequest(); | ||
} | ||
} | ||
|
||
@Override | ||
public void close() throws Exception { | ||
super.close(); | ||
SDK.close(); | ||
} | ||
|
||
@Override | ||
protected MySqlSplitState initializedState(MySqlSplit split) { | ||
if (split.isSnapshotSplit()) { | ||
|
@@ -380,4 +410,4 @@ private void logCurrentBinlogOffsets(List<MySqlSplit> splits, long checkpointId) | |
protected MySqlSplit toSplitType(String splitId, MySqlSplitState splitState) { | ||
return splitState.toMySqlSplit(); | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add a new property
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found a better way to do this at #11065 .