- 
                Notifications
    
You must be signed in to change notification settings  - Fork 1k
 
Update the OpenTelemetry SDK version to 1.50.0 #13834
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
      
      
    
  
     Merged
                    Changes from 4 commits
      Commits
    
    
            Show all changes
          
          
            8 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      281e8f8
              
                Update the OpenTelemetry SDK version to 1.50.0
              
              
                otelbot[bot] 0f465dd
              
                fix build errors
              
              
                laurit 8ac978f
              
                add bridging for 1.50 api
              
              
                laurit a9d95ab
              
                fix test
              
              
                laurit 8cce48a
              
                add bridging for extended attributes
              
              
                laurit 5ab98f4
              
                fix declarative config test
              
              
                laurit dae89d9
              
                Merge branch 'main' into otelbot/update-opentelemetry-sdk-to-1.50.0
              
              
                laurit cf22238
              
                remove ordered
              
              
                laurit 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
    
  
  
    
              
  
    
      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
    
  
  
    
              
  
    
      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
    
  
  
    
              
  
    
      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
    
  
  
    
              
  
    
      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
    
  
  
    
              
  
    
      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
    
  
  
    
              
  
    
      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
    
  
  
    
              
  
    
      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
    
  
  
    
              
        
          
  
    
      
          
            32 changes: 32 additions & 0 deletions
          
          32 
        
  instrumentation/opentelemetry-api/opentelemetry-api-1.50/javaagent/build.gradle.kts
  
  
      
      
   
        
      
      
    
  
    
      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,32 @@ | ||
| plugins { | ||
| id("otel.javaagent-instrumentation") | ||
| } | ||
| 
     | 
||
| dependencies { | ||
| compileOnly(project(":opentelemetry-api-shaded-for-instrumenting", configuration = "v1_50")) | ||
| compileOnly("io.opentelemetry:opentelemetry-api-incubator") | ||
| 
     | 
||
| implementation(project(":instrumentation:opentelemetry-api:opentelemetry-api-1.0:javaagent")) | ||
| implementation(project(":instrumentation:opentelemetry-api:opentelemetry-api-1.27:javaagent")) | ||
| implementation(project(":instrumentation:opentelemetry-api:opentelemetry-api-1.40:javaagent")) | ||
| implementation(project(":instrumentation:opentelemetry-api:opentelemetry-api-1.42:javaagent")) | ||
| implementation(project(":instrumentation:opentelemetry-api:opentelemetry-api-1.47:javaagent")) | ||
| 
     | 
||
| testImplementation("io.opentelemetry:opentelemetry-api-incubator") | ||
| } | ||
| 
     | 
||
| testing { | ||
| suites { | ||
| val incubatorTest by registering(JvmTestSuite::class) { | ||
| dependencies { | ||
| implementation("io.opentelemetry:opentelemetry-api-incubator:1.50.0-alpha") | ||
| } | ||
| } | ||
| } | ||
| } | ||
| 
     | 
||
| tasks { | ||
| test { | ||
| jvmArgs("-Dotel.instrumentation.opentelemetry-api-incubator-1.50.enabled=false") | ||
| } | ||
| } | 
        
          
  
    
      
          
            149 changes: 149 additions & 0 deletions
          
          149 
        
  ...telemetry/javaagent/instrumentation/opentelemetryapi/v1_50/incubator/logs/LoggerTest.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,149 @@ | ||
