Skip to content
This repository has been archived by the owner on Jul 31, 2023. It is now read-only.

Releases: census-ecosystem/opencensus-java-jdbc

ocjdbc-avec-options

26 Sep 18:35
b396089
Compare
Choose a tag to compare

In this release, we've added an option to allow spans to be annotated with the SQL statement that they are running with.
This option is called Observability.OPTION_ANNOTATE_TRACES_WITH_SQL

Exhibit

Before

package io.opencensus.tutorial.ocjdbc;

import io.opencensus.ocjdbc.Connection;
import io.opencensus.ocjdbc.Observability;

public static void main(String ...args) {
            java.sql.Connection originalConn = java.sql.DriverManager.getConnection("jdbc:mysql://localhost/repro?user=root&useSSL=false&serverTimezone=UTC");
            // Then create/wrap it with the instrumented Connection from "io.opencensus.ocjdbc".
            java.sql.Connection conn = new Connection(originalConn);
}

screen shot 2018-09-26 at 11 32 29 am

After

package io.opencensus.tutorial.ocjdbc;

import io.opencensus.ocjdbc.Connection;
import io.opencensus.ocjdbc.Observability;

public static void main(String ...args) {
            java.sql.Connection originalConn = java.sql.DriverManager.getConnection("jdbc:mysql://localhost/repro?user=root&useSSL=false&serverTimezone=UTC");
            // Then create/wrap it with the instrumented Connection from "io.opencensus.ocjdbc".
            java.sql.Connection conn = new Connection(originalConn,
                                                      // And passing this option to allow the spans
                                                      // to be annotated with the SQL queries.
                                                      // Please note that this could be a security concern
                                                      // since it could reveal personally identifying information.
                                                      Observability.OPTION_ANNOTATE_TRACES_WITH_SQL);
}

screen shot 2018-09-26 at 11 34 16 am

ocjdbc-alive

25 Sep 20:35
6e1f63a
Compare
Choose a tag to compare

OCJDBC -- OpenCensus Java Database Connectivity is a wrapper to add observability with tracing and metrics from OpenCensus to your JDBC connections.

Using it simply requires:

Dependency

  • Using Maven
<dependency>
    <groupId>io.opencensus</groupId>
    <artifactId>ocjdbc</artifactId>
    <version>0.0.1</version>
</dependency>

In code

import io.opencensus.ocjdbc.Connection;
import io.opencensus.ocjdbc.Observability;

public static void main(String ...args) {
    // Then create/wrap it with the instrumented Connection from "io.opencensus.ocjdbc".
    java.sql.Connection conn = new Connection(originalConn);
}

and then add the various OpenCensus exporters. Please take a look at https://opencensus.io/guides/integrations/sql/