- 
                Notifications
    
You must be signed in to change notification settings  - Fork 1k
 
Remove experimental methods out of (to-be-public) TelemetryBuilder classes #12847
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
          
     Merged
      
      
            trask
  merged 8 commits into
  open-telemetry:main
from
trask:move-experimental-out-of-public-api
  
      
      
   
  Dec 17, 2024 
      
    
  
     Merged
                    Changes from 2 commits
      Commits
    
    
            Show all changes
          
          
            8 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      eed12e5
              
                Move experimental methods out of public API
              
              
                trask 3093273
              
                Merge remote-tracking branch 'upstream/main' into move-experimental-o…
              
              
                trask 1ff7911
              
                Merge remote-tracking branch 'upstream/main' into move-experimental-o…
              
              
                trask 9cc335e
              
                Fix javadoc todo
              
              
                trask 94a0a70
              
                remove reflection
              
              
                trask e00ea5e
              
                Merge remote-tracking branch 'upstream/main' into move-experimental-o…
              
              
                trask 923cab9
              
                volatile
              
              
                trask 9ba23d6
              
                static
              
              
                trask File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
        
          
  
    
      
          
            55 changes: 55 additions & 0 deletions
          
          55 
        
  ...in/java/io/opentelemetry/instrumentation/apachehttpclient/v4_3/internal/Experimental.java
  
  
      
      
   
        
      
      
    
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| /* | ||
| * Copyright The OpenTelemetry Authors | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
| 
     | 
||
| package io.opentelemetry.instrumentation.apachehttpclient.v4_3.internal; | ||
| 
     | 
||
| import static java.util.logging.Level.FINE; | ||
| 
     | 
||
| import io.opentelemetry.instrumentation.apachehttpclient.v4_3.ApacheHttpClientTelemetryBuilder; | ||
| import java.lang.reflect.InvocationTargetException; | ||
| import java.lang.reflect.Method; | ||
| import java.util.logging.Logger; | ||
| import javax.annotation.Nullable; | ||
| 
     | 
||
| /** | ||
| * This class is internal and is hence not for public use. Its APIs are unstable and can change at | ||
| * any time. | ||
| */ | ||
| // TODO (trask) update the above javadoc similar to | ||
| // https://github.com/open-telemetry/opentelemetry-java/pull/6886 | ||
| public class Experimental { | ||
| 
     | 
||
| private static final Logger logger = Logger.getLogger(Experimental.class.getName()); | ||
| 
     | 
||
| @Nullable | ||
| private static final Method emitExperimentalTelemetryMethod = | ||
| getEmitExperimentalTelemetryMethod(); | ||
| 
     | 
||
| public void setEmitExperimentalTelemetry( | ||
| ApacheHttpClientTelemetryBuilder builder, boolean emitExperimentalTelemetry) { | ||
| 
     | 
||
| if (emitExperimentalTelemetryMethod != null) { | ||
| try { | ||
| emitExperimentalTelemetryMethod.invoke(builder, emitExperimentalTelemetry); | ||
| } catch (IllegalAccessException | InvocationTargetException e) { | ||
| logger.log(FINE, e.getMessage(), e); | ||
| } | ||
| } | ||
| } | ||
| 
     | 
||
| @Nullable | ||
| private static Method getEmitExperimentalTelemetryMethod() { | ||
| try { | ||
| Method method = | ||
| ApacheHttpClientTelemetryBuilder.class.getDeclaredMethod( | ||
| "setEmitExperimentalHttpClientMetrics", boolean.class); | ||
| method.setAccessible(true); | ||
| return method; | ||
| } catch (NoSuchMethodException e) { | ||
| logger.log(FINE, e.getMessage(), e); | ||
| return null; | ||
| } | ||
| } | ||
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
        
          
  
    
      
          
            55 changes: 55 additions & 0 deletions
          
          55 
        
  ...rary/src/main/java/io/opentelemetry/instrumentation/httpclient/internal/Experimental.java
  
  
      
      
   
        
      
      
    
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| /* | ||
| * Copyright The OpenTelemetry Authors | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
| 
     | 
||
| package io.opentelemetry.instrumentation.httpclient.internal; | ||
| 
     | 
||
| import static java.util.logging.Level.FINE; | ||
| 
     | 
||
| import io.opentelemetry.instrumentation.httpclient.JavaHttpClientTelemetryBuilder; | ||
| import java.lang.reflect.InvocationTargetException; | ||
| import java.lang.reflect.Method; | ||
| import java.util.logging.Logger; | ||
| import javax.annotation.Nullable; | ||
| 
     | 
||
| /** | ||
| * This class is internal and is hence not for public use. Its APIs are unstable and can change at | ||
| * any time. | ||
| */ | ||
| // TODO (trask) update the above javadoc similar to | ||
| // https://github.com/open-telemetry/opentelemetry-java/pull/6886 | ||
| public class Experimental { | ||
| 
     | 
||
| private static final Logger logger = Logger.getLogger(Experimental.class.getName()); | ||
| 
     | 
||
| @Nullable | ||
| private static final Method emitExperimentalTelemetryMethod = | ||
| getEmitExperimentalTelemetryMethod(); | ||
| 
     | 
||
| public void setEmitExperimentalTelemetry( | ||
| JavaHttpClientTelemetryBuilder builder, boolean emitExperimentalTelemetry) { | ||
| 
     | 
||
| if (emitExperimentalTelemetryMethod != null) { | ||
| try { | ||
| emitExperimentalTelemetryMethod.invoke(builder, emitExperimentalTelemetry); | ||
| } catch (IllegalAccessException | InvocationTargetException e) { | ||
| logger.log(FINE, e.getMessage(), e); | ||
| } | ||
| } | ||
| } | ||
| 
     | 
||
| @Nullable | ||
| private static Method getEmitExperimentalTelemetryMethod() { | ||
| try { | ||
| Method method = | ||
| JavaHttpClientTelemetryBuilder.class.getDeclaredMethod( | ||
| "setEmitExperimentalHttpClientMetrics", boolean.class); | ||
| method.setAccessible(true); | ||
| return method; | ||
| } catch (NoSuchMethodException e) { | ||
| logger.log(FINE, e.getMessage(), e); | ||
| return null; | ||
| } | ||
| } | ||
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
        
          
  
    
      
          
            55 changes: 55 additions & 0 deletions
          
          55 
        
  ...n/java/io/opentelemetry/instrumentation/jetty/httpclient/v12_0/internal/Experimental.java
  
  
      
      
   
        
      
      
    
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| /* | ||
| * Copyright The OpenTelemetry Authors | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
| 
     | 
||
| package io.opentelemetry.instrumentation.jetty.httpclient.v12_0.internal; | ||
| 
     | 
||
| import static java.util.logging.Level.FINE; | ||
| 
     | 
||
| import io.opentelemetry.instrumentation.jetty.httpclient.v12_0.JettyClientTelemetryBuilder; | ||
| import java.lang.reflect.InvocationTargetException; | ||
| import java.lang.reflect.Method; | ||
| import java.util.logging.Logger; | ||
| import javax.annotation.Nullable; | ||
| 
     | 
||
| /** | ||
| * This class is internal and is hence not for public use. Its APIs are unstable and can change at | ||
| * any time. | ||
| */ | ||
| // TODO (trask) update the above javadoc similar to | ||
| // https://github.com/open-telemetry/opentelemetry-java/pull/6886 | ||
| public class Experimental { | ||
| 
     | 
||
| private static final Logger logger = Logger.getLogger(Experimental.class.getName()); | ||
| 
     | 
||
| @Nullable | ||
| private static final Method emitExperimentalTelemetryMethod = | ||
| getEmitExperimentalTelemetryMethod(); | ||
| 
     | 
||
| public void setEmitExperimentalTelemetry( | ||
| JettyClientTelemetryBuilder builder, boolean emitExperimentalTelemetry) { | ||
| 
     | 
||
| if (emitExperimentalTelemetryMethod != null) { | ||
| try { | ||
| emitExperimentalTelemetryMethod.invoke(builder, emitExperimentalTelemetry); | ||
| } catch (IllegalAccessException | InvocationTargetException e) { | ||
| logger.log(FINE, e.getMessage(), e); | ||
| } | ||
| } | ||
| } | ||
| 
     | 
||
| @Nullable | ||
| private static Method getEmitExperimentalTelemetryMethod() { | ||
| try { | ||
| Method method = | ||
| JettyClientTelemetryBuilder.class.getDeclaredMethod( | ||
| "setEmitExperimentalHttpClientMetrics", boolean.class); | ||
| method.setAccessible(true); | ||
| return method; | ||
| } catch (NoSuchMethodException e) { | ||
| logger.log(FINE, e.getMessage(), e); | ||
| return null; | ||
| } | ||
| } | ||
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
        
          
  
    
      
          
            55 changes: 55 additions & 0 deletions
          
          55 
        
  ...in/java/io/opentelemetry/instrumentation/jetty/httpclient/v9_2/internal/Experimental.java
  
  
      
      
   
        
      
      
    
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| /* | ||
| * Copyright The OpenTelemetry Authors | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
| 
     | 
||
| package io.opentelemetry.instrumentation.jetty.httpclient.v9_2.internal; | ||
| 
     | 
||
| import static java.util.logging.Level.FINE; | ||
| 
     | 
||
| import io.opentelemetry.instrumentation.jetty.httpclient.v9_2.JettyClientTelemetryBuilder; | ||
| import java.lang.reflect.InvocationTargetException; | ||
| import java.lang.reflect.Method; | ||
| import java.util.logging.Logger; | ||
| import javax.annotation.Nullable; | ||
| 
     | 
||
| /** | ||
| * This class is internal and is hence not for public use. Its APIs are unstable and can change at | ||
| * any time. | ||
| */ | ||
| // TODO (trask) update the above javadoc similar to | ||
| // https://github.com/open-telemetry/opentelemetry-java/pull/6886 | ||
| public class Experimental { | ||
| 
     | 
||
| private static final Logger logger = Logger.getLogger(Experimental.class.getName()); | ||
| 
     | 
||
| @Nullable | ||
| private static final Method emitExperimentalTelemetryMethod = | ||
| getEmitExperimentalTelemetryMethod(); | ||
| 
     | 
||
| public void setEmitExperimentalTelemetry( | ||
| JettyClientTelemetryBuilder builder, boolean emitExperimentalTelemetry) { | ||
| 
     | 
||
| if (emitExperimentalTelemetryMethod != null) { | ||
| try { | ||
| emitExperimentalTelemetryMethod.invoke(builder, emitExperimentalTelemetry); | ||
| } catch (IllegalAccessException | InvocationTargetException e) { | ||
| logger.log(FINE, e.getMessage(), e); | ||
| } | ||
| } | ||
| } | ||
| 
     | 
||
| @Nullable | ||
| private static Method getEmitExperimentalTelemetryMethod() { | ||
| try { | ||
| Method method = | ||
| JettyClientTelemetryBuilder.class.getDeclaredMethod( | ||
| "setEmitExperimentalHttpClientMetrics", boolean.class); | ||
| method.setAccessible(true); | ||
| return method; | ||
| } catch (NoSuchMethodException e) { | ||
| logger.log(FINE, e.getMessage(), e); | ||
| return null; | ||
| } | ||
| } | ||
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
      
      Oops, something went wrong.
        
    
  
      
      Oops, something went wrong.
        
    
  
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I combined this with emitExperimentalTelemetry, which matches how it's enabled under single java agent flag
otel.instrumentation.http.client.emit-experimental-telemetry