| /* | ||
| * Copyright The OpenTelemetry Authors | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
| 
     | 
||
| package io.opentelemetry.javaagent.instrumentation.opentelemetryapi.v1_50.incubator.logs; | ||
| 
     | 
||
| import static org.assertj.core.api.Assertions.assertThat; | ||
| import static org.awaitility.Awaitility.await; | ||
| 
     | 
||
| import io.opentelemetry.api.GlobalOpenTelemetry; | ||
| import io.opentelemetry.api.common.AttributeKey; | ||
| import io.opentelemetry.api.common.Attributes; | ||
| import io.opentelemetry.api.common.KeyValue; | ||
| import io.opentelemetry.api.common.Value; | ||
| import io.opentelemetry.api.common.ValueType; | ||
| import io.opentelemetry.api.incubator.logs.ExtendedLogger; | ||
| import io.opentelemetry.api.logs.Logger; | ||
| import io.opentelemetry.api.logs.Severity; | ||
| import io.opentelemetry.api.trace.Span; | ||
| import io.opentelemetry.api.trace.SpanContext; | ||
| import io.opentelemetry.api.trace.TraceFlags; | ||
| import io.opentelemetry.api.trace.TraceState; | ||
| import io.opentelemetry.context.Context; | ||
| import io.opentelemetry.instrumentation.testing.junit.AgentInstrumentationExtension; | ||
| import io.opentelemetry.sdk.logs.data.internal.ExtendedLogRecordData; | ||
| import io.opentelemetry.sdk.trace.IdGenerator; | ||
| import java.time.Instant; | ||
| import java.util.concurrent.TimeUnit; | ||
| import java.util.stream.Stream; | ||
| import org.junit.jupiter.api.BeforeEach; | ||
| import org.junit.jupiter.api.Test; | ||
| import org.junit.jupiter.api.TestInfo; | ||
| import org.junit.jupiter.api.extension.RegisterExtension; | ||
| import org.junit.jupiter.params.ParameterizedTest; | ||
| import org.junit.jupiter.params.provider.Arguments; | ||
| import org.junit.jupiter.params.provider.MethodSource; | ||
| 
     | 
||
| class LoggerTest { | ||
| 
     | 
||
| @RegisterExtension | ||
| static final AgentInstrumentationExtension testing = AgentInstrumentationExtension.create(); | ||
| 
     | 
||
| private String instrumentationName; | ||
| private Logger logger; | ||
| 
     | 
||
| @BeforeEach | ||
| void setupLogger(TestInfo test) { | ||
| instrumentationName = "test-" + test.getDisplayName(); | ||
| logger = | ||
| GlobalOpenTelemetry.get() | ||
| .getLogsBridge() | ||
| .loggerBuilder(instrumentationName) | ||
| .setInstrumentationVersion("1.2.3") | ||
| .setSchemaUrl("http://schema.org") | ||
| .build(); | ||
| } | ||
| 
     | 
||
| @Test | ||
| void logRecordBuilder() { | ||
| assertThat(logger).isInstanceOf(ExtendedLogger.class); | ||
| 
     | 
||
| SpanContext spanContext = | ||
| SpanContext.create( | ||
| IdGenerator.random().generateTraceId(), | ||
| IdGenerator.random().generateSpanId(), | ||
| TraceFlags.getDefault(), | ||
| TraceState.getDefault()); | ||
| 
     | 
||
| ((ExtendedLogger) logger) | ||
| .logRecordBuilder() | ||
| .setEventName("eventName") | ||
| .setTimestamp(1, TimeUnit.SECONDS) | ||
| .setTimestamp(Instant.now()) | ||
| .setContext(Context.current().with(Span.wrap(spanContext))) | ||
| .setSeverity(Severity.DEBUG) | ||
| .setSeverityText("debug") | ||
| .setBody("body") | ||
| .setAttribute(AttributeKey.stringKey("key"), "value") | ||
| .setAllAttributes(Attributes.builder().put("key", "value").build()) | ||
| .emit(); | ||
| 
     | 
||
| await() | ||
| .untilAsserted( | ||
| () -> | ||
| assertThat(testing.logRecords()) | ||
| .satisfiesExactly( | ||
| logRecordData -> { | ||
| assertThat(logRecordData.getInstrumentationScopeInfo().getName()) | ||
| .isEqualTo(instrumentationName); | ||
| assertThat(((ExtendedLogRecordData) logRecordData).getEventName()) | ||
| .isEqualTo("eventName"); | ||
| assertThat(logRecordData.getInstrumentationScopeInfo().getVersion()) | ||
| .isEqualTo("1.2.3"); | ||
| assertThat(logRecordData.getTimestampEpochNanos()).isGreaterThan(0); | ||
| assertThat(logRecordData.getSpanContext()).isEqualTo(spanContext); | ||
| assertThat(logRecordData.getSeverity()).isEqualTo(Severity.DEBUG); | ||
| assertThat(logRecordData.getSeverityText()).isEqualTo("debug"); | ||
| assertThat(logRecordData.getBodyValue().getType()) | ||
| .isEqualTo(ValueType.STRING); | ||
| assertThat(logRecordData.getBodyValue().getValue()).isEqualTo("body"); | ||
| assertThat(logRecordData.getAttributes()) | ||
| .isEqualTo(Attributes.builder().put("key", "value").build()); | ||
| })); | ||
| } | ||
| 
     | 
||
| private static Stream<Arguments> bodyValues() { | ||
| return Stream.of( | ||
| Arguments.of(Value.of("hello")), | ||
| Arguments.of(Value.of(42)), | ||
| Arguments.of(Value.of(42.42)), | ||
| Arguments.of(Value.of(true)), | ||
| Arguments.of(Value.of(new byte[] {4, 2})), | ||
| Arguments.of(Value.of(Value.of("hello"), Value.of(42))), | ||
| Arguments.of(Value.of(KeyValue.of("key", Value.of(42))))); | ||
| } | ||
| 
     | 
||
| @ParameterizedTest | ||
| @MethodSource("bodyValues") | ||
| void logBodyValue() { | ||
| Value<?> value = Value.of(42); | ||
| logger.logRecordBuilder().setBody(value).emit(); | ||
| 
     | 
||
| await() | ||
| .untilAsserted( | ||
| () -> | ||
| assertThat(testing.logRecords()) | ||
| .satisfiesExactly( | ||
| logRecordData -> { | ||
| assertThat(logRecordData.getBodyValue().getType()) | ||
| .isEqualTo(value.getType()); | ||
| assertThat(logRecordData.getBodyValue().getValue()) | ||
| .isEqualTo(value.getValue()); | ||
| })); | ||
| } | ||
| 
     | 
||
| @Test | ||
| void logNullBody() { | ||
| Value<?> value = null; | ||
| logger.logRecordBuilder().setBody(value).emit(); | ||
| 
     | 
||
| await() | ||
| .untilAsserted( | ||
| () -> | ||
| assertThat(testing.logRecords()) | ||
| .satisfiesExactly( | ||
| logRecordData -> assertThat(logRecordData.getBodyValue()).isNull())); | ||
| } | ||
| } | ||
      
      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.
what do you think about adding extended attributes to the test?
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.
Good catch. Looks like I forgot to implement bridging for these. Should be fixed now.