Skip to content

Commit 6ec7a0a

Browse files
committed
Merge branch 'main' of https://github.com/open-telemetry/opentelemetry-java into config-provider
2 parents c5cdc1c + 6fc1d21 commit 6ec7a0a

File tree

170 files changed

+3314
-447
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

170 files changed

+3314
-447
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ jobs:
7474
RUN_JMH_BASED_TESTS: ${{ matrix.jmh-based-tests }}
7575

7676
- name: Check for diff
77-
# The jApiCmp diff compares current to latest, which isn't appropriate for release branches
78-
if: ${{ !startsWith(github.ref_name, 'release/') && !startsWith(github.base_ref, 'release/') }}
77+
# The jApiCmp diff compares current to latest, which isn't appropriate for release branches, or for bot-generated PRs
78+
if: ${{ !startsWith(github.ref_name, 'release/') && !startsWith(github.base_ref, 'release/') && (github.actor != 'opentelemetrybot') }}
7979
run: |
8080
# need to "git add" in case any generated files did not already exist
8181
git add docs/apidiffs

.github/workflows/gradle-wrapper-validation.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ jobs:
1313
steps:
1414
- uses: actions/checkout@v4
1515

16-
- uses: gradle/actions/wrapper-validation@v3.4.2
16+
- uses: gradle/actions/wrapper-validation@v3.5.0

CHANGELOG.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,24 @@
22

33
## Unreleased
44

