diff --git a/exporters/otlp/profiles/build.gradle.kts b/exporters/otlp/profiles/build.gradle.kts index 00ddf18651d..3942682039b 100644 --- a/exporters/otlp/profiles/build.gradle.kts +++ b/exporters/otlp/profiles/build.gradle.kts @@ -10,16 +10,16 @@ description = "OpenTelemetry - Profiles Exporter" otelJava.moduleName.set("io.opentelemetry.exporter.otlp.profiles") val versions: Map by project + dependencies { api(project(":sdk:common")) + api(project(":sdk:profiles")) api(project(":exporters:common")) implementation(project(":exporters:otlp:common")) implementation(project(":exporters:otlp:all")) compileOnly("io.grpc:grpc-stub") - annotationProcessor("com.google.auto.value:auto-value") - testCompileOnly("com.google.guava:guava") testImplementation("com.fasterxml.jackson.core:jackson-databind") testImplementation("com.google.protobuf:protobuf-java-util") diff --git a/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/internal/data/ImmutableFunctionData.java b/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/internal/data/ImmutableFunctionData.java deleted file mode 100644 index cd0c12e901c..00000000000 --- a/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/internal/data/ImmutableFunctionData.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright The OpenTelemetry Authors - * SPDX-License-Identifier: Apache-2.0 - */ - -package io.opentelemetry.exporter.otlp.internal.data; - -import com.google.auto.value.AutoValue; -import io.opentelemetry.exporter.otlp.profiles.FunctionData; -import javax.annotation.concurrent.Immutable; - -/** - * Auto value implementation of {@link FunctionData}, which describes a code function. - * - *

This class is internal and is hence not for public use. Its APIs are unstable and can change - * at any time. - */ -@Immutable -@AutoValue -public abstract class ImmutableFunctionData implements FunctionData { - - /** - * Returns a new FunctionData describing the given function characteristics. - * - * @return a new FunctionData describing the given function characteristics. - */ - public static FunctionData create( - int nameStringIndex, int systemNameStringIndex, int filenameStringIndex, long startLine) { - return new AutoValue_ImmutableFunctionData( - nameStringIndex, systemNameStringIndex, filenameStringIndex, startLine); - } - - ImmutableFunctionData() {} -} diff --git a/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/internal/data/ImmutableKeyValueAndUnitData.java b/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/internal/data/ImmutableKeyValueAndUnitData.java deleted file mode 100644 index 1285b13617c..00000000000 --- a/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/internal/data/ImmutableKeyValueAndUnitData.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright The OpenTelemetry Authors - * SPDX-License-Identifier: Apache-2.0 - */ - -package io.opentelemetry.exporter.otlp.internal.data; - -import com.google.auto.value.AutoValue; -import io.opentelemetry.api.common.Value; -import io.opentelemetry.exporter.otlp.profiles.KeyValueAndUnitData; -import javax.annotation.concurrent.Immutable; - -/** - * Auto value implementation of {@link KeyValueAndUnitData}, which describes a Key Value pair with - * optional unit for the value. - * - *

This class is internal and is hence not for public use. Its APIs are unstable and can change - * at any time. - */ -@Immutable -@AutoValue -public abstract class ImmutableKeyValueAndUnitData implements KeyValueAndUnitData { - - /** Returns a {@link KeyValueAndUnitData} for the given parameters. */ - public static ImmutableKeyValueAndUnitData create( - int keyStringIndex, Value value, int unitStringIndex) { - return new AutoValue_ImmutableKeyValueAndUnitData(keyStringIndex, value, unitStringIndex); - } - - ImmutableKeyValueAndUnitData() {} -} diff --git a/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/internal/data/ImmutableLineData.java b/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/internal/data/ImmutableLineData.java deleted file mode 100644 index e0eebeaff60..00000000000 --- a/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/internal/data/ImmutableLineData.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright The OpenTelemetry Authors - * SPDX-License-Identifier: Apache-2.0 - */ - -package io.opentelemetry.exporter.otlp.internal.data; - -import com.google.auto.value.AutoValue; -import io.opentelemetry.exporter.otlp.profiles.LineData; -import javax.annotation.concurrent.Immutable; - -/** - * Auto value implementation of {@link LineData}, which details a specific line in a source code, - * linked to a function. - * - *

This class is internal and is hence not for public use. Its APIs are unstable and can change - * at any time. - */ -@Immutable -@AutoValue -public abstract class ImmutableLineData implements LineData { - - /** - * Returns a new LineData describing the given details a specific line in a source code. - * - * @return a new LineData describing the given details a specific line in a source code. - */ - public static LineData create(int functionIndex, long line, long column) { - return new AutoValue_ImmutableLineData(functionIndex, line, column); - } - - ImmutableLineData() {} -} diff --git a/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/internal/data/ImmutableLinkData.java b/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/internal/data/ImmutableLinkData.java deleted file mode 100644 index 1345503b405..00000000000 --- a/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/internal/data/ImmutableLinkData.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright The OpenTelemetry Authors - * SPDX-License-Identifier: Apache-2.0 - */ - -package io.opentelemetry.exporter.otlp.internal.data; - -import com.google.auto.value.AutoValue; -import io.opentelemetry.exporter.otlp.profiles.LinkData; -import javax.annotation.concurrent.Immutable; - -/** - * Auto value implementation of {@link LinkData}, which represents a connection from a profile - * Sample to a trace Span. - * - *

This class is internal and is hence not for public use. Its APIs are unstable and can change - * at any time. - */ -@Immutable -@AutoValue -public abstract class ImmutableLinkData implements LinkData { - - /** - * Returns a new LinkData representing an association to the given trace span. - * - * @return a new LinkData representing an association to the given trace span. - */ - public static LinkData create(String traceId, String spanId) { - return new AutoValue_ImmutableLinkData(traceId, spanId); - } - - ImmutableLinkData() {} -} diff --git a/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/internal/data/ImmutableLocationData.java b/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/internal/data/ImmutableLocationData.java deleted file mode 100644 index 32b01f8b093..00000000000 --- a/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/internal/data/ImmutableLocationData.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright The OpenTelemetry Authors - * SPDX-License-Identifier: Apache-2.0 - */ - -package io.opentelemetry.exporter.otlp.internal.data; - -import com.google.auto.value.AutoValue; -import io.opentelemetry.exporter.otlp.profiles.LineData; -import io.opentelemetry.exporter.otlp.profiles.LocationData; -import java.util.List; -import javax.annotation.concurrent.Immutable; - -/** - * Auto value implementation of {@link LocationData}, which describes function and line table debug - * information. - * - *

This class is internal and is hence not for public use. Its APIs are unstable and can change - * at any time. - */ -@Immutable -@AutoValue -public abstract class ImmutableLocationData implements LocationData { - - /** - * Returns a new LocationData describing the given function and line table information. - * - * @return a new LocationData describing the given function and line table information. - */ - public static LocationData create( - int mappingIndex, long address, List lines, List attributeIndices) { - return new AutoValue_ImmutableLocationData(mappingIndex, address, lines, attributeIndices); - } - - ImmutableLocationData() {} -} diff --git a/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/internal/data/ImmutableMappingData.java b/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/internal/data/ImmutableMappingData.java deleted file mode 100644 index 00fe523b88a..00000000000 --- a/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/internal/data/ImmutableMappingData.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright The OpenTelemetry Authors - * SPDX-License-Identifier: Apache-2.0 - */ - -package io.opentelemetry.exporter.otlp.internal.data; - -import com.google.auto.value.AutoValue; -import io.opentelemetry.exporter.otlp.profiles.MappingData; -import java.util.List; -import javax.annotation.concurrent.Immutable; - -/** - * Auto value implementation of {@link MappingData}, which describes the mapping of a binary in - * memory. - * - *

This class is internal and is hence not for public use. Its APIs are unstable and can change - * at any time. - */ -@Immutable -@AutoValue -public abstract class ImmutableMappingData implements MappingData { - - /** - * Returns a new MappingData describing the given mapping of a binary in memory. - * - * @return a new MappingData describing the given mapping of a binary in memory. - */ - @SuppressWarnings("TooManyParameters") - public static MappingData create( - long memoryStart, - long memoryLimit, - long fileOffset, - int filenameStringIndex, - List attributeIndices) { - return new AutoValue_ImmutableMappingData( - memoryStart, memoryLimit, fileOffset, filenameStringIndex, attributeIndices); - } - - ImmutableMappingData() {} -} diff --git a/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/internal/data/ImmutableProfileData.java b/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/internal/data/ImmutableProfileData.java deleted file mode 100644 index e30682f528c..00000000000 --- a/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/internal/data/ImmutableProfileData.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright The OpenTelemetry Authors - * SPDX-License-Identifier: Apache-2.0 - */ - -package io.opentelemetry.exporter.otlp.internal.data; - -import com.google.auto.value.AutoValue; -import io.opentelemetry.exporter.otlp.profiles.ProfileData; -import io.opentelemetry.exporter.otlp.profiles.ProfilesDictionaryData; -import io.opentelemetry.exporter.otlp.profiles.SampleData; -import io.opentelemetry.exporter.otlp.profiles.ValueTypeData; -import io.opentelemetry.sdk.common.InstrumentationScopeInfo; -import io.opentelemetry.sdk.resources.Resource; -import java.nio.ByteBuffer; -import java.util.List; -import javax.annotation.concurrent.Immutable; - -/** - * Auto value implementation of {@link ProfileData}, which represents a complete profile, including - * sample types, samples, mappings to binaries, locations, and additional metadata. - * - *

This class is internal and is hence not for public use. Its APIs are unstable and can change - * at any time. - */ -@Immutable -@AutoValue -public abstract class ImmutableProfileData implements ProfileData { - - /** - * Returns a new ProfileData representing the given data. - * - * @return a new ProfileData representing the given data. - */ - @SuppressWarnings("TooManyParameters") - public static ProfileData create( - Resource resource, - InstrumentationScopeInfo instrumentationScopeInfo, - ProfilesDictionaryData profilesDictionaryData, - ValueTypeData sampleType, - List samples, - long timeNanos, - long durationNanos, - ValueTypeData periodType, - long period, - String profileId, - int droppedAttributesCount, - String originalPayloadFormat, - ByteBuffer originalPayload, - List attributeIndices) { - return new AutoValue_ImmutableProfileData( - resource, - instrumentationScopeInfo, - profilesDictionaryData, - sampleType, - samples, - timeNanos, - durationNanos, - periodType, - period, - profileId, - droppedAttributesCount, - originalPayloadFormat, - originalPayload, - attributeIndices); - } - - ImmutableProfileData() {} -} diff --git a/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/internal/data/ImmutableProfilesDictionaryData.java b/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/internal/data/ImmutableProfilesDictionaryData.java deleted file mode 100644 index e06c0997d69..00000000000 --- a/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/internal/data/ImmutableProfilesDictionaryData.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright The OpenTelemetry Authors - * SPDX-License-Identifier: Apache-2.0 - */ - -package io.opentelemetry.exporter.otlp.internal.data; - -import com.google.auto.value.AutoValue; -import io.opentelemetry.exporter.otlp.profiles.FunctionData; -import io.opentelemetry.exporter.otlp.profiles.KeyValueAndUnitData; -import io.opentelemetry.exporter.otlp.profiles.LinkData; -import io.opentelemetry.exporter.otlp.profiles.LocationData; -import io.opentelemetry.exporter.otlp.profiles.MappingData; -import io.opentelemetry.exporter.otlp.profiles.ProfilesDictionaryData; -import io.opentelemetry.exporter.otlp.profiles.StackData; -import java.util.List; -import javax.annotation.concurrent.Immutable; - -/** - * Auto value implementation of {@link ProfilesDictionaryData}, which represents profiles data - * shared across the entire message being sent. - * - *

This class is internal and is hence not for public use. Its APIs are unstable and can change - * at any time. - */ -@Immutable -@AutoValue -public abstract class ImmutableProfilesDictionaryData implements ProfilesDictionaryData { - - /** - * Returns a new ProfileData representing the given data. - * - * @return a new ProfileData representing the given data. - */ - @SuppressWarnings("TooManyParameters") - public static ProfilesDictionaryData create( - List mappingTable, - List locationTable, - List functionTable, - List linkTable, - List stringTable, - List attributeTable, - List stackTable) { - return new AutoValue_ImmutableProfilesDictionaryData( - mappingTable, - locationTable, - functionTable, - linkTable, - stringTable, - attributeTable, - stackTable); - } - - ImmutableProfilesDictionaryData() {} -} diff --git a/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/internal/data/ImmutableSampleData.java b/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/internal/data/ImmutableSampleData.java deleted file mode 100644 index c79de9900df..00000000000 --- a/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/internal/data/ImmutableSampleData.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright The OpenTelemetry Authors - * SPDX-License-Identifier: Apache-2.0 - */ - -package io.opentelemetry.exporter.otlp.internal.data; - -import com.google.auto.value.AutoValue; -import io.opentelemetry.exporter.otlp.profiles.SampleData; -import java.util.List; -import javax.annotation.concurrent.Immutable; - -/** - * Auto value implementation of {@link SampleData}, which records values encountered in some program - * context. - * - *

This class is internal and is hence not for public use. Its APIs are unstable and can change - * at any time. - */ -@Immutable -@AutoValue -public abstract class ImmutableSampleData implements SampleData { - - /** - * Returns a new SampleData representing the given program context. - * - * @return a new SampleData representing the given program context. - */ - public static SampleData create( - int stackIndex, - List attributeIndices, - int linkIndex, - List values, - List timestamps) { - return new AutoValue_ImmutableSampleData( - stackIndex, attributeIndices, linkIndex, values, timestamps); - } - - ImmutableSampleData() {} -} diff --git a/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/internal/data/ImmutableStackData.java b/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/internal/data/ImmutableStackData.java deleted file mode 100644 index a1c57c53812..00000000000 --- a/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/internal/data/ImmutableStackData.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright The OpenTelemetry Authors - * SPDX-License-Identifier: Apache-2.0 - */ - -package io.opentelemetry.exporter.otlp.internal.data; - -import com.google.auto.value.AutoValue; -import io.opentelemetry.exporter.otlp.profiles.StackData; -import java.util.List; -import javax.annotation.concurrent.Immutable; - -/** - * Auto value implementation of {@link StackData}, which records a list of locations, starting from - * the leaf frame. - * - *

This class is internal and is hence not for public use. Its APIs are unstable and can change - * at any time. - */ -@Immutable -@AutoValue -public abstract class ImmutableStackData implements StackData { - - /** - * Returns a new StackData representing the given list of frames. - * - * @return a new StackData representing the given list of frames. - */ - public static StackData create(List locationIndices) { - return new AutoValue_ImmutableStackData(locationIndices); - } - - ImmutableStackData() {} -} diff --git a/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/internal/data/ImmutableValueTypeData.java b/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/internal/data/ImmutableValueTypeData.java deleted file mode 100644 index 15fe4ce6fc7..00000000000 --- a/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/internal/data/ImmutableValueTypeData.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright The OpenTelemetry Authors - * SPDX-License-Identifier: Apache-2.0 - */ - -package io.opentelemetry.exporter.otlp.internal.data; - -import com.google.auto.value.AutoValue; -import io.opentelemetry.exporter.otlp.profiles.ValueTypeData; -import javax.annotation.concurrent.Immutable; - -/** - * Auto value implementation of {@link ValueTypeData}, which describes the type and units of a - * value. - * - *

This class is internal and is hence not for public use. Its APIs are unstable and can change - * at any time. - */ -@Immutable -@AutoValue -public abstract class ImmutableValueTypeData implements ValueTypeData { - - /** - * Returns a new ValueTypeData describing the given type and unit characteristics. - * - * @return a new ValueTypeData describing the given type and unit characteristics. - */ - public static ValueTypeData create(int typeStringIndex, int unitStringIndex) { - return new AutoValue_ImmutableValueTypeData(typeStringIndex, unitStringIndex); - } - - ImmutableValueTypeData() {} -} diff --git a/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/FunctionMarshaler.java b/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/FunctionMarshaler.java index d5b391702ce..22ccb061850 100644 --- a/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/FunctionMarshaler.java +++ b/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/FunctionMarshaler.java @@ -9,6 +9,7 @@ import io.opentelemetry.exporter.internal.marshal.MarshalerWithSize; import io.opentelemetry.exporter.internal.marshal.Serializer; import io.opentelemetry.proto.profiles.v1development.internal.Function; +import io.opentelemetry.sdk.profiles.data.FunctionData; import java.io.IOException; import java.util.List; import java.util.function.Consumer; diff --git a/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/KeyValueAndUnitMarshaler.java b/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/KeyValueAndUnitMarshaler.java index f2e45b570cf..fac47e819ed 100644 --- a/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/KeyValueAndUnitMarshaler.java +++ b/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/KeyValueAndUnitMarshaler.java @@ -11,6 +11,7 @@ import io.opentelemetry.exporter.internal.marshal.Serializer; import io.opentelemetry.exporter.internal.otlp.AnyValueMarshaler; import io.opentelemetry.proto.profiles.v1development.internal.KeyValueAndUnit; +import io.opentelemetry.sdk.profiles.data.KeyValueAndUnitData; import java.io.IOException; import java.util.List; import java.util.function.Consumer; diff --git a/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/LineMarshaler.java b/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/LineMarshaler.java index ec7a780b9d7..4c84c62b84b 100644 --- a/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/LineMarshaler.java +++ b/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/LineMarshaler.java @@ -9,6 +9,7 @@ import io.opentelemetry.exporter.internal.marshal.MarshalerWithSize; import io.opentelemetry.exporter.internal.marshal.Serializer; import io.opentelemetry.proto.profiles.v1development.internal.Line; +import io.opentelemetry.sdk.profiles.data.LineData; import java.io.IOException; import java.util.List; import java.util.function.Consumer; diff --git a/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/LinkMarshaler.java b/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/LinkMarshaler.java index eb5673c8cae..fc1d8892f0a 100644 --- a/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/LinkMarshaler.java +++ b/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/LinkMarshaler.java @@ -12,6 +12,7 @@ import io.opentelemetry.exporter.internal.marshal.MarshalerWithSize; import io.opentelemetry.exporter.internal.marshal.Serializer; import io.opentelemetry.proto.profiles.v1development.internal.Link; +import io.opentelemetry.sdk.profiles.data.LinkData; import java.io.IOException; import java.util.List; import java.util.function.Consumer; diff --git a/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/LocationMarshaler.java b/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/LocationMarshaler.java index 6027f6a47e8..2222a0f87fd 100644 --- a/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/LocationMarshaler.java +++ b/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/LocationMarshaler.java @@ -9,6 +9,7 @@ import io.opentelemetry.exporter.internal.marshal.MarshalerWithSize; import io.opentelemetry.exporter.internal.marshal.Serializer; import io.opentelemetry.proto.profiles.v1development.internal.Location; +import io.opentelemetry.sdk.profiles.data.LocationData; import java.io.IOException; import java.util.List; import java.util.function.Consumer; diff --git a/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/MappingMarshaler.java b/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/MappingMarshaler.java index a37b9640df7..2a737483bf0 100644 --- a/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/MappingMarshaler.java +++ b/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/MappingMarshaler.java @@ -9,6 +9,7 @@ import io.opentelemetry.exporter.internal.marshal.MarshalerWithSize; import io.opentelemetry.exporter.internal.marshal.Serializer; import io.opentelemetry.proto.profiles.v1development.internal.Mapping; +import io.opentelemetry.sdk.profiles.data.MappingData; import java.io.IOException; import java.util.List; import java.util.function.Consumer; diff --git a/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/NoopProfileExporter.java b/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/NoopProfileExporter.java index 0978692ad5c..d895969c225 100644 --- a/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/NoopProfileExporter.java +++ b/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/NoopProfileExporter.java @@ -6,6 +6,8 @@ package io.opentelemetry.exporter.otlp.profiles; import io.opentelemetry.sdk.common.CompletableResultCode; +import io.opentelemetry.sdk.profiles.ProfileExporter; +import io.opentelemetry.sdk.profiles.data.ProfileData; import java.util.Collection; final class NoopProfileExporter implements ProfileExporter { diff --git a/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/OtlpGrpcProfileExporter.java b/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/OtlpGrpcProfileExporter.java index 3510b204293..b47fddd39c1 100644 --- a/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/OtlpGrpcProfileExporter.java +++ b/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/OtlpGrpcProfileExporter.java @@ -8,6 +8,8 @@ import io.opentelemetry.exporter.internal.grpc.GrpcExporter; import io.opentelemetry.exporter.internal.grpc.GrpcExporterBuilder; import io.opentelemetry.sdk.common.CompletableResultCode; +import io.opentelemetry.sdk.profiles.ProfileExporter; +import io.opentelemetry.sdk.profiles.data.ProfileData; import java.util.Collection; import java.util.StringJoiner; import javax.annotation.concurrent.ThreadSafe; diff --git a/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/ProfileMarshaler.java b/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/ProfileMarshaler.java index da1795479e2..ab954de690a 100644 --- a/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/ProfileMarshaler.java +++ b/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/ProfileMarshaler.java @@ -9,6 +9,7 @@ import io.opentelemetry.exporter.internal.marshal.MarshalerWithSize; import io.opentelemetry.exporter.internal.marshal.Serializer; import io.opentelemetry.proto.profiles.v1development.internal.Profile; +import io.opentelemetry.sdk.profiles.data.ProfileData; import java.io.IOException; import java.nio.ByteBuffer; import java.util.List; diff --git a/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/ProfilesDictionaryMarshaler.java b/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/ProfilesDictionaryMarshaler.java index 0ba6473782d..15097c6712c 100644 --- a/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/ProfilesDictionaryMarshaler.java +++ b/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/ProfilesDictionaryMarshaler.java @@ -9,6 +9,7 @@ import io.opentelemetry.exporter.internal.marshal.MarshalerWithSize; import io.opentelemetry.exporter.internal.marshal.Serializer; import io.opentelemetry.proto.profiles.v1development.internal.ProfilesDictionary; +import io.opentelemetry.sdk.profiles.data.ProfilesDictionaryData; import java.io.IOException; import java.nio.charset.StandardCharsets; diff --git a/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/ProfilesRequestMarshaler.java b/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/ProfilesRequestMarshaler.java index 9b9d621c1e0..ae1f3cc905e 100644 --- a/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/ProfilesRequestMarshaler.java +++ b/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/ProfilesRequestMarshaler.java @@ -12,8 +12,9 @@ import io.opentelemetry.exporter.internal.marshal.MarshalerWithSize; import io.opentelemetry.exporter.internal.marshal.ProtoFieldInfo; import io.opentelemetry.exporter.internal.marshal.Serializer; -import io.opentelemetry.exporter.otlp.internal.data.ImmutableProfilesDictionaryData; import io.opentelemetry.proto.collector.profiles.v1development.internal.ExportProfilesServiceRequest; +import io.opentelemetry.sdk.profiles.data.ProfileData; +import io.opentelemetry.sdk.profiles.data.ProfilesDictionaryData; import java.io.IOException; import java.util.Collection; import java.util.Collections; @@ -27,7 +28,7 @@ public final class ProfilesRequestMarshaler extends MarshalerWithSize { private static final ProfilesDictionaryData EMPTY_DICTIONARY_DATA = - ImmutableProfilesDictionaryData.create( + ProfilesDictionaryData.create( Collections.emptyList(), Collections.emptyList(), Collections.emptyList(), diff --git a/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/ResourceProfilesMarshaler.java b/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/ResourceProfilesMarshaler.java index b063f6c92ae..3f75bc1be20 100644 --- a/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/ResourceProfilesMarshaler.java +++ b/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/ResourceProfilesMarshaler.java @@ -12,6 +12,7 @@ import io.opentelemetry.exporter.internal.otlp.ResourceMarshaler; import io.opentelemetry.proto.profiles.v1development.internal.ResourceProfiles; import io.opentelemetry.sdk.common.InstrumentationScopeInfo; +import io.opentelemetry.sdk.profiles.data.ProfileData; import io.opentelemetry.sdk.resources.Resource; import java.io.IOException; import java.util.Collection; diff --git a/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/SampleMarshaler.java b/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/SampleMarshaler.java index e5650366ac1..000b6f09d54 100644 --- a/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/SampleMarshaler.java +++ b/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/SampleMarshaler.java @@ -9,6 +9,7 @@ import io.opentelemetry.exporter.internal.marshal.MarshalerWithSize; import io.opentelemetry.exporter.internal.marshal.Serializer; import io.opentelemetry.proto.profiles.v1development.internal.Sample; +import io.opentelemetry.sdk.profiles.data.SampleData; import java.io.IOException; import java.util.List; import java.util.function.Consumer; diff --git a/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/StackData.java b/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/StackData.java deleted file mode 100644 index a5fe6ac6b04..00000000000 --- a/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/StackData.java +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright The OpenTelemetry Authors - * SPDX-License-Identifier: Apache-2.0 - */ - -package io.opentelemetry.exporter.otlp.profiles; - -import java.util.List; -import javax.annotation.concurrent.Immutable; - -/** - * A Stack represents a list of locations. The first location is the leaf frame. - * - * @see "profiles.proto::Stack" - */ -@Immutable -public interface StackData { - - List getLocationIndices(); -} diff --git a/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/StackMarshaler.java b/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/StackMarshaler.java index 831f28cf664..1b0ab1130b7 100644 --- a/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/StackMarshaler.java +++ b/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/StackMarshaler.java @@ -9,6 +9,7 @@ import io.opentelemetry.exporter.internal.marshal.MarshalerWithSize; import io.opentelemetry.exporter.internal.marshal.Serializer; import io.opentelemetry.proto.profiles.v1development.internal.Stack; +import io.opentelemetry.sdk.profiles.data.StackData; import java.io.IOException; import java.util.List; import java.util.function.Consumer; diff --git a/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/ValueTypeData.java b/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/ValueTypeData.java deleted file mode 100644 index 5ce324b1988..00000000000 --- a/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/ValueTypeData.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright The OpenTelemetry Authors - * SPDX-License-Identifier: Apache-2.0 - */ - -package io.opentelemetry.exporter.otlp.profiles; - -import javax.annotation.concurrent.Immutable; - -/** - * ValueType describes the type and units of a value. - * - * @see "profiles.proto::ValueType" - */ -@Immutable -public interface ValueTypeData { - - /** Index into string table. */ - int getTypeStringIndex(); - - /** Index into string table. */ - int getUnitStringIndex(); -} diff --git a/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/ValueTypeMarshaler.java b/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/ValueTypeMarshaler.java index 8d60435d98c..160abeb8dfb 100644 --- a/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/ValueTypeMarshaler.java +++ b/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/ValueTypeMarshaler.java @@ -9,6 +9,7 @@ import io.opentelemetry.exporter.internal.marshal.MarshalerWithSize; import io.opentelemetry.exporter.internal.marshal.Serializer; import io.opentelemetry.proto.profiles.v1development.internal.ValueType; +import io.opentelemetry.sdk.profiles.data.ValueTypeData; import java.io.IOException; import java.util.List; import java.util.function.Consumer; diff --git a/exporters/otlp/profiles/src/test/java/io/opentelemetry/exporter/otlp/profiles/FakeTelemetryUtil.java b/exporters/otlp/profiles/src/test/java/io/opentelemetry/exporter/otlp/profiles/FakeTelemetryUtil.java index 6b6a5baa0fb..4c68f1ef766 100644 --- a/exporters/otlp/profiles/src/test/java/io/opentelemetry/exporter/otlp/profiles/FakeTelemetryUtil.java +++ b/exporters/otlp/profiles/src/test/java/io/opentelemetry/exporter/otlp/profiles/FakeTelemetryUtil.java @@ -6,10 +6,10 @@ package io.opentelemetry.exporter.otlp.profiles; import io.opentelemetry.api.common.Attributes; -import io.opentelemetry.exporter.otlp.internal.data.ImmutableProfileData; -import io.opentelemetry.exporter.otlp.internal.data.ImmutableProfilesDictionaryData; -import io.opentelemetry.exporter.otlp.internal.data.ImmutableValueTypeData; import io.opentelemetry.sdk.common.InstrumentationScopeInfo; +import io.opentelemetry.sdk.profiles.data.ProfileData; +import io.opentelemetry.sdk.profiles.data.ProfilesDictionaryData; +import io.opentelemetry.sdk.profiles.data.ValueTypeData; import io.opentelemetry.sdk.resources.Resource; import java.nio.ByteBuffer; import java.util.Collections; @@ -18,7 +18,7 @@ class FakeTelemetryUtil { private static final ProfilesDictionaryData EMPTY_PROFILE_DICTIONARY_DATA = - ImmutableProfilesDictionaryData.create( + ProfilesDictionaryData.create( Collections.emptyList(), Collections.emptyList(), Collections.emptyList(), @@ -38,15 +38,15 @@ private FakeTelemetryUtil() {} /** Generate a fake {@link ProfileData}. */ static ProfileData generateFakeProfileData() { String profileId = "0123456789abcdef0123456789abcdef"; - return ImmutableProfileData.create( + return ProfileData.create( Resource.create(Attributes.empty()), SCOPE_INFO, EMPTY_PROFILE_DICTIONARY_DATA, - ImmutableValueTypeData.create(1, 2), + ValueTypeData.create(1, 2), Collections.emptyList(), 5L, 6L, - ImmutableValueTypeData.create(1, 2), + ValueTypeData.create(1, 2), 7L, profileId, 8, diff --git a/exporters/otlp/profiles/src/test/java/io/opentelemetry/exporter/otlp/profiles/OtlpGrpcProfileExporterTest.java b/exporters/otlp/profiles/src/test/java/io/opentelemetry/exporter/otlp/profiles/OtlpGrpcProfileExporterTest.java index 3af11db2d6b..2afd6b85176 100644 --- a/exporters/otlp/profiles/src/test/java/io/opentelemetry/exporter/otlp/profiles/OtlpGrpcProfileExporterTest.java +++ b/exporters/otlp/profiles/src/test/java/io/opentelemetry/exporter/otlp/profiles/OtlpGrpcProfileExporterTest.java @@ -16,6 +16,7 @@ import io.opentelemetry.internal.testing.slf4j.SuppressLogger; import io.opentelemetry.proto.profiles.v1development.ResourceProfiles; import io.opentelemetry.sdk.common.export.GrpcStatusCode; +import io.opentelemetry.sdk.profiles.data.ProfileData; import java.io.Closeable; import java.util.Collections; import java.util.List; diff --git a/exporters/otlp/profiles/src/test/java/io/opentelemetry/exporter/otlp/profiles/ProfilesRequestMarshalerTest.java b/exporters/otlp/profiles/src/test/java/io/opentelemetry/exporter/otlp/profiles/ProfilesRequestMarshalerTest.java index caad7b06f49..169f9566f79 100644 --- a/exporters/otlp/profiles/src/test/java/io/opentelemetry/exporter/otlp/profiles/ProfilesRequestMarshalerTest.java +++ b/exporters/otlp/profiles/src/test/java/io/opentelemetry/exporter/otlp/profiles/ProfilesRequestMarshalerTest.java @@ -14,17 +14,6 @@ import io.opentelemetry.api.common.Attributes; import io.opentelemetry.api.common.Value; import io.opentelemetry.exporter.internal.marshal.Marshaler; -import io.opentelemetry.exporter.otlp.internal.data.ImmutableFunctionData; -import io.opentelemetry.exporter.otlp.internal.data.ImmutableKeyValueAndUnitData; -import io.opentelemetry.exporter.otlp.internal.data.ImmutableLineData; -import io.opentelemetry.exporter.otlp.internal.data.ImmutableLinkData; -import io.opentelemetry.exporter.otlp.internal.data.ImmutableLocationData; -import io.opentelemetry.exporter.otlp.internal.data.ImmutableMappingData; -import io.opentelemetry.exporter.otlp.internal.data.ImmutableProfileData; -import io.opentelemetry.exporter.otlp.internal.data.ImmutableProfilesDictionaryData; -import io.opentelemetry.exporter.otlp.internal.data.ImmutableSampleData; -import io.opentelemetry.exporter.otlp.internal.data.ImmutableStackData; -import io.opentelemetry.exporter.otlp.internal.data.ImmutableValueTypeData; import io.opentelemetry.proto.common.v1.AnyValue; import io.opentelemetry.proto.common.v1.InstrumentationScope; import io.opentelemetry.proto.profiles.v1development.Function; @@ -40,6 +29,17 @@ import io.opentelemetry.proto.profiles.v1development.Stack; import io.opentelemetry.proto.profiles.v1development.ValueType; import io.opentelemetry.sdk.common.InstrumentationScopeInfo; +import io.opentelemetry.sdk.profiles.data.FunctionData; +import io.opentelemetry.sdk.profiles.data.KeyValueAndUnitData; +import io.opentelemetry.sdk.profiles.data.LineData; +import io.opentelemetry.sdk.profiles.data.LinkData; +import io.opentelemetry.sdk.profiles.data.LocationData; +import io.opentelemetry.sdk.profiles.data.MappingData; +import io.opentelemetry.sdk.profiles.data.ProfileData; +import io.opentelemetry.sdk.profiles.data.ProfilesDictionaryData; +import io.opentelemetry.sdk.profiles.data.SampleData; +import io.opentelemetry.sdk.profiles.data.StackData; +import io.opentelemetry.sdk.profiles.data.ValueTypeData; import io.opentelemetry.sdk.resources.Resource; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -56,7 +56,7 @@ public class ProfilesRequestMarshalerTest { @Test void compareFunctionMarshaling() { - FunctionData input = ImmutableFunctionData.create(1, 2, 3, 4); + FunctionData input = FunctionData.create(1, 2, 3, 4); Function builderResult = Function.newBuilder() .setNameStrindex(1) @@ -73,8 +73,8 @@ void compareFunctionMarshaling() { @Test void compareRepeatedFunctionMarshaling() { List inputs = new ArrayList<>(); - inputs.add(ImmutableFunctionData.create(1, 2, 3, 4)); - inputs.add(ImmutableFunctionData.create(5, 6, 7, 8)); + inputs.add(FunctionData.create(1, 2, 3, 4)); + inputs.add(FunctionData.create(5, 6, 7, 8)); List builderResults = new ArrayList<>(); builderResults.add( @@ -102,7 +102,7 @@ void compareRepeatedFunctionMarshaling() { @Test void compareLineMarshaling() { - LineData input = ImmutableLineData.create(1, 2, 3); + LineData input = LineData.create(1, 2, 3); Line builderResult = Line.newBuilder().setFunctionIndex(1).setLine(2).setColumn(3).build(); Line roundTripResult = parse(Line.getDefaultInstance(), LineMarshaler.create(input)); @@ -112,8 +112,8 @@ void compareLineMarshaling() { @Test void compareRepeatedLineMarshaling() { List inputs = new ArrayList<>(); - inputs.add(ImmutableLineData.create(1, 2, 3)); - inputs.add(ImmutableLineData.create(4, 5, 6)); + inputs.add(LineData.create(1, 2, 3)); + inputs.add(LineData.create(4, 5, 6)); List builderResults = new ArrayList<>(); builderResults.add(Line.newBuilder().setFunctionIndex(1).setLine(2).setColumn(3).build()); @@ -129,7 +129,7 @@ void compareRepeatedLineMarshaling() { @Test void compareKeyValueAndUnitMarshaling() { - KeyValueAndUnitData input = ImmutableKeyValueAndUnitData.create(1, Value.of("foo"), 3); + KeyValueAndUnitData input = KeyValueAndUnitData.create(1, Value.of("foo"), 3); KeyValueAndUnit builderResult = KeyValueAndUnit.newBuilder() .setKeyStrindex(1) @@ -145,8 +145,8 @@ void compareKeyValueAndUnitMarshaling() { @Test void compareRepeatedKeyValueAndUnitMarshaling() { List inputs = new ArrayList<>(); - inputs.add(ImmutableKeyValueAndUnitData.create(1, Value.of("foo"), 3)); - inputs.add(ImmutableKeyValueAndUnitData.create(4, Value.of("bar"), 6)); + inputs.add(KeyValueAndUnitData.create(1, Value.of("foo"), 3)); + inputs.add(KeyValueAndUnitData.create(4, Value.of("bar"), 6)); List builderResults = new ArrayList<>(); builderResults.add( @@ -174,7 +174,7 @@ void compareRepeatedKeyValueAndUnitMarshaling() { void compareLinkMarshaling() { String traceId = "0123456789abcdef0123456789abcdef"; String spanId = "fedcba9876543210"; - LinkData input = ImmutableLinkData.create(traceId, spanId); + LinkData input = LinkData.create(traceId, spanId); Link builderResult = Link.newBuilder() .setTraceId(ByteString.fromHex(traceId)) @@ -188,8 +188,8 @@ void compareLinkMarshaling() { @Test void compareRepeatedLinkMarshaling() { List inputs = new ArrayList<>(); - inputs.add(ImmutableLinkData.create("0123456789abcdef0123456789abcdef", "fedcba9876543210")); - inputs.add(ImmutableLinkData.create("123456789abcdef0123456789abcdef0", "edcba9876543210f")); + inputs.add(LinkData.create("0123456789abcdef0123456789abcdef", "fedcba9876543210")); + inputs.add(LinkData.create("123456789abcdef0123456789abcdef0", "edcba9876543210f")); List builderResults = new ArrayList<>(); builderResults.add( @@ -213,7 +213,7 @@ void compareRepeatedLinkMarshaling() { @Test void compareLocationMarshaling() { - LocationData input = ImmutableLocationData.create(1, 2, Collections.emptyList(), listOf(4, 5)); + LocationData input = LocationData.create(1, 2, Collections.emptyList(), listOf(4, 5)); Location builderResult = Location.newBuilder() .setMappingIndex(1) @@ -229,8 +229,8 @@ void compareLocationMarshaling() { @Test void compareRepeatedLocationMarshaling() { List inputs = new ArrayList<>(); - inputs.add(ImmutableLocationData.create(1, 2, Collections.emptyList(), listOf(3, 4))); - inputs.add(ImmutableLocationData.create(5, 6, Collections.emptyList(), listOf(7, 8))); + inputs.add(LocationData.create(1, 2, Collections.emptyList(), listOf(3, 4))); + inputs.add(LocationData.create(5, 6, Collections.emptyList(), listOf(7, 8))); List builderResults = new ArrayList<>(); builderResults.add( @@ -256,7 +256,7 @@ void compareRepeatedLocationMarshaling() { @Test void compareMappingMarshaling() { - MappingData input = ImmutableMappingData.create(1, 2, 3, 4, listOf(5, 6)); + MappingData input = MappingData.create(1, 2, 3, 4, listOf(5, 6)); Mapping builderResult = Mapping.newBuilder() .setMemoryStart(1) @@ -273,8 +273,8 @@ void compareMappingMarshaling() { @Test void compareRepeatedMappingMarshaling() { List inputs = new ArrayList<>(); - inputs.add(ImmutableMappingData.create(1, 2, 3, 4, listOf(5, 6))); - inputs.add(ImmutableMappingData.create(7, 8, 9, 10, listOf(11, 12))); + inputs.add(MappingData.create(1, 2, 3, 4, listOf(5, 6))); + inputs.add(MappingData.create(7, 8, 9, 10, listOf(11, 12))); List builderResults = new ArrayList<>(); builderResults.add( @@ -304,7 +304,7 @@ void compareRepeatedMappingMarshaling() { @Test void compareStackMarshaling() { - StackData input = ImmutableStackData.create(listOf(1, 2)); + StackData input = StackData.create(listOf(1, 2)); Stack builderResult = Stack.newBuilder().addAllLocationIndices(listOf(1, 2)).build(); Stack roundTripResult = parse(Stack.getDefaultInstance(), StackMarshaler.create(input)); @@ -314,8 +314,8 @@ void compareStackMarshaling() { @Test void compareRepeatedStackMarshaling() { List inputs = new ArrayList<>(); - inputs.add(ImmutableStackData.create(listOf(1, 2))); - inputs.add(ImmutableStackData.create(listOf(3, 4))); + inputs.add(StackData.create(listOf(1, 2))); + inputs.add(StackData.create(listOf(3, 4))); List builderResults = new ArrayList<>(); builderResults.add(Stack.newBuilder().addAllLocationIndices(listOf(1, 2)).build()); @@ -334,10 +334,10 @@ void compareResourceProfilesMarshaling() { String profileId = "0123456789abcdef0123456789abcdef"; ProfileData profileContainerData = - ImmutableProfileData.create( + ProfileData.create( Resource.create(Attributes.empty()), InstrumentationScopeInfo.create("testscope"), - ImmutableProfilesDictionaryData.create( + ProfilesDictionaryData.create( Collections.emptyList(), Collections.emptyList(), Collections.emptyList(), @@ -345,11 +345,11 @@ void compareResourceProfilesMarshaling() { Collections.emptyList(), Collections.emptyList(), Collections.emptyList()), - ImmutableValueTypeData.create(1, 2), + ValueTypeData.create(1, 2), Collections.emptyList(), 5L, 6L, - ImmutableValueTypeData.create(1, 2), + ValueTypeData.create(1, 2), 7L, profileId, 8, @@ -391,8 +391,7 @@ void compareResourceProfilesMarshaling() { @Test void compareSampleMarshaling() { - SampleData input = - ImmutableSampleData.create(1, listOf(2, 3), 4, listOf(5L, 6L), listOf(7L, 8L)); + SampleData input = SampleData.create(1, listOf(2, 3), 4, listOf(5L, 6L), listOf(7L, 8L)); Sample builderResult = Sample.newBuilder() .setStackIndex(1) @@ -409,9 +408,8 @@ void compareSampleMarshaling() { @Test void compareRepeatedSampleMarshaling() { List inputs = new ArrayList<>(); - inputs.add(ImmutableSampleData.create(1, listOf(2, 3), 4, listOf(5L, 6L), listOf(7L, 8L))); - inputs.add( - ImmutableSampleData.create(11, listOf(12, 13), 14, listOf(15L, 16L), listOf(17L, 18L))); + inputs.add(SampleData.create(1, listOf(2, 3), 4, listOf(5L, 6L), listOf(7L, 8L))); + inputs.add(SampleData.create(11, listOf(12, 13), 14, listOf(15L, 16L), listOf(17L, 18L))); List builderResults = new ArrayList<>(); builderResults.add( @@ -441,7 +439,7 @@ void compareRepeatedSampleMarshaling() { @Test void compareValueTypeMarshaling() { - ValueTypeData input = ImmutableValueTypeData.create(1, 2); + ValueTypeData input = ValueTypeData.create(1, 2); ValueType builderResult = ValueType.newBuilder().setTypeStrindex(1).setUnitStrindex(2).build(); ValueType roundTripResult = @@ -452,8 +450,8 @@ void compareValueTypeMarshaling() { @Test void compareRepeatedValueTypeMarshaling() { List inputs = new ArrayList<>(); - inputs.add(ImmutableValueTypeData.create(1, 2)); - inputs.add(ImmutableValueTypeData.create(3, 4)); + inputs.add(ValueTypeData.create(1, 2)); + inputs.add(ValueTypeData.create(3, 4)); List builderResults = new ArrayList<>(); builderResults.add(ValueType.newBuilder().setTypeStrindex(1).setUnitStrindex(2).build()); diff --git a/exporters/otlp/testing-internal/build.gradle.kts b/exporters/otlp/testing-internal/build.gradle.kts index 624d4759405..c302db6ca70 100644 --- a/exporters/otlp/testing-internal/build.gradle.kts +++ b/exporters/otlp/testing-internal/build.gradle.kts @@ -9,6 +9,7 @@ dependencies { api(project(":exporters:otlp:common")) api(project(":sdk:logs")) api(project(":sdk:metrics")) + api(project(":sdk:profiles")) api(project(":sdk:trace")) api(project(":sdk:testing")) diff --git a/exporters/otlp/testing-internal/src/main/java/io/opentelemetry/exporter/otlp/testing/internal/GrpcProfilesExporterBuilderWrapper.java b/exporters/otlp/testing-internal/src/main/java/io/opentelemetry/exporter/otlp/testing/internal/GrpcProfilesExporterBuilderWrapper.java index 21364ad882e..ac34a9504e2 100644 --- a/exporters/otlp/testing-internal/src/main/java/io/opentelemetry/exporter/otlp/testing/internal/GrpcProfilesExporterBuilderWrapper.java +++ b/exporters/otlp/testing-internal/src/main/java/io/opentelemetry/exporter/otlp/testing/internal/GrpcProfilesExporterBuilderWrapper.java @@ -9,10 +9,10 @@ import io.opentelemetry.api.metrics.MeterProvider; import io.opentelemetry.common.ComponentLoader; import io.opentelemetry.exporter.otlp.profiles.OtlpGrpcProfilesExporterBuilder; -import io.opentelemetry.exporter.otlp.profiles.ProfileData; import io.opentelemetry.sdk.common.InternalTelemetryVersion; import io.opentelemetry.sdk.common.export.ProxyOptions; import io.opentelemetry.sdk.common.export.RetryPolicy; +import io.opentelemetry.sdk.profiles.data.ProfileData; import java.time.Duration; import java.util.Map; import java.util.concurrent.ExecutorService; diff --git a/exporters/otlp/testing-internal/src/main/java/io/opentelemetry/exporter/otlp/testing/internal/TelemetryExporter.java b/exporters/otlp/testing-internal/src/main/java/io/opentelemetry/exporter/otlp/testing/internal/TelemetryExporter.java index 6bb4c3132cc..3ce553bc654 100644 --- a/exporters/otlp/testing-internal/src/main/java/io/opentelemetry/exporter/otlp/testing/internal/TelemetryExporter.java +++ b/exporters/otlp/testing-internal/src/main/java/io/opentelemetry/exporter/otlp/testing/internal/TelemetryExporter.java @@ -7,8 +7,6 @@ import com.google.common.base.Strings; import com.google.protobuf.AbstractMessageLite; -import io.opentelemetry.exporter.otlp.profiles.ProfileData; -import io.opentelemetry.exporter.otlp.profiles.ProfileExporter; import io.opentelemetry.proto.collector.logs.v1.ExportLogsPartialSuccess; import io.opentelemetry.proto.collector.logs.v1.ExportLogsServiceResponse; import io.opentelemetry.proto.collector.metrics.v1.ExportMetricsPartialSuccess; @@ -22,6 +20,8 @@ import io.opentelemetry.sdk.logs.export.LogRecordExporter; import io.opentelemetry.sdk.metrics.data.MetricData; import io.opentelemetry.sdk.metrics.export.MetricExporter; +import io.opentelemetry.sdk.profiles.ProfileExporter; +import io.opentelemetry.sdk.profiles.data.ProfileData; import io.opentelemetry.sdk.trace.data.SpanData; import io.opentelemetry.sdk.trace.export.SpanExporter; import java.util.Collection; diff --git a/exporters/otlp/testing-internal/src/main/java/io/opentelemetry/exporter/otlp/testing/internal/TelemetryExporterBuilder.java b/exporters/otlp/testing-internal/src/main/java/io/opentelemetry/exporter/otlp/testing/internal/TelemetryExporterBuilder.java index 0ecac66d031..779cc63905e 100644 --- a/exporters/otlp/testing-internal/src/main/java/io/opentelemetry/exporter/otlp/testing/internal/TelemetryExporterBuilder.java +++ b/exporters/otlp/testing-internal/src/main/java/io/opentelemetry/exporter/otlp/testing/internal/TelemetryExporterBuilder.java @@ -10,13 +10,13 @@ import io.opentelemetry.exporter.otlp.logs.OtlpGrpcLogRecordExporterBuilder; import io.opentelemetry.exporter.otlp.metrics.OtlpGrpcMetricExporterBuilder; import io.opentelemetry.exporter.otlp.profiles.OtlpGrpcProfilesExporterBuilder; -import io.opentelemetry.exporter.otlp.profiles.ProfileData; import io.opentelemetry.exporter.otlp.trace.OtlpGrpcSpanExporterBuilder; import io.opentelemetry.sdk.common.InternalTelemetryVersion; import io.opentelemetry.sdk.common.export.ProxyOptions; import io.opentelemetry.sdk.common.export.RetryPolicy; import io.opentelemetry.sdk.logs.data.LogRecordData; import io.opentelemetry.sdk.metrics.data.MetricData; +import io.opentelemetry.sdk.profiles.data.ProfileData; import io.opentelemetry.sdk.trace.data.SpanData; import java.time.Duration; import java.util.Map; diff --git a/opentelemetry-jfr-profiles-shim/build.gradle.kts b/opentelemetry-jfr-profiles-shim/build.gradle.kts new file mode 100644 index 00000000000..69a60c25193 --- /dev/null +++ b/opentelemetry-jfr-profiles-shim/build.gradle.kts @@ -0,0 +1,29 @@ +plugins { + id("otel.java-conventions") + // TODO decide what to do about JfrExportExample before publishing. + // unlike the other classes here it's an example, not a reusable utility. + // id("otel.publish-conventions") +} + +description = "OpenTelemetry - JFR to Profiles data conversion example" +otelJava.moduleName.set("io.opentelemetry.jfr.profiles.shim") + +tasks { + // this module uses the jdk.jfr.consumer API, which was backported into 1.8 but is '@since 9' + // and therefore a bit of a pain to get gradle to compile against... + compileJava { + sourceCompatibility = "1.8" + targetCompatibility = "1.8" + options.release.set(null as Int?) + } + compileTestJava { + sourceCompatibility = "1.8" + targetCompatibility = "1.8" + options.release.set(null as Int?) + } +} + +dependencies { + api(project(":exporters:otlp:profiles")) + api(project(":sdk:profiles")) +} diff --git a/opentelemetry-jfr-profiles-shim/gradle.properties b/opentelemetry-jfr-profiles-shim/gradle.properties new file mode 100644 index 00000000000..4476ae57e31 --- /dev/null +++ b/opentelemetry-jfr-profiles-shim/gradle.properties @@ -0,0 +1 @@ +otel.release=alpha diff --git a/opentelemetry-jfr-profiles-shim/src/main/java/io/opentelemetry/sdk/profiles/jfr/JfrExecutionSampleEventConverter.java b/opentelemetry-jfr-profiles-shim/src/main/java/io/opentelemetry/sdk/profiles/jfr/JfrExecutionSampleEventConverter.java new file mode 100644 index 00000000000..b78ddf71bf4 --- /dev/null +++ b/opentelemetry-jfr-profiles-shim/src/main/java/io/opentelemetry/sdk/profiles/jfr/JfrExecutionSampleEventConverter.java @@ -0,0 +1,84 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +package io.opentelemetry.sdk.profiles.jfr; + +import io.opentelemetry.sdk.profiles.ProfilesDictionaryCompositor; +import io.opentelemetry.sdk.profiles.SampleCompositionBuilder; +import io.opentelemetry.sdk.profiles.SampleCompositionKey; +import io.opentelemetry.sdk.profiles.data.SampleData; +import java.time.Instant; +import java.util.Collections; +import java.util.List; +import java.util.concurrent.TimeUnit; +import jdk.jfr.consumer.RecordedEvent; + +/** + * Converter for batching a steam of recorded jfr.ExecutionSample events into a format suitable for + * consumption in a ProfileData i.e. for OTLP export. Similar converters, or a more generalized + * converter, are need for each JFR event type. + */ +public class JfrExecutionSampleEventConverter { + + /* + * The profiles signal encoding uses dictionary lookup tables to save space by deduplicating + * repeated object occurrences. The dictionary compositor is used to assemble these tables. + */ + private final ProfilesDictionaryCompositor profilesDictionaryCompositor = + new ProfilesDictionaryCompositor(); + + /* + * stack frames are dictionary encoded in multiple steps. + * first, frames are converted to Locations, each of which is placed in the dictionary. + * Then the stack as a whole is represented as an array of those Locations, + * and the Stack message itself is also placed in the dictionary. + * This assembly is handled by a JfrLocationDataCompositor wrapping the dictionary + */ + private final JfrLocationDataCompositor locationCompositor = + new JfrLocationDataCompositor(profilesDictionaryCompositor); + + /* + * Samples are occurrences of the same observation, with an optional value and timestamp. + * In JFR, for each given event type, a SampleCompositionBuilder is used to split the + * events (observations) by key (stack+metadata) and record the timestamps. + * If processing multiple event types, a Map would be used. + */ + private final SampleCompositionBuilder sampleCompositionBuilder = new SampleCompositionBuilder(); + + /** + * Convert and add a JFR event, if of appropriate type. + * + * @param recordedEvent the event to process. + */ + public void accept(RecordedEvent recordedEvent) { + if (!"jdk.ExecutionSample".equals(recordedEvent.getEventType().getName())) { + return; + } + + int stackIndex = locationCompositor.putIfAbsent(recordedEvent.getStackTrace().getFrames()); + SampleCompositionKey key = new SampleCompositionKey(stackIndex, Collections.emptyList(), 0); + Instant instant = recordedEvent.getStartTime(); + long epochNanos = TimeUnit.SECONDS.toNanos(instant.getEpochSecond()) + instant.getNano(); + sampleCompositionBuilder.add(key, null, epochNanos); + } + + /** + * Gets the underlying dictionary storage. + * + * @return the ProfilesDictionaryCompositor used by this converter. + */ + public ProfilesDictionaryCompositor getProfilesDictionaryCompositor() { + return profilesDictionaryCompositor; + } + + /** + * Gets the samples assembled from the accepted events. + * + * @return the data samples. + */ + public List getSamples() { + return sampleCompositionBuilder.build(); + } +} diff --git a/opentelemetry-jfr-profiles-shim/src/main/java/io/opentelemetry/sdk/profiles/jfr/JfrExportExample.java b/opentelemetry-jfr-profiles-shim/src/main/java/io/opentelemetry/sdk/profiles/jfr/JfrExportExample.java new file mode 100644 index 00000000000..6e83e00e094 --- /dev/null +++ b/opentelemetry-jfr-profiles-shim/src/main/java/io/opentelemetry/sdk/profiles/jfr/JfrExportExample.java @@ -0,0 +1,95 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +package io.opentelemetry.sdk.profiles.jfr; + +import io.opentelemetry.api.common.Attributes; +import io.opentelemetry.exporter.otlp.profiles.OtlpGrpcProfileExporter; +import io.opentelemetry.exporter.otlp.profiles.OtlpGrpcProfilesExporterBuilder; +import io.opentelemetry.sdk.common.CompletableResultCode; +import io.opentelemetry.sdk.common.InstrumentationScopeInfo; +import io.opentelemetry.sdk.profiles.ProfileExporter; +import io.opentelemetry.sdk.profiles.data.ProfileData; +import io.opentelemetry.sdk.profiles.data.ValueTypeData; +import io.opentelemetry.sdk.resources.Resource; +import java.io.IOException; +import java.nio.ByteBuffer; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.Collections; +import java.util.List; +import java.util.concurrent.TimeUnit; +import jdk.jfr.consumer.RecordingFile; + +/** + * Simple example of how to wire up the profiles signal OTLP exporter to convert and send the + * content of a JFR recording file. This is not a supported CLI and is not intended to be + * configurable by e.g. command line flags. + */ +public class JfrExportExample { + + private JfrExportExample() {} + + @SuppressWarnings("SystemOut") + public static void main(String[] args) throws IOException { + + Path jfrFilePath = Path.of("/tmp/demo.jfr"); // TODO set the JFR file location here + ProfileData profileData = convertJfrFile(jfrFilePath); + + // for test purposes https://github.com/elastic/devfiler/ provides a handy standalone backend. + // by default devfiler listens on port 11000 + String destination = "127.0.0.1:11000"; // TODO set the location of the backend receiver here + + OtlpGrpcProfilesExporterBuilder exporterBuilder = OtlpGrpcProfileExporter.builder(); + exporterBuilder.setEndpoint("http://" + destination); + ProfileExporter exporter = exporterBuilder.build(); + + CompletableResultCode completableResultCode = exporter.export(List.of(profileData)); + completableResultCode.join(1, TimeUnit.MINUTES); + System.out.println(completableResultCode.isSuccess() ? "success" : "failure"); + } + + /** + * Read the content of the JFR recording file and convert it to a ProfileData object in + * preparation for OTLP export. + * + * @param jfrFilePath the data source. + * @return a ProfileData object constructed from the JFR recording. + * @throws IOException if the conversion fails. + */ + public static ProfileData convertJfrFile(Path jfrFilePath) throws IOException { + + JfrExecutionSampleEventConverter converter = new JfrExecutionSampleEventConverter(); + + RecordingFile recordingFile = new RecordingFile(jfrFilePath); + while (recordingFile.hasMoreEvents()) { + converter.accept(recordingFile.readEvent()); + } + recordingFile.close(); + + String profileId = "0123456789abcdef0123456789abcdef"; + InstrumentationScopeInfo scopeInfo = + InstrumentationScopeInfo.builder("testLib") + .setVersion("1.0") + .setSchemaUrl("http://url") + .build(); + + return ProfileData.create( + Resource.create(Attributes.empty()), + scopeInfo, + converter.getProfilesDictionaryCompositor().getProfileDictionaryData(), + ValueTypeData.create(0, 0), + converter.getSamples(), + 0, + 0, + ValueTypeData.create(0, 0), + 0, + profileId, + 0, + "format", + ByteBuffer.wrap(Files.readAllBytes(jfrFilePath)), + Collections.emptyList()); + } +} diff --git a/opentelemetry-jfr-profiles-shim/src/main/java/io/opentelemetry/sdk/profiles/jfr/JfrLocationDataCompositor.java b/opentelemetry-jfr-profiles-shim/src/main/java/io/opentelemetry/sdk/profiles/jfr/JfrLocationDataCompositor.java new file mode 100644 index 00000000000..e691e75671f --- /dev/null +++ b/opentelemetry-jfr-profiles-shim/src/main/java/io/opentelemetry/sdk/profiles/jfr/JfrLocationDataCompositor.java @@ -0,0 +1,97 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +package io.opentelemetry.sdk.profiles.jfr; + +import io.opentelemetry.sdk.profiles.ProfilesDictionaryCompositor; +import io.opentelemetry.sdk.profiles.data.FunctionData; +import io.opentelemetry.sdk.profiles.data.LineData; +import io.opentelemetry.sdk.profiles.data.LocationData; +import io.opentelemetry.sdk.profiles.data.StackData; +import java.util.Collections; +import java.util.List; +import jdk.jfr.consumer.RecordedFrame; + +/** + * Allows for the conversion and storage of JFR thread stacks in the dictionary encoding structure + * used by OTLP profile signal exporters. + * + *

The compositor resembles a builder, though without the fluent API. Instead, mutation methods + * return the index of the offered element, this information being required to construct any element + * that references into the tables. + * + *

This class is not threadsafe and must be externally synchronized. + */ +public class JfrLocationDataCompositor { + + private final ProfilesDictionaryCompositor profilesDictionaryCompositor; + + /** + * Wrap the given dictionary with additional JFR-specific stack data handling functionality. + * + * @param profilesDictionaryCompositor the underlying storage. + */ + public JfrLocationDataCompositor(ProfilesDictionaryCompositor profilesDictionaryCompositor) { + this.profilesDictionaryCompositor = profilesDictionaryCompositor; + } + + /** + * Stores the provided list of frames as a StackData element in the dictionary if an equivalent is + * not already present, and returns its index. + * + * @param frameList the JFR stack data. + * @return the index of the added or existing StackData element. + */ + public int putIfAbsent(List frameList) { + + List locationIndices = frameList.stream().map(this::frameToLocation).toList(); + + StackData stackData = StackData.create(locationIndices); + int stackIndex = profilesDictionaryCompositor.putIfAbsent(stackData); + return stackIndex; + } + + /** + * Convert a single frame of a stack to a LocationData, store it and its components in the + * dictionary and return its index. + * + * @param frame the source data + * @return the LocationData storage index in the dictionary + */ + protected int frameToLocation(RecordedFrame frame) { + + // the LocationData references several components which need creating and placing in their + // respective dictionary tables + + String name = nameFrom(frame); + int nameStringIndex = profilesDictionaryCompositor.putIfAbsent(name); + + FunctionData functionData = FunctionData.create(nameStringIndex, 0, 0, 0); + int functionIndex = profilesDictionaryCompositor.putIfAbsent(functionData); + + int lineNumber = frame.getLineNumber() != -1 ? frame.getLineNumber() : 0; + LineData lineData = LineData.create(functionIndex, lineNumber, 0); + + LocationData locationData = + LocationData.create(0, 0, List.of(lineData), Collections.emptyList()); + + int locationIndex = profilesDictionaryCompositor.putIfAbsent(locationData); + return locationIndex; + } + + /** + * Construct a name String from the frame. Note that the wire spec and semantic conventions don't + * define a specific string format. Override this method to customize the conversion. + * + * @param frame the JFR frame data. + * @return the name as a String. + */ + protected String nameFrom(RecordedFrame frame) { + String name = frame.getMethod().getType() != null ? frame.getMethod().getType().getName() : ""; + name += "."; + name += frame.getMethod().getName() != null ? frame.getMethod().getName() : ""; + return name; + } +} diff --git a/sdk/profiles/build.gradle.kts b/sdk/profiles/build.gradle.kts new file mode 100644 index 00000000000..8e7b7546277 --- /dev/null +++ b/sdk/profiles/build.gradle.kts @@ -0,0 +1,15 @@ +plugins { + id("otel.java-conventions") +// id("otel.publish-conventions") + + id("otel.animalsniffer-conventions") +} + +description = "OpenTelemetry - Profiles SDK" +otelJava.moduleName.set("sdk.profiles") + +dependencies { + api(project(":sdk:common")) + + annotationProcessor("com.google.auto.value:auto-value") +} diff --git a/sdk/profiles/gradle.properties b/sdk/profiles/gradle.properties new file mode 100644 index 00000000000..4476ae57e31 --- /dev/null +++ b/sdk/profiles/gradle.properties @@ -0,0 +1 @@ +otel.release=alpha diff --git a/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/DictionaryTable.java b/sdk/profiles/src/main/java/io/opentelemetry/sdk/profiles/DictionaryTable.java similarity index 97% rename from exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/DictionaryTable.java rename to sdk/profiles/src/main/java/io/opentelemetry/sdk/profiles/DictionaryTable.java index 6650cc9bc99..3b103f1d3b6 100644 --- a/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/DictionaryTable.java +++ b/sdk/profiles/src/main/java/io/opentelemetry/sdk/profiles/DictionaryTable.java @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -package io.opentelemetry.exporter.otlp.profiles; +package io.opentelemetry.sdk.profiles; import java.util.ArrayList; import java.util.Collections; diff --git a/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/ProfileExporter.java b/sdk/profiles/src/main/java/io/opentelemetry/sdk/profiles/ProfileExporter.java similarity index 94% rename from exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/ProfileExporter.java rename to sdk/profiles/src/main/java/io/opentelemetry/sdk/profiles/ProfileExporter.java index 1ba75a6757d..efeefab3712 100644 --- a/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/ProfileExporter.java +++ b/sdk/profiles/src/main/java/io/opentelemetry/sdk/profiles/ProfileExporter.java @@ -3,9 +3,10 @@ * SPDX-License-Identifier: Apache-2.0 */ -package io.opentelemetry.exporter.otlp.profiles; +package io.opentelemetry.sdk.profiles; import io.opentelemetry.sdk.common.CompletableResultCode; +import io.opentelemetry.sdk.profiles.data.ProfileData; import java.io.Closeable; import java.util.Collection; import java.util.concurrent.TimeUnit; diff --git a/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/ProfilesDictionaryCompositor.java b/sdk/profiles/src/main/java/io/opentelemetry/sdk/profiles/ProfilesDictionaryCompositor.java similarity index 81% rename from exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/ProfilesDictionaryCompositor.java rename to sdk/profiles/src/main/java/io/opentelemetry/sdk/profiles/ProfilesDictionaryCompositor.java index 462b0acc7bd..972112e1710 100644 --- a/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/ProfilesDictionaryCompositor.java +++ b/sdk/profiles/src/main/java/io/opentelemetry/sdk/profiles/ProfilesDictionaryCompositor.java @@ -3,16 +3,16 @@ * SPDX-License-Identifier: Apache-2.0 */ -package io.opentelemetry.exporter.otlp.profiles; +package io.opentelemetry.sdk.profiles; import io.opentelemetry.api.common.Value; -import io.opentelemetry.exporter.otlp.internal.data.ImmutableFunctionData; -import io.opentelemetry.exporter.otlp.internal.data.ImmutableKeyValueAndUnitData; -import io.opentelemetry.exporter.otlp.internal.data.ImmutableLinkData; -import io.opentelemetry.exporter.otlp.internal.data.ImmutableLocationData; -import io.opentelemetry.exporter.otlp.internal.data.ImmutableMappingData; -import io.opentelemetry.exporter.otlp.internal.data.ImmutableProfilesDictionaryData; -import io.opentelemetry.exporter.otlp.internal.data.ImmutableStackData; +import io.opentelemetry.sdk.profiles.data.FunctionData; +import io.opentelemetry.sdk.profiles.data.KeyValueAndUnitData; +import io.opentelemetry.sdk.profiles.data.LinkData; +import io.opentelemetry.sdk.profiles.data.LocationData; +import io.opentelemetry.sdk.profiles.data.MappingData; +import io.opentelemetry.sdk.profiles.data.ProfilesDictionaryData; +import io.opentelemetry.sdk.profiles.data.StackData; import java.util.Collections; /** @@ -50,14 +50,14 @@ public ProfilesDictionaryCompositor() { // They could be public static constants on this class or the corresponding Immutable*Data // classes if other use cases require them. - mappingTable.putIfAbsent(ImmutableMappingData.create(0, 0, 0, 0, Collections.emptyList())); + mappingTable.putIfAbsent(MappingData.create(0, 0, 0, 0, Collections.emptyList())); locationTable.putIfAbsent( - ImmutableLocationData.create(0, 0, Collections.emptyList(), Collections.emptyList())); - functionTable.putIfAbsent(ImmutableFunctionData.create(0, 0, 0, 0)); - linkTable.putIfAbsent(ImmutableLinkData.create("", "")); + LocationData.create(0, 0, Collections.emptyList(), Collections.emptyList())); + functionTable.putIfAbsent(FunctionData.create(0, 0, 0, 0)); + linkTable.putIfAbsent(LinkData.create("", "")); stringTable.putIfAbsent(""); - attributeTable.putIfAbsent(ImmutableKeyValueAndUnitData.create(0, Value.of(""), 0)); - stackTable.putIfAbsent(ImmutableStackData.create(Collections.emptyList())); + attributeTable.putIfAbsent(KeyValueAndUnitData.create(0, Value.of(""), 0)); + stackTable.putIfAbsent(StackData.create(Collections.emptyList())); } /** @@ -69,7 +69,7 @@ public ProfilesDictionaryCompositor() { * @return a ProfileDictionaryData with the contents of the tables. */ public ProfilesDictionaryData getProfileDictionaryData() { - return ImmutableProfilesDictionaryData.create( + return ProfilesDictionaryData.create( mappingTable.getTable(), locationTable.getTable(), functionTable.getTable(), diff --git a/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/SampleCompositionBuilder.java b/sdk/profiles/src/main/java/io/opentelemetry/sdk/profiles/SampleCompositionBuilder.java similarity index 92% rename from exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/SampleCompositionBuilder.java rename to sdk/profiles/src/main/java/io/opentelemetry/sdk/profiles/SampleCompositionBuilder.java index ec059157c5b..c389a407ff8 100644 --- a/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/SampleCompositionBuilder.java +++ b/sdk/profiles/src/main/java/io/opentelemetry/sdk/profiles/SampleCompositionBuilder.java @@ -3,9 +3,9 @@ * SPDX-License-Identifier: Apache-2.0 */ -package io.opentelemetry.exporter.otlp.profiles; +package io.opentelemetry.sdk.profiles; -import io.opentelemetry.exporter.otlp.internal.data.ImmutableSampleData; +import io.opentelemetry.sdk.profiles.data.SampleData; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -38,7 +38,7 @@ public List build() { SampleCompositionKey key = entry.getKey(); SampleCompositionValue value = entry.getValue(); SampleData sampleData = - ImmutableSampleData.create( + SampleData.create( key.getStackIndex(), key.getAttributeIndices(), key.getLinkIndex(), diff --git a/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/SampleCompositionKey.java b/sdk/profiles/src/main/java/io/opentelemetry/sdk/profiles/SampleCompositionKey.java similarity index 97% rename from exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/SampleCompositionKey.java rename to sdk/profiles/src/main/java/io/opentelemetry/sdk/profiles/SampleCompositionKey.java index 58789b37742..3a5eeddb582 100644 --- a/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/SampleCompositionKey.java +++ b/sdk/profiles/src/main/java/io/opentelemetry/sdk/profiles/SampleCompositionKey.java @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -package io.opentelemetry.exporter.otlp.profiles; +package io.opentelemetry.sdk.profiles; import java.util.ArrayList; import java.util.Collections; diff --git a/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/SampleCompositionValue.java b/sdk/profiles/src/main/java/io/opentelemetry/sdk/profiles/SampleCompositionValue.java similarity index 96% rename from exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/SampleCompositionValue.java rename to sdk/profiles/src/main/java/io/opentelemetry/sdk/profiles/SampleCompositionValue.java index 9570d0d4e04..6b97b2d2003 100644 --- a/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/SampleCompositionValue.java +++ b/sdk/profiles/src/main/java/io/opentelemetry/sdk/profiles/SampleCompositionValue.java @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -package io.opentelemetry.exporter.otlp.profiles; +package io.opentelemetry.sdk.profiles; import java.util.ArrayList; import java.util.Collections; diff --git a/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/FunctionData.java b/sdk/profiles/src/main/java/io/opentelemetry/sdk/profiles/data/FunctionData.java similarity index 57% rename from exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/FunctionData.java rename to sdk/profiles/src/main/java/io/opentelemetry/sdk/profiles/data/FunctionData.java index e50ba846907..04c346e8648 100644 --- a/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/FunctionData.java +++ b/sdk/profiles/src/main/java/io/opentelemetry/sdk/profiles/data/FunctionData.java @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -package io.opentelemetry.exporter.otlp.profiles; +package io.opentelemetry.sdk.profiles.data; import javax.annotation.concurrent.Immutable; @@ -15,6 +15,18 @@ @Immutable public interface FunctionData { + /** + * Returns a new FunctionData describing the given function characteristics. + * + * @return a new FunctionData describing the given function characteristics. + */ + @SuppressWarnings("AutoValueSubclassLeaked") + static FunctionData create( + int nameStringIndex, int systemNameStringIndex, int filenameStringIndex, long startLine) { + return new AutoValue_ImmutableFunctionData( + nameStringIndex, systemNameStringIndex, filenameStringIndex, startLine); + } + /** Name of the function, in human-readable form if available. Index into string table. */ int getNameStringIndex(); diff --git a/sdk/profiles/src/main/java/io/opentelemetry/sdk/profiles/data/ImmutableFunctionData.java b/sdk/profiles/src/main/java/io/opentelemetry/sdk/profiles/data/ImmutableFunctionData.java new file mode 100644 index 00000000000..09185a188fd --- /dev/null +++ b/sdk/profiles/src/main/java/io/opentelemetry/sdk/profiles/data/ImmutableFunctionData.java @@ -0,0 +1,22 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +package io.opentelemetry.sdk.profiles.data; + +import com.google.auto.value.AutoValue; +import javax.annotation.concurrent.Immutable; + +/** + * Auto value implementation of {@link FunctionData}, which describes a code function. + * + *

This class is internal and is hence not for public use. Its APIs are unstable and can change + * at any time. + */ +@Immutable +@AutoValue +abstract class ImmutableFunctionData implements FunctionData { + + ImmutableFunctionData() {} +} diff --git a/sdk/profiles/src/main/java/io/opentelemetry/sdk/profiles/data/ImmutableKeyValueAndUnitData.java b/sdk/profiles/src/main/java/io/opentelemetry/sdk/profiles/data/ImmutableKeyValueAndUnitData.java new file mode 100644 index 00000000000..e51f6e19645 --- /dev/null +++ b/sdk/profiles/src/main/java/io/opentelemetry/sdk/profiles/data/ImmutableKeyValueAndUnitData.java @@ -0,0 +1,23 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +package io.opentelemetry.sdk.profiles.data; + +import com.google.auto.value.AutoValue; +import javax.annotation.concurrent.Immutable; + +/** + * Auto value implementation of {@link KeyValueAndUnitData}, which describes a Key Value pair with + * optional unit for the value. + * + *

This class is internal and is hence not for public use. Its APIs are unstable and can change + * at any time. + */ +@Immutable +@AutoValue +abstract class ImmutableKeyValueAndUnitData implements KeyValueAndUnitData { + + ImmutableKeyValueAndUnitData() {} +} diff --git a/sdk/profiles/src/main/java/io/opentelemetry/sdk/profiles/data/ImmutableLineData.java b/sdk/profiles/src/main/java/io/opentelemetry/sdk/profiles/data/ImmutableLineData.java new file mode 100644 index 00000000000..cc2edf2590d --- /dev/null +++ b/sdk/profiles/src/main/java/io/opentelemetry/sdk/profiles/data/ImmutableLineData.java @@ -0,0 +1,23 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +package io.opentelemetry.sdk.profiles.data; + +import com.google.auto.value.AutoValue; +import javax.annotation.concurrent.Immutable; + +/** + * Auto value implementation of {@link LineData}, which details a specific line in a source code, + * linked to a function. + * + *

This class is internal and is hence not for public use. Its APIs are unstable and can change + * at any time. + */ +@Immutable +@AutoValue +abstract class ImmutableLineData implements LineData { + + ImmutableLineData() {} +} diff --git a/sdk/profiles/src/main/java/io/opentelemetry/sdk/profiles/data/ImmutableLinkData.java b/sdk/profiles/src/main/java/io/opentelemetry/sdk/profiles/data/ImmutableLinkData.java new file mode 100644 index 00000000000..8016d37cb31 --- /dev/null +++ b/sdk/profiles/src/main/java/io/opentelemetry/sdk/profiles/data/ImmutableLinkData.java @@ -0,0 +1,23 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +package io.opentelemetry.sdk.profiles.data; + +import com.google.auto.value.AutoValue; +import javax.annotation.concurrent.Immutable; + +/** + * Auto value implementation of {@link LinkData}, which represents a connection from a profile + * Sample to a trace Span. + * + *

This class is internal and is hence not for public use. Its APIs are unstable and can change + * at any time. + */ +@Immutable +@AutoValue +abstract class ImmutableLinkData implements LinkData { + + ImmutableLinkData() {} +} diff --git a/sdk/profiles/src/main/java/io/opentelemetry/sdk/profiles/data/ImmutableLocationData.java b/sdk/profiles/src/main/java/io/opentelemetry/sdk/profiles/data/ImmutableLocationData.java new file mode 100644 index 00000000000..2b8c66f356c --- /dev/null +++ b/sdk/profiles/src/main/java/io/opentelemetry/sdk/profiles/data/ImmutableLocationData.java @@ -0,0 +1,23 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +package io.opentelemetry.sdk.profiles.data; + +import com.google.auto.value.AutoValue; +import javax.annotation.concurrent.Immutable; + +/** + * Auto value implementation of {@link LocationData}, which describes function and line table debug + * information. + * + *

This class is internal and is hence not for public use. Its APIs are unstable and can change + * at any time. + */ +@Immutable +@AutoValue +abstract class ImmutableLocationData implements LocationData { + + ImmutableLocationData() {} +} diff --git a/sdk/profiles/src/main/java/io/opentelemetry/sdk/profiles/data/ImmutableMappingData.java b/sdk/profiles/src/main/java/io/opentelemetry/sdk/profiles/data/ImmutableMappingData.java new file mode 100644 index 00000000000..a52bcbb0bc2 --- /dev/null +++ b/sdk/profiles/src/main/java/io/opentelemetry/sdk/profiles/data/ImmutableMappingData.java @@ -0,0 +1,23 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +package io.opentelemetry.sdk.profiles.data; + +import com.google.auto.value.AutoValue; +import javax.annotation.concurrent.Immutable; + +/** + * Auto value implementation of {@link MappingData}, which describes the mapping of a binary in + * memory. + * + *

This class is internal and is hence not for public use. Its APIs are unstable and can change + * at any time. + */ +@Immutable +@AutoValue +abstract class ImmutableMappingData implements MappingData { + + ImmutableMappingData() {} +} diff --git a/sdk/profiles/src/main/java/io/opentelemetry/sdk/profiles/data/ImmutableProfileData.java b/sdk/profiles/src/main/java/io/opentelemetry/sdk/profiles/data/ImmutableProfileData.java new file mode 100644 index 00000000000..383afe17d4a --- /dev/null +++ b/sdk/profiles/src/main/java/io/opentelemetry/sdk/profiles/data/ImmutableProfileData.java @@ -0,0 +1,23 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +package io.opentelemetry.sdk.profiles.data; + +import com.google.auto.value.AutoValue; +import javax.annotation.concurrent.Immutable; + +/** + * Auto value implementation of {@link ProfileData}, which represents a complete profile, including + * sample types, samples, mappings to binaries, locations, and additional metadata. + * + *

This class is internal and is hence not for public use. Its APIs are unstable and can change + * at any time. + */ +@Immutable +@AutoValue +abstract class ImmutableProfileData implements ProfileData { + + ImmutableProfileData() {} +} diff --git a/sdk/profiles/src/main/java/io/opentelemetry/sdk/profiles/data/ImmutableProfilesDictionaryData.java b/sdk/profiles/src/main/java/io/opentelemetry/sdk/profiles/data/ImmutableProfilesDictionaryData.java new file mode 100644 index 00000000000..da3ccc15166 --- /dev/null +++ b/sdk/profiles/src/main/java/io/opentelemetry/sdk/profiles/data/ImmutableProfilesDictionaryData.java @@ -0,0 +1,23 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +package io.opentelemetry.sdk.profiles.data; + +import com.google.auto.value.AutoValue; +import javax.annotation.concurrent.Immutable; + +/** + * Auto value implementation of {@link ProfilesDictionaryData}, which represents profiles data + * shared across the entire message being sent. + * + *

This class is internal and is hence not for public use. Its APIs are unstable and can change + * at any time. + */ +@Immutable +@AutoValue +abstract class ImmutableProfilesDictionaryData implements ProfilesDictionaryData { + + ImmutableProfilesDictionaryData() {} +} diff --git a/sdk/profiles/src/main/java/io/opentelemetry/sdk/profiles/data/ImmutableSampleData.java b/sdk/profiles/src/main/java/io/opentelemetry/sdk/profiles/data/ImmutableSampleData.java new file mode 100644 index 00000000000..972a3624bac --- /dev/null +++ b/sdk/profiles/src/main/java/io/opentelemetry/sdk/profiles/data/ImmutableSampleData.java @@ -0,0 +1,23 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +package io.opentelemetry.sdk.profiles.data; + +import com.google.auto.value.AutoValue; +import javax.annotation.concurrent.Immutable; + +/** + * Auto value implementation of {@link SampleData}, which records values encountered in some program + * context. + * + *

This class is internal and is hence not for public use. Its APIs are unstable and can change + * at any time. + */ +@Immutable +@AutoValue +abstract class ImmutableSampleData implements SampleData { + + ImmutableSampleData() {} +} diff --git a/sdk/profiles/src/main/java/io/opentelemetry/sdk/profiles/data/ImmutableStackData.java b/sdk/profiles/src/main/java/io/opentelemetry/sdk/profiles/data/ImmutableStackData.java new file mode 100644 index 00000000000..266c99302ef --- /dev/null +++ b/sdk/profiles/src/main/java/io/opentelemetry/sdk/profiles/data/ImmutableStackData.java @@ -0,0 +1,23 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +package io.opentelemetry.sdk.profiles.data; + +import com.google.auto.value.AutoValue; +import javax.annotation.concurrent.Immutable; + +/** + * Auto value implementation of {@link StackData}, which records a list of locations, starting from + * the leaf frame. + * + *

This class is internal and is hence not for public use. Its APIs are unstable and can change + * at any time. + */ +@Immutable +@AutoValue +abstract class ImmutableStackData implements StackData { + + ImmutableStackData() {} +} diff --git a/sdk/profiles/src/main/java/io/opentelemetry/sdk/profiles/data/ImmutableValueTypeData.java b/sdk/profiles/src/main/java/io/opentelemetry/sdk/profiles/data/ImmutableValueTypeData.java new file mode 100644 index 00000000000..f4d9547f10e --- /dev/null +++ b/sdk/profiles/src/main/java/io/opentelemetry/sdk/profiles/data/ImmutableValueTypeData.java @@ -0,0 +1,23 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +package io.opentelemetry.sdk.profiles.data; + +import com.google.auto.value.AutoValue; +import javax.annotation.concurrent.Immutable; + +/** + * Auto value implementation of {@link ValueTypeData}, which describes the type and units of a + * value. + * + *

This class is internal and is hence not for public use. Its APIs are unstable and can change + * at any time. + */ +@Immutable +@AutoValue +abstract class ImmutableValueTypeData implements ValueTypeData { + + ImmutableValueTypeData() {} +} diff --git a/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/KeyValueAndUnitData.java b/sdk/profiles/src/main/java/io/opentelemetry/sdk/profiles/data/KeyValueAndUnitData.java similarity index 61% rename from exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/KeyValueAndUnitData.java rename to sdk/profiles/src/main/java/io/opentelemetry/sdk/profiles/data/KeyValueAndUnitData.java index ef0fe7e310b..ff3cc0a8fe7 100644 --- a/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/KeyValueAndUnitData.java +++ b/sdk/profiles/src/main/java/io/opentelemetry/sdk/profiles/data/KeyValueAndUnitData.java @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -package io.opentelemetry.exporter.otlp.profiles; +package io.opentelemetry.sdk.profiles.data; import io.opentelemetry.api.common.Value; @@ -16,6 +16,13 @@ */ public interface KeyValueAndUnitData { + /** Returns a {@link KeyValueAndUnitData} for the given parameters. */ + @SuppressWarnings("AutoValueSubclassLeaked") + static ImmutableKeyValueAndUnitData create( + int keyStringIndex, Value value, int unitStringIndex) { + return new AutoValue_ImmutableKeyValueAndUnitData(keyStringIndex, value, unitStringIndex); + } + /** Index into string table. */ int getKeyStringIndex(); diff --git a/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/LineData.java b/sdk/profiles/src/main/java/io/opentelemetry/sdk/profiles/data/LineData.java similarity index 54% rename from exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/LineData.java rename to sdk/profiles/src/main/java/io/opentelemetry/sdk/profiles/data/LineData.java index 7f5c4738ceb..89198eead34 100644 --- a/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/LineData.java +++ b/sdk/profiles/src/main/java/io/opentelemetry/sdk/profiles/data/LineData.java @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -package io.opentelemetry.exporter.otlp.profiles; +package io.opentelemetry.sdk.profiles.data; import javax.annotation.concurrent.Immutable; @@ -15,6 +15,16 @@ @Immutable public interface LineData { + /** + * Returns a new LineData describing the given details a specific line in a source code. + * + * @return a new LineData describing the given details a specific line in a source code. + */ + @SuppressWarnings("AutoValueSubclassLeaked") + static LineData create(int functionIndex, long line, long column) { + return new AutoValue_ImmutableLineData(functionIndex, line, column); + } + /** The index of the corresponding Function for this line. Index into function table. */ int getFunctionIndex(); diff --git a/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/LinkData.java b/sdk/profiles/src/main/java/io/opentelemetry/sdk/profiles/data/LinkData.java similarity index 58% rename from exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/LinkData.java rename to sdk/profiles/src/main/java/io/opentelemetry/sdk/profiles/data/LinkData.java index ea3c1e1d7b8..4daf3d0fbf0 100644 --- a/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/LinkData.java +++ b/sdk/profiles/src/main/java/io/opentelemetry/sdk/profiles/data/LinkData.java @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -package io.opentelemetry.exporter.otlp.profiles; +package io.opentelemetry.sdk.profiles.data; import javax.annotation.concurrent.Immutable; @@ -15,6 +15,16 @@ @Immutable public interface LinkData { + /** + * Returns a new LinkData representing an association to the given trace span. + * + * @return a new LinkData representing an association to the given trace span. + */ + @SuppressWarnings("AutoValueSubclassLeaked") + static LinkData create(String traceId, String spanId) { + return new AutoValue_ImmutableLinkData(traceId, spanId); + } + /** * Returns a unique identifier of a trace that this linked span is part of as 32 character * lowercase hex String. diff --git a/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/LocationData.java b/sdk/profiles/src/main/java/io/opentelemetry/sdk/profiles/data/LocationData.java similarity index 63% rename from exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/LocationData.java rename to sdk/profiles/src/main/java/io/opentelemetry/sdk/profiles/data/LocationData.java index 5233766f7f3..83e8eb156dd 100644 --- a/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/LocationData.java +++ b/sdk/profiles/src/main/java/io/opentelemetry/sdk/profiles/data/LocationData.java @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -package io.opentelemetry.exporter.otlp.profiles; +package io.opentelemetry.sdk.profiles.data; import java.util.List; import javax.annotation.concurrent.Immutable; @@ -16,6 +16,17 @@ @Immutable public interface LocationData { + /** + * Returns a new LocationData describing the given function and line table information. + * + * @return a new LocationData describing the given function and line table information. + */ + @SuppressWarnings("AutoValueSubclassLeaked") + static LocationData create( + int mappingIndex, long address, List lines, List attributeIndices) { + return new AutoValue_ImmutableLocationData(mappingIndex, address, lines, attributeIndices); + } + /** * The index of the corresponding profile.Mapping for this location. It can be 0 if the mapping is * unknown or not applicable for this profile type. diff --git a/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/MappingData.java b/sdk/profiles/src/main/java/io/opentelemetry/sdk/profiles/data/MappingData.java similarity index 60% rename from exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/MappingData.java rename to sdk/profiles/src/main/java/io/opentelemetry/sdk/profiles/data/MappingData.java index 09ac08c086e..363d50fbd90 100644 --- a/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/MappingData.java +++ b/sdk/profiles/src/main/java/io/opentelemetry/sdk/profiles/data/MappingData.java @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -package io.opentelemetry.exporter.otlp.profiles; +package io.opentelemetry.sdk.profiles.data; import java.util.List; import javax.annotation.concurrent.Immutable; @@ -16,6 +16,22 @@ @Immutable public interface MappingData { + /** + * Returns a new MappingData describing the given mapping of a binary in memory. + * + * @return a new MappingData describing the given mapping of a binary in memory. + */ + @SuppressWarnings({"TooManyParameters", "AutoValueSubclassLeaked"}) + static MappingData create( + long memoryStart, + long memoryLimit, + long fileOffset, + int filenameStringIndex, + List attributeIndices) { + return new AutoValue_ImmutableMappingData( + memoryStart, memoryLimit, fileOffset, filenameStringIndex, attributeIndices); + } + /** Address at which the binary (or DLL) is loaded into memory. */ long getMemoryStart(); diff --git a/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/ProfileData.java b/sdk/profiles/src/main/java/io/opentelemetry/sdk/profiles/data/ProfileData.java similarity index 73% rename from exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/ProfileData.java rename to sdk/profiles/src/main/java/io/opentelemetry/sdk/profiles/data/ProfileData.java index 0ab7ce79f86..892893b4ea5 100644 --- a/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/ProfileData.java +++ b/sdk/profiles/src/main/java/io/opentelemetry/sdk/profiles/data/ProfileData.java @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -package io.opentelemetry.exporter.otlp.profiles; +package io.opentelemetry.sdk.profiles.data; import io.opentelemetry.api.internal.OtelEncodingUtils; import io.opentelemetry.sdk.common.InstrumentationScopeInfo; @@ -22,6 +22,44 @@ @Immutable public interface ProfileData { + /** + * Returns a new ProfileData representing the given data. + * + * @return a new ProfileData representing the given data. + */ + @SuppressWarnings({"TooManyParameters", "AutoValueSubclassLeaked"}) + static ProfileData create( + Resource resource, + InstrumentationScopeInfo instrumentationScopeInfo, + ProfilesDictionaryData profilesDictionaryData, + ValueTypeData sampleType, + List samples, + long timeNanos, + long durationNanos, + ValueTypeData periodType, + long period, + String profileId, + int droppedAttributesCount, + String originalPayloadFormat, + ByteBuffer originalPayload, + List attributeIndices) { + return new AutoValue_ImmutableProfileData( + resource, + instrumentationScopeInfo, + profilesDictionaryData, + sampleType, + samples, + timeNanos, + durationNanos, + periodType, + period, + profileId, + droppedAttributesCount, + originalPayloadFormat, + originalPayload, + attributeIndices); + } + /** Returns the resource of this profile. */ Resource getResource(); diff --git a/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/ProfilesDictionaryData.java b/sdk/profiles/src/main/java/io/opentelemetry/sdk/profiles/data/ProfilesDictionaryData.java similarity index 58% rename from exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/ProfilesDictionaryData.java rename to sdk/profiles/src/main/java/io/opentelemetry/sdk/profiles/data/ProfilesDictionaryData.java index 441855247b6..f1add24a96a 100644 --- a/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/ProfilesDictionaryData.java +++ b/sdk/profiles/src/main/java/io/opentelemetry/sdk/profiles/data/ProfilesDictionaryData.java @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -package io.opentelemetry.exporter.otlp.profiles; +package io.opentelemetry.sdk.profiles.data; import java.util.List; import javax.annotation.concurrent.Immutable; @@ -16,6 +16,30 @@ @Immutable public interface ProfilesDictionaryData { + /** + * Returns a new ProfileData representing the given data. + * + * @return a new ProfileData representing the given data. + */ + @SuppressWarnings({"TooManyParameters", "AutoValueSubclassLeaked"}) + static ProfilesDictionaryData create( + List mappingTable, + List locationTable, + List functionTable, + List linkTable, + List stringTable, + List attributeTable, + List stackTable) { + return new AutoValue_ImmutableProfilesDictionaryData( + mappingTable, + locationTable, + functionTable, + linkTable, + stringTable, + attributeTable, + stackTable); + } + /** * Mapping from address ranges to the image/binary/library mapped into that address range. * mapping[0] will be the main binary. diff --git a/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/SampleData.java b/sdk/profiles/src/main/java/io/opentelemetry/sdk/profiles/data/SampleData.java similarity index 70% rename from exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/SampleData.java rename to sdk/profiles/src/main/java/io/opentelemetry/sdk/profiles/data/SampleData.java index ea96ad7774f..af2958a0317 100644 --- a/exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/SampleData.java +++ b/sdk/profiles/src/main/java/io/opentelemetry/sdk/profiles/data/SampleData.java @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -package io.opentelemetry.exporter.otlp.profiles; +package io.opentelemetry.sdk.profiles.data; import java.util.List; import javax.annotation.concurrent.Immutable; @@ -24,6 +24,22 @@ @Immutable public interface SampleData { + /** + * Returns a new SampleData representing the given program context. + * + * @return a new SampleData representing the given program context. + */ + @SuppressWarnings("AutoValueSubclassLeaked") + static SampleData create( + int stackIndex, + List attributeIndices, + int linkIndex, + List values, + List timestamps) { + return new AutoValue_ImmutableSampleData( + stackIndex, attributeIndices, linkIndex, values, timestamps); + } + /** Reference to stack in Profile.stack_table. */ int getStackIndex(); diff --git a/sdk/profiles/src/main/java/io/opentelemetry/sdk/profiles/data/StackData.java b/sdk/profiles/src/main/java/io/opentelemetry/sdk/profiles/data/StackData.java new file mode 100644 index 00000000000..465084c710d --- /dev/null +++ b/sdk/profiles/src/main/java/io/opentelemetry/sdk/profiles/data/StackData.java @@ -0,0 +1,30 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +package io.opentelemetry.sdk.profiles.data; + +import java.util.List; +import javax.annotation.concurrent.Immutable; + +/** + * A Stack represents a list of locations. The first location is the leaf frame. + * + * @see "profiles.proto::Stack" + */ +@Immutable +public interface StackData { + + /** + * Returns a new StackData representing the given list of frames. + * + * @return a new StackData representing the given list of frames. + */ + @SuppressWarnings("AutoValueSubclassLeaked") + static StackData create(List locationIndices) { + return new AutoValue_ImmutableStackData(locationIndices); + } + + List getLocationIndices(); +} diff --git a/sdk/profiles/src/main/java/io/opentelemetry/sdk/profiles/data/ValueTypeData.java b/sdk/profiles/src/main/java/io/opentelemetry/sdk/profiles/data/ValueTypeData.java new file mode 100644 index 00000000000..61ead44b0e8 --- /dev/null +++ b/sdk/profiles/src/main/java/io/opentelemetry/sdk/profiles/data/ValueTypeData.java @@ -0,0 +1,33 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +package io.opentelemetry.sdk.profiles.data; + +import javax.annotation.concurrent.Immutable; + +/** + * ValueType describes the type and units of a value. + * + * @see "profiles.proto::ValueType" + */ +@Immutable +public interface ValueTypeData { + + /** + * Returns a new ValueTypeData describing the given type and unit characteristics. + * + * @return a new ValueTypeData describing the given type and unit characteristics. + */ + @SuppressWarnings("AutoValueSubclassLeaked") + static ValueTypeData create(int typeStringIndex, int unitStringIndex) { + return new AutoValue_ImmutableValueTypeData(typeStringIndex, unitStringIndex); + } + + /** Index into string table. */ + int getTypeStringIndex(); + + /** Index into string table. */ + int getUnitStringIndex(); +} diff --git a/sdk/profiles/src/main/java/io/opentelemetry/sdk/profiles/package-info.java b/sdk/profiles/src/main/java/io/opentelemetry/sdk/profiles/package-info.java new file mode 100644 index 00000000000..6e53e2e7c37 --- /dev/null +++ b/sdk/profiles/src/main/java/io/opentelemetry/sdk/profiles/package-info.java @@ -0,0 +1,10 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/** The sdk to support profiles signal. */ +@ParametersAreNonnullByDefault +package io.opentelemetry.sdk.profiles; + +import javax.annotation.ParametersAreNonnullByDefault; diff --git a/exporters/otlp/profiles/src/test/java/io/opentelemetry/exporter/otlp/profiles/DictionaryTableTest.java b/sdk/profiles/src/test/java/io/opentelemetry/sdk/profiles/DictionaryTableTest.java similarity index 95% rename from exporters/otlp/profiles/src/test/java/io/opentelemetry/exporter/otlp/profiles/DictionaryTableTest.java rename to sdk/profiles/src/test/java/io/opentelemetry/sdk/profiles/DictionaryTableTest.java index 797d6f7c06c..95337956862 100644 --- a/exporters/otlp/profiles/src/test/java/io/opentelemetry/exporter/otlp/profiles/DictionaryTableTest.java +++ b/sdk/profiles/src/test/java/io/opentelemetry/sdk/profiles/DictionaryTableTest.java @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -package io.opentelemetry.exporter.otlp.profiles; +package io.opentelemetry.sdk.profiles; import static org.assertj.core.api.Assertions.assertThat; diff --git a/exporters/otlp/profiles/src/test/java/io/opentelemetry/exporter/otlp/profiles/ProfilesDictionaryCompositorTest.java b/sdk/profiles/src/test/java/io/opentelemetry/sdk/profiles/ProfilesDictionaryCompositorTest.java similarity index 74% rename from exporters/otlp/profiles/src/test/java/io/opentelemetry/exporter/otlp/profiles/ProfilesDictionaryCompositorTest.java rename to sdk/profiles/src/test/java/io/opentelemetry/sdk/profiles/ProfilesDictionaryCompositorTest.java index f3258afb0aa..3c92469f58e 100644 --- a/exporters/otlp/profiles/src/test/java/io/opentelemetry/exporter/otlp/profiles/ProfilesDictionaryCompositorTest.java +++ b/sdk/profiles/src/test/java/io/opentelemetry/sdk/profiles/ProfilesDictionaryCompositorTest.java @@ -3,17 +3,18 @@ * SPDX-License-Identifier: Apache-2.0 */ -package io.opentelemetry.exporter.otlp.profiles; +package io.opentelemetry.sdk.profiles; import static org.assertj.core.api.Assertions.assertThat; import io.opentelemetry.api.common.Value; -import io.opentelemetry.exporter.otlp.internal.data.ImmutableFunctionData; -import io.opentelemetry.exporter.otlp.internal.data.ImmutableKeyValueAndUnitData; -import io.opentelemetry.exporter.otlp.internal.data.ImmutableLinkData; -import io.opentelemetry.exporter.otlp.internal.data.ImmutableLocationData; -import io.opentelemetry.exporter.otlp.internal.data.ImmutableMappingData; -import io.opentelemetry.exporter.otlp.internal.data.ImmutableStackData; +import io.opentelemetry.sdk.profiles.data.FunctionData; +import io.opentelemetry.sdk.profiles.data.KeyValueAndUnitData; +import io.opentelemetry.sdk.profiles.data.LinkData; +import io.opentelemetry.sdk.profiles.data.LocationData; +import io.opentelemetry.sdk.profiles.data.MappingData; +import io.opentelemetry.sdk.profiles.data.ProfilesDictionaryData; +import io.opentelemetry.sdk.profiles.data.StackData; import java.util.Arrays; import java.util.Collections; import org.junit.jupiter.api.BeforeEach; @@ -42,8 +43,8 @@ void hasInitialZeroElements() { @Test void handlesMappings() { - MappingData a = ImmutableMappingData.create(1, 2, 3, 4, Collections.emptyList()); - MappingData b = ImmutableMappingData.create(2, 3, 4, 5, Collections.emptyList()); + MappingData a = MappingData.create(1, 2, 3, 4, Collections.emptyList()); + MappingData b = MappingData.create(2, 3, 4, 5, Collections.emptyList()); assertThat(compositor.putIfAbsent(a)).isEqualTo(1); assertThat(compositor.putIfAbsent(a)).isEqualTo(1); @@ -57,10 +58,8 @@ void handlesMappings() { @Test void handlesLocations() { - LocationData a = - ImmutableLocationData.create(1, 2, Collections.emptyList(), Collections.emptyList()); - LocationData b = - ImmutableLocationData.create(3, 4, Collections.emptyList(), Collections.emptyList()); + LocationData a = LocationData.create(1, 2, Collections.emptyList(), Collections.emptyList()); + LocationData b = LocationData.create(3, 4, Collections.emptyList(), Collections.emptyList()); assertThat(compositor.putIfAbsent(a)).isEqualTo(1); assertThat(compositor.putIfAbsent(a)).isEqualTo(1); @@ -74,8 +73,8 @@ void handlesLocations() { @Test void handlesFunctions() { - FunctionData a = ImmutableFunctionData.create(1, 2, 3, 4); - FunctionData b = ImmutableFunctionData.create(5, 6, 7, 8); + FunctionData a = FunctionData.create(1, 2, 3, 4); + FunctionData b = FunctionData.create(5, 6, 7, 8); assertThat(compositor.putIfAbsent(a)).isEqualTo(1); assertThat(compositor.putIfAbsent(a)).isEqualTo(1); @@ -89,8 +88,8 @@ void handlesFunctions() { @Test void handlesLinks() { - LinkData a = ImmutableLinkData.create("a1", "a2"); - LinkData b = ImmutableLinkData.create("b1", "b2"); + LinkData a = LinkData.create("a1", "a2"); + LinkData b = LinkData.create("b1", "b2"); assertThat(compositor.putIfAbsent(a)).isEqualTo(1); assertThat(compositor.putIfAbsent(a)).isEqualTo(1); @@ -119,8 +118,8 @@ void handlesStrings() { @Test void handlesAttributes() { - KeyValueAndUnitData a = ImmutableKeyValueAndUnitData.create(1, Value.of("a"), 2); - KeyValueAndUnitData b = ImmutableKeyValueAndUnitData.create(3, Value.of("b"), 4); + KeyValueAndUnitData a = KeyValueAndUnitData.create(1, Value.of("a"), 2); + KeyValueAndUnitData b = KeyValueAndUnitData.create(3, Value.of("b"), 4); assertThat(compositor.putIfAbsent(a)).isEqualTo(1); assertThat(compositor.putIfAbsent(a)).isEqualTo(1); @@ -134,8 +133,8 @@ void handlesAttributes() { @Test void handlesStacks() { - StackData a = ImmutableStackData.create(Arrays.asList(1, 2)); - StackData b = ImmutableStackData.create(Arrays.asList(3, 4)); + StackData a = StackData.create(Arrays.asList(1, 2)); + StackData b = StackData.create(Arrays.asList(3, 4)); assertThat(compositor.putIfAbsent(a)).isEqualTo(1); assertThat(compositor.putIfAbsent(a)).isEqualTo(1); diff --git a/exporters/otlp/profiles/src/test/java/io/opentelemetry/exporter/otlp/profiles/SampleCompositionTest.java b/sdk/profiles/src/test/java/io/opentelemetry/sdk/profiles/SampleCompositionTest.java similarity index 96% rename from exporters/otlp/profiles/src/test/java/io/opentelemetry/exporter/otlp/profiles/SampleCompositionTest.java rename to sdk/profiles/src/test/java/io/opentelemetry/sdk/profiles/SampleCompositionTest.java index a4ae1f75f8a..48fabfe3bf7 100644 --- a/exporters/otlp/profiles/src/test/java/io/opentelemetry/exporter/otlp/profiles/SampleCompositionTest.java +++ b/sdk/profiles/src/test/java/io/opentelemetry/sdk/profiles/SampleCompositionTest.java @@ -3,10 +3,11 @@ * SPDX-License-Identifier: Apache-2.0 */ -package io.opentelemetry.exporter.otlp.profiles; +package io.opentelemetry.sdk.profiles; import static org.assertj.core.api.Assertions.assertThat; +import io.opentelemetry.sdk.profiles.data.SampleData; import java.util.ArrayList; import java.util.Collections; import java.util.List; diff --git a/settings.gradle.kts b/settings.gradle.kts index 8ba7a5f6003..08ec99f7605 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -56,12 +56,14 @@ include(":integration-tests:graal") include(":integration-tests:graal-incubating") include(":javadoc-crawler") include(":opencensus-shim") +include(":opentelemetry-jfr-profiles-shim") include(":opentracing-shim") include(":perf-harness") include(":sdk:all") include(":sdk:common") include(":sdk:logs") include(":sdk:metrics") +include(":sdk:profiles") include(":sdk:testing") include(":sdk:trace") include(":sdk:trace-shaded-deps")