-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #307 from newrelic/feature/external-conn/r2dbc
[NR-288604] ExternalConnection reporting for R2DBC driver
- Loading branch information
Showing
6 changed files
with
33 additions
and
1 deletion.
There are no files selected for viewing
3 changes: 3 additions & 0 deletions
3
...ion-security/r2dbc-h2/src/main/java/io/r2dbc/h2/client/SessionClient_Instrumentation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,19 @@ | ||
package io.r2dbc.h2.client; | ||
|
||
import com.newrelic.api.agent.security.NewRelicSecurity; | ||
import com.newrelic.api.agent.security.schema.ExternalConnectionType; | ||
import com.newrelic.api.agent.security.schema.R2DBCVendor; | ||
import com.newrelic.api.agent.weaver.MatchType; | ||
import com.newrelic.api.agent.weaver.Weave; | ||
import org.h2.engine.ConnectionInfo; | ||
|
||
@Weave(type = MatchType.ExactClass, originalName = "io.r2dbc.h2.client.SessionClient") | ||
public class SessionClient_Instrumentation { | ||
|
||
public SessionClient_Instrumentation(ConnectionInfo connectionInfo, boolean shutdownDatabaseOnClose) { | ||
if (NewRelicSecurity.isHookProcessingActive() && !NewRelicSecurity.getAgent().getSecurityMetaData().getRequest().isEmpty()) { | ||
NewRelicSecurity.getAgent().getSecurityMetaData().addCustomAttribute(R2DBCVendor.META_CONST_R2DBC_VENDOR, R2DBCVendor.H2); | ||
} | ||
NewRelicSecurity.getAgent().recordExternalConnection(null, -1, connectionInfo.getURL(), null, ExternalConnectionType.DATABASE_CONNECTION.name(), "R2DBC-H2"); | ||
} | ||
} |
10 changes: 9 additions & 1 deletion
10
...dbc-mariadb/src/main/java/org/mariadb/r2dbc/MariadbConnectionFactory_Instrumentation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,27 @@ | ||
package org.mariadb.r2dbc; | ||
|
||
import com.newrelic.api.agent.security.NewRelicSecurity; | ||
import com.newrelic.api.agent.security.schema.ExternalConnectionType; | ||
import com.newrelic.api.agent.security.schema.R2DBCVendor; | ||
import com.newrelic.api.agent.weaver.MatchType; | ||
import com.newrelic.api.agent.weaver.Weave; | ||
import com.newrelic.api.agent.weaver.Weaver; | ||
import org.mariadb.r2dbc.api.MariadbConnection; | ||
import reactor.core.publisher.Mono; | ||
|
||
@Weave(type = MatchType.Interface, originalName = "org.mariadb.r2dbc.MariadbConnectionFactory") | ||
import java.net.SocketAddress; | ||
|
||
@Weave(type = MatchType.ExactClass, originalName = "org.mariadb.r2dbc.MariadbConnectionFactory") | ||
public class MariadbConnectionFactory_Instrumentation { | ||
|
||
private final SocketAddress endpoint = Weaver.callOriginal(); | ||
private final MariadbConnectionConfiguration configuration = Weaver.callOriginal(); | ||
|
||
public Mono<MariadbConnection> create() { | ||
if (NewRelicSecurity.isHookProcessingActive() && !NewRelicSecurity.getAgent().getSecurityMetaData().getRequest().isEmpty()) { | ||
NewRelicSecurity.getAgent().getSecurityMetaData().addCustomAttribute(R2DBCVendor.META_CONST_R2DBC_VENDOR, R2DBCVendor.MARIA_DB); | ||
} | ||
NewRelicSecurity.getAgent().recordExternalConnection(configuration.getHost(), configuration.getPort(), endpoint.toString(), null, ExternalConnectionType.DATABASE_CONNECTION.name(), "R2DBC-MARIADB"); | ||
return Weaver.callOriginal(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
...ty/r2dbc-oracle/src/main/java/oracle/r2dbc/impl/OracleConnectionImpl_Instrumentation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,29 @@ | ||
package oracle.r2dbc.impl; | ||
|
||
import com.newrelic.api.agent.security.NewRelicSecurity; | ||
import com.newrelic.api.agent.security.schema.ExternalConnectionType; | ||
import com.newrelic.api.agent.security.schema.R2DBCVendor; | ||
import com.newrelic.api.agent.security.utils.logging.LogLevel; | ||
import com.newrelic.api.agent.weaver.Weave; | ||
import com.newrelic.api.agent.weaver.WeaveAllConstructors; | ||
import com.newrelic.api.agent.weaver.Weaver; | ||
|
||
import java.sql.SQLException; | ||
|
||
@Weave(originalName = "oracle.r2dbc.impl.OracleConnectionImpl") | ||
final class OracleConnectionImpl_Instrumentation { | ||
|
||
private final java.sql.Connection jdbcConnection = Weaver.callOriginal(); | ||
|
||
@WeaveAllConstructors | ||
OracleConnectionImpl_Instrumentation() { | ||
if (NewRelicSecurity.isHookProcessingActive() && !NewRelicSecurity.getAgent().getSecurityMetaData().getRequest().isEmpty()) { | ||
NewRelicSecurity.getAgent().getSecurityMetaData().addCustomAttribute(R2DBCVendor.META_CONST_R2DBC_VENDOR, R2DBCVendor.ORACLE); | ||
} | ||
try { | ||
NewRelicSecurity.getAgent().recordExternalConnection(null, -1, jdbcConnection.getMetaData().getURL(), null, ExternalConnectionType.DATABASE_CONNECTION.name(), "R2DBC-ORACLE"); | ||
} catch (SQLException e) { | ||
NewRelicSecurity.getAgent().log(LogLevel.WARNING, String.format("Instrumentation library: %s, Error while detecting external connection : %s", "R2DBC-ORACLE", e.getMessage()), e, this.getClass().getName()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters