Skip to content

Commit

Permalink
Add telemetry to mysql event listener
Browse files Browse the repository at this point in the history
  • Loading branch information
wendigo committed Dec 5, 2024
1 parent 7b026b3 commit 400afca
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
5 changes: 5 additions & 0 deletions plugin/trino-mysql-event-listener/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@
<artifactId>jdbi3-core</artifactId>
</dependency>

<dependency>
<groupId>org.jdbi</groupId>
<artifactId>jdbi3-opentelemetry</artifactId>
</dependency>

<dependency>
<groupId>org.jdbi</groupId>
<artifactId>jdbi3-sqlobject</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,15 @@
import com.mysql.cj.jdbc.Driver;
import io.airlift.bootstrap.Bootstrap;
import io.airlift.json.JsonModule;
import io.opentelemetry.api.OpenTelemetry;
import io.trino.spi.TrinoWarning;
import io.trino.spi.eventlistener.EventListener;
import io.trino.spi.eventlistener.EventListenerFactory;
import io.trino.spi.eventlistener.QueryInputMetadata;
import io.trino.spi.eventlistener.QueryOutputMetadata;
import org.jdbi.v3.core.ConnectionFactory;
import org.jdbi.v3.core.Jdbi;
import org.jdbi.v3.opentelemetry.JdbiOpenTelemetryPlugin;
import org.jdbi.v3.sqlobject.SqlObjectPlugin;

import java.util.Map;
Expand All @@ -57,6 +59,7 @@ public EventListener create(Map<String, String> config, EventListenerContext con
new JsonModule(),
new MysqlDataSourceModule(),
binder -> {
binder.bind(OpenTelemetry.class).toInstance(context.getOpenTelemetry());
jsonCodecBinder(binder).bindJsonCodec(new TypeLiteral<Set<String>>() {});
jsonCodecBinder(binder).bindMapJsonCodec(String.class, String.class);
jsonCodecBinder(binder).bindListJsonCodec(QueryInputMetadata.class);
Expand Down Expand Up @@ -92,10 +95,11 @@ public ConnectionFactory createConnectionFactory(MysqlEventListenerConfig config

@Singleton
@Provides
public static Jdbi createJdbi(ConnectionFactory connectionFactory)
public static Jdbi createJdbi(ConnectionFactory connectionFactory, OpenTelemetry openTelemetry)
{
return Jdbi.create(connectionFactory)
.installPlugin(new SqlObjectPlugin());
.installPlugin(new SqlObjectPlugin())
.installPlugin(new JdbiOpenTelemetryPlugin(openTelemetry));
}
}

Expand Down

0 comments on commit 400afca

Please sign in to comment.