Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…y-java-contrib into rule-based-sampler-provider
  • Loading branch information
jack-berg committed Sep 16, 2024
2 parents 73607f5 + f6fa909 commit 5307231
Show file tree
Hide file tree
Showing 16 changed files with 98 additions and 44 deletions.
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,26 @@ feature or via instrumentation, this project is hopefully for you.
* [AWS Resources](./aws-resources/README.md)
* [AWS X-Ray SDK Support](./aws-xray/README.md)
* [AWS X-Ray Propagator](./aws-xray-propagator/README.md)
* [Baggage Span Processor](./baggage-processor/README.md)
* [zstd Compressor](./compressors/compressor-zstd/README.md)
* [Consistent Sampling](./consistent-sampling/README.md)
* [Disk Buffering](./disk-buffering/README.md)
* [GCP Resources](./gcp-resources/README.md)
* [Inferred Spans](./inferred-spans/README.md)
* [JFR Connection](./jfr-connection/README.md)
* [JFR Events](./jfr-events/README.md)
* [JMX Metric Gatherer](./jmx-metrics/README.md)
* [No-Op API](./noop-api/README.md)
* [Kafka Support](./kafka-exporter/README.md)
* [OpenTelemetry Maven Extension](./maven-extension/README.md)
* [Micrometer MeterProvider](./micrometer-meter-provider/README.md)
* [No-Op API](./noop-api/README.md)
* [Intercept and Process Signals Globally](./processors/README.md)
* [Prometheus Client Bridge](./prometheus-client-bridge/README.md)
* [Resource Providers](./resource-providers/README.md)
* [Runtime Attach](./runtime-attach/README.md)
* [Samplers](./samplers/README.md)
* [Span Stacktrace Capture](./span-stacktrace/README.md)
* [Static Instrumenter](./static-instrumenter/README.md)
* [Kafka Support](./kafka-exporter/README.md)

## Getting Started

Expand Down
2 changes: 1 addition & 1 deletion buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ dependencies {
implementation("com.diffplug.spotless:spotless-plugin-gradle:6.25.0")
implementation("net.ltgt.gradle:gradle-errorprone-plugin:4.0.1")
implementation("net.ltgt.gradle:gradle-nullaway-plugin:2.0.0")
implementation("com.gradle.enterprise:com.gradle.enterprise.gradle.plugin:3.18")
implementation("com.gradle.enterprise:com.gradle.enterprise.gradle.plugin:3.18.1")
}

