Skip to content

Instantly share code, notes, and snippets.

@codefromthecrypt
Last active September 11, 2019 09:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codefromthecrypt/e47ba194b2559031ae2c3723fdfd5984 to your computer and use it in GitHub Desktop.
Save codefromthecrypt/e47ba194b2559031ae2c3723fdfd5984 to your computer and use it in GitHub Desktop.
Add custom armeria configuration to zipkin
#!/bin/sh
#
# NOTE: if you are reading this, probably you should upvote https://github.com/line/armeria/issues/1909
#
# get normal zipkin server
curl -sSL https://zipkin.io/quickstart.sh | bash -s
# Write pom.xml thats responsible for generating armeria-configurator.jar
cat << 'EOF' > pom.xml
<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>
<groupId>armeria.custom</groupId>
<artifactId>armeria-configurator</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.build.resourceEncoding>UTF-8</project.build.resourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>com.linecorp.armeria</groupId>
<artifactId>armeria-spring-boot-autoconfigure</artifactId>
<scope>provided</scope>
<version>0.90.0</version>
</dependency>
</dependencies>
<build>
<finalName>armeria-configurator</finalName>
</build>
</project>
EOF
# make the auto-configuration file (in this case access logger)
mkdir -p src/main/java/armeria/server
cat << 'EOF' > src/main/java/armeria/server/ArmeriaServerConfiguratorAutoConfiguration.java
package armeria.server;
import com.linecorp.armeria.server.logging.AccessLogWriter;
import com.linecorp.armeria.spring.ArmeriaServerConfigurator;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
class ArmeriaServerConfiguratorAutoConfiguration {
@Bean ArmeriaServerConfigurator configureAccessLogs() {
return sb -> sb.accessLogWriter(AccessLogWriter.common(), true);
}
}
EOF
# make the file that tells spring to autoconfigure the above
mkdir -p src/main/resources/META-INF
cat << 'EOF' > src/main/resources/META-INF/spring.factories
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
armeria.server.ArmeriaServerConfiguratorAutoConfiguration
EOF
# Build armeria-configurator jar
mvn clean package
# run with the custom configurator
java \
-Dloader.path=target/armeria-configurator.jar \
-cp zipkin.jar \
org.springframework.boot.loader.PropertiesLauncher
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment