Skip to content

Commit

Permalink
Merge pull request #383 from blacktooth/master
Browse files Browse the repository at this point in the history
Emit usage metrics for glue schema registry
  • Loading branch information
joshua-kim authored Sep 30, 2021
2 parents 092dbf6 + a33b2af commit 855bec7
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 4 deletions.
40 changes: 39 additions & 1 deletion java/amazon-kinesis-producer/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,44 @@
</execution>
</executions>
</plugin>
<!-- Required for generating maven version as a Java class for runtime access -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>templating-maven-plugin</artifactId>
<version>1.0.0</version>
<executions>
<execution>
<id>generate-version-class</id>
<goals>
<goal>filter-sources</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>copy-dist</id>
<phase>prepare-package</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.build.outputDirectory}</outputDirectory>
<resources>
<resource>
<directory>${project.basedir}/target/generated-sources/java-templates/</directory>
<filtering>false</filtering>
<excludes>
</excludes>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

Expand Down Expand Up @@ -94,7 +132,7 @@
<dependency>
<groupId>software.amazon.glue</groupId>
<artifactId>schema-registry-serde</artifactId>
<version>1.1.1</version>
<version>1.1.4</version>
</dependency>
<dependency>
<groupId>junit</groupId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.amazonaws.services.kinesis.producer;

public final class KinesisProducerLibraryPackage {
public static final String VERSION = "${project.version}";
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
public final class GlueSchemaRegistrySerializerInstance {

private volatile GlueSchemaRegistrySerializer instance = null;
private static final String USER_AGENT_APP_NAME = "kpl" + "-" + KinesisProducerLibraryPackage.VERSION;

/**
* Instantiate GlueSchemaRegistrySerializer using the KinesisProducerConfiguration.
Expand Down Expand Up @@ -39,11 +40,14 @@ public GlueSchemaRegistrySerializer get(KinesisProducerConfiguration configurati

private GlueSchemaRegistryConfiguration getConfigFromKinesisProducerConfig(
KinesisProducerConfiguration configuration) {
if (configuration.getGlueSchemaRegistryConfiguration() == null) {
GlueSchemaRegistryConfiguration glueSchemaRegistryConfiguration = configuration.getGlueSchemaRegistryConfiguration();
if (glueSchemaRegistryConfiguration == null) {
//Reuse the region from KinesisProducerConfiguration.
return new GlueSchemaRegistryConfiguration(configuration.getRegion());
glueSchemaRegistryConfiguration = new GlueSchemaRegistryConfiguration(configuration.getRegion());
}

return configuration.getGlueSchemaRegistryConfiguration();
glueSchemaRegistryConfiguration.setUserAgentApp(USER_AGENT_APP_NAME);

return glueSchemaRegistryConfiguration;
}
}

0 comments on commit 855bec7

Please sign in to comment.