diff --git a/sdk_extensions/zpages/build.gradle b/sdk_extensions/zpages/build.gradle
index 1a8e83455d..03fa926452 100644
--- a/sdk_extensions/zpages/build.gradle
+++ b/sdk_extensions/zpages/build.gradle
@@ -13,7 +13,12 @@ dependencies {
project(':opentelemetry-sdk')
implementation libraries.guava
+
compileOnly 'com.sun.net.httpserver:http:20070405'
+ annotationProcessor libraries.auto_value
+
+ testAnnotationProcessor libraries.auto_value
+
signature "org.codehaus.mojo.signature:java17:1.0@signature"
}
diff --git a/sdk_extensions/zpages/src/main/java/io/opentelemetry/sdk/extensions/zpages/TraceConfigzZPageHandler.java b/sdk_extensions/zpages/src/main/java/io/opentelemetry/sdk/extensions/zpages/TraceConfigzZPageHandler.java
new file mode 100644
index 0000000000..56ff21aecc
--- /dev/null
+++ b/sdk_extensions/zpages/src/main/java/io/opentelemetry/sdk/extensions/zpages/TraceConfigzZPageHandler.java
@@ -0,0 +1,414 @@
+/*
+ * Copyright 2020, OpenTelemetry 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
+ *
+ * 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.
+ */
+
+package io.opentelemetry.sdk.extensions.zpages;
+
+import io.opentelemetry.sdk.trace.Samplers;
+import io.opentelemetry.sdk.trace.TracerSdkProvider;
+import io.opentelemetry.sdk.trace.config.TraceConfig;
+import java.io.OutputStream;
+import java.io.PrintStream;
+import java.util.Map;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+final class TraceConfigzZPageHandler extends ZPageHandler {
+ private static final String TRACE_CONFIGZ_URL = "/traceconfigz";
+ private static final String TRACE_CONFIGZ_NAME = "TraceConfigZ";
+ private static final String TRACE_CONFIGZ_DESCRIPTION =
+ "TraceConfigZ displays information about the current active tracing configuration"
+ + " and allows users to change it";
+ private static final String QUERY_STRING_ACTION = "action";
+ private static final String QUERY_STRING_ACTION_CHANGE = "change";
+ private static final String QUERY_STRING_ACTION_DEFAULT = "default";
+ private static final String QUERY_STRING_SAMPLING_PROBABILITY = "samplingprobability";
+ private static final String QUERY_STRING_MAX_NUM_OF_ATTRIBUTES = "maxnumofattributes";
+ private static final String QUERY_STRING_MAX_NUM_OF_EVENTS = "maxnumofevents";
+ private static final String QUERY_STRING_MAX_NUM_OF_LINKS = "maxnumoflinks";
+ private static final String QUERY_STRING_MAX_NUM_OF_ATTRIBUTES_PER_EVENT =
+ "maxnumofattributesperevent";
+ private static final String QUERY_STRING_MAX_NUM_OF_ATTRIBUTES_PER_LINK =
+ "maxnumofattributesperlink";
+ // Background color used for zebra striping rows in table
+ private static final String ZEBRA_STRIPE_COLOR = "#e6e6e6";
+ private static final Logger logger = Logger.getLogger(TraceConfigzZPageHandler.class.getName());
+ private final TracerSdkProvider tracerProvider;
+
+ TraceConfigzZPageHandler(TracerSdkProvider tracerProvider) {
+ this.tracerProvider = tracerProvider;
+ }
+
+ @Override
+ public String getUrlPath() {
+ return TRACE_CONFIGZ_URL;
+ }
+
+ @Override
+ public String getPageName() {
+ return TRACE_CONFIGZ_NAME;
+ }
+
+ @Override
+ public String getPageDescription() {
+ return TRACE_CONFIGZ_DESCRIPTION;
+ }
+
+ /**
+ * Emits CSS styles to the {@link PrintStream} {@code out}. Content emited by this function should
+ * be enclosed by
tag.
+ *
+ * @param out the {@link PrintStream} {@code out}.
+ */
+ private static void emitHtmlStyle(PrintStream out) {
+ out.print("");
+ }
+
+ /**
+ * Emits a row of the change tracing parameter table to the {@link PrintStream} {@code out}. Each
+ * row corresponds to one tracing parameter.
+ *
+ * @param out the {@link PrintStream} {@code out}.
+ * @param rowName the display name of the corresponding tracing parameter.
+ * @param paramName the name of the corresponding tracing parameter (this will be used to
+ * construct the query parameter in URL).
+ * @param inputPlaceHolder placeholder for the HTML element.
+ * @param paramDefaultValue the default value of the corresponding tracing parameter.
+ * @param zebraStripeColor hex code of the color used for zebra striping rows.
+ * @param zebraStripe boolean indicating if the row is zebra striped.
+ */
+ private static void emitChangeTableRow(
+ PrintStream out,
+ String rowName,
+ String paramName,
+ String inputPlaceHolder,
+ String paramDefaultValue,
+ String zebraStripeColor,
+ boolean zebraStripe) {
+ if (zebraStripe) {
+ out.print("
");
+ } else {
+ out.print("
");
+ }
+ out.print("
Update " + rowName + "
");
+ out.print(
+ "
");
+ out.print("
(" + paramDefaultValue + ")
");
+ out.print("
");
+ }
+
+ /**
+ * Emits the change tracing parameter table to the {@link PrintStream} {@code out}.
+ *
+ * @param out the {@link PrintStream} {@code out}.
+ */
+ private static void emitChangeTable(PrintStream out) {
+ out.print("
");
+ }
+
+ /**
+ * Emits a row of the active tracing parameter table to the {@link PrintStream} {@code out}. Each
+ * row corresponds to one tracing parameter.
+ *
+ * @param out the {@link PrintStream} {@code out}.
+ * @param paramName the name of the corresponding tracing parameter.
+ * @param paramValue the value of the corresponding tracing parameter.
+ * @param zebraStripeColor hex code of the color used for zebra striping rows.
+ * @param zebraStripe boolean indicating if the row is zebra striped.
+ */
+ private static void emitActiveTableRow(
+ PrintStream out,
+ String paramName,
+ String paramValue,
+ String zebraStripeColor,
+ boolean zebraStripe) {
+ if (zebraStripe) {
+ out.print("
");
+ } else {
+ out.print("
");
+ }
+ out.print("
" + paramName + "
");
+ out.print("
" + paramValue + "
");
+ out.print("
");
+ }
+
+ /**
+ * Emits the active tracing parameters table to the {@link PrintStream} {@code out}.
+ *
+ * @param out the {@link PrintStream} {@code out}.
+ */
+ private void emitActiveTable(PrintStream out) {
+ out.print("
");
+ }
+
+ /**
+ * Emits HTML body content to the {@link PrintStream} {@code out}. Content emitted by this
+ * function should be enclosed by tag.
+ *
+ * @param out the {@link PrintStream} {@code out}.
+ */
+ private void emitHtmlBody(PrintStream out) {
+ out.print(
+ "");
+ out.print("