Decide whether to compress the JSON profile based on the filename.

Fixes #10171

RELNOTES: None
PiperOrigin-RevId: 279278854
diff --git a/src/main/java/com/google/devtools/build/lib/runtime/CommonCommandOptions.java b/src/main/java/com/google/devtools/build/lib/runtime/CommonCommandOptions.java
index 839e312..9542381 100644
--- a/src/main/java/com/google/devtools/build/lib/runtime/CommonCommandOptions.java
+++ b/src/main/java/com/google/devtools/build/lib/runtime/CommonCommandOptions.java
@@ -30,6 +30,7 @@
 import com.google.devtools.common.options.OptionMetadataTag;
 import com.google.devtools.common.options.OptionsBase;
 import com.google.devtools.common.options.OptionsParsingException;
+import com.google.devtools.common.options.TriState;
 import java.util.List;
 import java.util.Map;
 import java.util.UUID;
@@ -256,12 +257,16 @@
   public boolean enableTracer;
 
   @Option(
-      name = "experimental_json_trace_compression",
-      defaultValue = "false",
+      name = "json_trace_compression",
+      oldName = "experimental_json_trace_compression",
+      defaultValue = "auto",
       documentationCategory = OptionDocumentationCategory.LOGGING,
       effectTags = {OptionEffectTag.AFFECTS_OUTPUTS, OptionEffectTag.BAZEL_MONITORING},
-      help = "If enabled, Bazel compresses the JSON-format profile with gzip.")
-  public boolean enableTracerCompression;
+      help =
+          "If enabled, Bazel compresses the JSON-format profile with gzip. "
+              + "By default, this is decided based on the extension of the file specified in "
+              + "--profile.")
+  public TriState enableTracerCompression;
 
   @Option(
       name = "experimental_post_profile_started_event",