Skip to content

Commit

Permalink
Merge branch 'main' into drop-aws-extension
Browse files Browse the repository at this point in the history
  • Loading branch information
jack-berg committed Nov 16, 2022
2 parents e6c3aad + 6c7637b commit f975b9b
Show file tree
Hide file tree
Showing 40 changed files with 457 additions and 137 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/build.yml
Expand Up @@ -60,6 +60,8 @@ jobs:
-Porg.gradle.java.installations.paths=${{ steps.setup-java-test.outputs.path }},${{ steps.setup-java.outputs.path }}
- name: Check for diff
# The jApiCmp diff compares current to latest, which isn't appropriate for release branches
if: ${{ !startsWith(github.ref_name, 'release/') && !startsWith(github.base_ref, 'release/') }}
run: |
if git diff --quiet
then
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Expand Up @@ -2,6 +2,14 @@

## Unreleased

## Version 1.20.1 (2022-11-15)

### Bugfixes

* Fix bug in `ComponentRegistry` that produces `ConcurrentModificationException` when reading
metrics at the same time as obtaining a meter.
[(#4951)](https://github.com/open-telemetry/opentelemetry-java/pull/4951)

## Version 1.20.0 (2022-11-11)

### API
Expand Down
72 changes: 36 additions & 36 deletions README.md

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions buildscripts/semantic-convention/generate.sh
Expand Up @@ -4,7 +4,7 @@ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
ROOT_DIR="${SCRIPT_DIR}/../../"

# freeze the spec & generator tools versions to make SemanticAttributes generation reproducible
SEMCONV_VERSION=1.13.0
SEMCONV_VERSION=1.15.0
SPEC_VERSION=v$SEMCONV_VERSION
SCHEMA_URL=https://opentelemetry.io/schemas/$SEMCONV_VERSION
GENERATOR_VERSION=0.14.0
Expand All @@ -22,13 +22,15 @@ git reset --hard FETCH_HEAD
cd ${SCRIPT_DIR}

docker run --rm \
-v ${SCRIPT_DIR}/opentelemetry-specification/semantic_conventions/trace:/source \
-v ${SCRIPT_DIR}/opentelemetry-specification/semantic_conventions:/source \
-v ${SCRIPT_DIR}/templates:/templates \
-v ${ROOT_DIR}/semconv/src/main/java/io/opentelemetry/semconv/trace/attributes/:/output \
otel/semconvgen:$GENERATOR_VERSION \
--exclude resource/** \
-f /source code \
--template /templates/SemanticAttributes.java.j2 \
--output /output/SemanticAttributes.java \
-Dsemconv=trace \
-Dclass=SemanticAttributes \
-DschemaUrl=$SCHEMA_URL \
-Dpkg=io.opentelemetry.semconv.trace.attributes
Expand Down
Expand Up @@ -56,6 +56,7 @@ import io.opentelemetry.api.common.AttributeKey;
import java.util.List;

// DO NOT EDIT, this is an Auto-generated file from buildscripts/semantic-convention{{template}}
@SuppressWarnings("unused")
public final class {{class}} {
/**
* The URL of the OpenTelemetry schema for these keys and values.
Expand All @@ -70,12 +71,12 @@ public final class {{class}} {
* <p>Notes:
<ul> {{attribute.note | render_markdown(code="{{@code {0}}}", paragraph="<li>{0}</li>", list="{0}")}} </ul>
{%- endif %}
{%- if attribute.deprecated %}
{%- if (attribute.stability | string()) == "StabilityLevel.DEPRECATED" %}
*
* @deprecated {{attribute.deprecated | to_doc_brief}}.
* @deprecated {{attribute.brief | to_doc_brief}}.
{%- endif %}
*/
{%- if attribute.deprecated %}
{%- if (attribute.stability | string()) == "StabilityLevel.DEPRECATED" %}
@Deprecated
{%- endif %}
public static final AttributeKey<{{upFirst(to_java_return_type(attribute.attr_type | string))}}> {{attribute.fqn | to_const_name}} = {{to_java_key_type(attribute.attr_type | string)}}("{{attribute.fqn}}");
Expand Down Expand Up @@ -177,6 +178,13 @@ public final class {{class}} {
@Deprecated
public static final AttributeKey<String> NET_HOST_IP = stringKey("net.host.ip");

/**
* The ordinal number of request re-sending attempt.
* @deprecated This item has been removed as of 1.15.0 of the semantic conventions. Use {@link SemanticAttributes#HTTP_RESEND_COUNT} instead.
*/
@Deprecated
public static final AttributeKey<Long> HTTP_RETRY_COUNT = longKey("http.retry_count");

{% endif %}

private {{class}}() {}
Expand Down
2 changes: 1 addition & 1 deletion dependencyManagement/build.gradle.kts
Expand Up @@ -97,7 +97,7 @@ val DEPENDENCIES = listOf(
"org.bouncycastle:bcpkix-jdk15on:1.70",
"org.codehaus.mojo:animal-sniffer-annotations:1.22",
"org.jctools:jctools-core:4.0.1",
"org.junit-pioneer:junit-pioneer:1.8.0",
"org.junit-pioneer:junit-pioneer:1.9.0",
"org.skyscreamer:jsonassert:1.5.1",
)

Expand Down
2 changes: 2 additions & 0 deletions docs/apidiffs/1.20.1_vs_1.20.0/opentelemetry-api.txt
@@ -0,0 +1,2 @@
Comparing source compatibility of against
No changes.
2 changes: 2 additions & 0 deletions docs/apidiffs/1.20.1_vs_1.20.0/opentelemetry-context.txt
@@ -0,0 +1,2 @@
Comparing source compatibility of against
No changes.
@@ -0,0 +1,2 @@
Comparing source compatibility of against
No changes.
@@ -0,0 +1,2 @@
Comparing source compatibility of against
No changes.
@@ -0,0 +1,2 @@
Comparing source compatibility of against
No changes.
@@ -0,0 +1,2 @@
Comparing source compatibility of against
No changes.
@@ -0,0 +1,2 @@
Comparing source compatibility of against
No changes.
@@ -0,0 +1,2 @@
Comparing source compatibility of against
No changes.
@@ -0,0 +1,2 @@
Comparing source compatibility of against
No changes.
@@ -0,0 +1,2 @@
Comparing source compatibility of against
No changes.
@@ -0,0 +1,2 @@
Comparing source compatibility of against
No changes.
@@ -0,0 +1,2 @@
Comparing source compatibility of against
No changes.
@@ -0,0 +1,2 @@
Comparing source compatibility of against
No changes.
2 changes: 2 additions & 0 deletions docs/apidiffs/1.20.1_vs_1.20.0/opentelemetry-sdk-common.txt
@@ -0,0 +1,2 @@
Comparing source compatibility of against
No changes.
@@ -0,0 +1,2 @@
Comparing source compatibility of against
No changes.
@@ -0,0 +1,2 @@
Comparing source compatibility of against
No changes.
2 changes: 2 additions & 0 deletions docs/apidiffs/1.20.1_vs_1.20.0/opentelemetry-sdk-metrics.txt
@@ -0,0 +1,2 @@
Comparing source compatibility of against
No changes.
2 changes: 2 additions & 0 deletions docs/apidiffs/1.20.1_vs_1.20.0/opentelemetry-sdk-testing.txt
@@ -0,0 +1,2 @@
Comparing source compatibility of against
No changes.
2 changes: 2 additions & 0 deletions docs/apidiffs/1.20.1_vs_1.20.0/opentelemetry-sdk-trace.txt
@@ -0,0 +1,2 @@
Comparing source compatibility of against
No changes.
2 changes: 2 additions & 0 deletions docs/apidiffs/1.20.1_vs_1.20.0/opentelemetry-sdk.txt
@@ -0,0 +1,2 @@
Comparing source compatibility of against
No changes.
Expand Up @@ -164,7 +164,7 @@ public SpanBuilder withTag(String key, Number value) {
if (value == null) {
return this;
}
// TODO - Verify only the 'basic' types are supported/used.

if (value instanceof Integer
|| value instanceof Long
|| value instanceof Short
Expand All @@ -175,7 +175,8 @@ public SpanBuilder withTag(String key, Number value) {
this.spanBuilderAttributeKeys.add(doubleKey(key));
this.spanBuilderAttributeValues.add(value.doubleValue());
} else {
throw new IllegalArgumentException("Number type not supported");
this.spanBuilderAttributeKeys.add(stringKey(key));
this.spanBuilderAttributeValues.add(value.toString());
}

return this;
Expand Down
Expand Up @@ -112,7 +112,7 @@ public Span setTag(String key, Number value) {
if (value == null) {
return this;
}
// TODO - Verify only the 'basic' types are supported/used.

if (value instanceof Integer
|| value instanceof Long
|| value instanceof Short
Expand All @@ -121,7 +121,7 @@ public Span setTag(String key, Number value) {
} else if (value instanceof Float || value instanceof Double) {
span.setAttribute(key, value.doubleValue());
} else {
throw new IllegalArgumentException("Number type not supported");
span.setAttribute(key, value.toString());
}

return this;
Expand Down
Expand Up @@ -22,6 +22,7 @@
import io.opentelemetry.sdk.trace.samplers.SamplingResult;
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;
import io.opentracing.References;
import java.math.BigInteger;
import java.util.List;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -296,6 +297,20 @@ void withStartTimestamp() {
assertThat(spanData.getStartEpochNanos()).isEqualTo(micros * 1000L);
}

@Test
void setAttribute_unrecognizedType() {
SpanShim span =
(SpanShim)
new SpanBuilderShim(telemetryInfo, SPAN_NAME).withTag("foo", BigInteger.TEN).start();
try {
SpanData spanData = ((ReadableSpan) span.getSpan()).toSpanData();
assertThat(spanData.getAttributes().size()).isEqualTo(1);
assertThat(spanData.getAttributes().get(AttributeKey.stringKey("foo"))).isEqualTo("10");
} finally {
span.finish();
}
}

@Test
void setAttributes_beforeSpanStart() {
SdkTracerProvider tracerSdkFactory =
Expand Down
Expand Up @@ -17,6 +17,7 @@
import io.opentelemetry.sdk.trace.data.SpanData;
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;
import io.opentracing.log.Fields;
import java.math.BigInteger;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ExecutorService;
Expand Down Expand Up @@ -59,6 +60,16 @@ void context_simple() {
assertThat(contextShim.baggageItems().iterator().hasNext()).isFalse();
}

@Test
void setAttribute_unrecognizedType() {
SpanShim spanShim = new SpanShim(telemetryInfo, span);
spanShim.setTag("foo", BigInteger.ONE);

SpanData spanData = ((ReadableSpan) span).toSpanData();
assertThat(spanData.getAttributes().size()).isEqualTo(1);
assertThat(spanData.getAttributes().get(AttributeKey.stringKey("foo"))).isEqualTo("1");
}

@Test
void baggage() {
SpanShim spanShim = new SpanShim(telemetryInfo, span);
Expand Down
35 changes: 21 additions & 14 deletions sdk-extensions/incubator/README.md
Expand Up @@ -108,30 +108,37 @@ make sure your
version of the JDK includes this package.

To setup the zPages, register zPages with your `OpenTelemetrySdk` and
call `ZPageServer.startHttpServerAndRegisterAllPages(int port)`:
call `startHttpServerAndRegisterAllPages(int port)` on your ZPageServer instance:

```java
public class MyMainClass {
public static void main(String[] args) throws Exception {
// Create a new ZPageServer
ZPageServer zpageServer = ZPageServer.create();
// Configure OpenTelemetrySdk with zPages
OpenTelemetry openTelemetry = OpenTelemetrySdk.builder()
.setTracerProvider(
SdkTracerProvider.builder()
.addSpanProcessor(ZPageServer.getSpanProcessor())
.setSpanLimits(ZPageServer.getTracezTraceConfigSupplier())
.setSampler(ZPageServer.getTracezSampler())
.build())
.build();
OpenTelemetry openTelemetry =
OpenTelemetrySdk.builder().setTracerProvider(zpageServer.buildSdkTracerProvider()).build();

// Start zPages server
ZPageServer.startHttpServerAndRegisterAllPages(8080);
// ... do work
zpageServer.startHttpServerAndRegisterAllPages(8080);
// ...Do work (this is just an example)
long count = 0;
while (true) {
Tracer tracer = openTelemetry.getTracer("demo");
Span span = tracer.spanBuilder("exampleSpan" + ++count).startSpan();
try (Scope scope = span.makeCurrent()) {
System.out.println("Inside a span...");
TimeUnit.SECONDS.sleep(2);
}
span.end();
}
}
}
```

Alternatively, you can call `ZPageServer.registerAllPagesToHttpServer(HttpServer server)` to
register the zPages to a shared server:
Note that `startHttpServerAndRegisterAllPages()` will create a new `HttpServer` and register the zPages
with it. If you already have an existing or shared `HttpServer`, you can instead call
`registerAllPagesToHttpServer(HttpServer server)`:

```java
public class MyMainClass {
Expand All @@ -140,7 +147,7 @@ public class MyMainClass {

// Start zPages server
HttpServer server = HttpServer.create(new InetSocketAddress(8000), 10);
ZPageServer.registerAllPagesToHttpServer(server);
zPageServer.registerAllPagesToHttpServer(server);
server.start();
// ... do work
}
Expand Down

0 comments on commit f975b9b

Please sign in to comment.