diff --git a/.github/dco.yml b/.github/dco.yml new file mode 100644 index 0000000..0c4b142 --- /dev/null +++ b/.github/dco.yml @@ -0,0 +1,2 @@ +require: + members: false diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..bdd24a5 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,18 @@ +version: 2 +updates: +- package-ecosystem: maven + directory: "/" + schedule: + interval: daily + open-pull-requests-limit: 10 + ignore: + - dependency-name: org.springframework.cloud:spring-cloud-dependencies + versions: + - ">= 2020.1.a, < 2020.2" + - dependency-name: org.springframework.cloud:spring-cloud-dependencies + versions: + - 2020.0.2 + - 2021.0.0-SNAPSHOT + - dependency-name: org.springframework.boot:spring-boot-starter-parent + versions: + - 2.4.4 diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml new file mode 100644 index 0000000..2d2eeb3 --- /dev/null +++ b/.github/workflows/maven.yml @@ -0,0 +1,24 @@ +# This workflow will build a Java project with Maven +# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven + +name: Java CI with Maven + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Set up JDK 1.8 + uses: actions/setup-java@v1 + with: + java-version: 1.8 + - name: Build with Maven + run: ./scripts/runAcceptanceTests.sh diff --git a/.gitignore b/.gitignore index 3f0175e..cb0de90 100644 --- a/.gitignore +++ b/.gitignore @@ -15,6 +15,15 @@ _site/ *.log .gradle *.jar +*/target/** */build/** *.class -build/ \ No newline at end of file +target/ +build/ +zipkin.jar +zipkin.jar.asc +zipkin.jar.md5.asc +out/ +bin/ +target/ +.vscode/ diff --git a/.mvn/wrapper/maven-wrapper.jar b/.mvn/wrapper/maven-wrapper.jar new file mode 100644 index 0000000..5fd4d50 Binary files /dev/null and b/.mvn/wrapper/maven-wrapper.jar differ diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties new file mode 100644 index 0000000..c315043 --- /dev/null +++ b/.mvn/wrapper/maven-wrapper.properties @@ -0,0 +1 @@ +distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.0/apache-maven-3.5.0-bin.zip diff --git a/.travis.yml b/.travis.yml index 55fb400..113f0ac 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,10 +1,3 @@ -sudo: required -services: - - docker - - rabbitmq - -language: groovy - jdk: - oraclejdk8 @@ -16,16 +9,4 @@ before_script: - "export JAVA_OPTS=-Xmx256m" script: -- ./gradlew clean build --parallel $SWITCH - -env: - global: - - TERM=dumb - - SHOULD_START_RABBIT=no - - RETRIES=200 - matrix: - - SWITCH='-DWHAT_TO_TEST=SLEUTH' - - SWITCH='-DWHAT_TO_TEST=SLEUTH_STREAM' - - SWITCH='-DWHAT_TO_TEST=ZOOKEEPER' - - SWITCH='-DWHAT_TO_TEST=EUREKA' - - SWITCH='-DWHAT_TO_TEST=CONSUL' \ No newline at end of file +- ./mvnw clean install \ No newline at end of file diff --git a/README.md b/README.md index 1140fcd..1b44ce1 100644 --- a/README.md +++ b/README.md @@ -1,201 +1,27 @@ -[![Build Status](https://travis-ci.org/spring-cloud-samples/brewery.svg)](https://travis-ci.org/spring-cloud-samples/brewery) +![Java CI with Maven](https://github.com/spring-cloud-samples/sleuth-documentation-apps/workflows/Java%20CI%20with%20Maven/badge.svg) -# Brewery +# Sleuth documentation apps -Ever wanted to brew your beer using microservices? This repository will allow you to do so! +[Apps used for the Sleuth documentation graphs](https://cloud.spring.io/spring-cloud-sleuth/spring-cloud-sleuth.html) . They're not using +service discovery so don't treat them as reference production applications ;) -This repository is used throughout the Spring Cloud libraries builds as end to end testing set up. Check -[Acceptance Tests Readme](acceptance-tests/README.md) for more information. +The apps are sending spans to Zipkin via RabbitMQ and `spring-cloud-sleuth-stream`. -## How does the brewery work? +# Running acceptance tests -Since pictures say more than words... - -Here is the business flow of the app. Below you'll see more detailed explanation with numbers corresponding -to the numbers in the diagram - -![Diagram](img/Brewery.png) - -And here additional tech related applications: - -![Diagram](img/Tech_apps.png) - -### Presenting service (point of entry to the system) - -Here is the UI - -![UI](img/Brewery_UI.png) - -- Go to the presenting service (http://localhost:9991) and order ingredients **(1)** -- A request from the presenting service is sent to the aggregating service when order is placed **(2)** -- A "PROCESS-ID" header is set and will be passed through each part of beer brewing - -### Brewing service - -Brewing service contains the following functionalities: - -#### Aggregating - -- Service contains a warehouse ("database") where is stores the ingredients -- Basing on the order placed it will contact the Zuul proxy to fetch ingredients **(3)** -- Once the ingredients have been received an event is emitted **(7)** -- You have to have all 4 ingredients reach their threshold (1000) to start maturing the beer -- Once the brewing has been started an event is emitted **(7)** -- Once the threshold is met the application sends a request to the maturing service **(8)** -- Each time a request is sent to the aggregating service it returns as a response its warehouse state - -#### Ingredients - -- Returns a fixed value of ingredients **(5)** - -#### Maturing - -- It receives a request with ingredients needed to brew a beer -- The brewing process starts thanks to the `Thread.sleep` method -- Once it's done an event is emitted **(9)** -- And a request to the bottling service is sent with number of worts **(10)** -- Presenting service is called to update the current status of the beer brewing process - -#### Bottling - -- Waits some time to bottle the beer -- Once it's done an event is emitted **(11)** -- Presenting service is called to update the current status of the beer brewing process **(12)** - -#### Reporting - -- Listens to events and stores them in the "database" - -### Zuul proxy - -- Proxy over the "adapters" to external world to fetch ingredients -- Routes all requests to the respective "ingredient adapter" **(4)** -- For simplicity we have one ingredient adapter called "ingredients" that returns a stubbed quantity -- Returns back the ingredients to the aggregating **(6)** - -## Project structure - -``` -├── acceptance-tests (code containing acceptace-tests of brewery) -├── brewing (service that creates beer - consists of aggregating, maturing, bottling, reporting and ingredients functionalities) -├── common (common code for the services) -├── docker (docker scripts for additional apps - e.g. graphite) -├── config-server (set up for the config server) -├── eureka (Eureka server needed for Eureka tests) -├── git-props (properties for config-server to pick) -├── gradle (gradle related stuff) -├── img (the fabulous diagram of the brewery) -├── presenting (UI of the brewery) -├── zipkin-server (Zipkin Server for Sleuth Stream tests) -├── zookeeper (embedded zookeeper) -└── zuul (Zuul proxy that forwards requests to ingredients) -``` - -## How to build it? - -``` -./gradlew clean build -``` - -## How to build one module? - -E.g. `brewing` module - -``` -./gradlew brewing:clean brewing:build -``` - -## How to run it? - -The easiest way is to: - -* GO to the cloned `brewery` where you have the `runAcceptanceTests.sh` script (which in fact is already a symbolic link to `acceptance-tests/scripts/runDockerAcceptanceTests.sh` - for your convenience) -* You can execute that script with such options - * `-t` what do you want to test (`SLEUTH`, `ZOOKEEPER`, `CONSUL`, `SLEUTH`, `SLEUTH_STREAM`) - * `-v` in which version of the BOM (defaults to `Brixton.BUILD-SNAPSHOT`) - * `-h` where is your docker host? (defaults to '127.0.0.1' - provide your docker-machine host here) - * `-r` is brewery repo already in place and needs to be reset? (defaults to `not` resetting of repo) - * `-k` should the apps and all running docker containers be killed after the tests are executed? pass `-k` to turn on (defaults to `not` killing the apps) - * `-n` should the apps and all running docker containers be killed now and nothing else should happen? pass `-n` to turn on (defaults to `not` doing that) - * `-x` should the apps be booted no tests should be ran? pass `-x` to turn on (defaults to `not` doing that) - * `-s` should the building of apps be skipped? pass `-s` to turn on (defaults to `no` - the apps will be cleaned and built) -* For more options just run `runAcceptanceTests.sh` without any options or with `--help` switch - -Once you run the script, the brewery app will be cloned, built with proper lib versions and proper tests -will be executed. - -You can run this script to have the setup done for you in no time (example for SLEUTH tests execution): +Run: ``` -git clone https://github.com/spring-cloud-samples/brewery.git -cd brewery -bash runAcceptanceTests.sh -t SLEUTH +./runAcceptanceTests.sh ``` -### Examples - -#### I want to just run all the apps and have fun - -Execute: +# Running the apps locally with RabbitMQ -``` -bash runAcceptanceTests.sh -x -``` - -#### I want to just run all the apps with Eureka and have fun +Provide the env variable `DEFAULT_HEALTH_HOST` pointing to your Docker Machine. By default it will be `localhost`. +That way we'll start a RabbitMQ instance for you. -Execute: +Run: ``` -bash runAcceptanceTests.sh -x -t EUREKA +./scripts/start_with_zipkin_server.sh ``` - -#### I want to run end to end tests of Consul and kill all the apps after the tests finish - -Execute: - -``` -bash runAcceptanceTests.sh -t CONSUL -k -``` - -#### I want to run end to end tests of Consul on my docker-machine (ip. 1.2.3.4) and kill all the apps after the tests finish - -Execute: - -``` -bash runAcceptanceTests.sh -t CONSUL -k -h 1.2.3.4 -``` - -#### I want to run end to end tests of Consul, kill all the apps after the tests finish and skip build - -Execute: - -``` -bash runAcceptanceTests.sh -t CONSUL -k -s -``` - -#### I just want to kill all the brewery related apps - -Execute: - -``` -bash runAcceptanceTests.sh -n -``` - - -## How to run a single module? - -To run a single module just execute (e.g. `presenting` module): - -``` -./gradlew presenting:bootRun -Dspring.profiles.active=dev -``` - -## Authors - -The code is ported from https://github.com/uservices-hackathon - -The authors of the initial version of the code are: -- Marcin Grzejszczak (marcingrzejszczak) -- Tomasz Szymanski (szimano) diff --git a/acceptance-tests/.mvn/wrapper/maven-wrapper.properties b/acceptance-tests/.mvn/wrapper/maven-wrapper.properties new file mode 100644 index 0000000..c315043 --- /dev/null +++ b/acceptance-tests/.mvn/wrapper/maven-wrapper.properties @@ -0,0 +1 @@ +distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.0/apache-maven-3.5.0-bin.zip diff --git a/acceptance-tests/mvnw b/acceptance-tests/mvnw new file mode 100755 index 0000000..a1ba1bf --- /dev/null +++ b/acceptance-tests/mvnw @@ -0,0 +1,233 @@ +#!/bin/sh +# ---------------------------------------------------------------------------- +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# ---------------------------------------------------------------------------- + +# ---------------------------------------------------------------------------- +# Maven2 Start Up Batch script +# +# Required ENV vars: +# ------------------ +# JAVA_HOME - location of a JDK home dir +# +# Optional ENV vars +# ----------------- +# M2_HOME - location of maven2's installed home dir +# MAVEN_OPTS - parameters passed to the Java VM when running Maven +# e.g. to debug Maven itself, use +# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +# MAVEN_SKIP_RC - flag to disable loading of mavenrc files +# ---------------------------------------------------------------------------- + +if [ -z "$MAVEN_SKIP_RC" ] ; then + + if [ -f /etc/mavenrc ] ; then + . /etc/mavenrc + fi + + if [ -f "$HOME/.mavenrc" ] ; then + . "$HOME/.mavenrc" + fi + +fi + +# OS specific support. $var _must_ be set to either true or false. +cygwin=false; +darwin=false; +mingw=false +case "`uname`" in + CYGWIN*) cygwin=true ;; + MINGW*) mingw=true;; + Darwin*) darwin=true + # + # Look for the Apple JDKs first to preserve the existing behaviour, and then look + # for the new JDKs provided by Oracle. + # + if [ -z "$JAVA_HOME" ] && [ -L /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK ] ; then + # + # Apple JDKs + # + export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home + fi + + if [ -z "$JAVA_HOME" ] && [ -L /System/Library/Java/JavaVirtualMachines/CurrentJDK ] ; then + # + # Apple JDKs + # + export JAVA_HOME=/System/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home + fi + + if [ -z "$JAVA_HOME" ] && [ -L "/Library/Java/JavaVirtualMachines/CurrentJDK" ] ; then + # + # Oracle JDKs + # + export JAVA_HOME=/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home + fi + + if [ -z "$JAVA_HOME" ] && [ -x "/usr/libexec/java_home" ]; then + # + # Apple JDKs + # + export JAVA_HOME=`/usr/libexec/java_home` + fi + ;; +esac + +if [ -z "$JAVA_HOME" ] ; then + if [ -r /etc/gentoo-release ] ; then + JAVA_HOME=`java-config --jre-home` + fi +fi + +if [ -z "$M2_HOME" ] ; then + ## resolve links - $0 may be a link to maven's home + PRG="$0" + + # need this for relative symlinks + while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG="`dirname "$PRG"`/$link" + fi + done + + saveddir=`pwd` + + M2_HOME=`dirname "$PRG"`/.. + + # make it fully qualified + M2_HOME=`cd "$M2_HOME" && pwd` + + cd "$saveddir" + # echo Using m2 at $M2_HOME +fi + +# For Cygwin, ensure paths are in UNIX format before anything is touched +if $cygwin ; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --unix "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --unix "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --unix "$CLASSPATH"` +fi + +# For Migwn, ensure paths are in UNIX format before anything is touched +if $mingw ; then + [ -n "$M2_HOME" ] && + M2_HOME="`(cd "$M2_HOME"; pwd)`" + [ -n "$JAVA_HOME" ] && + JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" + # TODO classpath? +fi + +if [ -z "$JAVA_HOME" ]; then + javaExecutable="`which javac`" + if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then + # readlink(1) is not available as standard on Solaris 10. + readLink=`which readlink` + if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then + if $darwin ; then + javaHome="`dirname \"$javaExecutable\"`" + javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" + else + javaExecutable="`readlink -f \"$javaExecutable\"`" + fi + javaHome="`dirname \"$javaExecutable\"`" + javaHome=`expr "$javaHome" : '\(.*\)/bin'` + JAVA_HOME="$javaHome" + export JAVA_HOME + fi + fi +fi + +if [ -z "$JAVACMD" ] ; then + if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + else + JAVACMD="`which java`" + fi +fi + +if [ ! -x "$JAVACMD" ] ; then + echo "Error: JAVA_HOME is not defined correctly." >&2 + echo " We cannot execute $JAVACMD" >&2 + exit 1 +fi + +if [ -z "$JAVA_HOME" ] ; then + echo "Warning: JAVA_HOME environment variable is not set." +fi + +CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher + +# For Cygwin, switch paths to Windows format before running java +if $cygwin; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --path --windows "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --windows "$CLASSPATH"` +fi + +# traverses directory structure from process work directory to filesystem root +# first directory with .mvn subdirectory is considered project base directory +find_maven_basedir() { + local basedir=$(pwd) + local wdir=$(pwd) + while [ "$wdir" != '/' ] ; do + if [ -d "$wdir"/.mvn ] ; then + basedir=$wdir + break + fi + wdir=$(cd "$wdir/.."; pwd) + done + echo "${basedir}" +} + +# concatenates all lines of a file +concat_lines() { + if [ -f "$1" ]; then + echo "$(tr -s '\n' ' ' < "$1")" + fi +} + +export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-$(find_maven_basedir)} +MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" + +# Provide a "standardized" way to retrieve the CLI args that will +# work with both Windows and non-Windows executions. +MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" +export MAVEN_CMD_LINE_ARGS + +WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +exec "$JAVACMD" \ + $MAVEN_OPTS \ + -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ + "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ + ${WRAPPER_LAUNCHER} "$@" diff --git a/acceptance-tests/mvnw.cmd b/acceptance-tests/mvnw.cmd new file mode 100644 index 0000000..5a8e45d --- /dev/null +++ b/acceptance-tests/mvnw.cmd @@ -0,0 +1,145 @@ +@REM ---------------------------------------------------------------------------- +@REM Licensed to the Apache Software Foundation (ASF) under one +@REM or more contributor license agreements. See the NOTICE file +@REM distributed with this work for additional information +@REM regarding copyright ownership. The ASF licenses this file +@REM to you under the Apache License, Version 2.0 (the +@REM "License"); you may not use this file except in compliance +@REM with the License. You may obtain a copy of the License at +@REM +@REM http://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, +@REM software distributed under the License is distributed on an +@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +@REM KIND, either express or implied. See the License for the +@REM specific language governing permissions and limitations +@REM under the License. +@REM ---------------------------------------------------------------------------- + +@REM ---------------------------------------------------------------------------- +@REM Maven2 Start Up Batch script +@REM +@REM Required ENV vars: +@REM JAVA_HOME - location of a JDK home dir +@REM +@REM Optional ENV vars +@REM M2_HOME - location of maven2's installed home dir +@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands +@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending +@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven +@REM e.g. to debug Maven itself, use +@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,city=8000 +@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files +@REM ---------------------------------------------------------------------------- + +@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' +@echo off +@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on' +@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% + +@REM set %HOME% to equivalent of $HOME +if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") + +@REM Execute a user defined script before this one +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre +@REM check for pre script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" +if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" +:skipRcPre + +@setlocal + +set ERROR_CODE=0 + +@REM To isolate internal variables from possible post scripts, we use another setlocal +@setlocal + +@REM ==== START VALIDATION ==== +if not "%JAVA_HOME%" == "" goto OkJHome + +echo. +echo Error: JAVA_HOME not found in your environment. >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +:OkJHome +if exist "%JAVA_HOME%\bin\java.exe" goto init + +echo. +echo Error: JAVA_HOME is set to an invalid directory. >&2 +echo JAVA_HOME = "%JAVA_HOME%" >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +@REM ==== END VALIDATION ==== + +:init + +set MAVEN_CMD_LINE_ARGS=%* + +@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". +@REM Fallback to current working directory if not found. + +set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% +IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir + +set EXEC_DIR=%CD% +set WDIR=%EXEC_DIR% +:findBaseDir +IF EXIST "%WDIR%"\.mvn goto baseDirFound +cd .. +IF "%WDIR%"=="%CD%" goto baseDirNotFound +set WDIR=%CD% +goto findBaseDir + +:baseDirFound +set MAVEN_PROJECTBASEDIR=%WDIR% +cd "%EXEC_DIR%" +goto endDetectBaseDir + +:baseDirNotFound +set MAVEN_PROJECTBASEDIR=%EXEC_DIR% +cd "%EXEC_DIR%" + +:endDetectBaseDir + +IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig + +@setlocal EnableExtensions EnableDelayedExpansion +for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a +@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% + +:endReadAdditionalConfig + +SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" + +set WRAPPER_JAR="".\.mvn\wrapper\maven-wrapper.jar"" +set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CMD_LINE_ARGS% +if ERRORLEVEL 1 goto error +goto end + +:error +set ERROR_CODE=1 + +:end +@endlocal & set ERROR_CODE=%ERROR_CODE% + +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost +@REM check for post script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" +if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" +:skipRcPost + +@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' +if "%MAVEN_BATCH_PAUSE%" == "on" pause + +if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% + +exit /B %ERROR_CODE% \ No newline at end of file diff --git a/acceptance-tests/pom.xml b/acceptance-tests/pom.xml new file mode 100644 index 0000000..5175203 --- /dev/null +++ b/acceptance-tests/pom.xml @@ -0,0 +1,186 @@ + + + 4.0.0 + io.spring.cloud.sleuth.docs + acceptance-tests + 1.0.0.SLEUTH_DOCS + + + org.springframework.boot + spring-boot-starter-parent + 2.7.4 + + + + + 2021.0.2-SNAPSHOT + UTF-8 + UTF-8 + 1.8 + + + + org.aspectj + aspectjrt + compile + + + org.springframework.boot + spring-boot-starter-web + compile + + + org.codehaus.groovy + groovy + + + org.codehaus.groovy + groovy-json + + + org.springframework.boot + spring-boot-starter-actuator + test + + + org.awaitility + awaitility + 4.2.0 + test + + + org.springframework.boot + spring-boot-starter-test + test + + + org.springframework.cloud + spring-cloud-starter-sleuth + test + + + io.zipkin.java + zipkin + 2.10.1 + test + + + + + + org.springframework.cloud + spring-cloud-dependencies + ${spring-cloud.version} + import + pom + + + org.codehaus.groovy + groovy-all + 3.0.19 + pom + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + + **/*Test.* + **/*Tests.* + + true + + + + org.codehaus.gmavenplus + gmavenplus-plugin + 2.1.0 + + + + compileTests + addTestSources + + + + + + + ${project.basedir}/src/test/groovy + + **/*.groovy + + + + + + + + + + + spring-snapshots + Spring Snapshots + https://repo.spring.io/snapshot + + true + + + + spring-milestones + Spring Milestones + https://repo.spring.io/milestone + + false + + + + spring-releases + Spring Releases + https://repo.spring.io/release + + false + + + + + + spring-snapshots + Spring Snapshots + https://repo.spring.io/snapshot + + true + + + + spring-milestones + Spring Milestones + https://repo.spring.io/milestone + + false + + + + spring-plugin-snapshots + Spring Snapshots + https://repo.spring.io/snapshot + + true + + + + spring-plugin-milestones + Spring Milestones + https://repo.spring.io/release + + false + + + + + diff --git a/acceptance-tests/src/main/resources/banner.txt b/acceptance-tests/src/main/resources/banner.txt new file mode 100644 index 0000000..e76f0ed --- /dev/null +++ b/acceptance-tests/src/main/resources/banner.txt @@ -0,0 +1,5 @@ + _ ___ ___ __ ___ _____ _ __ ___ __ _____ __ __ _____ __ + /_\ / __\ / __\ /__\/ _ \/__ \/_\ /\ \ \/ __\ /__\ /__ \/__\/ _\/__ \/ _\ + //_\\ / / / / /_\ / /_)/ / /\//_\\ / \/ / / /_\_____ / /\/_\ \ \ / /\/\ \ +/ _ \/ /___/ /___//__/ ___/ / / / _ \/ /\ / /___//_|_____/ / //__ _\ \ / / _\ \ +\_/ \_/\____/\____/\__/\/ \/ \_/ \_/\_\ \/\____/\__/ \/ \__/ \__/ \/ \__/ diff --git a/acceptance-tests/src/test/groovy/io/spring/cloud/samples/docs/acceptance/MessageFlowTests.groovy b/acceptance-tests/src/test/groovy/io/spring/cloud/samples/docs/acceptance/MessageFlowTests.groovy new file mode 100644 index 0000000..2ac2e7f --- /dev/null +++ b/acceptance-tests/src/test/groovy/io/spring/cloud/samples/docs/acceptance/MessageFlowTests.groovy @@ -0,0 +1,247 @@ +/* + * Copyright 2013-2015 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package io.spring.cloud.samples.docs.acceptance + +import groovy.json.JsonSlurper +import groovy.transform.CompileDynamic +import groovy.transform.CompileStatic +import groovy.util.logging.Slf4j +import io.spring.cloud.samples.docs.acceptance.common.tech.ExceptionLoggingRestTemplate +import io.spring.cloud.samples.docs.acceptance.common.tech.SpanUtil +import io.spring.cloud.samples.docs.acceptance.common.tech.TestConfiguration +import org.awaitility.core.ThrowingRunnable +import org.junit.jupiter.api.Test +import zipkin2.Span +import zipkin2.codec.SpanBytesDecoder + +import org.springframework.beans.factory.annotation.Value +import org.springframework.boot.test.context.SpringBootTest +import org.springframework.http.HttpHeaders +import org.springframework.http.HttpMethod +import org.springframework.http.HttpStatus +import org.springframework.http.RequestEntity +import org.springframework.http.ResponseEntity +import org.springframework.web.client.RestTemplate + +import static java.util.concurrent.TimeUnit.SECONDS +import static org.awaitility.Awaitility.await + +@SpringBootTest(classes = TestConfiguration) +@Slf4j +@CompileStatic +class MessageFlowTests { + + public static final String TRACE_ID_HEADER_NAME = "X-B3-TraceId" + public static final String SPAN_ID_NAME = "X-B3-SpanId" + private static final List APP_NAMES = ['service1', 'service2', 'service3', 'service4'] + + @Value('${service1.address:http://localhost:8081}') + String service1Url + @Value('${zipkin.query.port:9411}') + Integer zipkinQueryPort + @Value('${LOCAL_URL:http://localhost}') + String zipkinQueryUrl + + @Test + void 'should send message to service1 and receive combined response for traceId'() { + String traceId = SpanUtil.idToHex(new Random().nextLong()) + //given: "Request with a traceId" + RequestEntity request = request_to_service1(traceId) + //when: "Request is sent to the Service1" + request_sent_for_service1_with_traceId(request) + //then: "Entry in Zipkin is present for the traceId" + entry_for_trace_id_is_present_in_Zipkin(traceId) + //and: "The dependency graph looks like in the docs" + dependency_graph_is_correct() + } + + @Test + void 'should send message to service1 and get read timeout'() { + String traceId = SpanUtil.idToHex(new Random().nextLong()) + //given: "Request with a traceId" + RequestEntity request = request_to_service1_at_readtimeout(traceId) + //when: "Failing request is sent to the Service1" + failing_request_sent_for_service1_with_traceId(request) + //then: "Entry in Zipkin is present for the traceId" + failed_entry_for_trace_id_is_present_in_Zipkin(traceId) + } + + @CompileStatic + private void request_sent_for_service1_with_traceId(RequestEntity request) { + await().pollInterval(1, SECONDS).atMost(60, SECONDS).untilAsserted(new ThrowingRunnable() { + @Override + void run() { + ResponseEntity service1Response = restTemplate().exchange(request, String) + log.info("Response from service1Response is [$service1Response]") + assert service1Response != null + assert service1Response.statusCode == HttpStatus.OK + assert service1Response.body.contains('Hello from service2, response from service3 [Hello from service3] and from service4 [Hello from service4]') + log.info("The Sleuth Docs apps are working! Let's be happy!") + } + }) + } + + @CompileStatic + private failing_request_sent_for_service1_with_traceId(RequestEntity request) { + await().pollInterval(1, SECONDS).atMost(60, SECONDS).untilAsserted(new ThrowingRunnable() { + @Override + void run() { + ResponseEntity service1Response = restTemplate().exchange(request, String) + log.info("Response from service1Response is [$service1Response]") + assert service1Response != null + assert service1Response.statusCode == HttpStatus.INTERNAL_SERVER_ERROR || service1Response.body.contains('''"status":500,"error":"Internal Server Error"''') + } + }) + } + + private RequestEntity request_to_service1(String traceId) { + HttpHeaders headers = new HttpHeaders() + headers.add(SPAN_ID_NAME, traceId) + headers.add(TRACE_ID_HEADER_NAME, traceId) + URI uri = URI.create(wrapWithProtocolIfPresent("$service1Url/start")) + RequestEntity requestEntity = new RequestEntity<>(headers, HttpMethod.POST, uri) + log.info("Request with traceid [$traceId] to service1 [$requestEntity] is ready") + return requestEntity + } + + private RequestEntity request_to_service1_at_readtimeout(String traceId) { + HttpHeaders headers = new HttpHeaders() + headers.add(SPAN_ID_NAME, traceId) + headers.add(TRACE_ID_HEADER_NAME, traceId) + URI uri = URI.create(wrapWithProtocolIfPresent("$service1Url/readtimeout")) + RequestEntity requestEntity = new RequestEntity<>(headers, HttpMethod.POST, uri) + log.info("Request with traceid [$traceId] to service1 [$requestEntity] is ready") + return requestEntity + } + + private void entry_for_trace_id_is_present_in_Zipkin(String traceId) { + await().pollInterval(1, SECONDS).atMost(60, SECONDS).untilAsserted(new ThrowingRunnable() { + @Override + @CompileDynamic + void run() { + ResponseEntity response = checkStateOfTheTraceId(traceId) + log.info("Response from the Zipkin query service about the trace id [$response] for trace with id [$traceId]") + assert response.statusCode == HttpStatus.OK + assert response.hasBody() + log.info("Checking spans") + List spans = SpanBytesDecoder.JSON_V2.decodeList(response.body.bytes) + List serviceNamesNotFoundInZipkin = serviceNamesNotFoundInZipkin(spans) + log.info("The following services were not found in Zipkin $serviceNamesNotFoundInZipkin") + assert serviceNamesNotFoundInZipkin.empty + log.info("Zipkin tracing is working! Sleuth is working! Let's be happy!") + } + + @CompileDynamic + private List serviceNamesNotFoundInZipkin(List spans) { + List remoteServiceName = spans.collect { + it.remoteServiceName() + }.flatten().unique() + List localServiceName = spans.collect { + it.localServiceName() + }.flatten().unique() + return (APP_NAMES - remoteServiceName - localServiceName) + } + }) + } + + private void failed_entry_for_trace_id_is_present_in_Zipkin(String traceId) { + await().pollInterval(1, SECONDS).atMost(60, SECONDS).untilAsserted(new ThrowingRunnable() { + @Override + @CompileDynamic + void run() { + ResponseEntity response = checkStateOfTheTraceId(traceId) + log.info("Response from the Zipkin query service about the trace id [$response] for trace with id [$traceId]") + assert response.statusCode == HttpStatus.OK + assert response.hasBody() + List spans = SpanBytesDecoder.JSON_V2.decodeList(response.body.bytes) + // we're checking if the latest annotation based functionality is working + Span foundSpan = spans.find { + it.name() == "first_span" && it.tags().find { it.key == "someTag" } && + // Brave || Otel + it.tags().find { it.key == "error" } || it.annotations().find { it.value() == "exception" } + } + log.info("The following spans <{}> were found in Zipkin for the traceid <{}>", spans, traceId) + log.info("Span with name [first_span] found? [" + foundSpan + "]") + assert foundSpan != null + log.info("Zipkin tracing is working! Sleuth is working! Let's be happy!") + } + }) + } + + private String parsedZipkinQuery() { + return zipkinQueryUrl.split(" ")[0] + } + + private ResponseEntity checkStateOfTheTraceId(String traceId) { + URI uri = URI.create("${wrapQueryWithProtocolIfPresent() ?: parsedZipkinQuery()}:${zipkinQueryPort}/api/v2/trace/$traceId") + HttpHeaders headers = new HttpHeaders() + log.info("Sending request to the Zipkin query service [$uri]. Checking presence of trace id [$traceId]") + return new ExceptionLoggingRestTemplate().exchange( + new RequestEntity<>(headers, HttpMethod.GET, uri), String + ) + } + + @CompileDynamic + private void dependency_graph_is_correct() { + await().pollInterval(1, SECONDS).atMost(60, SECONDS).untilAsserted(new ThrowingRunnable() { + @Override + void run() { + ResponseEntity response = checkDependencies() + log.info("Response from the Zipkin query service about the dependencies [$response]") + assert response.statusCode == HttpStatus.OK + assert response.hasBody() + Map> parentsAndChildren = [:] + new JsonSlurper().parseText(response.body).inject(parentsAndChildren) { Map acc, def json -> + def list = acc[json.parent] ?: [] + list << json.child + acc.put(json.parent, list) + return acc + } + assert parentsAndChildren['service1'] == ['service2'] + assert parentsAndChildren['service2'].containsAll(['service3', 'service4']) + } + }) + } + + private ResponseEntity checkDependencies() { + URI uri = URI.create(wrapWithProtocolIfPresent("${wrapQueryWithProtocolIfPresent() ?: parsedZipkinQuery()}:${zipkinQueryPort}/api/v2/dependencies?endTs=${System.currentTimeMillis()}")) + HttpHeaders headers = new HttpHeaders() + log.info("Sending request to the Zipkin query service [$uri]. Checking the dependency graph") + return new ExceptionLoggingRestTemplate().exchange( + new RequestEntity<>(headers, HttpMethod.GET, uri), String + ) + } + + private String wrapQueryWithProtocolIfPresent() { + String zipkinUrlFromEnvs = System.getenv('spring.zipkin.query.url') + if (zipkinUrlFromEnvs) { + zipkinUrlFromEnvs = zipkinUrlFromEnvs.split(" ")[0] + return "https://$zipkinurlfromenvs/" + } + return zipkinUrlFromEnvs + } + + private String wrapWithProtocolIfPresent(String url) { + if (!url.startsWith("http")) { + return "http://$url/" + } + return url + } + + private RestTemplate restTemplate() { + return new ExceptionLoggingRestTemplate() + } +} diff --git a/acceptance-tests/src/test/groovy/io/spring/cloud/samples/docs/acceptance/common/tech/ExceptionLoggingErrorHandler.groovy b/acceptance-tests/src/test/groovy/io/spring/cloud/samples/docs/acceptance/common/tech/ExceptionLoggingErrorHandler.groovy new file mode 100644 index 0000000..3b94e9e --- /dev/null +++ b/acceptance-tests/src/test/groovy/io/spring/cloud/samples/docs/acceptance/common/tech/ExceptionLoggingErrorHandler.groovy @@ -0,0 +1,15 @@ +package io.spring.cloud.samples.docs.acceptance.common.tech + +import groovy.util.logging.Slf4j +import org.springframework.http.client.ClientHttpResponse +import org.springframework.web.client.DefaultResponseErrorHandler + +@Slf4j +class ExceptionLoggingErrorHandler extends DefaultResponseErrorHandler { + @Override + void handleError(ClientHttpResponse response) throws IOException { + if (hasError(response)) { + log.error("Response has status code [${response.statusCode}] and text [${response.statusText}]") + } + } +} diff --git a/acceptance-tests/src/test/groovy/io/spring/cloud/samples/docs/acceptance/common/tech/ExceptionLoggingRestTemplate.groovy b/acceptance-tests/src/test/groovy/io/spring/cloud/samples/docs/acceptance/common/tech/ExceptionLoggingRestTemplate.groovy new file mode 100644 index 0000000..793233f --- /dev/null +++ b/acceptance-tests/src/test/groovy/io/spring/cloud/samples/docs/acceptance/common/tech/ExceptionLoggingRestTemplate.groovy @@ -0,0 +1,26 @@ +package io.spring.cloud.samples.docs.acceptance.common.tech + +import groovy.util.logging.Slf4j +import org.springframework.http.HttpMethod +import org.springframework.web.client.RequestCallback +import org.springframework.web.client.ResponseExtractor +import org.springframework.web.client.RestClientException +import org.springframework.web.client.RestTemplate + +@Slf4j +class ExceptionLoggingRestTemplate extends RestTemplate { + + ExceptionLoggingRestTemplate() { + errorHandler = new ExceptionLoggingErrorHandler() + } + + @Override + protected T doExecute(URI url, HttpMethod method, RequestCallback requestCallback, ResponseExtractor responseExtractor) throws RestClientException { + try { + return super.doExecute(url, method, requestCallback, responseExtractor) + } catch (Exception e) { + log.error("Exception occurred while trying to send a request", e) + throw new AssertionError(e) + } + } +} diff --git a/acceptance-tests/src/test/groovy/io/spring/cloud/samples/docs/acceptance/common/tech/TestConfiguration.groovy b/acceptance-tests/src/test/groovy/io/spring/cloud/samples/docs/acceptance/common/tech/TestConfiguration.groovy new file mode 100644 index 0000000..5cd359d --- /dev/null +++ b/acceptance-tests/src/test/groovy/io/spring/cloud/samples/docs/acceptance/common/tech/TestConfiguration.groovy @@ -0,0 +1,9 @@ +package io.spring.cloud.samples.docs.acceptance.common.tech +import org.springframework.boot.autoconfigure.EnableAutoConfiguration +import org.springframework.context.annotation.Configuration + +@Configuration +@EnableAutoConfiguration +class TestConfiguration { + +} diff --git a/acceptance-tests/src/test/java/io/spring/cloud/samples/docs/acceptance/common/tech/SpanUtil.java b/acceptance-tests/src/test/java/io/spring/cloud/samples/docs/acceptance/common/tech/SpanUtil.java new file mode 100644 index 0000000..78c355d --- /dev/null +++ b/acceptance-tests/src/test/java/io/spring/cloud/samples/docs/acceptance/common/tech/SpanUtil.java @@ -0,0 +1,37 @@ +package io.spring.cloud.samples.docs.acceptance.common.tech; + +/** + * @author Marcin Grzejszczak + * @since + */ +public class SpanUtil { + + /** + * Represents given long id as 16-character lower-hex string + */ + public static String idToHex(long id) { + char[] data = new char[16]; + writeHexLong(data, 0, id); + return new String(data); + } + + /** Inspired by {@code okio.Buffer.writeLong} */ + static void writeHexLong(char[] data, int pos, long v) { + writeHexByte(data, pos + 0, (byte) ((v >>> 56L) & 0xff)); + writeHexByte(data, pos + 2, (byte) ((v >>> 48L) & 0xff)); + writeHexByte(data, pos + 4, (byte) ((v >>> 40L) & 0xff)); + writeHexByte(data, pos + 6, (byte) ((v >>> 32L) & 0xff)); + writeHexByte(data, pos + 8, (byte) ((v >>> 24L) & 0xff)); + writeHexByte(data, pos + 10, (byte) ((v >>> 16L) & 0xff)); + writeHexByte(data, pos + 12, (byte) ((v >>> 8L) & 0xff)); + writeHexByte(data, pos + 14, (byte) (v & 0xff)); + } + + static void writeHexByte(char[] data, int pos, byte b) { + data[pos + 0] = HEX_DIGITS[(b >> 4) & 0xf]; + data[pos + 1] = HEX_DIGITS[b & 0xf]; + } + + static final char[] HEX_DIGITS = + {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'}; +} diff --git a/acceptance-tests/src/test/resources/bootstrap.yaml b/acceptance-tests/src/test/resources/bootstrap.yaml new file mode 100644 index 0000000..4c8b246 --- /dev/null +++ b/acceptance-tests/src/test/resources/bootstrap.yaml @@ -0,0 +1,3 @@ +spring: + application: + name: acceptance-tests \ No newline at end of file diff --git a/acceptance-tests/src/test/resources/logback-test.xml b/acceptance-tests/src/test/resources/logback-test.xml new file mode 100644 index 0000000..ee27473 --- /dev/null +++ b/acceptance-tests/src/test/resources/logback-test.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/build.gradle b/build.gradle deleted file mode 100644 index f188efa..0000000 --- a/build.gradle +++ /dev/null @@ -1,95 +0,0 @@ -buildscript { - repositories { - mavenLocal() - jcenter() - mavenCentral() - } - dependencies { - classpath "org.springframework.boot:spring-boot-gradle-plugin:1.3.2.RELEASE" - } -} - -allprojects { - apply plugin: 'java' -} - -configure(subprojects) { - - apply plugin: 'java' - apply plugin: 'eclipse' - apply plugin: 'idea' - apply plugin: 'spring-boot' - - ext { - systemPropsFromGradle = { - project.gradle.startParameter.systemPropertiesArgs.entrySet().collect{"-D${it.key}=${it.value}"} - } - buildNrLoc = project.hasProperty('buildNr') ? "${buildNr}" : "1.0.0" - } - - group = 'io.spring.cloud.sleuth.docs' - version = buildNrLoc - - sourceCompatibility = '1.8' - - configurations { - all { - resolutionStrategy { - eachDependency { DependencyResolveDetails details -> - // To prevent an accidental usage of groovy-all.jar and groovy.jar in different versions - // all modularized Groovy jars are replaced with groovy-all.jar by default. - if (details.requested.group == 'org.codehaus.groovy' && details.requested.name != "groovy-all") { - details.useTarget("org.codehaus.groovy:groovy-all:${details.requested.version}") - } - } - } - } - } - - repositories { - mavenLocal() - jcenter() - maven { - url "http://repo.spring.io/snapshot" - } - maven { - url "http://repo.spring.io/milestone" - } - } - - dependencyManagement { - imports { - mavenBom "org.springframework.cloud:spring-cloud-starter-parent:$BOM_VERSION" - } - } -} - -configure(subprojects) { - - dependencies { - compile "org.springframework.boot:spring-boot-starter-web" - compile "org.springframework:spring-web" - compile 'org.apache.tomcat.embed:tomcat-embed-core:8.0.23' - compile "org.springframework.cloud:spring-cloud-starter-hystrix" - compile "org.springframework.cloud:spring-cloud-starter-zipkin" - compile "org.springframework.boot:spring-boot-starter-actuator" - compile "org.springframework:spring-context-support" - compile 'com.fasterxml.jackson.core:jackson-databind' - compile "org.codehaus.jackson:jackson-mapper-asl:$jacksonMapper" - compile "org.codehaus.jackson:jackson-core-asl:$jacksonMapper" - compile "org.aspectj:aspectjrt" - - runtime 'cglib:cglib-nodep:3.1' - runtime 'org.objenesis:objenesis:2.2' - runtime 'org.aspectj:aspectjweaver' - } - - wrapper { - gradleVersion '2.11' - } - - bootRun { - jvmArgs = systemPropsFromGradle() - } - -} diff --git a/deploy_script b/deploy_script new file mode 100644 index 0000000..5107cea --- /dev/null +++ b/deploy_script @@ -0,0 +1,12 @@ +cd service1 +cf push +cd .. +cd service2 +cf push +cd .. +cd service3 +cf push +cd .. +cd service4 +cf push + diff --git a/docker-compose-rabbit.yml b/docker-compose-rabbit.yml new file mode 100644 index 0000000..c188b5c --- /dev/null +++ b/docker-compose-rabbit.yml @@ -0,0 +1,5 @@ +rabbitmq: + image: rabbitmq:management + ports: + - 5672:5672 + - 15672:15672 diff --git a/docker-compose.yml b/docker-compose.yml index 6ee8355..db4787e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,34 +1,5 @@ -mysql: - image: openzipkin/zipkin-mysql:1.33.2 - ports: - - 3306:3306 - -query: - image: openzipkin/zipkin-java:0.5.3 - environment: - # Remove TRANSPORT_TYPE to disable tracing - - TRANSPORT_TYPE=http - - STORAGE_TYPE=mysql - ports: - - 9411:9411 - - 9901:9901 - links: - - mysql:storage - -web: - image: openzipkin/zipkin-web:1.33.2 - environment: - # Remove TRANSPORT_TYPE to disable tracing - - TRANSPORT_TYPE=http - ports: - - 8080:8080 - - 9990:9990 - links: - - query - rabbitmq: image: rabbitmq:management ports: - 9672:5672 - - 15672 - + - 15672:15672 diff --git a/docs/analysis.txt b/docs/analysis.txt deleted file mode 100644 index 0c6e97e..0000000 --- a/docs/analysis.txt +++ /dev/null @@ -1,27 +0,0 @@ -SPAN A (CS + CR) - -[{"traceId":"c2222484229d0442","name":"http:/start","id":"c2222484229d0442","timestamp":1456485146726000,"duration":968878000,"annotations":[{"endpoint":{"serviceName":"service1","ipv4":"10.69.252.83","port":65535},"timestamp":1456485847641000,"value":"cs"},{"endpoint":{"serviceName":"service1","ipv4":"10.69.252.83","port":65535},"timestamp":1456486115567000,"value":"cr"}],"binaryAnnotations":[{"key":"http.url","value":"http://localhost:8081/start","endpoint":{"serviceName":"service1","ipv4":"10.69.252.83","port":65535}},{"key":"http.host","value":"localhost","endpoint":{"serviceName":"service1","ipv4":"10.69.252.83","port":65535}},{"key":"http.path","value":"/start","endpoint":{"serviceName":"service1","ipv4":"10.69.252.83","port":65535}},{"key":"http.method","value":"GET","endpoint":{"serviceName":"service1","ipv4":"10.69.252.83","port":65535}},{"key":"http.status_code","value":"500","endpoint":{"serviceName":"service1","ipv4":"10.69.252.83","port":65535}}]}] - -SPAN A (SR + SS) - -[{"traceId":"c2222484229d0442","name":"http:/start","id":"c2222484229d0442","timestamp":1456485914794000,"duration":391322000,"annotations":[{"endpoint":{"serviceName":"service2","ipv4":"10.69.252.83","port":65535},"timestamp":1456485959919000,"value":"sr"},{"endpoint":{"serviceName":"service2","ipv4":"10.69.252.83","port":65535},"timestamp":1456486115559000,"value":"ss"}],"binaryAnnotations":[]}] - -SPAN B (CS + CR) - -[{"traceId":"c2222484229d0442","name":"http:/foo","id":"f5d80382128237cb","parentId":"c2222484229d0442","timestamp":1456485940662000,"duration":367527000,"annotations":[{"endpoint":{"serviceName":"service2","ipv4":"10.69.252.83","port":65535},"timestamp":1456485980431000,"value":"cs"},{"endpoint":{"serviceName":"service2","ipv4":"10.69.252.83","port":65535},"timestamp":1456486033121000,"value":"cr"},{"endpoint":{"serviceName":"service2","ipv4":"10.69.252.83","port":65535},"timestamp":1456486082905000,"value":"cs"},{"endpoint":{"serviceName":"service2","ipv4":"10.69.252.83","port":65535},"timestamp":1456486115502000,"value":"cr"}],"binaryAnnotations":[{"key":"http.url","value":"http://localhost:8082/foo","endpoint":{"serviceName":"service2","ipv4":"10.69.252.83","port":65535}},{"key":"http.host","value":"localhost","endpoint":{"serviceName":"service2","ipv4":"10.69.252.83","port":65535}},{"key":"http.path","value":"/foo","endpoint":{"serviceName":"service2","ipv4":"10.69.252.83","port":65535}},{"key":"http.method","value":"GET","endpoint":{"serviceName":"service2","ipv4":"10.69.252.83","port":65535}}]}] - -SPAN B (SR + SS - service3) - -[{"traceId":"c2222484229d0442","name":"http:/foo","id":"f5d80382128237cb","parentId":"c2222484229d0442","timestamp":1456486004295000,"duration":461997000,"annotations":[{"endpoint":{"serviceName":"service3","ipv4":"10.69.252.83","port":65535},"timestamp":1456486033065000,"value":"sr"},{"endpoint":{"serviceName":"service3","ipv4":"10.69.252.83","port":65535},"timestamp":1456486033114000,"value":"ss"}],"binaryAnnotations":[]}] - -SPAN B (SR + SS - service4) - -[{"traceId":"c2222484229d0442","name":"http:/foo","id":"f5d80382128237cb","parentId":"c2222484229d0442","timestamp":1456486087231000,"duration":496896000,"annotations":[{"endpoint":{"serviceName":"service4","ipv4":"10.69.252.83","port":65535},"timestamp":1456486115460000,"value":"sr"},{"endpoint":{"serviceName":"service4","ipv4":"10.69.252.83","port":65535},"timestamp":1456486115503000,"value":"ss"}],"binaryAnnotations":[]}] - -SPAN C - -[{"traceId":"c2222484229d0442","name":"http:/bar","id":"fba87415b0113111","parentId":"f5d80382128237cb","timestamp":1456486022451000,"duration":446351000,"annotations":[],"binaryAnnotations":[{"key":"http.url","value":"http://localhost:8083/bar","endpoint":{"serviceName":"service3","ipv4":"10.69.252.83","port":65535}},{"key":"http.host","value":"localhost","endpoint":{"serviceName":"service3","ipv4":"10.69.252.83","port":65535}},{"key":"http.path","value":"/bar","endpoint":{"serviceName":"service3","ipv4":"10.69.252.83","port":65535}},{"key":"http.method","value":"GET","endpoint":{"serviceName":"service3","ipv4":"10.69.252.83","port":65535}}]}] - -SPAN D - -[{"traceId":"c2222484229d0442","name":"http:/baz","id":"72411986da0589d1","parentId":"f5d80382128237cb","timestamp":1456486087232000,"duration":497511000,"annotations":[],"binaryAnnotations":[{"key":"http.url","value":"http://localhost:8084/baz","endpoint":{"serviceName":"service4","ipv4":"10.69.252.83","port":65535}},{"key":"http.host","value":"localhost","endpoint":{"serviceName":"service4","ipv4":"10.69.252.83","port":65535}},{"key":"http.path","value":"/baz","endpoint":{"serviceName":"service4","ipv4":"10.69.252.83","port":65535}},{"key":"http.method","value":"GET","endpoint":{"serviceName":"service4","ipv4":"10.69.252.83","port":65535}}]}] diff --git a/docs/duration_for_non_remote.txt b/docs/duration_for_non_remote.txt deleted file mode 100644 index 5e03ae8..0000000 --- a/docs/duration_for_non_remote.txt +++ /dev/null @@ -1,323 +0,0 @@ -build/service1.log: -{"traceId":"0ae504ece23418aa","name":"http:/start","id":"0ae504ece23418aa","timestamp":1456494334091000,"duration":1048000,"annotations":[{"endpoint":{"serviceName":"service1","ipv4":"10.69.252.83","port":65535},"timestamp":1456494334096000,"value":"cs"},{"endpoint":{"serviceName":"service1","ipv4":"10.69.252.83","port":65535},"timestamp":1456494335032000,"value":"cr"}],"binaryAnnotations":[{"key":"http.url","value":"http://localhost:8081/start","endpoint":{"serviceName":"service1","ipv4":"10.69.252.83","port":65535}},{"key":"http.host","value":"localhost","endpoint":{"serviceName":"service1","ipv4":"10.69.252.83","port":65535}},{"key":"http.path","value":"/start","endpoint":{"serviceName":"service1","ipv4":"10.69.252.83","port":65535}},{"key":"http.method","value":"GET","endpoint":{"serviceName":"service1","ipv4":"10.69.252.83","port":65535}}]} - -build/service2.log: -{"traceId":"0ae504ece23418aa","name":"http:/start","id":"0ae504ece23418aa","timestamp":1456494334097000,"annotations":[{"endpoint":{"serviceName":"service2","ipv4":"10.69.252.83","port":65535},"timestamp":1456494334098000,"value":"sr"},{"endpoint":{"serviceName":"service2","ipv4":"10.69.252.83","port":65535},"timestamp":1456494335032000,"value":"ss"}],"binaryAnnotations":[]} - -build/service2.log: -{"traceId":"0ae504ece23418aa","name":"http:/foo","id":"62b45b766b711741","parentId":"0ae504ece23418aa","timestamp":1456494334097000,"duration":936000,"annotations":[{"endpoint":{"serviceName":"service2","ipv4":"10.69.252.83","port":65535},"timestamp":1456494334305000,"value":"cs"},{"endpoint":{"serviceName":"service2","ipv4":"10.69.252.83","port":65535},"timestamp":1456494334617000,"value":"cr"},{"endpoint":{"serviceName":"service2","ipv4":"10.69.252.83","port":65535},"timestamp":1456494334618000,"value":"cs"},{"endpoint":{"serviceName":"service2","ipv4":"10.69.252.83","port":65535},"timestamp":1456494335030000,"value":"cr"}],"binaryAnnotations":[{"key":"http.url","value":"http://localhost:8082/foo","endpoint":{"serviceName":"service2","ipv4":"10.69.252.83","port":65535}},{"key":"http.host","value":"localhost","endpoint":{"serviceName":"service2","ipv4":"10.69.252.83","port":65535}},{"key":"http.path","value":"/foo","endpoint":{"serviceName":"service2","ipv4":"10.69.252.83","port":65535}},{"key":"http.method","value":"GET","endpoint":{"serviceName":"service2","ipv4":"10.69.252.83","port":65535}}]} - -build/service3.log: -{"traceId":"0ae504ece23418aa","name":"http:/foo","id":"62b45b766b711741","parentId":"0ae504ece23418aa","timestamp":1456494334307000,"annotations":[{"endpoint":{"serviceName":"service3","ipv4":"10.69.252.83","port":65535},"timestamp":1456494334307000,"value":"sr"},{"endpoint":{"serviceName":"service3","ipv4":"10.69.252.83","port":65535},"timestamp":1456494334617000,"value":"ss"}],"binaryAnnotations":[]} - -build/service3.log: -{"traceId":"0ae504ece23418aa","name":"http:/bar","id":"ae2224ee81db30b1","parentId":"62b45b766b711741","timestamp":1456494334307000,"duration":311000,"annotations":[],"binaryAnnotations":[{"key":"http.url","value":"http://localhost:8083/bar","endpoint":{"serviceName":"service3","ipv4":"10.69.252.83","port":65535}},{"key":"http.host","value":"localhost","endpoint":{"serviceName":"service3","ipv4":"10.69.252.83","port":65535}},{"key":"http.path","value":"/bar","endpoint":{"serviceName":"service3","ipv4":"10.69.252.83","port":65535}},{"key":"http.method","value":"GET","endpoint":{"serviceName":"service3","ipv4":"10.69.252.83","port":65535}}]} - -build/service4.log: -{"traceId":"0ae504ece23418aa","name":"http:/foo","id":"62b45b766b711741","parentId":"0ae504ece23418aa","timestamp":1456494334622000,"annotations":[{"endpoint":{"serviceName":"service4","ipv4":"10.69.252.83","port":65535},"timestamp":1456494334622000,"value":"sr"},{"endpoint":{"serviceName":"service4","ipv4":"10.69.252.83","port":65535},"timestamp":1456494335030000,"value":"ss"}],"binaryAnnotations":[]} - -build/service4.log: -{"traceId":"0ae504ece23418aa","name":"http:/baz","id":"ff987807fd10e608","parentId":"62b45b766b711741","timestamp":1456494334622000,"duration":409000,"annotations":[],"binaryAnnotations":[{"key":"http.url","value":"http://localhost:8084/baz","endpoint":{"serviceName":"service4","ipv4":"10.69.252.83","port":65535}},{"key":"http.host","value":"localhost","endpoint":{"serviceName":"service4","ipv4":"10.69.252.83","port":65535}},{"key":"http.path","value":"/baz","endpoint":{"serviceName":"service4","ipv4":"10.69.252.83","port":65535}},{"key":"http.method","value":"GET","endpoint":{"serviceName":"service4","ipv4":"10.69.252.83","port":65535}}]} - - -QUERY server - -[ - { - "annotations": [ - { - "endpoint": { - "ipv4": "10.69.252.83", - "port": 65535, - "serviceName": "service1" - }, - "timestamp": 1456494334095000, - "value": "cs" - }, - { - "endpoint": { - "ipv4": "10.69.252.83", - "port": 65535, - "serviceName": "service2" - }, - "timestamp": 1456494334097000, - "value": "sr" - }, - { - "endpoint": { - "ipv4": "10.69.252.83", - "port": 65535, - "serviceName": "service1" - }, - "timestamp": 1456494335031000, - "value": "cr" - }, - { - "endpoint": { - "ipv4": "10.69.252.83", - "port": 65535, - "serviceName": "service2" - }, - "timestamp": 1456494335031000, - "value": "ss" - } - ], - "binaryAnnotations": [ - { - "endpoint": { - "ipv4": "10.69.252.83", - "port": 65535, - "serviceName": "service1" - }, - "key": "http.host", - "value": "localhost" - }, - { - "endpoint": { - "ipv4": "10.69.252.83", - "port": 65535, - "serviceName": "service1" - }, - "key": "http.method", - "value": "GET" - }, - { - "endpoint": { - "ipv4": "10.69.252.83", - "port": 65535, - "serviceName": "service1" - }, - "key": "http.path", - "value": "/start" - }, - { - "endpoint": { - "ipv4": "10.69.252.83", - "port": 65535, - "serviceName": "service1" - }, - "key": "http.url", - "value": "http://localhost:8081/start" - } - ], - "duration": 935000, - "id": "0ae504ece23418aa", - "name": "http:/start", - "timestamp": 1456494334095000, - "traceId": "0ae504ece23418aa" - }, - { - "annotations": [ - { - "endpoint": { - "ipv4": "10.69.252.83", - "port": 65535, - "serviceName": "service2" - }, - "timestamp": 1456494334302000, - "value": "cs" - }, - { - "endpoint": { - "ipv4": "10.69.252.83", - "port": 65535, - "serviceName": "service3" - }, - "timestamp": 1456494334304000, - "value": "sr" - }, - { - "endpoint": { - "ipv4": "10.69.252.83", - "port": 65535, - "serviceName": "service2" - }, - "timestamp": 1456494334614000, - "value": "cr" - }, - { - "endpoint": { - "ipv4": "10.69.252.83", - "port": 65535, - "serviceName": "service3" - }, - "timestamp": 1456494334614000, - "value": "ss" - }, - { - "endpoint": { - "ipv4": "10.69.252.83", - "port": 65535, - "serviceName": "service2" - }, - "timestamp": 1456494334615000, - "value": "cs" - }, - { - "endpoint": { - "ipv4": "10.69.252.83", - "port": 65535, - "serviceName": "service4" - }, - "timestamp": 1456494334619000, - "value": "sr" - }, - { - "endpoint": { - "ipv4": "10.69.252.83", - "port": 65535, - "serviceName": "service2" - }, - "timestamp": 1456494335027000, - "value": "cr" - }, - { - "endpoint": { - "ipv4": "10.69.252.83", - "port": 65535, - "serviceName": "service4" - }, - "timestamp": 1456494335027000, - "value": "ss" - } - ], - "binaryAnnotations": [ - { - "endpoint": { - "ipv4": "10.69.252.83", - "port": 65535, - "serviceName": "service2" - }, - "key": "http.host", - "value": "localhost" - }, - { - "endpoint": { - "ipv4": "10.69.252.83", - "port": 65535, - "serviceName": "service2" - }, - "key": "http.method", - "value": "GET" - }, - { - "endpoint": { - "ipv4": "10.69.252.83", - "port": 65535, - "serviceName": "service2" - }, - "key": "http.path", - "value": "/foo" - }, - { - "endpoint": { - "ipv4": "10.69.252.83", - "port": 65535, - "serviceName": "service2" - }, - "key": "http.url", - "value": "http://localhost:8082/foo" - } - ], - "duration": 408000, - "id": "62b45b766b711741", - "name": "http:/foo", - "parentId": "0ae504ece23418aa", - "timestamp": 1456494334302000, - "traceId": "0ae504ece23418aa" - }, - { - "annotations": [], - "binaryAnnotations": [ - { - "endpoint": { - "ipv4": "10.69.252.83", - "port": 65535, - "serviceName": "service3" - }, - "key": "http.host", - "value": "localhost" - }, - { - "endpoint": { - "ipv4": "10.69.252.83", - "port": 65535, - "serviceName": "service3" - }, - "key": "http.method", - "value": "GET" - }, - { - "endpoint": { - "ipv4": "10.69.252.83", - "port": 65535, - "serviceName": "service3" - }, - "key": "http.path", - "value": "/bar" - }, - { - "endpoint": { - "ipv4": "10.69.252.83", - "port": 65535, - "serviceName": "service3" - }, - "key": "http.url", - "value": "http://localhost:8083/bar" - } - ], - "duration": 311000, - "id": "ae2224ee81db30b1", - "name": "http:/bar", - "parentId": "62b45b766b711741", - "timestamp": 1456494334307000, - "traceId": "0ae504ece23418aa" - }, - { - "annotations": [], - "binaryAnnotations": [ - { - "endpoint": { - "ipv4": "10.69.252.83", - "port": 65535, - "serviceName": "service4" - }, - "key": "http.host", - "value": "localhost" - }, - { - "endpoint": { - "ipv4": "10.69.252.83", - "port": 65535, - "serviceName": "service4" - }, - "key": "http.method", - "value": "GET" - }, - { - "endpoint": { - "ipv4": "10.69.252.83", - "port": 65535, - "serviceName": "service4" - }, - "key": "http.path", - "value": "/baz" - }, - { - "endpoint": { - "ipv4": "10.69.252.83", - "port": 65535, - "serviceName": "service4" - }, - "key": "http.url", - "value": "http://localhost:8084/baz" - } - ], - "duration": 409000, - "id": "ff987807fd10e608", - "name": "http:/baz", - "parentId": "62b45b766b711741", - "timestamp": 1456494334622000, - "traceId": "0ae504ece23418aa" - } -] diff --git a/docs/too_short_foo_span.txt b/docs/too_short_foo_span.txt deleted file mode 100644 index 30b50ee..0000000 --- a/docs/too_short_foo_span.txt +++ /dev/null @@ -1,322 +0,0 @@ -===== SENT TO ZIPKIN ====== - -SERVICE 1 {"traceId":"6497bb6aa5b10776","name":"http:/start","id":"6497bb6aa5b10776","timestamp":1456487125176000,"duration":29000,"annotations":[{"endpoint":{"serviceName":"service1","ipv4":"10.69.252.83","port":65535},"timestamp":1456487125181000,"value":"cs"},{"endpoint":{"serviceName":"service1","ipv4":"10.69.252.83","port":65535},"timestamp":1456487125203000,"value":"cr"}],"binaryAnnotations":[{"key":"http.url","value":"http://localhost:8081/start","endpoint":{"serviceName":"service1","ipv4":"10.69.252.83","port":65535}},{"key":"http.host","value":"localhost","endpoint":{"serviceName":"service1","ipv4":"10.69.252.83","port":65535}},{"key":"http.path","value":"/start","endpoint":{"serviceName":"service1","ipv4":"10.69.252.83","port":65535}},{"key":"http.method","value":"GET","endpoint":{"serviceName":"service1","ipv4":"10.69.252.83","port":65535}}]} - -SERVICE 2 -{"traceId":"6497bb6aa5b10776","name":"http:/start","id":"6497bb6aa5b10776","timestamp":1456487125186000,"duration":17000,"annotations":[{"endpoint":{"serviceName":"service2","ipv4":"10.69.252.83","port":65535},"timestamp":1456487125186000,"value":"sr"},{"endpoint":{"serviceName":"service2","ipv4":"10.69.252.83","port":65535},"timestamp":1456487125203000,"value":"ss"}],"binaryAnnotations":[]} -SERVICE 2 -{"traceId":"6497bb6aa5b10776","name":"http:/foo","id":"18bfe57b90996a29","parentId":"6497bb6aa5b10776","timestamp":1456487125186000,"duration":18000,"annotations":[{"endpoint":{"serviceName":"service2","ipv4":"10.69.252.83","port":65535},"timestamp":1456487125189000,"value":"cs"},{"endpoint":{"serviceName":"service2","ipv4":"10.69.252.83","port":65535},"timestamp":1456487125195000,"value":"cr"},{"endpoint":{"serviceName":"service2","ipv4":"10.69.252.83","port":65535},"timestamp":1456487125195000,"value":"cs"},{"endpoint":{"serviceName":"service2","ipv4":"10.69.252.83","port":65535},"timestamp":1456487125201000,"value":"cr"}],"binaryAnnotations":[{"key":"http.url","value":"http://localhost:8082/foo","endpoint":{"serviceName":"service2","ipv4":"10.69.252.83","port":65535}},{"key":"http.host","value":"localhost","endpoint":{"serviceName":"service2","ipv4":"10.69.252.83","port":65535}},{"key":"http.path","value":"/foo","endpoint":{"serviceName":"service2","ipv4":"10.69.252.83","port":65535}},{"key":"http.method","value":"GET","endpoint":{"serviceName":"service2","ipv4":"10.69.252.83","port":65535}}]} - -SERVICE 3 -{"traceId":"6497bb6aa5b10776","name":"http:/foo","id":"18bfe57b90996a29","parentId":"6497bb6aa5b10776","timestamp":1456487125191000,"duration":4000,"annotations":[{"endpoint":{"serviceName":"service3","ipv4":"10.69.252.83","port":65535},"timestamp":1456487125191000,"value":"sr"},{"endpoint":{"serviceName":"service3","ipv4":"10.69.252.83","port":65535},"timestamp":1456487125195000,"value":"ss"}],"binaryAnnotations":[]} - -SERVICE 3 -{"traceId":"6497bb6aa5b10776","name":"http:/bar","id":"d0f4456b5992498a","parentId":"18bfe57b90996a29","timestamp":1456487125191000,"duration":5000,"annotations":[],"binaryAnnotations":[{"key":"http.url","value":"http://localhost:8083/bar","endpoint":{"serviceName":"service3","ipv4":"10.69.252.83","port":65535}},{"key":"http.host","value":"localhost","endpoint":{"serviceName":"service3","ipv4":"10.69.252.83","port":65535}},{"key":"http.path","value":"/bar","endpoint":{"serviceName":"service3","ipv4":"10.69.252.83","port":65535}},{"key":"http.method","value":"GET","endpoint":{"serviceName":"service3","ipv4":"10.69.252.83","port":65535}}]} - -SERVICE 4 -{"traceId":"6497bb6aa5b10776","name":"http:/foo","id":"18bfe57b90996a29","parentId":"6497bb6aa5b10776","timestamp":1456487125197000,"duration":4000,"annotations":[{"endpoint":{"serviceName":"service4","ipv4":"10.69.252.83","port":65535},"timestamp":1456487125197000,"value":"sr"},{"endpoint":{"serviceName":"service4","ipv4":"10.69.252.83","port":65535},"timestamp":1456487125201000,"value":"ss"}],"binaryAnnotations":[]} - -SERVICE 4 -{"traceId":"6497bb6aa5b10776","name":"http:/baz","id":"b221c5ed1255f30e","parentId":"18bfe57b90996a29","timestamp":1456487125197000,"duration":5000,"annotations":[],"binaryAnnotations":[{"key":"http.url","value":"http://localhost:8084/baz","endpoint":{"serviceName":"service4","ipv4":"10.69.252.83","port":65535}},{"key":"http.host","value":"localhost","endpoint":{"serviceName":"service4","ipv4":"10.69.252.83","port":65535}},{"key":"http.path","value":"/baz","endpoint":{"serviceName":"service4","ipv4":"10.69.252.83","port":65535}},{"key":"http.method","value":"GET","endpoint":{"serviceName":"service4","ipv4":"10.69.252.83","port":65535}}]} - -===== FROM QUERY SERVER ======= - -[ - { - "annotations": [ - { - "endpoint": { - "ipv4": "10.69.252.83", - "port": 65535, - "serviceName": "service1" - }, - "timestamp": 1456487125178500, - "value": "cs" - }, - { - "endpoint": { - "ipv4": "10.69.252.83", - "port": 65535, - "serviceName": "service2" - }, - "timestamp": 1456487125183500, - "value": "sr" - }, - { - "endpoint": { - "ipv4": "10.69.252.83", - "port": 65535, - "serviceName": "service1" - }, - "timestamp": 1456487125200500, - "value": "cr" - }, - { - "endpoint": { - "ipv4": "10.69.252.83", - "port": 65535, - "serviceName": "service2" - }, - "timestamp": 1456487125200500, - "value": "ss" - } - ], - "binaryAnnotations": [ - { - "endpoint": { - "ipv4": "10.69.252.83", - "port": 65535, - "serviceName": "service1" - }, - "key": "http.host", - "value": "localhost" - }, - { - "endpoint": { - "ipv4": "10.69.252.83", - "port": 65535, - "serviceName": "service1" - }, - "key": "http.method", - "value": "GET" - }, - { - "endpoint": { - "ipv4": "10.69.252.83", - "port": 65535, - "serviceName": "service1" - }, - "key": "http.path", - "value": "/start" - }, - { - "endpoint": { - "ipv4": "10.69.252.83", - "port": 65535, - "serviceName": "service1" - }, - "key": "http.url", - "value": "http://localhost:8081/start" - } - ], - "duration": 29000, - "id": "6497bb6aa5b10776", - "name": "http:/start", - "timestamp": 1456487125178500, - "traceId": "6497bb6aa5b10776" - }, - { - "annotations": [ - { - "endpoint": { - "ipv4": "10.69.252.83", - "port": 65535, - "serviceName": "service2" - }, - "timestamp": 1456487125185500, - "value": "cs" - }, - { - "endpoint": { - "ipv4": "10.69.252.83", - "port": 65535, - "serviceName": "service3" - }, - "timestamp": 1456487125187500, - "value": "sr" - }, - { - "endpoint": { - "ipv4": "10.69.252.83", - "port": 65535, - "serviceName": "service2" - }, - "timestamp": 1456487125191500, - "value": "cr" - }, - { - "endpoint": { - "ipv4": "10.69.252.83", - "port": 65535, - "serviceName": "service2" - }, - "timestamp": 1456487125191500, - "value": "cs" - }, - { - "endpoint": { - "ipv4": "10.69.252.83", - "port": 65535, - "serviceName": "service3" - }, - "timestamp": 1456487125191500, - "value": "ss" - }, - { - "endpoint": { - "ipv4": "10.69.252.83", - "port": 65535, - "serviceName": "service4" - }, - "timestamp": 1456487125193500, - "value": "sr" - }, - { - "endpoint": { - "ipv4": "10.69.252.83", - "port": 65535, - "serviceName": "service2" - }, - "timestamp": 1456487125197500, - "value": "cr" - }, - { - "endpoint": { - "ipv4": "10.69.252.83", - "port": 65535, - "serviceName": "service4" - }, - "timestamp": 1456487125197500, - "value": "ss" - } - ], - "binaryAnnotations": [ - { - "endpoint": { - "ipv4": "10.69.252.83", - "port": 65535, - "serviceName": "service2" - }, - "key": "http.host", - "value": "localhost" - }, - { - "endpoint": { - "ipv4": "10.69.252.83", - "port": 65535, - "serviceName": "service2" - }, - "key": "http.method", - "value": "GET" - }, - { - "endpoint": { - "ipv4": "10.69.252.83", - "port": 65535, - "serviceName": "service2" - }, - "key": "http.path", - "value": "/foo" - }, - { - "endpoint": { - "ipv4": "10.69.252.83", - "port": 65535, - "serviceName": "service2" - }, - "key": "http.url", - "value": "http://localhost:8082/foo" - } - ], - "duration": 4000, - "id": "18bfe57b90996a29", - "name": "http:/foo", - "parentId": "6497bb6aa5b10776", - "timestamp": 1456487125185500, - "traceId": "6497bb6aa5b10776" - }, - { - "annotations": [], - "binaryAnnotations": [ - { - "endpoint": { - "ipv4": "10.69.252.83", - "port": 65535, - "serviceName": "service4" - }, - "key": "http.host", - "value": "localhost" - }, - { - "endpoint": { - "ipv4": "10.69.252.83", - "port": 65535, - "serviceName": "service4" - }, - "key": "http.method", - "value": "GET" - }, - { - "endpoint": { - "ipv4": "10.69.252.83", - "port": 65535, - "serviceName": "service4" - }, - "key": "http.path", - "value": "/baz" - }, - { - "endpoint": { - "ipv4": "10.69.252.83", - "port": 65535, - "serviceName": "service4" - }, - "key": "http.url", - "value": "http://localhost:8084/baz" - } - ], - "duration": 5000, - "id": "b221c5ed1255f30e", - "name": "http:/baz", - "parentId": "18bfe57b90996a29", - "timestamp": 1456487125197000, - "traceId": "6497bb6aa5b10776" - }, - { - "annotations": [], - "binaryAnnotations": [ - { - "endpoint": { - "ipv4": "10.69.252.83", - "port": 65535, - "serviceName": "service3" - }, - "key": "http.host", - "value": "localhost" - }, - { - "endpoint": { - "ipv4": "10.69.252.83", - "port": 65535, - "serviceName": "service3" - }, - "key": "http.method", - "value": "GET" - }, - { - "endpoint": { - "ipv4": "10.69.252.83", - "port": 65535, - "serviceName": "service3" - }, - "key": "http.path", - "value": "/bar" - }, - { - "endpoint": { - "ipv4": "10.69.252.83", - "port": 65535, - "serviceName": "service3" - }, - "key": "http.url", - "value": "http://localhost:8083/bar" - } - ], - "duration": 5000, - "id": "d0f4456b5992498a", - "name": "http:/bar", - "parentId": "18bfe57b90996a29", - "timestamp": 1456487125191000, - "traceId": "6497bb6aa5b10776" - } -] diff --git a/gradle.properties b/gradle.properties deleted file mode 100644 index ab9073a..0000000 --- a/gradle.properties +++ /dev/null @@ -1,8 +0,0 @@ -org.gradle.daemon=true - -jacksonMapper=1.9.13 -gebVersion=0.10.0 -seleniumVersion=2.45.0 -restAssuredVersion=2.6.0 -amqpVersion=1.5.4.BUILD-SNAPSHOT -BOM_VERSION=Brixton.BUILD-SNAPSHOT diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar deleted file mode 100755 index 9411448..0000000 Binary files a/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties deleted file mode 100755 index acb2136..0000000 --- a/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,6 +0,0 @@ -#Tue Dec 22 11:27:22 CET 2015 -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-bin.zip diff --git a/gradlew b/gradlew deleted file mode 100755 index 9d82f78..0000000 --- a/gradlew +++ /dev/null @@ -1,160 +0,0 @@ -#!/usr/bin/env bash - -############################################################################## -## -## Gradle start up script for UN*X -## -############################################################################## - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" - -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" - -warn ( ) { - echo "$*" -} - -die ( ) { - echo - echo "$*" - echo - exit 1 -} - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; -esac - -# Attempt to set APP_HOME -# Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi -done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi -fi - -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi - -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi - # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" - fi - i=$((i+1)) - done - case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac -fi - -# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules -function splitJvmOpts() { - JVM_OPTS=("$@") -} -eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS -JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" - -exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" diff --git a/gradlew.bat b/gradlew.bat deleted file mode 100755 index 8a0b282..0000000 --- a/gradlew.bat +++ /dev/null @@ -1,90 +0,0 @@ -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windowz variants - -if not "%OS%" == "Windows_NT" goto win9xME_args -if "%@eval[2+2]" == "4" goto 4NT_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* -goto execute - -:4NT_args -@rem Get arguments from the 4NT Shell from JP Software -set CMD_LINE_ARGS=%$ - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/kill.sh b/kill.sh deleted file mode 100755 index ee8b29f..0000000 --- a/kill.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -kill `jps | grep "1.0.0.jar" | cut -d " " -f 1` \ No newline at end of file diff --git a/mvnw b/mvnw new file mode 100755 index 0000000..a1ba1bf --- /dev/null +++ b/mvnw @@ -0,0 +1,233 @@ +#!/bin/sh +# ---------------------------------------------------------------------------- +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# ---------------------------------------------------------------------------- + +# ---------------------------------------------------------------------------- +# Maven2 Start Up Batch script +# +# Required ENV vars: +# ------------------ +# JAVA_HOME - location of a JDK home dir +# +# Optional ENV vars +# ----------------- +# M2_HOME - location of maven2's installed home dir +# MAVEN_OPTS - parameters passed to the Java VM when running Maven +# e.g. to debug Maven itself, use +# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +# MAVEN_SKIP_RC - flag to disable loading of mavenrc files +# ---------------------------------------------------------------------------- + +if [ -z "$MAVEN_SKIP_RC" ] ; then + + if [ -f /etc/mavenrc ] ; then + . /etc/mavenrc + fi + + if [ -f "$HOME/.mavenrc" ] ; then + . "$HOME/.mavenrc" + fi + +fi + +# OS specific support. $var _must_ be set to either true or false. +cygwin=false; +darwin=false; +mingw=false +case "`uname`" in + CYGWIN*) cygwin=true ;; + MINGW*) mingw=true;; + Darwin*) darwin=true + # + # Look for the Apple JDKs first to preserve the existing behaviour, and then look + # for the new JDKs provided by Oracle. + # + if [ -z "$JAVA_HOME" ] && [ -L /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK ] ; then + # + # Apple JDKs + # + export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home + fi + + if [ -z "$JAVA_HOME" ] && [ -L /System/Library/Java/JavaVirtualMachines/CurrentJDK ] ; then + # + # Apple JDKs + # + export JAVA_HOME=/System/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home + fi + + if [ -z "$JAVA_HOME" ] && [ -L "/Library/Java/JavaVirtualMachines/CurrentJDK" ] ; then + # + # Oracle JDKs + # + export JAVA_HOME=/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home + fi + + if [ -z "$JAVA_HOME" ] && [ -x "/usr/libexec/java_home" ]; then + # + # Apple JDKs + # + export JAVA_HOME=`/usr/libexec/java_home` + fi + ;; +esac + +if [ -z "$JAVA_HOME" ] ; then + if [ -r /etc/gentoo-release ] ; then + JAVA_HOME=`java-config --jre-home` + fi +fi + +if [ -z "$M2_HOME" ] ; then + ## resolve links - $0 may be a link to maven's home + PRG="$0" + + # need this for relative symlinks + while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG="`dirname "$PRG"`/$link" + fi + done + + saveddir=`pwd` + + M2_HOME=`dirname "$PRG"`/.. + + # make it fully qualified + M2_HOME=`cd "$M2_HOME" && pwd` + + cd "$saveddir" + # echo Using m2 at $M2_HOME +fi + +# For Cygwin, ensure paths are in UNIX format before anything is touched +if $cygwin ; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --unix "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --unix "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --unix "$CLASSPATH"` +fi + +# For Migwn, ensure paths are in UNIX format before anything is touched +if $mingw ; then + [ -n "$M2_HOME" ] && + M2_HOME="`(cd "$M2_HOME"; pwd)`" + [ -n "$JAVA_HOME" ] && + JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" + # TODO classpath? +fi + +if [ -z "$JAVA_HOME" ]; then + javaExecutable="`which javac`" + if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then + # readlink(1) is not available as standard on Solaris 10. + readLink=`which readlink` + if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then + if $darwin ; then + javaHome="`dirname \"$javaExecutable\"`" + javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" + else + javaExecutable="`readlink -f \"$javaExecutable\"`" + fi + javaHome="`dirname \"$javaExecutable\"`" + javaHome=`expr "$javaHome" : '\(.*\)/bin'` + JAVA_HOME="$javaHome" + export JAVA_HOME + fi + fi +fi + +if [ -z "$JAVACMD" ] ; then + if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + else + JAVACMD="`which java`" + fi +fi + +if [ ! -x "$JAVACMD" ] ; then + echo "Error: JAVA_HOME is not defined correctly." >&2 + echo " We cannot execute $JAVACMD" >&2 + exit 1 +fi + +if [ -z "$JAVA_HOME" ] ; then + echo "Warning: JAVA_HOME environment variable is not set." +fi + +CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher + +# For Cygwin, switch paths to Windows format before running java +if $cygwin; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --path --windows "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --windows "$CLASSPATH"` +fi + +# traverses directory structure from process work directory to filesystem root +# first directory with .mvn subdirectory is considered project base directory +find_maven_basedir() { + local basedir=$(pwd) + local wdir=$(pwd) + while [ "$wdir" != '/' ] ; do + if [ -d "$wdir"/.mvn ] ; then + basedir=$wdir + break + fi + wdir=$(cd "$wdir/.."; pwd) + done + echo "${basedir}" +} + +# concatenates all lines of a file +concat_lines() { + if [ -f "$1" ]; then + echo "$(tr -s '\n' ' ' < "$1")" + fi +} + +export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-$(find_maven_basedir)} +MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" + +# Provide a "standardized" way to retrieve the CLI args that will +# work with both Windows and non-Windows executions. +MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" +export MAVEN_CMD_LINE_ARGS + +WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +exec "$JAVACMD" \ + $MAVEN_OPTS \ + -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ + "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ + ${WRAPPER_LAUNCHER} "$@" diff --git a/mvnw.cmd b/mvnw.cmd new file mode 100644 index 0000000..5a8e45d --- /dev/null +++ b/mvnw.cmd @@ -0,0 +1,145 @@ +@REM ---------------------------------------------------------------------------- +@REM Licensed to the Apache Software Foundation (ASF) under one +@REM or more contributor license agreements. See the NOTICE file +@REM distributed with this work for additional information +@REM regarding copyright ownership. The ASF licenses this file +@REM to you under the Apache License, Version 2.0 (the +@REM "License"); you may not use this file except in compliance +@REM with the License. You may obtain a copy of the License at +@REM +@REM http://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, +@REM software distributed under the License is distributed on an +@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +@REM KIND, either express or implied. See the License for the +@REM specific language governing permissions and limitations +@REM under the License. +@REM ---------------------------------------------------------------------------- + +@REM ---------------------------------------------------------------------------- +@REM Maven2 Start Up Batch script +@REM +@REM Required ENV vars: +@REM JAVA_HOME - location of a JDK home dir +@REM +@REM Optional ENV vars +@REM M2_HOME - location of maven2's installed home dir +@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands +@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending +@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven +@REM e.g. to debug Maven itself, use +@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,city=8000 +@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files +@REM ---------------------------------------------------------------------------- + +@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' +@echo off +@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on' +@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% + +@REM set %HOME% to equivalent of $HOME +if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") + +@REM Execute a user defined script before this one +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre +@REM check for pre script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" +if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" +:skipRcPre + +@setlocal + +set ERROR_CODE=0 + +@REM To isolate internal variables from possible post scripts, we use another setlocal +@setlocal + +@REM ==== START VALIDATION ==== +if not "%JAVA_HOME%" == "" goto OkJHome + +echo. +echo Error: JAVA_HOME not found in your environment. >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +:OkJHome +if exist "%JAVA_HOME%\bin\java.exe" goto init + +echo. +echo Error: JAVA_HOME is set to an invalid directory. >&2 +echo JAVA_HOME = "%JAVA_HOME%" >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +@REM ==== END VALIDATION ==== + +:init + +set MAVEN_CMD_LINE_ARGS=%* + +@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". +@REM Fallback to current working directory if not found. + +set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% +IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir + +set EXEC_DIR=%CD% +set WDIR=%EXEC_DIR% +:findBaseDir +IF EXIST "%WDIR%"\.mvn goto baseDirFound +cd .. +IF "%WDIR%"=="%CD%" goto baseDirNotFound +set WDIR=%CD% +goto findBaseDir + +:baseDirFound +set MAVEN_PROJECTBASEDIR=%WDIR% +cd "%EXEC_DIR%" +goto endDetectBaseDir + +:baseDirNotFound +set MAVEN_PROJECTBASEDIR=%EXEC_DIR% +cd "%EXEC_DIR%" + +:endDetectBaseDir + +IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig + +@setlocal EnableExtensions EnableDelayedExpansion +for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a +@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% + +:endReadAdditionalConfig + +SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" + +set WRAPPER_JAR="".\.mvn\wrapper\maven-wrapper.jar"" +set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CMD_LINE_ARGS% +if ERRORLEVEL 1 goto error +goto end + +:error +set ERROR_CODE=1 + +:end +@endlocal & set ERROR_CODE=%ERROR_CODE% + +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost +@REM check for post script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" +if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" +:skipRcPost + +@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' +if "%MAVEN_BATCH_PAUSE%" == "on" pause + +if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% + +exit /B %ERROR_CODE% \ No newline at end of file diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..65297b8 --- /dev/null +++ b/pom.xml @@ -0,0 +1,122 @@ + + + 4.0.0 + + io.spring.cloud.sleuth.docs + sleuth-documentation-apps-parent + pom + 1.0.0.SLEUTH_DOCS + + Sleuth Documentation Apps + Sleuth Documentation Apps + + + + tests + + acceptance-tests + + + + notests + + service1 + service2 + service3 + service4 + + + + all + + true + + + service1 + service2 + service3 + service4 + acceptance-tests + + + + ide + + false + + + presentation-service + service1 + service2 + service3 + service4 + acceptance-tests + + + + + + + spring-snapshots + Spring Snapshots + https://repo.spring.io/snapshot + + true + + + + spring-milestones + Spring Milestones + https://repo.spring.io/milestone + + false + + + + spring-releases + Spring Releases + https://repo.spring.io/release + + false + + + + + + spring-snapshots + Spring Snapshots + https://repo.spring.io/snapshot + + true + + + + spring-milestones + Spring Milestones + https://repo.spring.io/milestone + + false + + + + spring-plugin-snapshots + Spring Snapshots + https://repo.spring.io/snapshot + + true + + + + spring-plugin-milestones + Spring Milestones + https://repo.spring.io/release + + false + + + + + + diff --git a/presentation-service/HELP.md b/presentation-service/HELP.md new file mode 100644 index 0000000..e90c77e --- /dev/null +++ b/presentation-service/HELP.md @@ -0,0 +1,26 @@ +# Read Me First +The following was discovered as part of building this project: + +* The original package name 'com.example.presentation-service' is invalid and this project uses 'com.example.presentationservice' instead. + +# Getting Started + +### Reference Documentation +For further reference, please consider the following sections: + +* [Official Apache Maven documentation](https://maven.apache.org/guides/index.html) +* [Spring Boot Maven Plugin Reference Guide](https://docs.spring.io/spring-boot/docs/2.4.3-SNAPSHOT/maven-plugin/reference/html/) +* [Create an OCI image](https://docs.spring.io/spring-boot/docs/2.4.3-SNAPSHOT/maven-plugin/reference/html/#build-image) +* [Wavefront for Spring Boot documentation](https://docs.wavefront.com/wavefront_springboot.html) +* [Wavefront for Spring Boot repository](https://github.com/wavefrontHQ/wavefront-spring-boot) +* [Spring Boot Actuator](https://docs.spring.io/spring-boot/docs/2.4.3/reference/htmlsingle/#production-ready) + +### Guides +The following guides illustrate how to use some features concretely: + +* [Building a RESTful Web Service with Spring Boot Actuator](https://spring.io/guides/gs/actuator-service/) + +## Observability with Wavefront + +If you don't have a Wavefront account, the starter will create a freemium account for you. +The URL to access the Wavefront Service dashboard is logged on startup. diff --git a/presentation-service/mvnw b/presentation-service/mvnw new file mode 100755 index 0000000..a16b543 --- /dev/null +++ b/presentation-service/mvnw @@ -0,0 +1,310 @@ +#!/bin/sh +# ---------------------------------------------------------------------------- +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# ---------------------------------------------------------------------------- + +# ---------------------------------------------------------------------------- +# Maven Start Up Batch script +# +# Required ENV vars: +# ------------------ +# JAVA_HOME - location of a JDK home dir +# +# Optional ENV vars +# ----------------- +# M2_HOME - location of maven2's installed home dir +# MAVEN_OPTS - parameters passed to the Java VM when running Maven +# e.g. to debug Maven itself, use +# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +# MAVEN_SKIP_RC - flag to disable loading of mavenrc files +# ---------------------------------------------------------------------------- + +if [ -z "$MAVEN_SKIP_RC" ] ; then + + if [ -f /etc/mavenrc ] ; then + . /etc/mavenrc + fi + + if [ -f "$HOME/.mavenrc" ] ; then + . "$HOME/.mavenrc" + fi + +fi + +# OS specific support. $var _must_ be set to either true or false. +cygwin=false; +darwin=false; +mingw=false +case "`uname`" in + CYGWIN*) cygwin=true ;; + MINGW*) mingw=true;; + Darwin*) darwin=true + # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home + # See https://developer.apple.com/library/mac/qa/qa1170/_index.html + if [ -z "$JAVA_HOME" ]; then + if [ -x "/usr/libexec/java_home" ]; then + export JAVA_HOME="`/usr/libexec/java_home`" + else + export JAVA_HOME="/Library/Java/Home" + fi + fi + ;; +esac + +if [ -z "$JAVA_HOME" ] ; then + if [ -r /etc/gentoo-release ] ; then + JAVA_HOME=`java-config --jre-home` + fi +fi + +if [ -z "$M2_HOME" ] ; then + ## resolve links - $0 may be a link to maven's home + PRG="$0" + + # need this for relative symlinks + while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG="`dirname "$PRG"`/$link" + fi + done + + saveddir=`pwd` + + M2_HOME=`dirname "$PRG"`/.. + + # make it fully qualified + M2_HOME=`cd "$M2_HOME" && pwd` + + cd "$saveddir" + # echo Using m2 at $M2_HOME +fi + +# For Cygwin, ensure paths are in UNIX format before anything is touched +if $cygwin ; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --unix "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --unix "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --unix "$CLASSPATH"` +fi + +# For Mingw, ensure paths are in UNIX format before anything is touched +if $mingw ; then + [ -n "$M2_HOME" ] && + M2_HOME="`(cd "$M2_HOME"; pwd)`" + [ -n "$JAVA_HOME" ] && + JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" +fi + +if [ -z "$JAVA_HOME" ]; then + javaExecutable="`which javac`" + if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then + # readlink(1) is not available as standard on Solaris 10. + readLink=`which readlink` + if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then + if $darwin ; then + javaHome="`dirname \"$javaExecutable\"`" + javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" + else + javaExecutable="`readlink -f \"$javaExecutable\"`" + fi + javaHome="`dirname \"$javaExecutable\"`" + javaHome=`expr "$javaHome" : '\(.*\)/bin'` + JAVA_HOME="$javaHome" + export JAVA_HOME + fi + fi +fi + +if [ -z "$JAVACMD" ] ; then + if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + else + JAVACMD="`which java`" + fi +fi + +if [ ! -x "$JAVACMD" ] ; then + echo "Error: JAVA_HOME is not defined correctly." >&2 + echo " We cannot execute $JAVACMD" >&2 + exit 1 +fi + +if [ -z "$JAVA_HOME" ] ; then + echo "Warning: JAVA_HOME environment variable is not set." +fi + +CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher + +# traverses directory structure from process work directory to filesystem root +# first directory with .mvn subdirectory is considered project base directory +find_maven_basedir() { + + if [ -z "$1" ] + then + echo "Path not specified to find_maven_basedir" + return 1 + fi + + basedir="$1" + wdir="$1" + while [ "$wdir" != '/' ] ; do + if [ -d "$wdir"/.mvn ] ; then + basedir=$wdir + break + fi + # workaround for JBEAP-8937 (on Solaris 10/Sparc) + if [ -d "${wdir}" ]; then + wdir=`cd "$wdir/.."; pwd` + fi + # end of workaround + done + echo "${basedir}" +} + +# concatenates all lines of a file +concat_lines() { + if [ -f "$1" ]; then + echo "$(tr -s '\n' ' ' < "$1")" + fi +} + +BASE_DIR=`find_maven_basedir "$(pwd)"` +if [ -z "$BASE_DIR" ]; then + exit 1; +fi + +########################################################################################## +# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +# This allows using the maven wrapper in projects that prohibit checking in binary data. +########################################################################################## +if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found .mvn/wrapper/maven-wrapper.jar" + fi +else + if [ "$MVNW_VERBOSE" = true ]; then + echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." + fi + if [ -n "$MVNW_REPOURL" ]; then + jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + else + jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + fi + while IFS="=" read key value; do + case "$key" in (wrapperUrl) jarUrl="$value"; break ;; + esac + done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" + if [ "$MVNW_VERBOSE" = true ]; then + echo "Downloading from: $jarUrl" + fi + wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" + if $cygwin; then + wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"` + fi + + if command -v wget > /dev/null; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found wget ... using wget" + fi + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + wget "$jarUrl" -O "$wrapperJarPath" + else + wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" + fi + elif command -v curl > /dev/null; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found curl ... using curl" + fi + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + curl -o "$wrapperJarPath" "$jarUrl" -f + else + curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f + fi + + else + if [ "$MVNW_VERBOSE" = true ]; then + echo "Falling back to using Java to download" + fi + javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" + # For Cygwin, switch paths to Windows format before running javac + if $cygwin; then + javaClass=`cygpath --path --windows "$javaClass"` + fi + if [ -e "$javaClass" ]; then + if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo " - Compiling MavenWrapperDownloader.java ..." + fi + # Compiling the Java class + ("$JAVA_HOME/bin/javac" "$javaClass") + fi + if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then + # Running the downloader + if [ "$MVNW_VERBOSE" = true ]; then + echo " - Running MavenWrapperDownloader.java ..." + fi + ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") + fi + fi + fi +fi +########################################################################################## +# End of extension +########################################################################################## + +export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} +if [ "$MVNW_VERBOSE" = true ]; then + echo $MAVEN_PROJECTBASEDIR +fi +MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" + +# For Cygwin, switch paths to Windows format before running java +if $cygwin; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --path --windows "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --windows "$CLASSPATH"` + [ -n "$MAVEN_PROJECTBASEDIR" ] && + MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` +fi + +# Provide a "standardized" way to retrieve the CLI args that will +# work with both Windows and non-Windows executions. +MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" +export MAVEN_CMD_LINE_ARGS + +WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +exec "$JAVACMD" \ + $MAVEN_OPTS \ + -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ + "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ + ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" diff --git a/presentation-service/mvnw.cmd b/presentation-service/mvnw.cmd new file mode 100644 index 0000000..c8d4337 --- /dev/null +++ b/presentation-service/mvnw.cmd @@ -0,0 +1,182 @@ +@REM ---------------------------------------------------------------------------- +@REM Licensed to the Apache Software Foundation (ASF) under one +@REM or more contributor license agreements. See the NOTICE file +@REM distributed with this work for additional information +@REM regarding copyright ownership. The ASF licenses this file +@REM to you under the Apache License, Version 2.0 (the +@REM "License"); you may not use this file except in compliance +@REM with the License. You may obtain a copy of the License at +@REM +@REM https://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, +@REM software distributed under the License is distributed on an +@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +@REM KIND, either express or implied. See the License for the +@REM specific language governing permissions and limitations +@REM under the License. +@REM ---------------------------------------------------------------------------- + +@REM ---------------------------------------------------------------------------- +@REM Maven Start Up Batch script +@REM +@REM Required ENV vars: +@REM JAVA_HOME - location of a JDK home dir +@REM +@REM Optional ENV vars +@REM M2_HOME - location of maven2's installed home dir +@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands +@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending +@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven +@REM e.g. to debug Maven itself, use +@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files +@REM ---------------------------------------------------------------------------- + +@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' +@echo off +@REM set title of command window +title %0 +@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' +@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% + +@REM set %HOME% to equivalent of $HOME +if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") + +@REM Execute a user defined script before this one +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre +@REM check for pre script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" +if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" +:skipRcPre + +@setlocal + +set ERROR_CODE=0 + +@REM To isolate internal variables from possible post scripts, we use another setlocal +@setlocal + +@REM ==== START VALIDATION ==== +if not "%JAVA_HOME%" == "" goto OkJHome + +echo. +echo Error: JAVA_HOME not found in your environment. >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +:OkJHome +if exist "%JAVA_HOME%\bin\java.exe" goto init + +echo. +echo Error: JAVA_HOME is set to an invalid directory. >&2 +echo JAVA_HOME = "%JAVA_HOME%" >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +@REM ==== END VALIDATION ==== + +:init + +@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". +@REM Fallback to current working directory if not found. + +set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% +IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir + +set EXEC_DIR=%CD% +set WDIR=%EXEC_DIR% +:findBaseDir +IF EXIST "%WDIR%"\.mvn goto baseDirFound +cd .. +IF "%WDIR%"=="%CD%" goto baseDirNotFound +set WDIR=%CD% +goto findBaseDir + +:baseDirFound +set MAVEN_PROJECTBASEDIR=%WDIR% +cd "%EXEC_DIR%" +goto endDetectBaseDir + +:baseDirNotFound +set MAVEN_PROJECTBASEDIR=%EXEC_DIR% +cd "%EXEC_DIR%" + +:endDetectBaseDir + +IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig + +@setlocal EnableExtensions EnableDelayedExpansion +for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a +@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% + +:endReadAdditionalConfig + +SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" +set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" +set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + +FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( + IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B +) + +@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +@REM This allows using the maven wrapper in projects that prohibit checking in binary data. +if exist %WRAPPER_JAR% ( + if "%MVNW_VERBOSE%" == "true" ( + echo Found %WRAPPER_JAR% + ) +) else ( + if not "%MVNW_REPOURL%" == "" ( + SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + ) + if "%MVNW_VERBOSE%" == "true" ( + echo Couldn't find %WRAPPER_JAR%, downloading it ... + echo Downloading from: %DOWNLOAD_URL% + ) + + powershell -Command "&{"^ + "$webclient = new-object System.Net.WebClient;"^ + "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ + "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ + "}"^ + "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ + "}" + if "%MVNW_VERBOSE%" == "true" ( + echo Finished downloading %WRAPPER_JAR% + ) +) +@REM End of extension + +@REM Provide a "standardized" way to retrieve the CLI args that will +@REM work with both Windows and non-Windows executions. +set MAVEN_CMD_LINE_ARGS=%* + +%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* +if ERRORLEVEL 1 goto error +goto end + +:error +set ERROR_CODE=1 + +:end +@endlocal & set ERROR_CODE=%ERROR_CODE% + +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost +@REM check for post script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" +if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" +:skipRcPost + +@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' +if "%MAVEN_BATCH_PAUSE%" == "on" pause + +if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% + +exit /B %ERROR_CODE% diff --git a/presentation-service/pom.xml b/presentation-service/pom.xml new file mode 100644 index 0000000..0d7a8d6 --- /dev/null +++ b/presentation-service/pom.xml @@ -0,0 +1,129 @@ + + + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 2.7.4 + + + io.spring.cloud.sleuth.docs + presentation-service + 1.0.0.SLEUTH_DOCS + presentation-service + Demo project for Spring Boot + + 11 + 2021.0.2-SNAPSHOT + 2.3.0 + + + + org.springframework.boot + spring-boot-starter-actuator + + + org.springframework.boot + spring-boot-starter-web + + + com.wavefront + wavefront-spring-boot-starter + + + org.springframework.cloud + spring-cloud-starter-sleuth + + + io.logz.logback + logzio-logback-appender + 1.0.28 + + + net.logstash.logback + logstash-logback-encoder + 7.2 + runtime + + + logback-core + ch.qos.logback + + + + + + org.springframework.boot + spring-boot-starter-test + test + + + + + + org.springframework.cloud + spring-cloud-dependencies + ${spring-cloud.version} + pom + import + + + com.wavefront + wavefront-spring-boot-bom + ${wavefront.version} + pom + import + + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + build-image + package + + build-image + + + + + + + + + spring-milestones + Spring Milestones + https://repo.spring.io/milestone + + + spring-snapshots + Spring Snapshots + https://repo.spring.io/snapshot + + true + + + + + + spring-milestones + Spring Milestones + https://repo.spring.io/milestone + + + spring-snapshots + Spring Snapshots + https://repo.spring.io/snapshot + + true + + + + + diff --git a/presentation-service/run.sh b/presentation-service/run.sh new file mode 100644 index 0000000..267a0dc --- /dev/null +++ b/presentation-service/run.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +set -e + +sdk use java 15.0.0.hs-adpt + +# Generate project with Sleuth, Wavefront, Web +# Add logback encoder, logz.io integration +# Copy the properties and logback +# Run without wavefront props +# Run with wavefront props from the command line + +./mvnw spring-boot:run + +http :9876/ \ No newline at end of file diff --git a/presentation-service/src/main/java/com/example/presentationservice/PresentationServiceApplication.java b/presentation-service/src/main/java/com/example/presentationservice/PresentationServiceApplication.java new file mode 100644 index 0000000..f759998 --- /dev/null +++ b/presentation-service/src/main/java/com/example/presentationservice/PresentationServiceApplication.java @@ -0,0 +1,46 @@ +package com.example.presentationservice; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.client.RestTemplate; + +@SpringBootApplication +public class PresentationServiceApplication { + + public static void main(String[] args) { + SpringApplication.run(PresentationServiceApplication.class, args); + } + + @Bean + RestTemplate restTemplate() { + return new RestTemplate(); + } +} + +@RestController +class PresentationController { + + private static final Logger log = LoggerFactory.getLogger(PresentationController.class); + + private final RestTemplate restTemplate; + + private final String serviceUrl; + + PresentationController(RestTemplate restTemplate, @Value("${service1.address:localhost:9081}") String serviceUrl) { + this.restTemplate = restTemplate; + this.serviceUrl = serviceUrl; + } + + @GetMapping("/") + String start() { + log.info("HELLO FROM PRESENTATION-SERVICE"); + return "PRESENTATION SERVICE: " + this.restTemplate.postForObject("http://" + this.serviceUrl + "/start", "", String.class); + } +} diff --git a/presentation-service/src/main/resources/application.properties b/presentation-service/src/main/resources/application.properties new file mode 100644 index 0000000..3fdbe43 --- /dev/null +++ b/presentation-service/src/main/resources/application.properties @@ -0,0 +1,10 @@ +spring.application.name: presentation-service + +wavefront.application.name: sleuth-documentation-apps +wavefront.application.service: ${spring.application.name} + +# Taken from env vars +management.metrics.export.wavefront.api-token=${WAVEFRONT_API_TOKEN} +management.metrics.export.wavefront.uri=https://demo.wavefront.com + +server.port: 9876 \ No newline at end of file diff --git a/presentation-service/src/main/resources/logback-spring.xml b/presentation-service/src/main/resources/logback-spring.xml new file mode 100644 index 0000000..44c93e2 --- /dev/null +++ b/presentation-service/src/main/resources/logback-spring.xml @@ -0,0 +1,56 @@ + + + + + + + + + + + + DEBUG + + + ${CONSOLE_LOG_PATTERN} + utf8 + + + + + ${LOGZ_IO_API_TOKEN} + https://listener.logz.io:8071 + + INFO + + + + + UTC + + + + { + "timestamp": "@timestamp", + "severity": "%level", + "service": "${springAppName:-}", + "trace": "%X{traceId:-}", + "span": "%X{spanId:-}", + "baggage": "%X{key:-}", + "pid": "${PID:-}", + "thread": "%thread", + "class": "%logger{40}", + "rest": "%message" + } + + + + + + + + + + + + diff --git a/presentation-service/src/test/java/com/example/presentationservice/PresentationServiceApplicationTests.java b/presentation-service/src/test/java/com/example/presentationservice/PresentationServiceApplicationTests.java new file mode 100644 index 0000000..ffcaeb5 --- /dev/null +++ b/presentation-service/src/test/java/com/example/presentationservice/PresentationServiceApplicationTests.java @@ -0,0 +1,15 @@ +package com.example.presentationservice; + +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.TestPropertySource; + +@TestPropertySource(properties = "management.metrics.export.wavefront.enabled=false") +@SpringBootTest +class PresentationServiceApplicationTests { + + @Test + void contextLoads() { + } + +} diff --git a/scripts/curl_exception.sh b/scripts/curl_exception.sh new file mode 100755 index 0000000..3fc7319 --- /dev/null +++ b/scripts/curl_exception.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +set -e + +echo -e "Sending a request to service1" + +SERVICE1_PORT="${SERVICE1_PORT:-8081}" + +curl --fail localhost:${SERVICE1_PORT}/readtimeout diff --git a/scripts/curl_start.sh b/scripts/curl_start.sh new file mode 100755 index 0000000..0baf09c --- /dev/null +++ b/scripts/curl_start.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +set -e + +echo -e "Sending a request to service1" + +SERVICE1_PORT="${SERVICE1_PORT:-8081}" + +curl --fail localhost:${SERVICE1_PORT}/start && echo -e "\nIt worked!" && exit 0 || echo -e "\nFailed to send the request" && exit 1 diff --git a/scripts/kill.sh b/scripts/kill.sh new file mode 100755 index 0000000..e51d9bb --- /dev/null +++ b/scripts/kill.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +SERVICE1_PORT="${SERVICE1_PORT:-8081}" +SERVICE2_PORT="${SERVICE2_PORT:-8082}" +SERVICE3_PORT="${SERVICE3_PORT:-8083}" +SERVICE4_PORT="${SERVICE4_PORT:-8084}" + +function kill_app_at_port() { + kill -9 $(lsof -t -i:$1) && echo "Killed an app running on port [$1]" || echo "No app running on port [$1]" +} + +echo "Running apps:" +jps | grep "1.0.0.SLEUTH_DOCS.jar" + +echo "Running docker processes" +docker ps +docker ps -a -q | xargs -n 1 -P 8 -I {} docker rm --force {} || echo 'No docker containers running'; + +kill `jps | grep "1.0.0.SLEUTH_DOCS.jar" | cut -d " " -f 1` || echo "No apps running" +pkill -9 -f 1.0.0.SLEUTH_DOCS.jar || echo "Apps not running" +kill `jps | grep "zipkin.jar" | cut -d " " -f 1` || echo "No zipkin running" +kill_app_at_port ${SERVICE1_PORT} || echo "Failed to kill service" +kill_app_at_port ${SERVICE2_PORT} || echo "Failed to kill service" +kill_app_at_port ${SERVICE3_PORT} || echo "Failed to kill service" +kill_app_at_port ${SERVICE4_PORT} || echo "Failed to kill service" + +echo "Running apps:" +jps | grep "1.0.0.SLEUTH_DOCS.jar" + +echo "Running docker processes" +docker ps + +rm -rf "${CURRENT_DIR}/build" \ No newline at end of file diff --git a/scripts/runAcceptanceTests.sh b/scripts/runAcceptanceTests.sh new file mode 100755 index 0000000..e8bf57a --- /dev/null +++ b/scripts/runAcceptanceTests.sh @@ -0,0 +1,63 @@ +#!/usr/bin/env bash + +set -o errexit + +export CURRENT_DIR="$( pwd )" +export KILL_AT_END="${KILL_AT_END:-yes}" +# since 8081-8084 are often taken will bump those to 9081-9084 +export DEFAULT_HEALTH_HOST=${DEFAULT_HEALTH_HOST:-localhost} +export SERVICE1_PORT="${SERVICE1_PORT:-9081}" +export SERVICE1_ADDRESS="${SERVICE1_ADDRESS:-${DEFAULT_HEALTH_HOST}:${SERVICE1_PORT}}" +export SERVICE2_PORT="${SERVICE2_PORT:-9082}" +export SERVICE2_ADDRESS="${SERVICE2_ADDRESS:-${DEFAULT_HEALTH_HOST}:${SERVICE2_PORT}}" +export SERVICE3_PORT="${SERVICE3_PORT:-9083}" +export SERVICE3_ADDRESS="${SERVICE3_ADDRESS:-${DEFAULT_HEALTH_HOST}:${SERVICE3_PORT}}" +export SERVICE4_PORT="${SERVICE4_PORT:-9084}" +export SERVICE4_ADDRESS="${SERVICE4_ADDRESS:-${DEFAULT_HEALTH_HOST}:${SERVICE4_PORT}}" +export REPORTING_SYSTEM="${REPORTING_SYSTEM:-zipkin}" + +echo -e "\n\nRunning apps on addresses:\nservice1: [${SERVICE1_ADDRESS}]\nservice2: [${SERVICE2_ADDRESS}]\nservice3: [${SERVICE3_ADDRESS}]\nservice4: [${SERVICE4_ADDRESS}]\n\n" + +function print_logs() { + echo -e "\n\nSOMETHING WENT WRONG :( :( \n\n" + echo -e "\n\nPRINTING LOGS FROM ALL APPS\n\n" + tail -n +1 -- "${CURRENT_DIR}"/build/*.log +} + +function fail_with_message() { + echo -e $1 + print_logs + exit 1 +} + +export -f print_logs +export -f fail_with_message + +if [[ "${KILL_AT_END}" == "yes" ]] ; then + trap "{ ./scripts/kill.sh;docker ps -a -q | xargs -n 1 -P 8 -I {} docker rm --force {} || echo 'No docker containers running'; }" EXIT +fi + +# Kill the running apps +./scripts/kill.sh + +echo "Running reporting system [${REPORTING_SYSTEM}]" + +if [[ "${REPORTING_SYSTEM}" == "zipkin" ]]; then + # Next run the `./runApps.sh` script to initialize Zipkin and the apps (check the `README` of `sleuth-documentation-apps` for Docker setup info) + ./scripts/start_with_zipkin_server.sh +elif [[ "${REPORTING_SYSTEM}" == "wavefront" ]]; then + ./scripts/start_with_wavefront.sh +else + fail_with_message "No matching reporting system" +fi + +echo -e "\n\nReady to curl first request" + +./scripts/curl_start.sh || fail_with_message "Failed to send the request" + +echo -e "\n\nReady to curl a request that will cause an exception" + +./scripts/curl_exception.sh && fail_with_message "\n\nShould have failed the request but didn't :/" || echo -e "\n\nSent a request and got an exception!" + +echo -e "\n\nRunning acceptance tests" +./scripts/run_acceptance_tests.sh diff --git a/scripts/run_acceptance_tests.sh b/scripts/run_acceptance_tests.sh new file mode 100755 index 0000000..cee583e --- /dev/null +++ b/scripts/run_acceptance_tests.sh @@ -0,0 +1,34 @@ +#!/bin/bash + +set -e + +DEFAULT_HEALTH_HOST=${DEFAULT_HEALTH_HOST:-localhost} + +if [[ "${REPORTING_SYSTEM}" == "zipkin" ]]; then + ./mvnw clean install -Ptests +fi + +mkdir -p build +TESTS_PASSED="no" +echo -e "\n\nChecking if baggage was properly propagated\n\n" +grep "Service1: Baggage for \[key\] is \[foo\]" build/service1.log && +grep "Service2: Baggage for \[key\] is \[foo\]" build/service2.log && +grep "Service3: Baggage for \[key\] is \[foo\]" build/service3.log && +grep "Service4: Baggage for \[key\] is \[foo\]" build/service4.log + +echo -e "\n\nChecking if baggage was properly set in the logs\n\n" +grep "\,foo" build/service1.log && +grep "\,foo" build/service2.log && +grep "\,foo" build/service3.log && +grep "\,foo" build/service4.log && +TESTS_PASSED="yes" && echo "Baggage works fine!" + + +# Check the result of tests execution +if [[ "${TESTS_PASSED}" == "yes" ]] ; then + echo -e "\n\nBaggage was propagated successfully" + exit 0 +else + echo -e "\n\nBaggage wasn't propagated" + exit 1 +fi diff --git a/scripts/run_performance_tests.sh b/scripts/run_performance_tests.sh new file mode 100755 index 0000000..e45829c --- /dev/null +++ b/scripts/run_performance_tests.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +set -e + +wrk -t2 -c100 -d5 -R 18000 -L http://localhost:9876/ diff --git a/scripts/start_with_running_infra.sh b/scripts/start_with_running_infra.sh new file mode 100755 index 0000000..7a650d9 --- /dev/null +++ b/scripts/start_with_running_infra.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +set -e + +SERVICE1_PORT="${SERVICE1_PORT:-8081}" +SERVICE2_PORT="${SERVICE2_PORT:-8082}" +SERVICE3_PORT="${SERVICE3_PORT:-8083}" +SERVICE4_PORT="${SERVICE4_PORT:-8084}" + +# build apps +./mvnw clean install -Pnotests + +ROOT_FOLDER=${ROOT_FOLDER:-.} +if [[ "${JAVA_HOME}" != "" ]]; then + JAVA_BIN="${JAVA_HOME}/bin/java" +else + JAVA_BIN="java" +fi + +mkdir -p "${ROOT_FOLDER}/service1/build/" +mkdir -p "${ROOT_FOLDER}/service2/build/" +mkdir -p "${ROOT_FOLDER}/service3/build/" +mkdir -p "${ROOT_FOLDER}/service4/build/" + +nohup ${JAVA_BIN} -jar "${ROOT_FOLDER}/service1/build/*.jar" --server.port="${SERVICE1_PORT}" > target/service1.log & +nohup ${JAVA_BIN} -jar "${ROOT_FOLDER}/service2/build/*.jar" --server.port="${SERVICE2_PORT}" > target/service2.log & +nohup ${JAVA_BIN} -jar "${ROOT_FOLDER}/service3/build/*.jar" --server.port="${SERVICE3_PORT}" > target/service3.log & +nohup ${JAVA_BIN} -jar "${ROOT_FOLDER}/service4/build/*.jar" --server.port="${SERVICE4_PORT}" > target/service4.log & diff --git a/scripts/start_with_wavefront.sh b/scripts/start_with_wavefront.sh new file mode 100755 index 0000000..0944e10 --- /dev/null +++ b/scripts/start_with_wavefront.sh @@ -0,0 +1,108 @@ +#!/bin/bash + +set -o errexit + +RABBIT_PORT=${RABBIT_PORT:-9672} +DEFAULT_HEALTH_HOST=${DEFAULT_HEALTH_HOST:-localhost} +export SPRING_RABBITMQ_HOST="${DEFAULT_HEALTH_HOST}" +export SPRING_RABBITMQ_PORT="${RABBIT_PORT}" +WITH_RABBIT="${WITH_RABBIT:-no}" +WAIT_TIME="${WAIT_TIME:-5}" +RETRIES="${RETRIES:-30}" +SERVICE1_PORT="${SERVICE1_PORT:-8081}" +SERVICE2_PORT="${SERVICE2_PORT:-8082}" +SERVICE3_PORT="${SERVICE3_PORT:-8083}" +SERVICE4_PORT="${SERVICE4_PORT:-8084}" +ZIPKIN_PORT="${ZIPKIN_PORT:-9411}" +JAVA_PATH_TO_BIN="${JAVA_HOME}/bin/" +if [[ -z "${JAVA_HOME}" ]] ; then + JAVA_PATH_TO_BIN="" +fi + +[[ -z "${MEM_ARGS}" ]] && MEM_ARGS="-Xmx128m -Xss1024k" + +mkdir -p target + +function check_app() { + READY_FOR_TESTS="no" + curl_local_health_endpoint $1 && READY_FOR_TESTS="yes" || echo "Failed to reach health endpoint" + if [[ "${READY_FOR_TESTS}" == "no" ]] ; then + echo "Failed to start service running at port $1" + print_logs + exit 1 + fi +} + +# ${RETRIES} number of times will try to curl to /health endpoint to passed port $1 and localhost +function curl_local_health_endpoint() { + curl_health_endpoint $1 "127.0.0.1" +} + +# ${RETRIES} number of times will try to curl to /health endpoint to passed port $1 and host $2 +function curl_health_endpoint() { + local PASSED_HOST="${2:-$HEALTH_HOST}" + local READY_FOR_TESTS=1 + for i in $( seq 1 "${RETRIES}" ); do + sleep "${WAIT_TIME}" + curl --fail -m 5 "${PASSED_HOST}:$1/health" && READY_FOR_TESTS=0 && break || echo "Failed" + echo "Fail #$i/${RETRIES}... will try again in [${WAIT_TIME}] seconds" + done + return ${READY_FOR_TESTS} +} + +# Kills all docker related elements +function kill_docker() { + docker ps -a -q | xargs -n 1 -P 8 -I {} docker stop {} || echo "No running docker containers are left" +} + +export LOGZ_IO_API_TOKEN="${LOGZ_IO_API_TOKEN:-}" +PROFILES="notests,wavefront" + +if [[ "${LOGZ_IO_API_TOKEN}" != "" ]]; then + echo "Logz io token present - will enable the logzio profile" + PROFILES="${PROFILES},logzio" + TOKENS="--spring.profiles.active=logzio" + rm -rf /tmp/logzio-logback-queue/ +else + echo "Logz io token missing" + TOKENS="--spring.profiles.active=default" +fi + +echo "Building the apps with profiles [${PROFILES}]" + +./mvnw clean install -P"${PROFILES}" + +if [[ "${WITH_RABBIT}" == "yes" ]] ; then + # run rabbit + #kill_docker || echo "Failed to kill" + docker-compose kill || echo "Failed to kill" + docker-compose pull + docker-compose up -d +fi + +if [[ "${JAVA_HOME}" != "" ]]; then + JAVA_BIN="${JAVA_HOME}/bin/java" +else + JAVA_BIN="java" +fi + +export WAVEFRONT_API_TOKEN="${WAVEFRONT_API_TOKEN:-}" +echo "Will prepend the following runtime arguments [${TOKENS}]" +TOKENS="${TOKENS} --management.metrics.export.wavefront.api-token=${WAVEFRONT_API_TOKEN} --management.metrics.export.wavefront.uri=${WAVEFRONT_URI:-https://demo.wavefront.com}" + +mkdir -p build + +echo -e "\nStarting the apps..." +nohup ${JAVA_PATH_TO_BIN}java ${MEM_ARGS} -jar service1/target/*.jar --debug --server.port="${SERVICE1_PORT}" ${TOKENS} > build/service1.log 2>&1 & +nohup ${JAVA_PATH_TO_BIN}java ${MEM_ARGS} -jar service2/target/*.jar --debug --server.port="${SERVICE2_PORT}" ${TOKENS} > build/service2.log 2>&1 & +nohup ${JAVA_PATH_TO_BIN}java ${MEM_ARGS} -jar service3/target/*.jar --debug --server.port="${SERVICE3_PORT}" ${TOKENS} > build/service3.log 2>&1 & +nohup ${JAVA_PATH_TO_BIN}java ${MEM_ARGS} -jar service4/target/*.jar --debug --server.port="${SERVICE4_PORT}" ${TOKENS} > build/service4.log 2>&1 & + +echo -e "\n\nChecking if Service1 is alive" +check_app ${SERVICE1_PORT} +echo -e "\n\nChecking if Service2 is alive" +check_app ${SERVICE2_PORT} +echo -e "\n\nChecking if Service3 is alive" +check_app ${SERVICE3_PORT} +echo -e "\n\nChecking if Service4 is alive" +check_app ${SERVICE4_PORT} diff --git a/scripts/start_with_zipkin_server.sh b/scripts/start_with_zipkin_server.sh new file mode 100755 index 0000000..1c3626d --- /dev/null +++ b/scripts/start_with_zipkin_server.sh @@ -0,0 +1,119 @@ +#!/bin/bash + +set -o errexit + +RABBIT_PORT=${RABBIT_PORT:-9672} +DEFAULT_HEALTH_HOST=${DEFAULT_HEALTH_HOST:-localhost} +export SPRING_RABBITMQ_HOST="${DEFAULT_HEALTH_HOST}" +export SPRING_RABBITMQ_PORT="${RABBIT_PORT}" +WITH_RABBIT="${WITH_RABBIT:-no}" +WAIT_TIME="${WAIT_TIME:-5}" +RETRIES="${RETRIES:-30}" +SERVICE1_PORT="${SERVICE1_PORT:-8081}" +SERVICE2_PORT="${SERVICE2_PORT:-8082}" +SERVICE3_PORT="${SERVICE3_PORT:-8083}" +SERVICE4_PORT="${SERVICE4_PORT:-8084}" +ZIPKIN_PORT="${ZIPKIN_PORT:-9411}" +JAVA_PATH_TO_BIN="${JAVA_HOME}/bin/" +if [[ -z "${JAVA_HOME}" ]] ; then + JAVA_PATH_TO_BIN="" +fi +DOWNLOAD_ZIPKIN="${DOWNLOAD_ZIPKIN:-true}" + +[[ -z "${MEM_ARGS}" ]] && MEM_ARGS="-Xmx128m -Xss1024k" + +mkdir -p target + +function check_app() { + READY_FOR_TESTS="no" + curl_local_health_endpoint $1 && READY_FOR_TESTS="yes" || echo "Failed to reach health endpoint" + if [[ "${READY_FOR_TESTS}" == "no" ]] ; then + echo "Failed to start service running at port $1" + print_logs + exit 1 + fi +} + +# ${RETRIES} number of times will try to curl to /health endpoint to passed port $1 and localhost +function curl_local_health_endpoint() { + curl_health_endpoint $1 "127.0.0.1" +} + +# ${RETRIES} number of times will try to curl to /health endpoint to passed port $1 and host $2 +function curl_health_endpoint() { + local PASSED_HOST="${2:-$HEALTH_HOST}" + local READY_FOR_TESTS=1 + for i in $( seq 1 "${RETRIES}" ); do + sleep "${WAIT_TIME}" + curl --fail -m 5 "${PASSED_HOST}:$1/health" && READY_FOR_TESTS=0 && break || echo "Failed" + echo "Fail #$i/${RETRIES}... will try again in [${WAIT_TIME}] seconds" + done + return ${READY_FOR_TESTS} +} + +# Kills all docker related elements +function kill_docker() { + docker ps -a -q | xargs -n 1 -P 8 -I {} docker stop {} || echo "No running docker containers are left" +} + +# build apps +./mvnw clean install -Pnotests + +if [[ "${WITH_RABBIT}" == "yes" ]] ; then + # run rabbit + #kill_docker || echo "Failed to kill" + docker-compose kill || echo "Failed to kill" + docker-compose pull + docker-compose up -d +fi + +if [[ "${JAVA_HOME}" != "" ]]; then + JAVA_BIN="${JAVA_HOME}/bin/java" +else + JAVA_BIN="java" +fi + +# nohup ${JAVA_HOME}/bin/java ${DEFAULT_ARGS} ${MEM_ARGS} -jar zipkin-server/zipkin-server-*-exec.jar > target/zipkin-server.out & +pushd zipkin-server +mkdir -p target +cd target +if [[ "${DOWNLOAD_ZIPKIN}" == "true" ]]; then + echo -e "\nDownloading Zipkin Server" + rm -rf zipkin.jar || echo "No zipkin.jar to remove" + curl -sSL https://zipkin.io/quickstart.sh | bash -s +else + echo "Won't download zipkin - the [DOWNLOAD_ZIPKIN] switch is set to false" +fi +popd + +echo -e "\nWaiting for 30 seconds for rabbit to work" +sleep 30 + +echo -e "\nStarting Zipkin Server..." +if [[ "${WITH_RABBIT}" == "yes" ]] ; then + echo "Will use rabbit to send spans" + ZIPKIN_ARGS="-DRABBIT_ADDRESSES=${DEFAULT_HEALTH_HOST}:${RABBIT_PORT}" +else + echo "Will use web to send spans" + MEM_ARGS="${MEM_ARGS} -Dspring.zipkin.sender.type=WEB" +fi + +mkdir -p build +nohup ${JAVA_PATH_TO_BIN}java ${MEM_ARGS} ${ZIPKIN_ARGS} -jar zipkin-server/target/zipkin.jar > build/zipkin.log & + +echo -e "\nStarting the apps..." +nohup ${JAVA_PATH_TO_BIN}java ${MEM_ARGS} -jar service1/target/*.jar --server.port="${SERVICE1_PORT}" > build/service1.log & +nohup ${JAVA_PATH_TO_BIN}java ${MEM_ARGS} -jar service2/target/*.jar --server.port="${SERVICE2_PORT}" > build/service2.log & +nohup ${JAVA_PATH_TO_BIN}java ${MEM_ARGS} -jar service3/target/*.jar --server.port="${SERVICE3_PORT}" > build/service3.log & +nohup ${JAVA_PATH_TO_BIN}java ${MEM_ARGS} -jar service4/target/*.jar --server.port="${SERVICE4_PORT}" > build/service4.log & + +echo -e "\n\nChecking if Zipkin is alive" +check_app ${ZIPKIN_PORT} +echo -e "\n\nChecking if Service1 is alive" +check_app ${SERVICE1_PORT} +echo -e "\n\nChecking if Service2 is alive" +check_app ${SERVICE2_PORT} +echo -e "\n\nChecking if Service3 is alive" +check_app ${SERVICE3_PORT} +echo -e "\n\nChecking if Service4 is alive" +check_app ${SERVICE4_PORT} diff --git a/scripts/start_with_zipkin_server_and_run_tests.sh b/scripts/start_with_zipkin_server_and_run_tests.sh new file mode 100755 index 0000000..0929e09 --- /dev/null +++ b/scripts/start_with_zipkin_server_and_run_tests.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +set -e +CURRENT=`pwd` + +if [[ ! -e "${CURRENT}/scripts" ]]; then + . ./start_with_zipkin_server.sh + . ./run_acceptance_tests.sh +else + . ./scripts/start_with_zipkin_server.sh + . ./scripts/run_acceptance_tests.sh +fi diff --git a/service1/.mvn/wrapper/maven-wrapper.jar b/service1/.mvn/wrapper/maven-wrapper.jar new file mode 100644 index 0000000..5fd4d50 Binary files /dev/null and b/service1/.mvn/wrapper/maven-wrapper.jar differ diff --git a/service1/.mvn/wrapper/maven-wrapper.properties b/service1/.mvn/wrapper/maven-wrapper.properties new file mode 100644 index 0000000..c315043 --- /dev/null +++ b/service1/.mvn/wrapper/maven-wrapper.properties @@ -0,0 +1 @@ +distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.0/apache-maven-3.5.0-bin.zip diff --git a/service1/manifest.yml b/service1/manifest.yml new file mode 100644 index 0000000..8a0ec81 --- /dev/null +++ b/service1/manifest.yml @@ -0,0 +1,14 @@ +--- +applications: +- name: docssleuth-service1 + memory: 1024m + instances: 1 + host: docssleuth-service1 + path: target/service1-1.0.0.SLEUTH_DOCS.jar + services: + - docssleuth-rabbitmq + env: + SPRING_PROFILES_ACTIVE: cloud + SERVICE2_ADDRESS: docssleuth-service2.cfapps.io + SPRING_RABBITMQ_ADDRESSES: ${vcap.services.docssleuth-rabbitmq.credentials.uri} + DEBUG: "true" diff --git a/service1/mvnw b/service1/mvnw new file mode 100755 index 0000000..a1ba1bf --- /dev/null +++ b/service1/mvnw @@ -0,0 +1,233 @@ +#!/bin/sh +# ---------------------------------------------------------------------------- +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# ---------------------------------------------------------------------------- + +# ---------------------------------------------------------------------------- +# Maven2 Start Up Batch script +# +# Required ENV vars: +# ------------------ +# JAVA_HOME - location of a JDK home dir +# +# Optional ENV vars +# ----------------- +# M2_HOME - location of maven2's installed home dir +# MAVEN_OPTS - parameters passed to the Java VM when running Maven +# e.g. to debug Maven itself, use +# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +# MAVEN_SKIP_RC - flag to disable loading of mavenrc files +# ---------------------------------------------------------------------------- + +if [ -z "$MAVEN_SKIP_RC" ] ; then + + if [ -f /etc/mavenrc ] ; then + . /etc/mavenrc + fi + + if [ -f "$HOME/.mavenrc" ] ; then + . "$HOME/.mavenrc" + fi + +fi + +# OS specific support. $var _must_ be set to either true or false. +cygwin=false; +darwin=false; +mingw=false +case "`uname`" in + CYGWIN*) cygwin=true ;; + MINGW*) mingw=true;; + Darwin*) darwin=true + # + # Look for the Apple JDKs first to preserve the existing behaviour, and then look + # for the new JDKs provided by Oracle. + # + if [ -z "$JAVA_HOME" ] && [ -L /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK ] ; then + # + # Apple JDKs + # + export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home + fi + + if [ -z "$JAVA_HOME" ] && [ -L /System/Library/Java/JavaVirtualMachines/CurrentJDK ] ; then + # + # Apple JDKs + # + export JAVA_HOME=/System/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home + fi + + if [ -z "$JAVA_HOME" ] && [ -L "/Library/Java/JavaVirtualMachines/CurrentJDK" ] ; then + # + # Oracle JDKs + # + export JAVA_HOME=/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home + fi + + if [ -z "$JAVA_HOME" ] && [ -x "/usr/libexec/java_home" ]; then + # + # Apple JDKs + # + export JAVA_HOME=`/usr/libexec/java_home` + fi + ;; +esac + +if [ -z "$JAVA_HOME" ] ; then + if [ -r /etc/gentoo-release ] ; then + JAVA_HOME=`java-config --jre-home` + fi +fi + +if [ -z "$M2_HOME" ] ; then + ## resolve links - $0 may be a link to maven's home + PRG="$0" + + # need this for relative symlinks + while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG="`dirname "$PRG"`/$link" + fi + done + + saveddir=`pwd` + + M2_HOME=`dirname "$PRG"`/.. + + # make it fully qualified + M2_HOME=`cd "$M2_HOME" && pwd` + + cd "$saveddir" + # echo Using m2 at $M2_HOME +fi + +# For Cygwin, ensure paths are in UNIX format before anything is touched +if $cygwin ; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --unix "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --unix "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --unix "$CLASSPATH"` +fi + +# For Migwn, ensure paths are in UNIX format before anything is touched +if $mingw ; then + [ -n "$M2_HOME" ] && + M2_HOME="`(cd "$M2_HOME"; pwd)`" + [ -n "$JAVA_HOME" ] && + JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" + # TODO classpath? +fi + +if [ -z "$JAVA_HOME" ]; then + javaExecutable="`which javac`" + if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then + # readlink(1) is not available as standard on Solaris 10. + readLink=`which readlink` + if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then + if $darwin ; then + javaHome="`dirname \"$javaExecutable\"`" + javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" + else + javaExecutable="`readlink -f \"$javaExecutable\"`" + fi + javaHome="`dirname \"$javaExecutable\"`" + javaHome=`expr "$javaHome" : '\(.*\)/bin'` + JAVA_HOME="$javaHome" + export JAVA_HOME + fi + fi +fi + +if [ -z "$JAVACMD" ] ; then + if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + else + JAVACMD="`which java`" + fi +fi + +if [ ! -x "$JAVACMD" ] ; then + echo "Error: JAVA_HOME is not defined correctly." >&2 + echo " We cannot execute $JAVACMD" >&2 + exit 1 +fi + +if [ -z "$JAVA_HOME" ] ; then + echo "Warning: JAVA_HOME environment variable is not set." +fi + +CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher + +# For Cygwin, switch paths to Windows format before running java +if $cygwin; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --path --windows "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --windows "$CLASSPATH"` +fi + +# traverses directory structure from process work directory to filesystem root +# first directory with .mvn subdirectory is considered project base directory +find_maven_basedir() { + local basedir=$(pwd) + local wdir=$(pwd) + while [ "$wdir" != '/' ] ; do + if [ -d "$wdir"/.mvn ] ; then + basedir=$wdir + break + fi + wdir=$(cd "$wdir/.."; pwd) + done + echo "${basedir}" +} + +# concatenates all lines of a file +concat_lines() { + if [ -f "$1" ]; then + echo "$(tr -s '\n' ' ' < "$1")" + fi +} + +export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-$(find_maven_basedir)} +MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" + +# Provide a "standardized" way to retrieve the CLI args that will +# work with both Windows and non-Windows executions. +MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" +export MAVEN_CMD_LINE_ARGS + +WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +exec "$JAVACMD" \ + $MAVEN_OPTS \ + -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ + "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ + ${WRAPPER_LAUNCHER} "$@" diff --git a/service1/mvnw.cmd b/service1/mvnw.cmd new file mode 100644 index 0000000..5a8e45d --- /dev/null +++ b/service1/mvnw.cmd @@ -0,0 +1,145 @@ +@REM ---------------------------------------------------------------------------- +@REM Licensed to the Apache Software Foundation (ASF) under one +@REM or more contributor license agreements. See the NOTICE file +@REM distributed with this work for additional information +@REM regarding copyright ownership. The ASF licenses this file +@REM to you under the Apache License, Version 2.0 (the +@REM "License"); you may not use this file except in compliance +@REM with the License. You may obtain a copy of the License at +@REM +@REM http://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, +@REM software distributed under the License is distributed on an +@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +@REM KIND, either express or implied. See the License for the +@REM specific language governing permissions and limitations +@REM under the License. +@REM ---------------------------------------------------------------------------- + +@REM ---------------------------------------------------------------------------- +@REM Maven2 Start Up Batch script +@REM +@REM Required ENV vars: +@REM JAVA_HOME - location of a JDK home dir +@REM +@REM Optional ENV vars +@REM M2_HOME - location of maven2's installed home dir +@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands +@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending +@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven +@REM e.g. to debug Maven itself, use +@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,city=8000 +@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files +@REM ---------------------------------------------------------------------------- + +@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' +@echo off +@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on' +@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% + +@REM set %HOME% to equivalent of $HOME +if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") + +@REM Execute a user defined script before this one +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre +@REM check for pre script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" +if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" +:skipRcPre + +@setlocal + +set ERROR_CODE=0 + +@REM To isolate internal variables from possible post scripts, we use another setlocal +@setlocal + +@REM ==== START VALIDATION ==== +if not "%JAVA_HOME%" == "" goto OkJHome + +echo. +echo Error: JAVA_HOME not found in your environment. >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +:OkJHome +if exist "%JAVA_HOME%\bin\java.exe" goto init + +echo. +echo Error: JAVA_HOME is set to an invalid directory. >&2 +echo JAVA_HOME = "%JAVA_HOME%" >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +@REM ==== END VALIDATION ==== + +:init + +set MAVEN_CMD_LINE_ARGS=%* + +@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". +@REM Fallback to current working directory if not found. + +set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% +IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir + +set EXEC_DIR=%CD% +set WDIR=%EXEC_DIR% +:findBaseDir +IF EXIST "%WDIR%"\.mvn goto baseDirFound +cd .. +IF "%WDIR%"=="%CD%" goto baseDirNotFound +set WDIR=%CD% +goto findBaseDir + +:baseDirFound +set MAVEN_PROJECTBASEDIR=%WDIR% +cd "%EXEC_DIR%" +goto endDetectBaseDir + +:baseDirNotFound +set MAVEN_PROJECTBASEDIR=%EXEC_DIR% +cd "%EXEC_DIR%" + +:endDetectBaseDir + +IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig + +@setlocal EnableExtensions EnableDelayedExpansion +for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a +@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% + +:endReadAdditionalConfig + +SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" + +set WRAPPER_JAR="".\.mvn\wrapper\maven-wrapper.jar"" +set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CMD_LINE_ARGS% +if ERRORLEVEL 1 goto error +goto end + +:error +set ERROR_CODE=1 + +:end +@endlocal & set ERROR_CODE=%ERROR_CODE% + +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost +@REM check for post script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" +if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" +:skipRcPost + +@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' +if "%MAVEN_BATCH_PAUSE%" == "on" pause + +if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% + +exit /B %ERROR_CODE% \ No newline at end of file diff --git a/service1/pom.xml b/service1/pom.xml new file mode 100644 index 0000000..16e0247 --- /dev/null +++ b/service1/pom.xml @@ -0,0 +1,210 @@ + + + 4.0.0 + io.spring.cloud.sleuth.docs + service1 + 1.0.0.SLEUTH_DOCS + + + org.springframework.boot + spring-boot-starter-parent + 2.7.4 + + + + + 2021.0.2-SNAPSHOT + 1.1.5-SNAPSHOT + UTF-8 + UTF-8 + 1.8 + + + + org.springframework.cloud + spring-cloud-starter-sleuth + + + org.springframework.cloud + spring-cloud-sleuth-brave + + + + + org.springframework.cloud + spring-cloud-sleuth-otel-autoconfigure + + + org.springframework.boot + spring-boot-starter-actuator + + + org.springframework.boot + spring-boot-starter-webflux + + + net.logstash.logback + logstash-logback-encoder + 7.2 + runtime + + + logback-core + ch.qos.logback + + + + + + + + org.springframework.cloud + spring-cloud-dependencies + ${spring-cloud.version} + import + pom + + + org.springframework.cloud + spring-cloud-sleuth-otel-dependencies + ${spring-cloud-sleuth-otel.version} + import + pom + + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + build-image + package + + build-image + + + + + + + + + + default + + true + + + + org.springframework.cloud + spring-cloud-sleuth-zipkin + compile + + + io.opentelemetry + opentelemetry-exporter-zipkin + + + + + wavefront + + 2.3.0 + + + + + com.wavefront + wavefront-spring-boot-bom + ${wavefront.version} + pom + import + + + + + + com.wavefront + wavefront-spring-boot-starter + + + + + logzio + + + io.logz.logback + logzio-logback-appender + 1.0.28 + + + + + + + + spring-snapshots + Spring Snapshots + https://repo.spring.io/snapshot + + true + + + + spring-milestones + Spring Milestones + https://repo.spring.io/milestone + + false + + + + spring-releases + Spring Releases + https://repo.spring.io/release + + false + + + + + + spring-snapshots + Spring Snapshots + https://repo.spring.io/snapshot + + true + + + + spring-milestones + Spring Milestones + https://repo.spring.io/milestone + + false + + + + spring-plugin-snapshots + Spring Snapshots + https://repo.spring.io/snapshot + + true + + + + spring-plugin-milestones + Spring Milestones + https://repo.spring.io/release + + false + + + + + diff --git a/service1/src/main/java/io/spring/cloud/sleuth/docs/service1/Application.java b/service1/src/main/java/io/spring/cloud/sleuth/docs/service1/Application.java index a117a3e..61903c5 100644 --- a/service1/src/main/java/io/spring/cloud/sleuth/docs/service1/Application.java +++ b/service1/src/main/java/io/spring/cloud/sleuth/docs/service1/Application.java @@ -1,32 +1,14 @@ package io.spring.cloud.sleuth.docs.service1; -import java.lang.invoke.MethodHandles; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; -import org.springframework.web.client.RestTemplate; +import org.springframework.context.annotation.Bean; +import org.springframework.web.reactive.function.client.WebClient; @SpringBootApplication -@RestController public class Application { - private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); - - @Autowired RestTemplate restTemplate; - - @RequestMapping("/start") - public String start() throws InterruptedException { - log.info("Hello from service1. Calling service2"); - String response = restTemplate.getForObject("http://localhost:8082/foo",String.class); - Thread.sleep(100); - log.info("Got response from service2 [{}]", response); - return response; - } + @Bean WebClient webClient() { return WebClient.create(); } public static void main(String... args) { new SpringApplication(Application.class).run(args); diff --git a/service1/src/main/java/io/spring/cloud/sleuth/docs/service1/Service1Controller.java b/service1/src/main/java/io/spring/cloud/sleuth/docs/service1/Service1Controller.java new file mode 100644 index 0000000..4ed0d19 --- /dev/null +++ b/service1/src/main/java/io/spring/cloud/sleuth/docs/service1/Service1Controller.java @@ -0,0 +1,39 @@ +package io.spring.cloud.sleuth.docs.service1; + +import java.time.LocalDateTime; + +import reactor.core.publisher.Mono; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class Service1Controller { + + private final Service2Client service2Client; + + public Service1Controller(Service2Client service2Client) { + this.service2Client = service2Client; + } + + @GetMapping("/start") + public Mono start() { + return this.service2Client.start(); + } + + @GetMapping("/readtimeout") + public Mono timeout() throws InterruptedException { + return service2Client.timeout(LocalDateTime.now().toString()); + } + + @PostMapping("/start") + public Mono postStart() { + return start(); + } + + @PostMapping("/readtimeout") + public Mono postTimeout() throws InterruptedException { + return timeout(); + } +} diff --git a/service1/src/main/java/io/spring/cloud/sleuth/docs/service1/Service2Client.java b/service1/src/main/java/io/spring/cloud/sleuth/docs/service1/Service2Client.java new file mode 100644 index 0000000..e354868 --- /dev/null +++ b/service1/src/main/java/io/spring/cloud/sleuth/docs/service1/Service2Client.java @@ -0,0 +1,86 @@ +package io.spring.cloud.sleuth.docs.service1; + +import java.lang.invoke.MethodHandles; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import reactor.core.publisher.Mono; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.cloud.sleuth.annotation.NewSpan; +import org.springframework.cloud.sleuth.annotation.SpanTag; +import org.springframework.cloud.sleuth.BaggageInScope; +import org.springframework.cloud.sleuth.Span; +import org.springframework.cloud.sleuth.Tracer; +import org.springframework.http.HttpStatus; +import org.springframework.stereotype.Component; +import org.springframework.util.StringUtils; +import org.springframework.web.reactive.function.client.ClientResponse; +import org.springframework.web.reactive.function.client.WebClient; + +/** + * @author Marcin Grzejszczak + */ +@Component +class Service2Client { + + private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); + + private final WebClient webClient; + private final String serviceAddress; + private final Tracer tracer; + + Service2Client(WebClient webClient, + @Value("${service2.address:localhost:8082}") String serviceAddress, + Tracer tracer) { + this.webClient = webClient; + this.serviceAddress = serviceAddress; + this.tracer = tracer; + } + + public Mono start() { + log.info("Hello from service1. Setting baggage foo=>bar"); + Span span = tracer.currentSpan(); + BaggageInScope secretBaggageField = this.tracer.getBaggage("baggage"); + String secretBaggage = secretBaggageField != null ? secretBaggageField.get() : null; + log.info("Super secret baggage item for key [baggage] is [{}]", secretBaggage); + if (StringUtils.hasText(secretBaggage)) { + span.event("secret_baggage_received"); + span.tag("baggage", secretBaggage); + } + String baggageKey = "key"; + String baggageValue = "foo"; + BaggageInScope baggageField = this.tracer.createBaggage(baggageKey); + baggageField.set(span.context(), baggageValue); + span.event("baggage_set"); + span.tag(baggageKey, baggageValue); + log.info("Hello from service1. Calling service2"); + return webClient.get() + .uri("http://" + serviceAddress + "/foo") + .exchange() + .doOnSuccess(clientResponse -> { + log.info("Got response from service2 [{}]", clientResponse); + try (BaggageInScope bs = this.tracer.getBaggage("key")) { + log.info("Service1: Baggage for [key] is [" + (bs == null ? null : bs.get()) + "]"); + } + }) + .flatMap(clientResponse -> clientResponse.bodyToMono(String.class)) + .doOnTerminate(() -> { + if (secretBaggageField != null) { + secretBaggageField.close(); + } + baggageField.close(); + }); + } + + @NewSpan("first_span") + Mono timeout(@SpanTag("someTag") String tag) throws InterruptedException { + Thread.sleep(300); + log.info("Hello from service1. Calling service2 - should end up with read timeout"); + return webClient.get() + .uri("http://" + serviceAddress + "/readtimeout") + .retrieve() + .onStatus(HttpStatus::is5xxServerError, ClientResponse::createException) + .bodyToMono(String.class); + } +} diff --git a/service1/src/main/java/io/spring/cloud/sleuth/docs/service1/StoringZipkinSpanReporter.java b/service1/src/main/java/io/spring/cloud/sleuth/docs/service1/StoringZipkinSpanReporter.java deleted file mode 100644 index 32e52b0..0000000 --- a/service1/src/main/java/io/spring/cloud/sleuth/docs/service1/StoringZipkinSpanReporter.java +++ /dev/null @@ -1,54 +0,0 @@ -package io.spring.cloud.sleuth.docs.service1; - -import com.google.common.collect.LinkedListMultimap; -import com.google.common.collect.Multimap; -import com.google.common.collect.Multimaps; -import java.lang.invoke.MethodHandles; -import java.util.Collection; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.cloud.sleuth.metric.SpanMetricReporter; -import org.springframework.cloud.sleuth.zipkin.HttpZipkinSpanReporter; -import org.springframework.cloud.sleuth.zipkin.ZipkinProperties; -import org.springframework.cloud.sleuth.zipkin.ZipkinSpanReporter; -import org.springframework.http.ResponseEntity; -import org.springframework.stereotype.Component; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; -import zipkin.Span; - -/** - * @author Marcin Grzejszczak - */ -@Component -@RestController -public class StoringZipkinSpanReporter implements ZipkinSpanReporter { - - private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); - - private final Multimap sentSpans = Multimaps.synchronizedListMultimap( - LinkedListMultimap.create()); - private final HttpZipkinSpanReporter delegate; - - @Autowired - public StoringZipkinSpanReporter(SpanMetricReporter spanMetricReporter, ZipkinProperties zipkin) { - delegate = new HttpZipkinSpanReporter(zipkin.getBaseUrl(), zipkin.getFlushInterval(), - zipkin.getCompression().isEnabled(), spanMetricReporter); - } - - @RequestMapping("/spans/{traceId}") - public ResponseEntity> spans(@PathVariable String traceId) { - Collection spansForTrace = sentSpans - .get(org.springframework.cloud.sleuth.Span.hexToId(traceId)); - return ResponseEntity.ok(spansForTrace); - } - - @Override - public void report(Span span) { - sentSpans.put(span.traceId, span); - log.info("Sending span [\n\n" + span.toString() + "\n\n] to Zipkin"); - delegate.report(span); - } -} diff --git a/service1/src/main/resources/application-logzio.yml b/service1/src/main/resources/application-logzio.yml new file mode 100644 index 0000000..305c54a --- /dev/null +++ b/service1/src/main/resources/application-logzio.yml @@ -0,0 +1 @@ +logging.pattern.level: "%5p [${spring.zipkin.service.name:${spring.application.name:}},%X{traceId:-},%X{spanId:-},%X{key:-}]" \ No newline at end of file diff --git a/service1/src/main/resources/application.yaml b/service1/src/main/resources/application.yaml index f24bb35..6d76e36 100644 --- a/service1/src/main/resources/application.yaml +++ b/service1/src/main/resources/application.yaml @@ -3,5 +3,28 @@ spring: application: name: service1 sleuth: + propagation: + type: + - b3 + - w3c + baggage: + remote-fields: + - baggage + - key + correlation-fields: + - key + otel: + config: + trace-id-ratio-based: 1.0 sampler: - percentage: 1.0 \ No newline at end of file + probability: 1.0 + +logging.level.org.springframework.cloud.sleuth: INFO + +management.endpoints.web.base-path: / +management.endpoints.web.exposure.include: "*" + +logging.pattern.level: "%5p [${spring.zipkin.service.name:${spring.application.name:}},%X{traceId:-},%X{spanId:-},%X{key:-}]" + +wavefront.application.name: sleuth-documentation-apps +wavefront.application.service: service1 \ No newline at end of file diff --git a/service1/src/main/resources/logback-spring.xml b/service1/src/main/resources/logback-spring.xml new file mode 100644 index 0000000..b73a180 --- /dev/null +++ b/service1/src/main/resources/logback-spring.xml @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + DEBUG + + + ${CONSOLE_LOG_PATTERN} + utf8 + + + + + + ${LOG_FILE} + + ${LOG_FILE}.%d{yyyy-MM-dd}.gz + 7 + + + ${CONSOLE_LOG_PATTERN} + utf8 + + + + + + ${LOG_FILE}.json + + ${LOG_FILE}.json.%d{yyyy-MM-dd}.gz + 7 + + + + + UTC + + + + { + "timestamp": "@timestamp", + "severity": "%level", + "service": "${springAppName:-}", + "trace": "%X{traceId:-}", + "span": "%X{spanId:-}", + "baggage": "%X{key:-}", + "pid": "${PID:-}", + "thread": "%thread", + "class": "%logger{40}", + "rest": "%message" + } + + + + + + + + + + + ${LOGZ_IO_API_TOKEN} + https://listener.logz.io:8071 + + INFO + + true + + + + UTC + + + + { + "timestamp": "@timestamp", + "severity": "%level", + "service": "${springAppName:-}", + "trace": "%X{traceId:-}", + "span": "%X{spanId:-}", + "baggage": "%X{key:-}", + "pid": "${PID:-}", + "thread": "%thread", + "class": "%logger{40}", + "rest": "%message" + } + + + + + + + + + + + + + + + + + + + diff --git a/service2/.mvn/wrapper/maven-wrapper.jar b/service2/.mvn/wrapper/maven-wrapper.jar new file mode 100644 index 0000000..5fd4d50 Binary files /dev/null and b/service2/.mvn/wrapper/maven-wrapper.jar differ diff --git a/service2/.mvn/wrapper/maven-wrapper.properties b/service2/.mvn/wrapper/maven-wrapper.properties new file mode 100644 index 0000000..c315043 --- /dev/null +++ b/service2/.mvn/wrapper/maven-wrapper.properties @@ -0,0 +1 @@ +distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.0/apache-maven-3.5.0-bin.zip diff --git a/service2/manifest.yml b/service2/manifest.yml new file mode 100644 index 0000000..a122a99 --- /dev/null +++ b/service2/manifest.yml @@ -0,0 +1,15 @@ +--- +applications: +- name: docssleuth-service2 + memory: 1024M + instances: 1 + host: docssleuth-service2 + path: target/service2-1.0.0.SLEUTH_DOCS.jar + services: + - docssleuth-rabbitmq + env: + SPRING_PROFILES_ACTIVE: cloud + SERVICE3_ADDRESS: docssleuth-service3.cfapps.io + SERVICE4_ADDRESS: docssleuth-service4.cfapps.io + SPRING_RABBITMQ_ADDRESSES: ${vcap.services.docssleuth-rabbitmq.credentials.uri} + DEBUG: "true" diff --git a/service2/mvnw b/service2/mvnw new file mode 100755 index 0000000..a1ba1bf --- /dev/null +++ b/service2/mvnw @@ -0,0 +1,233 @@ +#!/bin/sh +# ---------------------------------------------------------------------------- +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# ---------------------------------------------------------------------------- + +# ---------------------------------------------------------------------------- +# Maven2 Start Up Batch script +# +# Required ENV vars: +# ------------------ +# JAVA_HOME - location of a JDK home dir +# +# Optional ENV vars +# ----------------- +# M2_HOME - location of maven2's installed home dir +# MAVEN_OPTS - parameters passed to the Java VM when running Maven +# e.g. to debug Maven itself, use +# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +# MAVEN_SKIP_RC - flag to disable loading of mavenrc files +# ---------------------------------------------------------------------------- + +if [ -z "$MAVEN_SKIP_RC" ] ; then + + if [ -f /etc/mavenrc ] ; then + . /etc/mavenrc + fi + + if [ -f "$HOME/.mavenrc" ] ; then + . "$HOME/.mavenrc" + fi + +fi + +# OS specific support. $var _must_ be set to either true or false. +cygwin=false; +darwin=false; +mingw=false +case "`uname`" in + CYGWIN*) cygwin=true ;; + MINGW*) mingw=true;; + Darwin*) darwin=true + # + # Look for the Apple JDKs first to preserve the existing behaviour, and then look + # for the new JDKs provided by Oracle. + # + if [ -z "$JAVA_HOME" ] && [ -L /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK ] ; then + # + # Apple JDKs + # + export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home + fi + + if [ -z "$JAVA_HOME" ] && [ -L /System/Library/Java/JavaVirtualMachines/CurrentJDK ] ; then + # + # Apple JDKs + # + export JAVA_HOME=/System/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home + fi + + if [ -z "$JAVA_HOME" ] && [ -L "/Library/Java/JavaVirtualMachines/CurrentJDK" ] ; then + # + # Oracle JDKs + # + export JAVA_HOME=/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home + fi + + if [ -z "$JAVA_HOME" ] && [ -x "/usr/libexec/java_home" ]; then + # + # Apple JDKs + # + export JAVA_HOME=`/usr/libexec/java_home` + fi + ;; +esac + +if [ -z "$JAVA_HOME" ] ; then + if [ -r /etc/gentoo-release ] ; then + JAVA_HOME=`java-config --jre-home` + fi +fi + +if [ -z "$M2_HOME" ] ; then + ## resolve links - $0 may be a link to maven's home + PRG="$0" + + # need this for relative symlinks + while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG="`dirname "$PRG"`/$link" + fi + done + + saveddir=`pwd` + + M2_HOME=`dirname "$PRG"`/.. + + # make it fully qualified + M2_HOME=`cd "$M2_HOME" && pwd` + + cd "$saveddir" + # echo Using m2 at $M2_HOME +fi + +# For Cygwin, ensure paths are in UNIX format before anything is touched +if $cygwin ; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --unix "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --unix "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --unix "$CLASSPATH"` +fi + +# For Migwn, ensure paths are in UNIX format before anything is touched +if $mingw ; then + [ -n "$M2_HOME" ] && + M2_HOME="`(cd "$M2_HOME"; pwd)`" + [ -n "$JAVA_HOME" ] && + JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" + # TODO classpath? +fi + +if [ -z "$JAVA_HOME" ]; then + javaExecutable="`which javac`" + if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then + # readlink(1) is not available as standard on Solaris 10. + readLink=`which readlink` + if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then + if $darwin ; then + javaHome="`dirname \"$javaExecutable\"`" + javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" + else + javaExecutable="`readlink -f \"$javaExecutable\"`" + fi + javaHome="`dirname \"$javaExecutable\"`" + javaHome=`expr "$javaHome" : '\(.*\)/bin'` + JAVA_HOME="$javaHome" + export JAVA_HOME + fi + fi +fi + +if [ -z "$JAVACMD" ] ; then + if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + else + JAVACMD="`which java`" + fi +fi + +if [ ! -x "$JAVACMD" ] ; then + echo "Error: JAVA_HOME is not defined correctly." >&2 + echo " We cannot execute $JAVACMD" >&2 + exit 1 +fi + +if [ -z "$JAVA_HOME" ] ; then + echo "Warning: JAVA_HOME environment variable is not set." +fi + +CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher + +# For Cygwin, switch paths to Windows format before running java +if $cygwin; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --path --windows "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --windows "$CLASSPATH"` +fi + +# traverses directory structure from process work directory to filesystem root +# first directory with .mvn subdirectory is considered project base directory +find_maven_basedir() { + local basedir=$(pwd) + local wdir=$(pwd) + while [ "$wdir" != '/' ] ; do + if [ -d "$wdir"/.mvn ] ; then + basedir=$wdir + break + fi + wdir=$(cd "$wdir/.."; pwd) + done + echo "${basedir}" +} + +# concatenates all lines of a file +concat_lines() { + if [ -f "$1" ]; then + echo "$(tr -s '\n' ' ' < "$1")" + fi +} + +export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-$(find_maven_basedir)} +MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" + +# Provide a "standardized" way to retrieve the CLI args that will +# work with both Windows and non-Windows executions. +MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" +export MAVEN_CMD_LINE_ARGS + +WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +exec "$JAVACMD" \ + $MAVEN_OPTS \ + -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ + "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ + ${WRAPPER_LAUNCHER} "$@" diff --git a/service2/mvnw.cmd b/service2/mvnw.cmd new file mode 100644 index 0000000..5a8e45d --- /dev/null +++ b/service2/mvnw.cmd @@ -0,0 +1,145 @@ +@REM ---------------------------------------------------------------------------- +@REM Licensed to the Apache Software Foundation (ASF) under one +@REM or more contributor license agreements. See the NOTICE file +@REM distributed with this work for additional information +@REM regarding copyright ownership. The ASF licenses this file +@REM to you under the Apache License, Version 2.0 (the +@REM "License"); you may not use this file except in compliance +@REM with the License. You may obtain a copy of the License at +@REM +@REM http://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, +@REM software distributed under the License is distributed on an +@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +@REM KIND, either express or implied. See the License for the +@REM specific language governing permissions and limitations +@REM under the License. +@REM ---------------------------------------------------------------------------- + +@REM ---------------------------------------------------------------------------- +@REM Maven2 Start Up Batch script +@REM +@REM Required ENV vars: +@REM JAVA_HOME - location of a JDK home dir +@REM +@REM Optional ENV vars +@REM M2_HOME - location of maven2's installed home dir +@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands +@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending +@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven +@REM e.g. to debug Maven itself, use +@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,city=8000 +@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files +@REM ---------------------------------------------------------------------------- + +@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' +@echo off +@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on' +@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% + +@REM set %HOME% to equivalent of $HOME +if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") + +@REM Execute a user defined script before this one +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre +@REM check for pre script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" +if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" +:skipRcPre + +@setlocal + +set ERROR_CODE=0 + +@REM To isolate internal variables from possible post scripts, we use another setlocal +@setlocal + +@REM ==== START VALIDATION ==== +if not "%JAVA_HOME%" == "" goto OkJHome + +echo. +echo Error: JAVA_HOME not found in your environment. >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +:OkJHome +if exist "%JAVA_HOME%\bin\java.exe" goto init + +echo. +echo Error: JAVA_HOME is set to an invalid directory. >&2 +echo JAVA_HOME = "%JAVA_HOME%" >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +@REM ==== END VALIDATION ==== + +:init + +set MAVEN_CMD_LINE_ARGS=%* + +@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". +@REM Fallback to current working directory if not found. + +set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% +IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir + +set EXEC_DIR=%CD% +set WDIR=%EXEC_DIR% +:findBaseDir +IF EXIST "%WDIR%"\.mvn goto baseDirFound +cd .. +IF "%WDIR%"=="%CD%" goto baseDirNotFound +set WDIR=%CD% +goto findBaseDir + +:baseDirFound +set MAVEN_PROJECTBASEDIR=%WDIR% +cd "%EXEC_DIR%" +goto endDetectBaseDir + +:baseDirNotFound +set MAVEN_PROJECTBASEDIR=%EXEC_DIR% +cd "%EXEC_DIR%" + +:endDetectBaseDir + +IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig + +@setlocal EnableExtensions EnableDelayedExpansion +for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a +@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% + +:endReadAdditionalConfig + +SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" + +set WRAPPER_JAR="".\.mvn\wrapper\maven-wrapper.jar"" +set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CMD_LINE_ARGS% +if ERRORLEVEL 1 goto error +goto end + +:error +set ERROR_CODE=1 + +:end +@endlocal & set ERROR_CODE=%ERROR_CODE% + +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost +@REM check for post script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" +if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" +:skipRcPost + +@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' +if "%MAVEN_BATCH_PAUSE%" == "on" pause + +if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% + +exit /B %ERROR_CODE% \ No newline at end of file diff --git a/service2/pom.xml b/service2/pom.xml new file mode 100644 index 0000000..7e8cf7d --- /dev/null +++ b/service2/pom.xml @@ -0,0 +1,187 @@ + + + 4.0.0 + io.spring.cloud.sleuth.docs + service2 + 1.0.0.SLEUTH_DOCS + + + org.springframework.boot + spring-boot-starter-parent + 2.7.4 + + + + + 2021.0.2-SNAPSHOT + UTF-8 + UTF-8 + 1.8 + + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.cloud + spring-cloud-starter-sleuth + + + org.springframework.boot + spring-boot-starter-actuator + + + net.logstash.logback + logstash-logback-encoder + 7.2 + runtime + + + logback-core + ch.qos.logback + + + + + + + + org.springframework.cloud + spring-cloud-dependencies + ${spring-cloud.version} + import + pom + + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + build-image + package + + build-image + + + + + + + + + + default + + true + + + + org.springframework.cloud + spring-cloud-sleuth-zipkin + + + + + wavefront + + 2.3.0 + + + + + com.wavefront + wavefront-spring-boot-bom + ${wavefront.version} + pom + import + + + + + + com.wavefront + wavefront-spring-boot-starter + + + + + logzio + + + io.logz.logback + logzio-logback-appender + 1.0.28 + + + + + + + + spring-snapshots + Spring Snapshots + https://repo.spring.io/snapshot + + true + + + + spring-milestones + Spring Milestones + https://repo.spring.io/milestone + + false + + + + spring-releases + Spring Releases + https://repo.spring.io/release + + false + + + + + + spring-snapshots + Spring Snapshots + https://repo.spring.io/snapshot + + true + + + + spring-milestones + Spring Milestones + https://repo.spring.io/milestone + + false + + + + spring-plugin-snapshots + Spring Snapshots + https://repo.spring.io/snapshot + + true + + + + spring-plugin-milestones + Spring Milestones + https://repo.spring.io/release + + false + + + + + diff --git a/service2/src/main/java/io/spring/cloud/sleuth/docs/service2/Application.java b/service2/src/main/java/io/spring/cloud/sleuth/docs/service2/Application.java index f6af744..23537bd 100644 --- a/service2/src/main/java/io/spring/cloud/sleuth/docs/service2/Application.java +++ b/service2/src/main/java/io/spring/cloud/sleuth/docs/service2/Application.java @@ -1,36 +1,135 @@ package io.spring.cloud.sleuth.docs.service2; -import java.lang.invoke.MethodHandles; +import java.io.IOException; +import java.util.concurrent.Callable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; + +import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.cloud.sleuth.BaggageInScope; +import org.springframework.cloud.sleuth.Span; +import org.springframework.cloud.sleuth.Tracer; +import org.springframework.context.annotation.Bean; +import org.springframework.http.client.ClientHttpResponse; +import org.springframework.http.client.SimpleClientHttpRequestFactory; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.client.DefaultResponseErrorHandler; import org.springframework.web.client.RestTemplate; @SpringBootApplication @RestController public class Application { - private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); + private static final Logger log = LoggerFactory.getLogger(Application.class); - @Autowired RestTemplate restTemplate; + @Bean + RestTemplate restTemplate() { + SimpleClientHttpRequestFactory clientHttpRequestFactory = new SimpleClientHttpRequestFactory(); + clientHttpRequestFactory.setConnectTimeout(2000); + clientHttpRequestFactory.setReadTimeout(3000); + RestTemplate restTemplate = new RestTemplate(clientHttpRequestFactory); + restTemplate.setErrorHandler(new DefaultResponseErrorHandler() { + @Override + public boolean hasError(ClientHttpResponse response) + throws IOException { + try { + return super.hasError(response); + } + catch (Exception e) { + return true; + } + } - @RequestMapping("/foo") - public String start() throws InterruptedException { - Thread.sleep(200); - log.info("Hello from service2. Calling service3 and then service4"); - String service3 = restTemplate.getForObject("http://localhost:8083/bar",String.class); - log.info("Got response from service3 [{}]", service3); - String service4 = restTemplate.getForObject("http://localhost:8084/baz",String.class); - log.info("Got response from service4 [{}]", service4); - return String.format("Hello from service2, response from service3 [%s] and from service4 [%s]", service3, service4); + @Override + public void handleError(ClientHttpResponse response) + throws IOException { + try { + super.handleError(response); + } + catch (Exception e) { + log.error("Exception [" + e.getMessage() + "] occurred while trying to send the request", e); + throw e; + } + } + }); + return restTemplate; } + public static void main(String... args) { new SpringApplication(Application.class).run(args); } } + +@RestController +class Service2Controller { + private static final Logger log = LoggerFactory.getLogger(Service2Controller.class); + + private final RestTemplate restTemplate; + private final Tracer tracer; + private final String serviceAddress3; + private final String serviceAddress4; + private final int port; + + Service2Controller(RestTemplate restTemplate, Tracer tracer, + @Value("${service3.address:localhost:8083}") String serviceAddress3, + @Value("${service4.address:localhost:8084}") String serviceAddress4, + @Value("${server.port:8082}") int port) { + this.restTemplate = restTemplate; + this.tracer = tracer; + this.serviceAddress3 = serviceAddress3; + this.serviceAddress4 = serviceAddress4; + this.port = port; + } + + // for the tracing presentation + @GetMapping("/memeoverflow") + public String memeOverflow() throws InterruptedException { + throw new IllegalStateException("Meme overflow occurred"); + } + + @RequestMapping("/foo") + public String service2MethodInController() throws InterruptedException { + Thread.sleep(200); + try (BaggageInScope baggage = this.tracer.getBaggage("key")) { + log.info("Service2: Baggage for [key] is [" + (baggage == null ? null : baggage.get()) + "]"); + log.info("Hello from service2. Calling service3 and then service4"); + String service3 = restTemplate.getForObject("http://" + serviceAddress3 + "/bar", String.class); + log.info("Got response from service3 [{}]", service3); + String service4 = restTemplate.getForObject("http://" + serviceAddress4 + "/baz", String.class); + log.info("Got response from service4 [{}]", service4); + return String.format("Hello from service2, response from service3 [%s] and from service4 [%s]", service3, service4); + } + } + + @RequestMapping("/readtimeout") + public String connectionTimeout() throws InterruptedException { + Span span = this.tracer.nextSpan().name("second_span"); + Thread.sleep(500); + try (Tracer.SpanInScope ws = this.tracer.withSpan(span.start())) { + log.info("Calling a missing service"); + restTemplate.getForObject("http://localhost/" + port + "/blowup", String.class); + return "Should blow up"; + } + catch (Exception e) { + log.error("Exception occurred while trying to send a request to a missing service", e); + throw e; + } + finally { + span.end(); + } + } + + @RequestMapping("/blowup") + public Callable blowUp() throws InterruptedException { + return () -> { + Thread.sleep(4000); + throw new RuntimeException("Should blow up"); + }; + } +} diff --git a/service2/src/main/java/io/spring/cloud/sleuth/docs/service2/StoringZipkinSpanReporter.java b/service2/src/main/java/io/spring/cloud/sleuth/docs/service2/StoringZipkinSpanReporter.java deleted file mode 100644 index 58a9c51..0000000 --- a/service2/src/main/java/io/spring/cloud/sleuth/docs/service2/StoringZipkinSpanReporter.java +++ /dev/null @@ -1,54 +0,0 @@ -package io.spring.cloud.sleuth.docs.service2; - -import com.google.common.collect.LinkedListMultimap; -import com.google.common.collect.Multimap; -import com.google.common.collect.Multimaps; -import java.lang.invoke.MethodHandles; -import java.util.Collection; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.cloud.sleuth.metric.SpanMetricReporter; -import org.springframework.cloud.sleuth.zipkin.HttpZipkinSpanReporter; -import org.springframework.cloud.sleuth.zipkin.ZipkinProperties; -import org.springframework.cloud.sleuth.zipkin.ZipkinSpanReporter; -import org.springframework.http.ResponseEntity; -import org.springframework.stereotype.Component; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; -import zipkin.Span; - -/** - * @author Marcin Grzejszczak - */ -@Component -@RestController -public class StoringZipkinSpanReporter implements ZipkinSpanReporter { - - private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); - - private final Multimap sentSpans = Multimaps.synchronizedListMultimap( - LinkedListMultimap.create()); - private final HttpZipkinSpanReporter delegate; - - @Autowired - public StoringZipkinSpanReporter(SpanMetricReporter spanMetricReporter, ZipkinProperties zipkin) { - delegate = new HttpZipkinSpanReporter(zipkin.getBaseUrl(), zipkin.getFlushInterval(), - zipkin.getCompression().isEnabled(), spanMetricReporter); - } - - @RequestMapping("/spans/{traceId}") - public ResponseEntity> spans(@PathVariable String traceId) { - Collection spansForTrace = sentSpans - .get(org.springframework.cloud.sleuth.Span.hexToId(traceId)); - return ResponseEntity.ok(spansForTrace); - } - - @Override - public void report(Span span) { - sentSpans.put(span.traceId, span); - log.info("Sending span [\n\n" + span.toString() + "\n\n] to Zipkin"); - delegate.report(span); - } -} diff --git a/service2/src/main/resources/application-logzio.yml b/service2/src/main/resources/application-logzio.yml new file mode 100644 index 0000000..305c54a --- /dev/null +++ b/service2/src/main/resources/application-logzio.yml @@ -0,0 +1 @@ +logging.pattern.level: "%5p [${spring.zipkin.service.name:${spring.application.name:}},%X{traceId:-},%X{spanId:-},%X{key:-}]" \ No newline at end of file diff --git a/service2/src/main/resources/application.yaml b/service2/src/main/resources/application.yaml index 92c9e1a..67fa29a 100644 --- a/service2/src/main/resources/application.yaml +++ b/service2/src/main/resources/application.yaml @@ -3,5 +3,25 @@ spring: application: name: service2 sleuth: + propagation: + type: + - b3 + - w3c + baggage: + remote-fields: + - baggage + - key + correlation-fields: + - key sampler: - percentage: 1.0 \ No newline at end of file + probability: 1.0 + +logging.level.org.springframework.cloud.sleuth: DEBUG + +management.endpoints.web.base-path: / +management.endpoints.web.exposure.include: "*" + +logging.pattern.level: "%5p [${spring.zipkin.service.name:${spring.application.name:}},%X{traceId:-},%X{spanId:-},%X{key:-}]" + +wavefront.application.name: sleuth-documentation-apps +wavefront.application.service: service2 diff --git a/service2/src/main/resources/logback-spring.xml b/service2/src/main/resources/logback-spring.xml new file mode 100644 index 0000000..b73a180 --- /dev/null +++ b/service2/src/main/resources/logback-spring.xml @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + DEBUG + + + ${CONSOLE_LOG_PATTERN} + utf8 + + + + + + ${LOG_FILE} + + ${LOG_FILE}.%d{yyyy-MM-dd}.gz + 7 + + + ${CONSOLE_LOG_PATTERN} + utf8 + + + + + + ${LOG_FILE}.json + + ${LOG_FILE}.json.%d{yyyy-MM-dd}.gz + 7 + + + + + UTC + + + + { + "timestamp": "@timestamp", + "severity": "%level", + "service": "${springAppName:-}", + "trace": "%X{traceId:-}", + "span": "%X{spanId:-}", + "baggage": "%X{key:-}", + "pid": "${PID:-}", + "thread": "%thread", + "class": "%logger{40}", + "rest": "%message" + } + + + + + + + + + + + ${LOGZ_IO_API_TOKEN} + https://listener.logz.io:8071 + + INFO + + true + + + + UTC + + + + { + "timestamp": "@timestamp", + "severity": "%level", + "service": "${springAppName:-}", + "trace": "%X{traceId:-}", + "span": "%X{spanId:-}", + "baggage": "%X{key:-}", + "pid": "${PID:-}", + "thread": "%thread", + "class": "%logger{40}", + "rest": "%message" + } + + + + + + + + + + + + + + + + + + + diff --git a/service3/.mvn/wrapper/maven-wrapper.jar b/service3/.mvn/wrapper/maven-wrapper.jar new file mode 100644 index 0000000..5fd4d50 Binary files /dev/null and b/service3/.mvn/wrapper/maven-wrapper.jar differ diff --git a/service3/.mvn/wrapper/maven-wrapper.properties b/service3/.mvn/wrapper/maven-wrapper.properties new file mode 100644 index 0000000..c315043 --- /dev/null +++ b/service3/.mvn/wrapper/maven-wrapper.properties @@ -0,0 +1 @@ +distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.0/apache-maven-3.5.0-bin.zip diff --git a/service3/manifest.yml b/service3/manifest.yml new file mode 100644 index 0000000..aa8b03a --- /dev/null +++ b/service3/manifest.yml @@ -0,0 +1,13 @@ +--- +applications: +- name: docssleuth-service3 + memory: 1024M + instances: 1 + host: docssleuth-service3 + path: target/service3-1.0.0.SLEUTH_DOCS.jar + services: + - docssleuth-rabbitmq + env: + SPRING_PROFILES_ACTIVE: cloud + SPRING_RABBITMQ_ADDRESSES: ${vcap.services.docssleuth-rabbitmq.credentials.uri} + DEBUG: "true" diff --git a/service3/mvnw b/service3/mvnw new file mode 100755 index 0000000..a1ba1bf --- /dev/null +++ b/service3/mvnw @@ -0,0 +1,233 @@ +#!/bin/sh +# ---------------------------------------------------------------------------- +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# ---------------------------------------------------------------------------- + +# ---------------------------------------------------------------------------- +# Maven2 Start Up Batch script +# +# Required ENV vars: +# ------------------ +# JAVA_HOME - location of a JDK home dir +# +# Optional ENV vars +# ----------------- +# M2_HOME - location of maven2's installed home dir +# MAVEN_OPTS - parameters passed to the Java VM when running Maven +# e.g. to debug Maven itself, use +# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +# MAVEN_SKIP_RC - flag to disable loading of mavenrc files +# ---------------------------------------------------------------------------- + +if [ -z "$MAVEN_SKIP_RC" ] ; then + + if [ -f /etc/mavenrc ] ; then + . /etc/mavenrc + fi + + if [ -f "$HOME/.mavenrc" ] ; then + . "$HOME/.mavenrc" + fi + +fi + +# OS specific support. $var _must_ be set to either true or false. +cygwin=false; +darwin=false; +mingw=false +case "`uname`" in + CYGWIN*) cygwin=true ;; + MINGW*) mingw=true;; + Darwin*) darwin=true + # + # Look for the Apple JDKs first to preserve the existing behaviour, and then look + # for the new JDKs provided by Oracle. + # + if [ -z "$JAVA_HOME" ] && [ -L /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK ] ; then + # + # Apple JDKs + # + export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home + fi + + if [ -z "$JAVA_HOME" ] && [ -L /System/Library/Java/JavaVirtualMachines/CurrentJDK ] ; then + # + # Apple JDKs + # + export JAVA_HOME=/System/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home + fi + + if [ -z "$JAVA_HOME" ] && [ -L "/Library/Java/JavaVirtualMachines/CurrentJDK" ] ; then + # + # Oracle JDKs + # + export JAVA_HOME=/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home + fi + + if [ -z "$JAVA_HOME" ] && [ -x "/usr/libexec/java_home" ]; then + # + # Apple JDKs + # + export JAVA_HOME=`/usr/libexec/java_home` + fi + ;; +esac + +if [ -z "$JAVA_HOME" ] ; then + if [ -r /etc/gentoo-release ] ; then + JAVA_HOME=`java-config --jre-home` + fi +fi + +if [ -z "$M2_HOME" ] ; then + ## resolve links - $0 may be a link to maven's home + PRG="$0" + + # need this for relative symlinks + while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG="`dirname "$PRG"`/$link" + fi + done + + saveddir=`pwd` + + M2_HOME=`dirname "$PRG"`/.. + + # make it fully qualified + M2_HOME=`cd "$M2_HOME" && pwd` + + cd "$saveddir" + # echo Using m2 at $M2_HOME +fi + +# For Cygwin, ensure paths are in UNIX format before anything is touched +if $cygwin ; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --unix "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --unix "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --unix "$CLASSPATH"` +fi + +# For Migwn, ensure paths are in UNIX format before anything is touched +if $mingw ; then + [ -n "$M2_HOME" ] && + M2_HOME="`(cd "$M2_HOME"; pwd)`" + [ -n "$JAVA_HOME" ] && + JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" + # TODO classpath? +fi + +if [ -z "$JAVA_HOME" ]; then + javaExecutable="`which javac`" + if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then + # readlink(1) is not available as standard on Solaris 10. + readLink=`which readlink` + if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then + if $darwin ; then + javaHome="`dirname \"$javaExecutable\"`" + javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" + else + javaExecutable="`readlink -f \"$javaExecutable\"`" + fi + javaHome="`dirname \"$javaExecutable\"`" + javaHome=`expr "$javaHome" : '\(.*\)/bin'` + JAVA_HOME="$javaHome" + export JAVA_HOME + fi + fi +fi + +if [ -z "$JAVACMD" ] ; then + if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + else + JAVACMD="`which java`" + fi +fi + +if [ ! -x "$JAVACMD" ] ; then + echo "Error: JAVA_HOME is not defined correctly." >&2 + echo " We cannot execute $JAVACMD" >&2 + exit 1 +fi + +if [ -z "$JAVA_HOME" ] ; then + echo "Warning: JAVA_HOME environment variable is not set." +fi + +CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher + +# For Cygwin, switch paths to Windows format before running java +if $cygwin; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --path --windows "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --windows "$CLASSPATH"` +fi + +# traverses directory structure from process work directory to filesystem root +# first directory with .mvn subdirectory is considered project base directory +find_maven_basedir() { + local basedir=$(pwd) + local wdir=$(pwd) + while [ "$wdir" != '/' ] ; do + if [ -d "$wdir"/.mvn ] ; then + basedir=$wdir + break + fi + wdir=$(cd "$wdir/.."; pwd) + done + echo "${basedir}" +} + +# concatenates all lines of a file +concat_lines() { + if [ -f "$1" ]; then + echo "$(tr -s '\n' ' ' < "$1")" + fi +} + +export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-$(find_maven_basedir)} +MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" + +# Provide a "standardized" way to retrieve the CLI args that will +# work with both Windows and non-Windows executions. +MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" +export MAVEN_CMD_LINE_ARGS + +WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +exec "$JAVACMD" \ + $MAVEN_OPTS \ + -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ + "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ + ${WRAPPER_LAUNCHER} "$@" diff --git a/service3/mvnw.cmd b/service3/mvnw.cmd new file mode 100644 index 0000000..5a8e45d --- /dev/null +++ b/service3/mvnw.cmd @@ -0,0 +1,145 @@ +@REM ---------------------------------------------------------------------------- +@REM Licensed to the Apache Software Foundation (ASF) under one +@REM or more contributor license agreements. See the NOTICE file +@REM distributed with this work for additional information +@REM regarding copyright ownership. The ASF licenses this file +@REM to you under the Apache License, Version 2.0 (the +@REM "License"); you may not use this file except in compliance +@REM with the License. You may obtain a copy of the License at +@REM +@REM http://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, +@REM software distributed under the License is distributed on an +@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +@REM KIND, either express or implied. See the License for the +@REM specific language governing permissions and limitations +@REM under the License. +@REM ---------------------------------------------------------------------------- + +@REM ---------------------------------------------------------------------------- +@REM Maven2 Start Up Batch script +@REM +@REM Required ENV vars: +@REM JAVA_HOME - location of a JDK home dir +@REM +@REM Optional ENV vars +@REM M2_HOME - location of maven2's installed home dir +@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands +@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending +@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven +@REM e.g. to debug Maven itself, use +@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,city=8000 +@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files +@REM ---------------------------------------------------------------------------- + +@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' +@echo off +@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on' +@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% + +@REM set %HOME% to equivalent of $HOME +if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") + +@REM Execute a user defined script before this one +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre +@REM check for pre script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" +if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" +:skipRcPre + +@setlocal + +set ERROR_CODE=0 + +@REM To isolate internal variables from possible post scripts, we use another setlocal +@setlocal + +@REM ==== START VALIDATION ==== +if not "%JAVA_HOME%" == "" goto OkJHome + +echo. +echo Error: JAVA_HOME not found in your environment. >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +:OkJHome +if exist "%JAVA_HOME%\bin\java.exe" goto init + +echo. +echo Error: JAVA_HOME is set to an invalid directory. >&2 +echo JAVA_HOME = "%JAVA_HOME%" >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +@REM ==== END VALIDATION ==== + +:init + +set MAVEN_CMD_LINE_ARGS=%* + +@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". +@REM Fallback to current working directory if not found. + +set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% +IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir + +set EXEC_DIR=%CD% +set WDIR=%EXEC_DIR% +:findBaseDir +IF EXIST "%WDIR%"\.mvn goto baseDirFound +cd .. +IF "%WDIR%"=="%CD%" goto baseDirNotFound +set WDIR=%CD% +goto findBaseDir + +:baseDirFound +set MAVEN_PROJECTBASEDIR=%WDIR% +cd "%EXEC_DIR%" +goto endDetectBaseDir + +:baseDirNotFound +set MAVEN_PROJECTBASEDIR=%EXEC_DIR% +cd "%EXEC_DIR%" + +:endDetectBaseDir + +IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig + +@setlocal EnableExtensions EnableDelayedExpansion +for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a +@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% + +:endReadAdditionalConfig + +SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" + +set WRAPPER_JAR="".\.mvn\wrapper\maven-wrapper.jar"" +set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CMD_LINE_ARGS% +if ERRORLEVEL 1 goto error +goto end + +:error +set ERROR_CODE=1 + +:end +@endlocal & set ERROR_CODE=%ERROR_CODE% + +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost +@REM check for post script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" +if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" +:skipRcPost + +@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' +if "%MAVEN_BATCH_PAUSE%" == "on" pause + +if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% + +exit /B %ERROR_CODE% \ No newline at end of file diff --git a/service3/pom.xml b/service3/pom.xml new file mode 100644 index 0000000..35153fe --- /dev/null +++ b/service3/pom.xml @@ -0,0 +1,187 @@ + + + 4.0.0 + io.spring.cloud.sleuth.docs + service3 + 1.0.0.SLEUTH_DOCS + + + org.springframework.boot + spring-boot-starter-parent + 2.7.4 + + + + + 2021.0.2-SNAPSHOT + UTF-8 + UTF-8 + 1.8 + + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.cloud + spring-cloud-starter-sleuth + + + org.springframework.boot + spring-boot-starter-actuator + + + net.logstash.logback + logstash-logback-encoder + 7.2 + runtime + + + logback-core + ch.qos.logback + + + + + + + + org.springframework.cloud + spring-cloud-dependencies + ${spring-cloud.version} + import + pom + + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + build-image + package + + build-image + + + + + + + + + + default + + true + + + + org.springframework.cloud + spring-cloud-sleuth-zipkin + + + + + wavefront + + 2.3.0 + + + + + com.wavefront + wavefront-spring-boot-bom + ${wavefront.version} + pom + import + + + + + + com.wavefront + wavefront-spring-boot-starter + + + + + logzio + + + io.logz.logback + logzio-logback-appender + 1.0.28 + + + + + + + + spring-snapshots + Spring Snapshots + https://repo.spring.io/snapshot + + true + + + + spring-milestones + Spring Milestones + https://repo.spring.io/milestone + + false + + + + spring-releases + Spring Releases + https://repo.spring.io/release + + false + + + + + + spring-snapshots + Spring Snapshots + https://repo.spring.io/snapshot + + true + + + + spring-milestones + Spring Milestones + https://repo.spring.io/milestone + + false + + + + spring-plugin-snapshots + Spring Snapshots + https://repo.spring.io/snapshot + + true + + + + spring-plugin-milestones + Spring Milestones + https://repo.spring.io/release + + false + + + + + diff --git a/service3/src/main/java/io/spring/cloud/sleuth/docs/service3/Application.java b/service3/src/main/java/io/spring/cloud/sleuth/docs/service3/Application.java index 33a618a..0df40f8 100644 --- a/service3/src/main/java/io/spring/cloud/sleuth/docs/service3/Application.java +++ b/service3/src/main/java/io/spring/cloud/sleuth/docs/service3/Application.java @@ -1,32 +1,30 @@ package io.spring.cloud.sleuth.docs.service3; -import java.lang.invoke.MethodHandles; - +import brave.baggage.BaggageField; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import org.springframework.web.client.RestTemplate; @SpringBootApplication -@RestController public class Application { - private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); + public static void main(String... args) { + new SpringApplication(Application.class).run(args); + } +} - @Autowired RestTemplate restTemplate; +@RestController +class Service3Controller { + private static final Logger log = LoggerFactory.getLogger(Service3Controller.class); @RequestMapping("/bar") - public String start() throws InterruptedException { + public String service3MethodInController() throws InterruptedException { Thread.sleep(300); log.info("Hello from service3"); + log.info("Service3: Baggage for [key] is [" + BaggageField.getByName("key").getValue() + "]"); return "Hello from service3"; } - - public static void main(String... args) { - new SpringApplication(Application.class).run(args); - } } diff --git a/service3/src/main/java/io/spring/cloud/sleuth/docs/service3/StoringZipkinSpanReporter.java b/service3/src/main/java/io/spring/cloud/sleuth/docs/service3/StoringZipkinSpanReporter.java deleted file mode 100644 index ea84900..0000000 --- a/service3/src/main/java/io/spring/cloud/sleuth/docs/service3/StoringZipkinSpanReporter.java +++ /dev/null @@ -1,54 +0,0 @@ -package io.spring.cloud.sleuth.docs.service3; - -import com.google.common.collect.LinkedListMultimap; -import com.google.common.collect.Multimap; -import com.google.common.collect.Multimaps; -import java.lang.invoke.MethodHandles; -import java.util.Collection; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.cloud.sleuth.metric.SpanMetricReporter; -import org.springframework.cloud.sleuth.zipkin.HttpZipkinSpanReporter; -import org.springframework.cloud.sleuth.zipkin.ZipkinProperties; -import org.springframework.cloud.sleuth.zipkin.ZipkinSpanReporter; -import org.springframework.http.ResponseEntity; -import org.springframework.stereotype.Component; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; -import zipkin.Span; - -/** - * @author Marcin Grzejszczak - */ -@Component -@RestController -public class StoringZipkinSpanReporter implements ZipkinSpanReporter { - - private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); - - private final Multimap sentSpans = Multimaps.synchronizedListMultimap( - LinkedListMultimap.create()); - private final HttpZipkinSpanReporter delegate; - - @Autowired - public StoringZipkinSpanReporter(SpanMetricReporter spanMetricReporter, ZipkinProperties zipkin) { - delegate = new HttpZipkinSpanReporter(zipkin.getBaseUrl(), zipkin.getFlushInterval(), - zipkin.getCompression().isEnabled(), spanMetricReporter); - } - - @RequestMapping("/spans/{traceId}") - public ResponseEntity> spans(@PathVariable String traceId) { - Collection spansForTrace = sentSpans - .get(org.springframework.cloud.sleuth.Span.hexToId(traceId)); - return ResponseEntity.ok(spansForTrace); - } - - @Override - public void report(Span span) { - sentSpans.put(span.traceId, span); - log.info("Sending span [\n\n" + span.toString() + "\n\n] to Zipkin"); - delegate.report(span); - } -} diff --git a/service3/src/main/resources/application-logzio.yml b/service3/src/main/resources/application-logzio.yml new file mode 100644 index 0000000..305c54a --- /dev/null +++ b/service3/src/main/resources/application-logzio.yml @@ -0,0 +1 @@ +logging.pattern.level: "%5p [${spring.zipkin.service.name:${spring.application.name:}},%X{traceId:-},%X{spanId:-},%X{key:-}]" \ No newline at end of file diff --git a/service3/src/main/resources/application.yaml b/service3/src/main/resources/application.yaml index a043877..1450882 100644 --- a/service3/src/main/resources/application.yaml +++ b/service3/src/main/resources/application.yaml @@ -3,5 +3,25 @@ spring: application: name: service3 sleuth: + propagation: + type: + - b3 + - w3c + baggage: + remote-fields: + - baggage + - key + correlation-fields: + - key sampler: - percentage: 1.0 \ No newline at end of file + probability: 1.0 + +logging.level.org.springframework.cloud.sleuth: DEBUG + +management.endpoints.web.base-path: / +management.endpoints.web.exposure.include: "*" + +logging.pattern.level: "%5p [${spring.zipkin.service.name:${spring.application.name:}},%X{traceId:-},%X{spanId:-},%X{key:-}]" + +wavefront.application.name: sleuth-documentation-apps +wavefront.application.service: service3 diff --git a/service3/src/main/resources/logback-spring.xml b/service3/src/main/resources/logback-spring.xml new file mode 100644 index 0000000..bd1e438 --- /dev/null +++ b/service3/src/main/resources/logback-spring.xml @@ -0,0 +1,94 @@ + + + + + + + + + + + + + + + + DEBUG + + + ${CONSOLE_LOG_PATTERN} + utf8 + + + + + + ${LOG_FILE} + + ${LOG_FILE}.%d{yyyy-MM-dd}.gz + 7 + + + ${CONSOLE_LOG_PATTERN} + utf8 + + + + + + ${LOG_FILE}.json + + ${LOG_FILE}.json.%d{yyyy-MM-dd}.gz + 7 + + + + + UTC + + + + { + "timestamp": "@timestamp", + "severity": "%level", + "service": "${springAppName:-}", + "trace": "%X{traceId:-}", + "span": "%X{spanId:-}", + "baggage": "%X{key:-}", + "pid": "${PID:-}", + "thread": "%thread", + "class": "%logger{40}", + "rest": "%message" + } + + + + + + + + + + + ${LOGZ_IO_API_TOKEN} + https://listener.logz.io:8071 + + INFO + + true + + + + + + + + + + + + + + + diff --git a/service4/.mvn/wrapper/maven-wrapper.jar b/service4/.mvn/wrapper/maven-wrapper.jar new file mode 100644 index 0000000..5fd4d50 Binary files /dev/null and b/service4/.mvn/wrapper/maven-wrapper.jar differ diff --git a/service4/.mvn/wrapper/maven-wrapper.properties b/service4/.mvn/wrapper/maven-wrapper.properties new file mode 100644 index 0000000..c315043 --- /dev/null +++ b/service4/.mvn/wrapper/maven-wrapper.properties @@ -0,0 +1 @@ +distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.0/apache-maven-3.5.0-bin.zip diff --git a/service4/manifest.yml b/service4/manifest.yml new file mode 100644 index 0000000..90da1c6 --- /dev/null +++ b/service4/manifest.yml @@ -0,0 +1,13 @@ +--- +applications: +- name: docssleuth-service4 + memory: 1024M + instances: 1 + host: docssleuth-service4 + path: target/service4-1.0.0.SLEUTH_DOCS.jar + services: + - docssleuth-rabbitmq + env: + SPRING_PROFILES_ACTIVE: cloud + SPRING_RABBITMQ_ADDRESSES: ${vcap.services.docssleuth-rabbitmq.credentials.uri} + DEBUG: "true" diff --git a/service4/mvnw b/service4/mvnw new file mode 100755 index 0000000..a1ba1bf --- /dev/null +++ b/service4/mvnw @@ -0,0 +1,233 @@ +#!/bin/sh +# ---------------------------------------------------------------------------- +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# ---------------------------------------------------------------------------- + +# ---------------------------------------------------------------------------- +# Maven2 Start Up Batch script +# +# Required ENV vars: +# ------------------ +# JAVA_HOME - location of a JDK home dir +# +# Optional ENV vars +# ----------------- +# M2_HOME - location of maven2's installed home dir +# MAVEN_OPTS - parameters passed to the Java VM when running Maven +# e.g. to debug Maven itself, use +# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +# MAVEN_SKIP_RC - flag to disable loading of mavenrc files +# ---------------------------------------------------------------------------- + +if [ -z "$MAVEN_SKIP_RC" ] ; then + + if [ -f /etc/mavenrc ] ; then + . /etc/mavenrc + fi + + if [ -f "$HOME/.mavenrc" ] ; then + . "$HOME/.mavenrc" + fi + +fi + +# OS specific support. $var _must_ be set to either true or false. +cygwin=false; +darwin=false; +mingw=false +case "`uname`" in + CYGWIN*) cygwin=true ;; + MINGW*) mingw=true;; + Darwin*) darwin=true + # + # Look for the Apple JDKs first to preserve the existing behaviour, and then look + # for the new JDKs provided by Oracle. + # + if [ -z "$JAVA_HOME" ] && [ -L /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK ] ; then + # + # Apple JDKs + # + export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home + fi + + if [ -z "$JAVA_HOME" ] && [ -L /System/Library/Java/JavaVirtualMachines/CurrentJDK ] ; then + # + # Apple JDKs + # + export JAVA_HOME=/System/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home + fi + + if [ -z "$JAVA_HOME" ] && [ -L "/Library/Java/JavaVirtualMachines/CurrentJDK" ] ; then + # + # Oracle JDKs + # + export JAVA_HOME=/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home + fi + + if [ -z "$JAVA_HOME" ] && [ -x "/usr/libexec/java_home" ]; then + # + # Apple JDKs + # + export JAVA_HOME=`/usr/libexec/java_home` + fi + ;; +esac + +if [ -z "$JAVA_HOME" ] ; then + if [ -r /etc/gentoo-release ] ; then + JAVA_HOME=`java-config --jre-home` + fi +fi + +if [ -z "$M2_HOME" ] ; then + ## resolve links - $0 may be a link to maven's home + PRG="$0" + + # need this for relative symlinks + while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG="`dirname "$PRG"`/$link" + fi + done + + saveddir=`pwd` + + M2_HOME=`dirname "$PRG"`/.. + + # make it fully qualified + M2_HOME=`cd "$M2_HOME" && pwd` + + cd "$saveddir" + # echo Using m2 at $M2_HOME +fi + +# For Cygwin, ensure paths are in UNIX format before anything is touched +if $cygwin ; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --unix "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --unix "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --unix "$CLASSPATH"` +fi + +# For Migwn, ensure paths are in UNIX format before anything is touched +if $mingw ; then + [ -n "$M2_HOME" ] && + M2_HOME="`(cd "$M2_HOME"; pwd)`" + [ -n "$JAVA_HOME" ] && + JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" + # TODO classpath? +fi + +if [ -z "$JAVA_HOME" ]; then + javaExecutable="`which javac`" + if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then + # readlink(1) is not available as standard on Solaris 10. + readLink=`which readlink` + if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then + if $darwin ; then + javaHome="`dirname \"$javaExecutable\"`" + javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" + else + javaExecutable="`readlink -f \"$javaExecutable\"`" + fi + javaHome="`dirname \"$javaExecutable\"`" + javaHome=`expr "$javaHome" : '\(.*\)/bin'` + JAVA_HOME="$javaHome" + export JAVA_HOME + fi + fi +fi + +if [ -z "$JAVACMD" ] ; then + if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + else + JAVACMD="`which java`" + fi +fi + +if [ ! -x "$JAVACMD" ] ; then + echo "Error: JAVA_HOME is not defined correctly." >&2 + echo " We cannot execute $JAVACMD" >&2 + exit 1 +fi + +if [ -z "$JAVA_HOME" ] ; then + echo "Warning: JAVA_HOME environment variable is not set." +fi + +CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher + +# For Cygwin, switch paths to Windows format before running java +if $cygwin; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --path --windows "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --windows "$CLASSPATH"` +fi + +# traverses directory structure from process work directory to filesystem root +# first directory with .mvn subdirectory is considered project base directory +find_maven_basedir() { + local basedir=$(pwd) + local wdir=$(pwd) + while [ "$wdir" != '/' ] ; do + if [ -d "$wdir"/.mvn ] ; then + basedir=$wdir + break + fi + wdir=$(cd "$wdir/.."; pwd) + done + echo "${basedir}" +} + +# concatenates all lines of a file +concat_lines() { + if [ -f "$1" ]; then + echo "$(tr -s '\n' ' ' < "$1")" + fi +} + +export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-$(find_maven_basedir)} +MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" + +# Provide a "standardized" way to retrieve the CLI args that will +# work with both Windows and non-Windows executions. +MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" +export MAVEN_CMD_LINE_ARGS + +WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +exec "$JAVACMD" \ + $MAVEN_OPTS \ + -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ + "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ + ${WRAPPER_LAUNCHER} "$@" diff --git a/service4/mvnw.cmd b/service4/mvnw.cmd new file mode 100644 index 0000000..5a8e45d --- /dev/null +++ b/service4/mvnw.cmd @@ -0,0 +1,145 @@ +@REM ---------------------------------------------------------------------------- +@REM Licensed to the Apache Software Foundation (ASF) under one +@REM or more contributor license agreements. See the NOTICE file +@REM distributed with this work for additional information +@REM regarding copyright ownership. The ASF licenses this file +@REM to you under the Apache License, Version 2.0 (the +@REM "License"); you may not use this file except in compliance +@REM with the License. You may obtain a copy of the License at +@REM +@REM http://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, +@REM software distributed under the License is distributed on an +@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +@REM KIND, either express or implied. See the License for the +@REM specific language governing permissions and limitations +@REM under the License. +@REM ---------------------------------------------------------------------------- + +@REM ---------------------------------------------------------------------------- +@REM Maven2 Start Up Batch script +@REM +@REM Required ENV vars: +@REM JAVA_HOME - location of a JDK home dir +@REM +@REM Optional ENV vars +@REM M2_HOME - location of maven2's installed home dir +@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands +@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending +@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven +@REM e.g. to debug Maven itself, use +@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,city=8000 +@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files +@REM ---------------------------------------------------------------------------- + +@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' +@echo off +@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on' +@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% + +@REM set %HOME% to equivalent of $HOME +if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") + +@REM Execute a user defined script before this one +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre +@REM check for pre script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" +if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" +:skipRcPre + +@setlocal + +set ERROR_CODE=0 + +@REM To isolate internal variables from possible post scripts, we use another setlocal +@setlocal + +@REM ==== START VALIDATION ==== +if not "%JAVA_HOME%" == "" goto OkJHome + +echo. +echo Error: JAVA_HOME not found in your environment. >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +:OkJHome +if exist "%JAVA_HOME%\bin\java.exe" goto init + +echo. +echo Error: JAVA_HOME is set to an invalid directory. >&2 +echo JAVA_HOME = "%JAVA_HOME%" >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +@REM ==== END VALIDATION ==== + +:init + +set MAVEN_CMD_LINE_ARGS=%* + +@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". +@REM Fallback to current working directory if not found. + +set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% +IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir + +set EXEC_DIR=%CD% +set WDIR=%EXEC_DIR% +:findBaseDir +IF EXIST "%WDIR%"\.mvn goto baseDirFound +cd .. +IF "%WDIR%"=="%CD%" goto baseDirNotFound +set WDIR=%CD% +goto findBaseDir + +:baseDirFound +set MAVEN_PROJECTBASEDIR=%WDIR% +cd "%EXEC_DIR%" +goto endDetectBaseDir + +:baseDirNotFound +set MAVEN_PROJECTBASEDIR=%EXEC_DIR% +cd "%EXEC_DIR%" + +:endDetectBaseDir + +IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig + +@setlocal EnableExtensions EnableDelayedExpansion +for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a +@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% + +:endReadAdditionalConfig + +SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" + +set WRAPPER_JAR="".\.mvn\wrapper\maven-wrapper.jar"" +set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CMD_LINE_ARGS% +if ERRORLEVEL 1 goto error +goto end + +:error +set ERROR_CODE=1 + +:end +@endlocal & set ERROR_CODE=%ERROR_CODE% + +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost +@REM check for post script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" +if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" +:skipRcPost + +@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' +if "%MAVEN_BATCH_PAUSE%" == "on" pause + +if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% + +exit /B %ERROR_CODE% \ No newline at end of file diff --git a/service4/pom.xml b/service4/pom.xml new file mode 100644 index 0000000..eca4e97 --- /dev/null +++ b/service4/pom.xml @@ -0,0 +1,209 @@ + + + 4.0.0 + io.spring.cloud.sleuth.docs + service4 + 1.0.0.SLEUTH_DOCS + + + org.springframework.boot + spring-boot-starter-parent + 2.7.4 + + + + + 2021.0.2-SNAPSHOT + 1.1.5-SNAPSHOT + UTF-8 + UTF-8 + 1.8 + + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.cloud + spring-cloud-starter-sleuth + + + org.springframework.cloud + spring-cloud-sleuth-brave + + + + + org.springframework.cloud + spring-cloud-sleuth-otel-autoconfigure + + + org.springframework.boot + spring-boot-starter-actuator + + + net.logstash.logback + logstash-logback-encoder + 7.2 + runtime + + + logback-core + ch.qos.logback + + + + + + + + org.springframework.cloud + spring-cloud-dependencies + ${spring-cloud.version} + import + pom + + + org.springframework.cloud + spring-cloud-sleuth-otel-dependencies + ${spring-cloud-sleuth-otel.version} + import + pom + + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + build-image + package + + build-image + + + + + + + + + + default + + true + + + + org.springframework.cloud + spring-cloud-sleuth-zipkin + + + io.opentelemetry + opentelemetry-exporter-zipkin + + + + + wavefront + + 2.3.0 + + + + + com.wavefront + wavefront-spring-boot-bom + ${wavefront.version} + pom + import + + + + + + com.wavefront + wavefront-spring-boot-starter + + + + + logzio + + + io.logz.logback + logzio-logback-appender + 1.0.28 + + + + + + + + spring-snapshots + Spring Snapshots + https://repo.spring.io/snapshot + + true + + + + spring-milestones + Spring Milestones + https://repo.spring.io/milestone + + false + + + + spring-releases + Spring Releases + https://repo.spring.io/release + + false + + + + + + spring-snapshots + Spring Snapshots + https://repo.spring.io/snapshot + + true + + + + spring-milestones + Spring Milestones + https://repo.spring.io/milestone + + false + + + + spring-plugin-snapshots + Spring Snapshots + https://repo.spring.io/snapshot + + true + + + + spring-plugin-milestones + Spring Milestones + https://repo.spring.io/release + + false + + + + + diff --git a/service4/src/main/java/io/spring/cloud/sleuth/docs/service4/Application.java b/service4/src/main/java/io/spring/cloud/sleuth/docs/service4/Application.java index 0ec1531..ebc44d0 100644 --- a/service4/src/main/java/io/spring/cloud/sleuth/docs/service4/Application.java +++ b/service4/src/main/java/io/spring/cloud/sleuth/docs/service4/Application.java @@ -1,32 +1,43 @@ package io.spring.cloud.sleuth.docs.service4; -import java.lang.invoke.MethodHandles; - +import io.opentelemetry.api.baggage.Baggage; +import io.opentelemetry.api.trace.Span; +import io.opentelemetry.api.trace.Tracer; +import io.opentelemetry.context.Scope; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; + import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import org.springframework.web.client.RestTemplate; @SpringBootApplication -@RestController public class Application { - private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); + public static void main(String... args) { + new SpringApplication(Application.class).run(args); + } +} + +@RestController +class Service4Controller { + private static final Logger log = LoggerFactory.getLogger(Service4Controller.class); + + private final Tracer tracer; - @Autowired RestTemplate restTemplate; + Service4Controller(Tracer tracer) { + this.tracer = tracer; + } @RequestMapping("/baz") - public String start() throws InterruptedException { + public String service4MethodInController() throws InterruptedException { Thread.sleep(400); - log.info("Hello from service4"); + Span newSpan = this.tracer.spanBuilder("new_span").startSpan(); + try (Scope scope = newSpan.makeCurrent()) { + log.info("Hello from service4"); + log.info("Service4: Baggage for [key] is [" + Baggage.current().getEntryValue("key") + "]"); + } return "Hello from service4"; } - - public static void main(String... args) { - new SpringApplication(Application.class).run(args); - } -} +} \ No newline at end of file diff --git a/service4/src/main/java/io/spring/cloud/sleuth/docs/service4/StoringZipkinSpanReporter.java b/service4/src/main/java/io/spring/cloud/sleuth/docs/service4/StoringZipkinSpanReporter.java deleted file mode 100644 index f56c194..0000000 --- a/service4/src/main/java/io/spring/cloud/sleuth/docs/service4/StoringZipkinSpanReporter.java +++ /dev/null @@ -1,57 +0,0 @@ -package io.spring.cloud.sleuth.docs.service4; - -import java.lang.invoke.MethodHandles; -import java.util.Collection; - -import com.google.common.collect.LinkedListMultimap; -import com.google.common.collect.Multimap; -import com.google.common.collect.Multimaps; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.cloud.sleuth.metric.SpanMetricReporter; -import org.springframework.cloud.sleuth.zipkin.HttpZipkinSpanReporter; -import org.springframework.cloud.sleuth.zipkin.ZipkinProperties; -import org.springframework.cloud.sleuth.zipkin.ZipkinSpanReporter; -import org.springframework.http.ResponseEntity; -import org.springframework.stereotype.Component; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import zipkin.Span; - -/** - * @author Marcin Grzejszczak - */ -@Component -@RestController -public class StoringZipkinSpanReporter implements ZipkinSpanReporter { - - private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); - - private final Multimap sentSpans = Multimaps.synchronizedListMultimap( - LinkedListMultimap.create()); - private final HttpZipkinSpanReporter delegate; - - @Autowired - public StoringZipkinSpanReporter(SpanMetricReporter spanMetricReporter, ZipkinProperties zipkin) { - delegate = new HttpZipkinSpanReporter(zipkin.getBaseUrl(), zipkin.getFlushInterval(), - zipkin.getCompression().isEnabled(), spanMetricReporter); - } - - @RequestMapping("/spans/{traceId}") - public ResponseEntity> spans(@PathVariable String traceId) { - Collection spansForTrace = sentSpans - .get(org.springframework.cloud.sleuth.Span.hexToId(traceId)); - return ResponseEntity.ok(spansForTrace); - } - - @Override - public void report(Span span) { - sentSpans.put(span.traceId, span); - log.info("Sending span [\n\n" + span.toString() + "\n\n] to Zipkin"); - delegate.report(span); - } -} diff --git a/service4/src/main/resources/application-logzio.yml b/service4/src/main/resources/application-logzio.yml new file mode 100644 index 0000000..305c54a --- /dev/null +++ b/service4/src/main/resources/application-logzio.yml @@ -0,0 +1 @@ +logging.pattern.level: "%5p [${spring.zipkin.service.name:${spring.application.name:}},%X{traceId:-},%X{spanId:-},%X{key:-}]" \ No newline at end of file diff --git a/service4/src/main/resources/application.yaml b/service4/src/main/resources/application.yaml index eee4bdc..ae5616a 100644 --- a/service4/src/main/resources/application.yaml +++ b/service4/src/main/resources/application.yaml @@ -3,5 +3,26 @@ spring: application: name: service4 sleuth: - sampler: - percentage: 1.0 \ No newline at end of file + propagation: + type: + - b3 + - w3c + baggage: + remote-fields: + - baggage + - key + correlation-fields: + - key + otel: + config: + trace-id-ratio-based: 1.0 + +logging.level.org.springframework.cloud.sleuth: DEBUG + +management.endpoints.web.base-path: / +management.endpoints.web.exposure.include: "*" + +logging.pattern.level: "%5p [${spring.zipkin.service.name:${spring.application.name:}},%X{traceId:-},%X{spanId:-},%X{key:-}]" + +wavefront.application.name: sleuth-documentation-apps +wavefront.application.service: service4 \ No newline at end of file diff --git a/service4/src/main/resources/logback-spring.xml b/service4/src/main/resources/logback-spring.xml new file mode 100644 index 0000000..b73a180 --- /dev/null +++ b/service4/src/main/resources/logback-spring.xml @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + DEBUG + + + ${CONSOLE_LOG_PATTERN} + utf8 + + + + + + ${LOG_FILE} + + ${LOG_FILE}.%d{yyyy-MM-dd}.gz + 7 + + + ${CONSOLE_LOG_PATTERN} + utf8 + + + + + + ${LOG_FILE}.json + + ${LOG_FILE}.json.%d{yyyy-MM-dd}.gz + 7 + + + + + UTC + + + + { + "timestamp": "@timestamp", + "severity": "%level", + "service": "${springAppName:-}", + "trace": "%X{traceId:-}", + "span": "%X{spanId:-}", + "baggage": "%X{key:-}", + "pid": "${PID:-}", + "thread": "%thread", + "class": "%logger{40}", + "rest": "%message" + } + + + + + + + + + + + ${LOGZ_IO_API_TOKEN} + https://listener.logz.io:8071 + + INFO + + true + + + + UTC + + + + { + "timestamp": "@timestamp", + "severity": "%level", + "service": "${springAppName:-}", + "trace": "%X{traceId:-}", + "span": "%X{spanId:-}", + "baggage": "%X{key:-}", + "pid": "${PID:-}", + "thread": "%thread", + "class": "%logger{40}", + "rest": "%message" + } + + + + + + + + + + + + + + + + + + + diff --git a/settings.gradle b/settings.gradle deleted file mode 100644 index 707747c..0000000 --- a/settings.gradle +++ /dev/null @@ -1,2 +0,0 @@ -rootProject.name = "doc-apps" -include 'service1', 'service2', 'service3', 'service4' diff --git a/start.sh b/start.sh deleted file mode 100755 index ce04c8e..0000000 --- a/start.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash - -# build apps -./gradlew clean build --parallel - -# run zipkin stuff -docker-compose up -d - -ZIPKIN_HOST="-Dspring.zipkin.baseUrl=http://${DEFAULT_HEALTH_HOST}:9411" - -nohup $JAVA_HOME/bin/java ${ZIPKIN_HOST} -jar service1/build/libs/*.jar > build/service1.log & -nohup $JAVA_HOME/bin/java ${ZIPKIN_HOST} -jar service2/build/libs/*.jar > build/service2.log & -nohup $JAVA_HOME/bin/java ${ZIPKIN_HOST} -jar service3/build/libs/*.jar > build/service3.log & -nohup $JAVA_HOME/bin/java ${ZIPKIN_HOST} -jar service4/build/libs/*.jar > build/service4.log & \ No newline at end of file diff --git a/start_linux.sh b/start_linux.sh deleted file mode 100755 index 11978d1..0000000 --- a/start_linux.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash - -# build apps -./gradlew clean build --parallel - -nohup $JAVA_HOME/bin/java -jar service1/build/libs/*.jar > build/service1.log & -nohup $JAVA_HOME/bin/java -jar service2/build/libs/*.jar > build/service2.log & -nohup $JAVA_HOME/bin/java -jar service3/build/libs/*.jar > build/service3.log & -nohup $JAVA_HOME/bin/java -jar service4/build/libs/*.jar > build/service4.log & diff --git a/zipkin-server-legacy/build.gradle b/zipkin-server-legacy/build.gradle new file mode 100644 index 0000000..c5c8886 --- /dev/null +++ b/zipkin-server-legacy/build.gradle @@ -0,0 +1,8 @@ +dependencies { + runtime 'org.hsqldb:hsqldb' + compile "org.springframework:spring-jdbc" + compile "org.springframework.boot:spring-boot-starter-actuator" + compile "org.springframework.cloud:spring-cloud-sleuth-zipkin-stream" + compile "org.springframework.cloud:spring-cloud-starter-stream-rabbit" + runtime "io.zipkin.java:zipkin-autoconfigure-ui:1.29.0" +} diff --git a/zipkin-server-legacy/manifest.yml b/zipkin-server-legacy/manifest.yml new file mode 100644 index 0000000..c7f061b --- /dev/null +++ b/zipkin-server-legacy/manifest.yml @@ -0,0 +1,14 @@ +--- +applications: +- name: docssleuth-zipkin-server + memory: 1024M + instances: 1 + host: docssleuth-zipkin-server + path: target/zipkin-server-1.0.0.SLEUTH_DOCS.jar + services: + - docssleuth-rabbitmq + - docssleuth-mysql + #- mysql-sleuth-rk + env: + SPRING_PROFILES_ACTIVE: cloud + DEBUG: "true" diff --git a/zipkin-server-legacy/settings.gradle b/zipkin-server-legacy/settings.gradle new file mode 100644 index 0000000..37f0066 --- /dev/null +++ b/zipkin-server-legacy/settings.gradle @@ -0,0 +1 @@ +rootProject.name = "zipkin" diff --git a/zipkin-server-legacy/src/main/java/io/spring/cloud/samples/docs/zipkin/Application.java b/zipkin-server-legacy/src/main/java/io/spring/cloud/samples/docs/zipkin/Application.java new file mode 100644 index 0000000..19a162c --- /dev/null +++ b/zipkin-server-legacy/src/main/java/io/spring/cloud/samples/docs/zipkin/Application.java @@ -0,0 +1,13 @@ +package io.spring.cloud.samples.docs.zipkin; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.cloud.sleuth.zipkin.stream.EnableZipkinStreamServer; + +@SpringBootApplication +@EnableZipkinStreamServer +public class Application { + public static void main(String[] args) { + new SpringApplication(Application.class).run(args); + } +} diff --git a/zipkin-server-legacy/src/main/resources/application-cloud.yaml b/zipkin-server-legacy/src/main/resources/application-cloud.yaml new file mode 100644 index 0000000..864dc2b --- /dev/null +++ b/zipkin-server-legacy/src/main/resources/application-cloud.yaml @@ -0,0 +1,3 @@ +spring.rabbitmq.addresses: ${vcap.services.docssleuth-rabbitmq.credentials.uri} + +spring.datasource.initialize: false \ No newline at end of file diff --git a/zipkin-server-legacy/src/main/resources/application.yaml b/zipkin-server-legacy/src/main/resources/application.yaml new file mode 100644 index 0000000..ad0d45a --- /dev/null +++ b/zipkin-server-legacy/src/main/resources/application.yaml @@ -0,0 +1,18 @@ +spring.application.name: zipkin + +logging: + level.org.springframework.cloud: DEBUG + +server: + port: 9411 + +spring: + rabbitmq: + host: ${RABBIT_HOST:localhost} + sleuth: + enabled: false +zipkin: + store: + type: mem + +logging.file: target/zipkin-server.log \ No newline at end of file diff --git a/zipkin-server/.gitignore b/zipkin-server/.gitignore new file mode 100644 index 0000000..363b80d --- /dev/null +++ b/zipkin-server/.gitignore @@ -0,0 +1,2 @@ +zipkin.jar +build/ \ No newline at end of file diff --git a/zipkin-server/manifest.yml b/zipkin-server/manifest.yml new file mode 100644 index 0000000..4b77397 --- /dev/null +++ b/zipkin-server/manifest.yml @@ -0,0 +1,13 @@ +applications: +- name: docssleuth-zipkin-server + memory: 1024M + instances: 1 + host: docssleuth-zipkin-server + path: build/zipkin.jar + services: + - docssleuth-rabbitmq + - docssleuth-mysql + env: + SPRING_PROFILES_ACTIVE: cloud + DEBUG: "true" + RABBIT_URI: ${vcap.services.docssleuth-rabbitmq.credentials.uri}