spotless {
Expand Down
2 changes: 1 addition & 1 deletion compressors/compressor-zstd/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ otelJava.moduleName.set("io.opentelemetry.contrib.compressor.zstd")
dependencies {
api("io.opentelemetry:opentelemetry-exporter-common")

implementation("com.github.luben:zstd-jni:1.5.6-4")
implementation("com.github.luben:zstd-jni:1.5.6-5")

testImplementation("io.opentelemetry:opentelemetry-sdk-testing")
testImplementation("io.opentelemetry:opentelemetry-exporter-otlp")
Expand Down
4 changes: 2 additions & 2 deletions dependencyManagement/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ val otelInstrumentationVersion = "2.8.0-alpha"
val DEPENDENCY_BOMS = listOf(
"com.fasterxml.jackson:jackson-bom:2.17.2",
"com.google.guava:guava-bom:33.3.0-jre",
"com.linecorp.armeria:armeria-bom:1.30.0",
"com.linecorp.armeria:armeria-bom:1.30.1",
"org.junit:junit-bom:5.11.0",
"io.grpc:grpc-bom:1.66.0",
"io.opentelemetry.instrumentation:opentelemetry-instrumentation-bom-alpha:${otelInstrumentationVersion}",
Expand All @@ -21,7 +21,7 @@ val DEPENDENCY_BOMS = listOf(

val autoServiceVersion = "1.1.1"
val autoValueVersion = "1.11.0"
val errorProneVersion = "2.30.0"
val errorProneVersion = "2.31.0"
val prometheusVersion = "0.16.0"
val mockitoVersion = "4.11.0"
val slf4jVersion = "2.0.16"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@

import static io.opentelemetry.contrib.disk.buffering.internal.serialization.mapping.spans.SpanDataMapper.flagsFromInt;
import static io.opentelemetry.contrib.disk.buffering.internal.utils.ProtobufTools.toUnsignedInt;
import static java.util.stream.Collectors.toList;

import io.opentelemetry.api.common.Attributes;
import io.opentelemetry.api.common.Value;
import io.opentelemetry.api.logs.Severity;
import io.opentelemetry.api.trace.SpanContext;
import io.opentelemetry.api.trace.TraceState;
Expand All @@ -19,9 +21,9 @@
import io.opentelemetry.proto.logs.v1.LogRecord;
import io.opentelemetry.proto.logs.v1.SeverityNumber;
import io.opentelemetry.sdk.common.InstrumentationScopeInfo;
import io.opentelemetry.sdk.logs.data.Body;
import io.opentelemetry.sdk.logs.data.LogRecordData;
import io.opentelemetry.sdk.resources.Resource;
import java.util.stream.Collectors;

public final class LogRecordDataMapper {

Expand All @@ -42,8 +44,8 @@ public LogRecord mapToProto(LogRecordData source) {
if (source.getSeverityText() != null) {
logRecord.severity_text(source.getSeverityText());
}
if (source.getBody() != null) {
logRecord.body(bodyToAnyValue(source.getBody()));
if (source.getBodyValue() != null) {
logRecord.body(bodyToAnyValue(source.getBodyValue()));
}

byte flags = source.getSpanContext().getTraceFlags().asByte();
Expand Down Expand Up @@ -73,7 +75,7 @@ public LogRecordData mapToSdk(
logRecordData.setSeverity(severityNumberToSdk(source.severity_number));
logRecordData.setSeverityText(source.severity_text);
if (source.body != null) {
logRecordData.setBody(anyValueToBody(source.body));
logRecordData.setBodyValue(anyValueToBody(source.body));
}

addExtrasToSdkItemBuilder(source, logRecordData, resource, scopeInfo);
Expand All @@ -99,20 +101,38 @@ private static void addExtrasToSdkItemBuilder(
target.setInstrumentationScopeInfo(scopeInfo);
}

private static AnyValue bodyToAnyValue(Body body) {
private static AnyValue bodyToAnyValue(Value<?> body) {
return new AnyValue.Builder().string_value(body.asString()).build();
}

private static SeverityNumber severityToProto(Severity severity) {
return SeverityNumber.fromValue(severity.getSeverityNumber());
}

private static Body anyValueToBody(AnyValue source) {
private static Value<?> anyValueToBody(AnyValue source) {
if (source.string_value != null) {
return Body.string(source.string_value);
} else {
return Body.empty();
return Value.of(source.string_value);
} else if (source.int_value != null) {
return Value.of(source.int_value);
} else if (source.double_value != null) {
return Value.of(source.double_value);
} else if (source.bool_value != null) {
return Value.of(source.bool_value);
} else if (source.bytes_value != null) {
return Value.of(source.bytes_value.toByteArray());
} else if (source.kvlist_value != null) {
return Value.of(
source.kvlist_value.values.stream()
.collect(
Collectors.toMap(
keyValue -> keyValue.key, keyValue -> anyValueToBody(keyValue.value))));
} else if (source.array_value != null) {
return Value.of(
source.array_value.values.stream()
.map(LogRecordDataMapper::anyValueToBody)
.collect(toList()));
}
throw new IllegalArgumentException("Unrecognized AnyValue type");
}

private static Severity severityNumberToSdk(SeverityNumber source) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@
package io.opentelemetry.contrib.disk.buffering.internal.serialization.mapping.logs.models;

import com.google.auto.value.AutoValue;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import io.opentelemetry.api.common.Attributes;
import io.opentelemetry.api.common.Value;
import io.opentelemetry.api.logs.Severity;
import io.opentelemetry.api.trace.SpanContext;
import io.opentelemetry.sdk.common.InstrumentationScopeInfo;
import io.opentelemetry.sdk.logs.data.Body;
import io.opentelemetry.sdk.logs.data.LogRecordData;
import io.opentelemetry.sdk.resources.Resource;
import javax.annotation.Nullable;

@AutoValue
public abstract class LogRecordDataImpl implements LogRecordData {
Expand All @@ -21,6 +23,18 @@ public static Builder builder() {
return new AutoValue_LogRecordDataImpl.Builder();
}

@Deprecated
public io.opentelemetry.sdk.logs.data.Body getBody() {
Value<?> valueBody = getBodyValue();
return valueBody == null
? io.opentelemetry.sdk.logs.data.Body.empty()
: io.opentelemetry.sdk.logs.data.Body.string(valueBody.asString());
}

@Override
@Nullable
public abstract Value<?> getBodyValue();

@AutoValue.Builder
public abstract static class Builder {
public abstract Builder setResource(Resource value);
Expand All @@ -37,7 +51,18 @@ public abstract static class Builder {

public abstract Builder setSeverityText(String value);

public abstract Builder setBody(Body value);
@Deprecated
@CanIgnoreReturnValue
public Builder setBody(io.opentelemetry.sdk.logs.data.Body body) {
if (body.getType() == io.opentelemetry.sdk.logs.data.Body.Type.STRING) {
setBodyValue(Value.of(body.asString()));
} else if (body.getType() == io.opentelemetry.sdk.logs.data.Body.Type.EMPTY) {
setBodyValue(null);
}
return this;
}

public abstract Builder setBodyValue(@Nullable Value<?> value);

public abstract Builder setAttributes(Attributes value);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@

import static org.junit.jupiter.api.Assertions.assertEquals;

import io.opentelemetry.api.common.Value;
import io.opentelemetry.api.logs.Severity;
import io.opentelemetry.contrib.disk.buffering.internal.serialization.mapping.logs.models.LogRecordDataImpl;
import io.opentelemetry.contrib.disk.buffering.testutils.TestData;
import io.opentelemetry.proto.logs.v1.LogRecord;
import io.opentelemetry.sdk.common.InstrumentationScopeInfo;
import io.opentelemetry.sdk.logs.data.Body;
import io.opentelemetry.sdk.logs.data.LogRecordData;
import io.opentelemetry.sdk.resources.Resource;
import org.junit.jupiter.api.Test;
Expand All @@ -25,7 +25,7 @@ class LogRecordDataMapperTest {
.setSpanContext(TestData.SPAN_CONTEXT)
.setInstrumentationScopeInfo(TestData.INSTRUMENTATION_SCOPE_INFO_FULL)
.setAttributes(TestData.ATTRIBUTES)
.setBody(Body.string("Log body"))
.setBodyValue(Value.of("Log body"))
.setSeverity(Severity.DEBUG)
.setSeverityText("Log severity text")
.setTimestampEpochNanos(100L)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;

import io.opentelemetry.api.common.Value;
import io.opentelemetry.api.logs.Severity;
import io.opentelemetry.contrib.disk.buffering.internal.serialization.mapping.logs.models.LogRecordDataImpl;
import io.opentelemetry.contrib.disk.buffering.testutils.TestData;
import io.opentelemetry.proto.logs.v1.LogRecord;
import io.opentelemetry.proto.logs.v1.LogsData;
import io.opentelemetry.proto.logs.v1.ResourceLogs;
import io.opentelemetry.proto.logs.v1.ScopeLogs;
import io.opentelemetry.sdk.logs.data.Body;
import io.opentelemetry.sdk.logs.data.LogRecordData;
import java.util.Arrays;
import java.util.Collection;
Expand All @@ -31,7 +31,7 @@ class ProtoLogsDataMapperTest {
.setSpanContext(TestData.SPAN_CONTEXT)
.setInstrumentationScopeInfo(TestData.INSTRUMENTATION_SCOPE_INFO_FULL)
.setAttributes(TestData.ATTRIBUTES)
.setBody(Body.string("Log body"))
.setBodyValue(Value.of("Log body"))
.setSeverity(Severity.DEBUG)
.setSeverityText("Log severity text")
.setTimestampEpochNanos(100L)
Expand All @@ -45,7 +45,7 @@ class ProtoLogsDataMapperTest {
.setSpanContext(TestData.SPAN_CONTEXT)
.setInstrumentationScopeInfo(TestData.INSTRUMENTATION_SCOPE_INFO_FULL)
.setAttributes(TestData.ATTRIBUTES)
.setBody(Body.string("Other log body"))
.setBodyValue(Value.of("Other log body"))
.setSeverity(Severity.DEBUG)
.setSeverityText("Log severity text")
.setTimestampEpochNanos(100L)
Expand All @@ -59,7 +59,7 @@ class ProtoLogsDataMapperTest {
.setSpanContext(TestData.SPAN_CONTEXT)
.setInstrumentationScopeInfo(TestData.INSTRUMENTATION_SCOPE_INFO_WITHOUT_VERSION)
.setAttributes(TestData.ATTRIBUTES)
.setBody(Body.string("Same resource other scope log"))
.setBodyValue(Value.of("Same resource other scope log"))
.setSeverity(Severity.DEBUG)
.setSeverityText("Log severity text")
.setTimestampEpochNanos(100L)
Expand All @@ -73,7 +73,7 @@ class ProtoLogsDataMapperTest {
.setSpanContext(TestData.SPAN_CONTEXT)
.setInstrumentationScopeInfo(TestData.INSTRUMENTATION_SCOPE_INFO_WITHOUT_VERSION)
.setAttributes(TestData.ATTRIBUTES)
.setBody(Body.string("Different resource log"))
.setBodyValue(Value.of("Different resource log"))
.setSeverity(Severity.DEBUG)
.setSeverityText("Log severity text")
.setTimestampEpochNanos(100L)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
package io.opentelemetry.contrib.disk.buffering.internal.serialization.serializers;

import io.opentelemetry.api.common.Attributes;
import io.opentelemetry.api.common.Value;
import io.opentelemetry.api.logs.Severity;
import io.opentelemetry.contrib.disk.buffering.internal.serialization.deserializers.SignalDeserializer;
import io.opentelemetry.contrib.disk.buffering.internal.serialization.mapping.logs.models.LogRecordDataImpl;
import io.opentelemetry.contrib.disk.buffering.testutils.BaseSignalSerializerTest;
import io.opentelemetry.contrib.disk.buffering.testutils.TestData;
import io.opentelemetry.sdk.logs.data.Body;
import io.opentelemetry.sdk.logs.data.LogRecordData;
import org.junit.jupiter.api.Test;

Expand All @@ -22,7 +22,7 @@ class LogRecordDataSerializerTest extends BaseSignalSerializerTest<LogRecordData
.setSpanContext(TestData.SPAN_CONTEXT)
.setInstrumentationScopeInfo(TestData.INSTRUMENTATION_SCOPE_INFO_FULL)
.setAttributes(TestData.ATTRIBUTES)
.setBody(Body.string("Log body"))
.setBodyValue(Value.of("Log body"))
.setSeverity(Severity.DEBUG)
.setSeverityText("Log severity text")
.setTimestampEpochNanos(100L)
Expand All @@ -36,7 +36,7 @@ class LogRecordDataSerializerTest extends BaseSignalSerializerTest<LogRecordData
.setSpanContext(TestData.SPAN_CONTEXT)
.setInstrumentationScopeInfo(TestData.INSTRUMENTATION_SCOPE_INFO_FULL)
.setAttributes(Attributes.empty())
.setBody(Body.string("Log body"))
.setBodyValue(Value.of("Log body"))
.setSeverity(Severity.DEBUG)
.setSeverityText("")
.setTimestampEpochNanos(100L)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

import io.opentelemetry.api.common.Value;
import io.opentelemetry.api.logs.Severity;
import io.opentelemetry.contrib.disk.buffering.internal.files.TemporaryFileProvider;
import io.opentelemetry.contrib.disk.buffering.internal.serialization.deserializers.SignalDeserializer;
Expand All @@ -24,7 +25,6 @@
import io.opentelemetry.contrib.disk.buffering.internal.storage.responses.ReadableResult;
import io.opentelemetry.contrib.disk.buffering.testutils.TestData;
import io.opentelemetry.sdk.common.Clock;
import io.opentelemetry.sdk.logs.data.Body;
import io.opentelemetry.sdk.logs.data.LogRecordData;
import java.io.File;
import java.io.FileOutputStream;
Expand Down Expand Up @@ -53,7 +53,7 @@ class ReadableFileTest {
.setSpanContext(TestData.SPAN_CONTEXT)
.setInstrumentationScopeInfo(TestData.INSTRUMENTATION_SCOPE_INFO_FULL)
.setAttributes(TestData.ATTRIBUTES)
.setBody(Body.string("First log body"))
.setBodyValue(Value.of("First log body"))
.setSeverity(Severity.DEBUG)
.setSeverityText("Log severity text")
.setTimestampEpochNanos(100L)
Expand All @@ -67,7 +67,7 @@ class ReadableFileTest {
.setSpanContext(TestData.SPAN_CONTEXT)
.setInstrumentationScopeInfo(TestData.INSTRUMENTATION_SCOPE_INFO_FULL)
.setAttributes(TestData.ATTRIBUTES)
.setBody(Body.string("Second log body"))
.setBodyValue(Value.of("Second log body"))
.setSeverity(Severity.DEBUG)
.setSeverityText("Log severity text")
.setTimestampEpochNanos(100L)
Expand All @@ -81,7 +81,7 @@ class ReadableFileTest {
.setSpanContext(TestData.SPAN_CONTEXT)
.setInstrumentationScopeInfo(TestData.INSTRUMENTATION_SCOPE_INFO_FULL)
.setAttributes(TestData.ATTRIBUTES)
.setBody(Body.string("Third log body"))
.setBodyValue(Value.of("Third log body"))
.setSeverity(Severity.DEBUG)
.setSeverityText("Log severity text")
.setTimestampEpochNanos(100L)
Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionSha256Sum=5b9c5eb3f9fc2c94abaea57d90bd78747ca117ddbbf96c859d3741181a12bf2a
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip
distributionSha256Sum=1541fa36599e12857140465f3c91a97409b4512501c26f9631fb113e392c5bd1
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.1-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
4 changes: 2 additions & 2 deletions micrometer-meter-provider/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ dependencies {
annotationProcessor("com.google.auto.value:auto-value")
compileOnly("com.google.auto.value:auto-value-annotations")

testImplementation("io.micrometer:micrometer-core:1.13.3")
testImplementation("io.micrometer:micrometer-core:1.13.4")
}

testing {
suites {
val integrationTest by registering(JvmTestSuite::class) {
dependencies {
implementation("io.micrometer:micrometer-registry-prometheus:1.13.3")
implementation("io.micrometer:micrometer-registry-prometheus:1.13.4")
}
}
}
Expand Down
Loading

0 comments on commit 5307231

Please sign in to comment.