5+
## Version 1.40.0 (2024-07-05)
6+
7+
### API
8+
9+
#### Incubator
10+
11+
* Narrow ExtendedSpanBuilder return types for chaining
12+
([#6514](https://github.com/open-telemetry/opentelemetry-java/pull/6514))
13+
* Add APIs to determine if tracer, logger, instruments are enabled
14+
([#6502](https://github.com/open-telemetry/opentelemetry-java/pull/6502))
15+
16+
### SDK
17+
18+
#### Extensions
19+
20+
* Move autoconfigure docs to opentelemetry.io
21+
([#6491](https://github.com/open-telemetry/opentelemetry-java/pull/6491))
22+
523
## Version 1.39.0 (2024-06-07)
624

725
### API
@@ -1921,7 +1939,7 @@ should not be many. Thanks for bearing with us on this.
19211939
### General
19221940

19231941
* Examples moved
1924-
to [opentelemetry-java-docs](https://github.com/open-telemetry/opentelemetry-java-docs)
1942+
to [opentelemetry-java-examples](https://github.com/open-telemetry/opentelemetry-java-examples)
19251943

19261944
### SDK
19271945

CONTRIBUTING.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ Other repositories in the OpenTelemetry Java ecosystem include:
9393
contains instrumentation.
9494
* [opentelemetry-java-contrib](https://github.com/open-telemetry/opentelemetry-java-contrib)
9595
contains extensions, prototypes, and instrumentation, including vendor specific components.
96-
* [opentelemetry-java-docs](https://github.com/open-telemetry/opentelemetry-java-docs) contains
96+
* [opentelemetry-java-examples](https://github.com/open-telemetry/opentelemetry-java-examples) contains
9797
working code snippets demonstrating various concepts.
9898

9999
## Style guideline
@@ -250,13 +250,18 @@ Example usage could be as follows:
250250
}
251251
```
252252

253+
Please confirm whether the local opentelemetry-java version is consistent with the
254+
opentelemetry-java version declared in the project that relies on opentelemetry-java.
255+
If it is inconsistent, `dependencySubstitution` may not take effect.
256+
253257
See [the Gradle documentation](https://docs.gradle.org/current/userguide/composite_builds.html#included_build_declaring_substitutions)
254258
for more information.
255-
256259
4. If you now build your project, it will use the included build to supply the opentelemetry-java
257260
artifacts, ignoring any version declarations. Use the prefix `:DIRECTORY:` to refer to
258261
tasks/projects within the included build, where DIRECTORY is the name of the directory in the
259262
included build (only the part after the last `/`).
263+
5. Here are some issues and solutions ([discussions/6551](https://github.com/open-telemetry/opentelemetry-java/discussions/6551))
264+
you may encounter that may be helpful to you.
260265

261266
### Updating the OTLP protobufs
262267

README.md

Lines changed: 39 additions & 39 deletions
Large diffs are not rendered by default.

animal-sniffer-signature/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ configurations.add(signatureJarClasspath)
2727
configurations.add(generatedSignature)
2828

2929
dependencies {
30-
signature("com.toasttab.android:gummy-bears-api-21:0.8.0@signature")
30+
signature("com.toasttab.android:gummy-bears-api-21:0.9.0@signature")
3131
signatureJar("com.android.tools:desugar_jdk_libs")
3232
}
3333

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* Copyright The OpenTelemetry Authors
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
package io.opentelemetry.api.internal;
7+
8+
import io.opentelemetry.context.Context;
9+
import io.opentelemetry.context.ContextKey;
10+
import java.util.Objects;
11+
12+
/**
13+
* This class is internal and is hence not for public use. Its APIs are unstable and can change at
14+
* any time.
15+
*/
16+
public final class InstrumentationUtil {
17+
private static final ContextKey<Boolean> SUPPRESS_INSTRUMENTATION_KEY =
18+
ContextKey.named("suppress_instrumentation");
19+
20+
private InstrumentationUtil() {}
21+
22+
/**
23+
* Adds a Context boolean key that will allow to identify HTTP calls coming from OTel exporters.
24+
* The key later be checked by an automatic instrumentation to avoid tracing OTel exporter's
25+
* calls.
26+
*/
27+
public static void suppressInstrumentation(Runnable runnable) {
28+
Context.current().with(SUPPRESS_INSTRUMENTATION_KEY, true).wrap(runnable).run();
29+
}
30+
31+
/**
32+
* Checks if an automatic instrumentation should be suppressed with the provided Context.
33+
*
34+
* @return TRUE to suppress the automatic instrumentation, FALSE to continue with the
35+
* instrumentation.
36+
*/
37+
public static boolean shouldSuppressInstrumentation(Context context) {
38+
return Objects.equals(context.get(SUPPRESS_INSTRUMENTATION_KEY), true);
39+
}
40+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
* Copyright The OpenTelemetry Authors
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
package io.opentelemetry.api.internal;
7+
8+
import static org.junit.jupiter.api.Assertions.assertFalse;
9+
import static org.junit.jupiter.api.Assertions.assertTrue;
10+
11+
import io.opentelemetry.context.Context;
12+
import org.junit.jupiter.api.Test;
13+
14+
class InstrumentationUtilTest {
15+
@Test
16+
void verifySuppressInstrumentation() {
17+
// Should be false by default.
18+
assertFalse(InstrumentationUtil.shouldSuppressInstrumentation(Context.current()));
19+
20+
// Should be true inside the Runnable passed to InstrumentationUtil.suppressInstrumentation.
21+
InstrumentationUtil.suppressInstrumentation(
22+
() -> assertTrue(InstrumentationUtil.shouldSuppressInstrumentation(Context.current())));
23+
24+
// Should be false after the runnable finishes.
25+
assertFalse(InstrumentationUtil.shouldSuppressInstrumentation(Context.current()));
26+
}
27+
}

api/incubator/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ See [EventApiUsageTest](./src/test/java/io/opentelemetry/api/incubator/events/Ev
1414

1515
Features:
1616

17+
* Check if logger is enabled before emitting logs to avoid uneccessary computation
1718
* Set AnyValue log record body with arbitrarily complex data
1819

1920
See [ExtendedLogsBridgeApiUsageTest](./src/test/java/io/opentelemetry/api/incubator/logs/ExtendedLogsBridgeApiUsageTest.java).
@@ -30,6 +31,7 @@ See [ExtendedMetricsApiUsageTest](./src/test/java/io/opentelemetry/api/incubator
3031

3132
Features:
3233

34+
* Check if instrument is enabled before recording measurements to avoid uneccessary computation
3335
* Simplified injection / extraction of context
3436

3537
See [ExtendedContextPropagatorsUsageTest](./src/test/java/io/opentelemetry/api/incubator/propagation/ExtendedContextPropagatorsUsageTest.java).
@@ -38,6 +40,7 @@ See [ExtendedContextPropagatorsUsageTest](./src/test/java/io/opentelemetry/api/i
3840

3941
Features:
4042

43+
* Check if tracer is enabled before starting spans to avoid uneccessary computation
4144
* Utility methods to reduce boilerplace using span API, including extracting context, and wrapping runnables / callables with spans
4245

4346
See [ExtendedTraceApiUsageTest](./src/test/java/io/opentelemetry/api/incubator/trace/ExtendedTraceApiUsageTest.java).
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* Copyright The OpenTelemetry Authors
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
package io.opentelemetry.api.incubator.logs;
7+
8+
import io.opentelemetry.api.logs.Logger;
9+
10+
/** Extended {@link Logger} with experimental APIs. */
11+
public interface ExtendedLogger extends Logger {
12+
13+
/**
14+
* Returns {@code true} if the logger is enabled.
15+
*
16+
* <p>This allows callers to avoid unnecessary compute when nothing is consuming the data. Because
17+
* the response is subject to change over the application, callers should call this before each
18+
* call to {@link #logRecordBuilder()}.
19+
*/
20+
default boolean isEnabled() {
21+
return true;
22+
}
23+
}

0 commit comments

Comments
 (0)