diff --git a/README.md b/README.md index 053605a6..25a41b20 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ The [Getting Started Guides](./getting-started-guides/README.md) demonstrate how * [.NET](./getting-started-guides/dotnet) * [Go](./getting-started-guides/go) -* Java ([uninstrumented](./getting-started-guides/java/uninstrumented) / [instrumented](./getting-started-guides/java/instrumented)) +* [Java](./getting-started-guides/java) * [JavaScript (Node.js)](./getting-started-guides/javascript) * [Python](./getting-started-guides/python) * [Ruby](./getting-started-guides/ruby) diff --git a/getting-started-guides/compose.yaml b/getting-started-guides/compose.yaml index 7e09c711..dc627f29 100644 --- a/getting-started-guides/compose.yaml +++ b/getting-started-guides/compose.yaml @@ -19,6 +19,20 @@ services: - OTEL_RESOURCE_ATTRIBUTES=service.instance.id=123 ports: - 8080 + java: + build: java + environment: + - OTEL_EXPORTER_OTLP_ENDPOINT + - OTEL_EXPORTER_OTLP_HEADERS + - OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT=4095 + - OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE=DELTA + - OTEL_EXPERIMENTAL_EXPORTER_OTLP_RETRY_ENABLED=true + - OTEL_EXPORTER_OTLP_METRICS_DEFAULT_HISTOGRAM_AGGREGATION=BASE2_EXPONENTIAL_BUCKET_HISTOGRAM + - OTEL_EXPORTER_OTLP_COMPRESSION=gzip + - OTEL_SERVICE_NAME=getting-started-java + - OTEL_EXPERIMENTAL_RESOURCE_DISABLED_KEYS=process.command_args + ports: + - 8080 javascript: build: javascript environment: diff --git a/getting-started-guides/java/Dockerfile b/getting-started-guides/java/Dockerfile new file mode 100644 index 00000000..6f866e40 --- /dev/null +++ b/getting-started-guides/java/Dockerfile @@ -0,0 +1,20 @@ +# syntax=docker/dockerfile:1 + +FROM eclipse-temurin:17 as build + +COPY . /source + +WORKDIR /source + +RUN ./gradlew bootJar + +FROM eclipse-temurin:17 as final + +WORKDIR /app + +COPY --from=build /source/build/libs/getting-started-java.jar . +COPY --from=build /source/build/agent/opentelemetry-javaagent.jar . + +ENTRYPOINT ["java", "-javaagent:opentelemetry-javaagent.jar", "-jar", "getting-started-java.jar"] + +EXPOSE 8080 diff --git a/getting-started-guides/java/README.md b/getting-started-guides/java/README.md new file mode 100644 index 00000000..d16824dc --- /dev/null +++ b/getting-started-guides/java/README.md @@ -0,0 +1,42 @@ +# Getting Started Guide - Java + +This is a simple application instrumented +with [OpenTelemetry Java's](https://github.com/open-telemetry/opentelemetry-java) [automatic instrumentation javaagent](https://opentelemetry.io/docs/languages/java/automatic/). +It demonstrates how to configure OpenTelemetry Java to send data to New Relic. + +## Requirements + +* Java JDK 17+, due to the use of Spring Boot 3; [Java 8+ otherwise](https://github.com/open-telemetry/opentelemetry-java/blob/main/VERSIONING.md#language-version-compatibility) +* [A New Relic account](https://one.newrelic.com/) +* [A New Relic license key](https://docs.newrelic.com/docs/apis/intro-apis/new-relic-api-keys/#license-key) + +## Running the application + +1. Set the following environment variables to configure OpenTelemetry to send + data to New Relic: + + ```shell + export OTEL_EXPORTER_OTLP_ENDPOINT=https://otlp.nr-data.net + export OTEL_EXPORTER_OTLP_HEADERS=api-key= + export OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT=4095 + export OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE=DELTA + export OTEL_EXPERIMENTAL_EXPORTER_OTLP_RETRY_ENABLED=true + export OTEL_EXPORTER_OTLP_METRICS_DEFAULT_HISTOGRAM_AGGREGATION=BASE2_EXPONENTIAL_BUCKET_HISTOGRAM + export OTEL_EXPORTER_OTLP_COMPRESSION=gzip + export OTEL_SERVICE_NAME=getting-started-java + export OTEL_EXPERIMENTAL_RESOURCE_DISABLED_KEYS=process.command_args + ``` + + * If your account is based in the EU, set the endpoint to: [https://otlp.eu01.nr-data.net](https://otlp.eu01.nr-data.net) + +2. Run the application with the following command and open + [http://localhost:8080/fibonacci?n=1](http://localhost:8080/fibonacci?n=1) + in your web browser to ensure it is working. + + ```shell + ./gradlew bootRun + ``` + +3. Experiment with providing different values for `n` in the query string. + Valid values are between 1 and 90. Values outside this range cause an error + which will show up in New Relic. diff --git a/getting-started-guides/java/build.gradle b/getting-started-guides/java/build.gradle index e8c990fe..7378f0df 100644 --- a/getting-started-guides/java/build.gradle +++ b/getting-started-guides/java/build.gradle @@ -1,25 +1,64 @@ +import org.springframework.boot.gradle.plugin.SpringBootPlugin + plugins { - id 'com.diffplug.spotless' apply false + id 'java' + id 'com.diffplug.spotless' version '6.25.0' + id 'org.springframework.boot' version '3.2.5' } -subprojects { - pluginManager.withPlugin('java') { - apply plugin: 'com.diffplug.spotless' +java { + toolchain { + languageVersion = JavaLanguageVersion.of(17) + } +} - java { - toolchain { - languageVersion = JavaLanguageVersion.of(17) - } - } +spotless { + java { + googleJavaFormat() + } +} - spotless { - java { - googleJavaFormat() - } - } +repositories { + mavenCentral() +} - repositories { - mavenCentral() - } - } -} \ No newline at end of file +configurations { + // Create a new configuration to hold the otel java agent + agent +} + +dependencies { + implementation platform(SpringBootPlugin.BOM_COORDINATES) + implementation 'org.springframework.boot:spring-boot-starter-web' + + implementation("io.opentelemetry:opentelemetry-api:1.38.0") + + // Add OpenTelemetry java agent to the "agent" configuration we previously defined + agent("io.opentelemetry.javaagent:opentelemetry-javaagent:2.3.0") +} + +tasks.register("copyAgent", Copy) { + from(configurations.agent.singleFile) + into(layout.buildDirectory.dir('agent')) + rename("opentelemetry-javaagent-.*\\.jar", "opentelemetry-javaagent.jar") +} + +bootJar { + archiveBaseName.set('getting-started-java') + // Before running, copy the agent to a reliable place in the build dir + dependsOn("copyAgent") +} + +bootRun { + // Before running, copy the agent to a reliable place in the build dir + dependsOn("copyAgent") + + mainClass.set 'com.example.demo.Application' + + def agentPath = project.buildDir.toString() + "/agent/opentelemetry-javaagent.jar" + jvmArgs = [ + // Set the opentelemetry-java-instrumentation agent as the javaagent + "-javaagent:${agentPath}" + ] + +} diff --git a/getting-started-guides/java/instrumented/README.md b/getting-started-guides/java/instrumented/README.md deleted file mode 100644 index af54b0d8..00000000 --- a/getting-started-guides/java/instrumented/README.md +++ /dev/null @@ -1,40 +0,0 @@ -# Getting Started Guide - Java - -This is the solution (completely instrumented with OpenTelemetry) for the Java demo application used in the Getting Started Guide - Java doc. - -Requires: - -* Java 17+ -* [A New Relic account](https://one.newrelic.com/) - -To run this demo app via the CLI: - -1. Switch to the `java` directory -2. Set these two environment variables to send data to your New Relic account: -``` -export OTEL_EXPORTER_OTLP_HEADERS=api-key= -export OTEL_EXPORTER_OTLP_ENDPOINT=https://otlp.nr-data.net -export OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf -export OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT=4095 -``` -* Make sure to use your [ingest license key](https://docs.newrelic.com/docs/apis/intro-apis/new-relic-api-keys/#license-key) -* If your account is based in the EU, set the endpoint to: https://otlp.eu01.nr-data.net - -3. Set this environment variable to name the demo app: -``` -export OTEL_SERVICE_NAME=getting-started-java -export OTEL_RESOURCE_ATTRIBUTES=service.instance.id=123 -``` - -4. Run the following command - -```shell -../gradlew bootRun -``` - -4. To generate traffic, in a new terminal tab run the following command -```shell -./load-generator.sh -``` - -5. To shut down the program, run the following in both shells or terminal tabs: `ctrl + c`. diff --git a/getting-started-guides/java/instrumented/build.gradle b/getting-started-guides/java/instrumented/build.gradle deleted file mode 100644 index d55da526..00000000 --- a/getting-started-guides/java/instrumented/build.gradle +++ /dev/null @@ -1,33 +0,0 @@ -import org.springframework.boot.gradle.plugin.SpringBootPlugin - -plugins { - id 'org.springframework.boot' - id 'java' -} - -bootRun { - mainClass.set 'com.example.demo.Application' -} - -configurations.all { - exclude module: 'spring-boot-starter-logging' -} - -dependencies { - implementation platform(SpringBootPlugin.BOM_COORDINATES) - implementation 'org.springframework.boot:spring-boot-starter-web' - implementation 'org.springframework.boot:spring-boot-starter-log4j2' - - // OpenTelemetry core - implementation platform('io.opentelemetry:opentelemetry-bom:1.38.0') - implementation 'io.opentelemetry:opentelemetry-api' - implementation 'io.opentelemetry:opentelemetry-sdk' - implementation 'io.opentelemetry:opentelemetry-exporter-otlp' - implementation 'io.opentelemetry:opentelemetry-sdk-extension-autoconfigure' - - // OpenTelemetry instrumentation - implementation platform('io.opentelemetry.instrumentation:opentelemetry-instrumentation-bom-alpha:2.3.0-alpha') - implementation 'io.opentelemetry.instrumentation:opentelemetry-runtime-telemetry-java8' - implementation 'io.opentelemetry.instrumentation:opentelemetry-log4j-appender-2.17' - implementation 'io.opentelemetry.instrumentation:opentelemetry-spring-webmvc-6.0' -} diff --git a/getting-started-guides/java/instrumented/call-app.ps1 b/getting-started-guides/java/instrumented/call-app.ps1 deleted file mode 100644 index 04e5d92d..00000000 --- a/getting-started-guides/java/instrumented/call-app.ps1 +++ /dev/null @@ -1,14 +0,0 @@ -Write-Output "GET $ENDPOINT/fibonacci?n=5" -Invoke-WebRequest -Uri "$ENDPOINT/fibonacci?n=5" | Select-Object -Expand Content - -Write-Output "GET $ENDPOINT/fibonacci?n=283" -Invoke-WebRequest -Uri "$ENDPOINT/fibonacci?n=283" | Select-Object -Expand Content - -Write-Output "GET $ENDPOINT/fibonacci?n=10" -Invoke-WebRequest -Uri "$ENDPOINT/fibonacci?n=10" | Select-Object -Expand Content - -Write-Output "GET $ENDPOINT/fibonacci?n=90" -Invoke-WebRequest -Uri "$ENDPOINT/fibonacci?n=90" | Select-Object -Expand Content - -Write-Output "GET $ENDPOINT/fibonacci?n=0" -Invoke-WebRequest -Uri "$ENDPOINT/fibonacci?n=0" | Select-Object -Expand Content diff --git a/getting-started-guides/java/instrumented/call-app.sh b/getting-started-guides/java/instrumented/call-app.sh deleted file mode 100755 index d63a747a..00000000 --- a/getting-started-guides/java/instrumented/call-app.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash - -echo "GET ${1}/fibonacci?n=5" -curl "${1}/fibonacci?n=5" || true -echo - -echo "GET ${1}/fibonacci?n=283" -curl "${1}/fibonacci?n=283" || true -echo - -echo "GET ${1}/fibonacci?n=10" -curl "${1}/fibonacci?n=10" || true -echo - -echo "GET ${1}/fibonacci?n=90" -curl "${1}/fibonacci?n=90" || true -echo - -echo "GET ${1}/fibonacci?n=0" -curl "${1}/fibonacci?n=0" || true -echo diff --git a/getting-started-guides/java/instrumented/load-generator.ps1 b/getting-started-guides/java/instrumented/load-generator.ps1 deleted file mode 100644 index cccd2140..00000000 --- a/getting-started-guides/java/instrumented/load-generator.ps1 +++ /dev/null @@ -1,7 +0,0 @@ -$ENDPOINT="http://localhost:8080" - -while ($true) { - Write-Output "Calling fibonacci-java" - & ".\call-app.ps1" - Start-Sleep -s 2 -} diff --git a/getting-started-guides/java/instrumented/load-generator.sh b/getting-started-guides/java/instrumented/load-generator.sh deleted file mode 100755 index 83d54f71..00000000 --- a/getting-started-guides/java/instrumented/load-generator.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash - -while : -do - echo "Calling fibonacci-java" - ./call-app.sh http://localhost:8080 || true - echo - - sleep 2 -done \ No newline at end of file diff --git a/getting-started-guides/java/instrumented/src/main/java/com/example/demo/Application.java b/getting-started-guides/java/instrumented/src/main/java/com/example/demo/Application.java deleted file mode 100644 index c78ebc66..00000000 --- a/getting-started-guides/java/instrumented/src/main/java/com/example/demo/Application.java +++ /dev/null @@ -1,63 +0,0 @@ -package com.example.demo; - -import io.opentelemetry.api.OpenTelemetry; -import io.opentelemetry.instrumentation.log4j.appender.v2_17.OpenTelemetryAppender; -import io.opentelemetry.instrumentation.runtimemetrics.java8.Classes; -import io.opentelemetry.instrumentation.runtimemetrics.java8.Cpu; -import io.opentelemetry.instrumentation.runtimemetrics.java8.GarbageCollector; -import io.opentelemetry.instrumentation.runtimemetrics.java8.MemoryPools; -import io.opentelemetry.instrumentation.runtimemetrics.java8.Threads; -import io.opentelemetry.instrumentation.runtimemetrics.java8.internal.ExperimentalBufferPools; -import io.opentelemetry.instrumentation.runtimemetrics.java8.internal.ExperimentalCpu; -import io.opentelemetry.instrumentation.runtimemetrics.java8.internal.ExperimentalMemoryPools; -import io.opentelemetry.instrumentation.spring.webmvc.v6_0.SpringWebMvcTelemetry; -import io.opentelemetry.sdk.OpenTelemetrySdk; -import io.opentelemetry.sdk.autoconfigure.AutoConfiguredOpenTelemetrySdk; -import jakarta.servlet.Filter; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.Bean; - -@SpringBootApplication -public class Application { - - private static volatile OpenTelemetry openTelemetry = OpenTelemetry.noop(); - - public static void main(String[] args) { - // Build the SDK auto-configuration extension module - OpenTelemetrySdk openTelemetrySdk = - AutoConfiguredOpenTelemetrySdk.builder().build().getOpenTelemetrySdk(); - Application.openTelemetry = openTelemetrySdk; - - // Register runtime metrics instrumentation - Classes.registerObservers(openTelemetrySdk); - Cpu.registerObservers(openTelemetrySdk); - GarbageCollector.registerObservers(openTelemetrySdk); - MemoryPools.registerObservers(openTelemetrySdk); - Threads.registerObservers(openTelemetrySdk); - - ExperimentalCpu.registerObservers(openTelemetrySdk); - ExperimentalBufferPools.registerObservers(openTelemetrySdk); - ExperimentalMemoryPools.registerObservers(openTelemetrySdk); - - SpringApplication.run(Application.class, args); - - // Setup log4j OpenTelemetryAppender - // Normally this is done before the framework (Spring) is initialized. However, spring boot - // erases any programmatic log configuration so we must initialize after Spring. Unfortunately, - // this means that Spring startup logs do not make it to the OpenTelemetry. - // See this issue for tracking: https://github.com/spring-projects/spring-boot/issues/25847 - OpenTelemetryAppender.install(openTelemetrySdk); - } - - @Bean - public OpenTelemetry openTelemetry() { - return openTelemetry; - } - - // Add Spring WebMVC instrumentation by registering a tracing filter - @Bean - public Filter webMvcTracingFilter(OpenTelemetry openTelemetry) { - return SpringWebMvcTelemetry.create(openTelemetry).createServletFilter(); - } -} diff --git a/getting-started-guides/java/settings.gradle b/getting-started-guides/java/settings.gradle deleted file mode 100644 index 48fdf87d..00000000 --- a/getting-started-guides/java/settings.gradle +++ /dev/null @@ -1,11 +0,0 @@ -pluginManagement { - plugins { - id 'com.diffplug.spotless' version '6.25.0' - id 'org.springframework.boot' version '3.2.5' - id 'de.undercouch.download' version '5.6.0' - } -} - -rootProject.name = "newrelic-getting-started-guides-java" -include 'instrumented' -include 'uninstrumented' diff --git a/getting-started-guides/java/src/main/java/com/example/demo/Application.java b/getting-started-guides/java/src/main/java/com/example/demo/Application.java new file mode 100644 index 00000000..40481185 --- /dev/null +++ b/getting-started-guides/java/src/main/java/com/example/demo/Application.java @@ -0,0 +1,23 @@ +package com.example.demo; + +import io.opentelemetry.api.GlobalOpenTelemetry; +import io.opentelemetry.api.OpenTelemetry; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; + +@SpringBootApplication +public class Application { + + public static void main(String[] args) { + SpringApplication.run(Application.class, args); + } + + @Bean + public OpenTelemetry openTelemetry() { + // OpenTelemetry javaagent will install the OpenTelemetrySdk and make the instance available via + // GlobalOpenTelemetry.get(). Set this instance as a spring bean so we can add additional manual + // instrumentation. + return GlobalOpenTelemetry.get(); + } +} diff --git a/getting-started-guides/java/instrumented/src/main/java/com/example/demo/Controller.java b/getting-started-guides/java/src/main/java/com/example/demo/Controller.java similarity index 100% rename from getting-started-guides/java/instrumented/src/main/java/com/example/demo/Controller.java rename to getting-started-guides/java/src/main/java/com/example/demo/Controller.java diff --git a/getting-started-guides/java/instrumented/src/main/resources/log4j2.xml b/getting-started-guides/java/src/main/resources/log4j2.xml similarity index 65% rename from getting-started-guides/java/instrumented/src/main/resources/log4j2.xml rename to getting-started-guides/java/src/main/resources/log4j2.xml index 53cd4f33..486877b6 100644 --- a/getting-started-guides/java/instrumented/src/main/resources/log4j2.xml +++ b/getting-started-guides/java/src/main/resources/log4j2.xml @@ -1,14 +1,12 @@ - + - - diff --git a/getting-started-guides/java/uninstrumented/README.md b/getting-started-guides/java/uninstrumented/README.md deleted file mode 100644 index e69c6071..00000000 --- a/getting-started-guides/java/uninstrumented/README.md +++ /dev/null @@ -1,19 +0,0 @@ -# Uninstrumented Java demo app - -Requires: - -* Java 17+ -* A New Relic account - -To run the uninstrumented java app via the CLI, switch to the `java` directory and run: - -```shell -../gradlew bootRun -``` - -To exercise, in a new shell: -```shell -./load-generator.sh -``` - -To shut down the program, run the following in both shells or terminal tabs: `ctrl + c`. \ No newline at end of file diff --git a/getting-started-guides/java/uninstrumented/build.gradle b/getting-started-guides/java/uninstrumented/build.gradle deleted file mode 100644 index a4d1c63c..00000000 --- a/getting-started-guides/java/uninstrumented/build.gradle +++ /dev/null @@ -1,15 +0,0 @@ -import org.springframework.boot.gradle.plugin.SpringBootPlugin - -plugins { - id 'org.springframework.boot' - id 'java' -} - -bootRun { - mainClass.set 'com.example.demo.Application' -} - -dependencies { - implementation platform(SpringBootPlugin.BOM_COORDINATES) - implementation 'org.springframework.boot:spring-boot-starter-web' -} diff --git a/getting-started-guides/java/uninstrumented/call-app.sh b/getting-started-guides/java/uninstrumented/call-app.sh deleted file mode 100755 index acfab95d..00000000 --- a/getting-started-guides/java/uninstrumented/call-app.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash - -echo "GET ${1}/fibonacci?n=5" -curl "${1}/fibonacci?n=5" || true -echo - -echo "GET ${1}/fibonacci?n=283" -curl "${1}/fibonacci?n=283" || true -echo - -echo "GET ${1}/fibonacci?n=10" -curl "${1}/fibonacci?n=10" || true -echo - -echo "GET ${1}/fibonacci?n=90" -curl "${1}/fibonacci?n=90" || true -echo - -echo "GET ${1}/fibonacci?n=0" -curl "${1}/fibonacci?n=0" || true -echo \ No newline at end of file diff --git a/getting-started-guides/java/uninstrumented/load-generator.sh b/getting-started-guides/java/uninstrumented/load-generator.sh deleted file mode 100755 index 79b7c7d8..00000000 --- a/getting-started-guides/java/uninstrumented/load-generator.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash - -while : -do - echo "Calling fibonacci-java" - ./call-app.sh http://localhost:8080 || true - echo - - sleep 2 -done diff --git a/getting-started-guides/java/uninstrumented/src/main/java/com/example/demo/Application.java b/getting-started-guides/java/uninstrumented/src/main/java/com/example/demo/Application.java deleted file mode 100644 index 8439bc4a..00000000 --- a/getting-started-guides/java/uninstrumented/src/main/java/com/example/demo/Application.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.example.demo; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -@SpringBootApplication -public class Application { - - public static void main(String[] args) { - SpringApplication.run(Application.class, args); - } -} diff --git a/getting-started-guides/java/uninstrumented/src/main/java/com/example/demo/Controller.java b/getting-started-guides/java/uninstrumented/src/main/java/com/example/demo/Controller.java deleted file mode 100644 index d9afd3da..00000000 --- a/getting-started-guides/java/uninstrumented/src/main/java/com/example/demo/Controller.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.example.demo; - -import java.util.Map; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.web.HttpRequestMethodNotSupportedException; -import org.springframework.web.bind.MissingServletRequestParameterException; -import org.springframework.web.bind.annotation.*; - -@RestController -public class Controller { - - @GetMapping(value = "/fibonacci") - public Map getFibonacci(@RequestParam(required = true, name = "n") long n) { - return Map.of("n", n, "result", fibonacci(n)); - } - - /** - * Compute the fibonacci number for {@code n}. - * - * @param n must be >=1 and <= 90. - */ - private long fibonacci(long n) { - if (n < 1 || n > 90) { - throw new IllegalArgumentException("n must be 1 <= n <= 90."); - } - - long result = 1; - if (n > 2) { - long a = 0; - long b = 1; - - for (long i = 1; i < n; i++) { - result = a + b; - a = b; - b = result; - } - } - - return result; - } - - @ControllerAdvice - private static class ErrorHandler { - - @ExceptionHandler({ - IllegalArgumentException.class, - MissingServletRequestParameterException.class, - HttpRequestMethodNotSupportedException.class - }) - public ResponseEntity handleException(Exception e) { - return new ResponseEntity<>(Map.of("message", e.getMessage()), HttpStatus.BAD_REQUEST); - } - } -} diff --git a/getting-started-guides/supporting-files/envoy.yaml b/getting-started-guides/supporting-files/envoy.yaml index 99f9b940..cac2fb41 100644 --- a/getting-started-guides/supporting-files/envoy.yaml +++ b/getting-started-guides/supporting-files/envoy.yaml @@ -22,6 +22,8 @@ static_resources: route: { cluster: dotnet, prefix_rewrite: "/fibonacci" } - match: { prefix: "/go/fibonacci" } route: { cluster: go, prefix_rewrite: "/fibonacci" } + - match: { prefix: "/java/fibonacci" } + route: { cluster: java, prefix_rewrite: "/fibonacci" } - match: { prefix: "/javascript/fibonacci" } route: { cluster: javascript, prefix_rewrite: "/fibonacci" } - match: { prefix: "/python/fibonacci" } @@ -58,6 +60,18 @@ static_resources: socket_address: address: go port_value: 8080 + - name: java + type: STRICT_DNS + lb_policy: ROUND_ROBIN + load_assignment: + cluster_name: java + endpoints: + - lb_endpoints: + - endpoint: + address: + socket_address: + address: java + port_value: 8080 - name: javascript type: STRICT_DNS lb_policy: ROUND_ROBIN diff --git a/getting-started-guides/supporting-files/loadgenerator.py b/getting-started-guides/supporting-files/loadgenerator.py index ffcc49ab..63158a21 100644 --- a/getting-started-guides/supporting-files/loadgenerator.py +++ b/getting-started-guides/supporting-files/loadgenerator.py @@ -6,7 +6,7 @@ def signal_handler(signal, frame): signal.signal(signal.SIGINT, signal_handler) -languages = ["dotnet", "go", "javascript", "python", "ruby"] +languages = ["dotnet", "go", "java", "javascript", "python", "ruby"] while True: n = random.randint(1, 100)