Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dependencyManagement/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ val DEPENDENCIES = listOf(
"io.jaegertracing:jaeger-client:1.8.1",
"io.opentelemetry.contrib:opentelemetry-aws-xray-propagator:1.46.0-alpha",
"io.opentelemetry.semconv:opentelemetry-semconv-incubating:1.32.0-alpha",
"io.opentelemetry.proto:opentelemetry-proto:1.5.0-alpha",
"io.opentelemetry.proto:opentelemetry-proto:1.7.0-alpha",
"io.opentracing:opentracing-api:0.33.0",
"io.opentracing:opentracing-noop:0.33.0",
"junit:junit:4.13.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,8 @@
package io.opentelemetry.exporter.otlp.internal.data;

import com.google.auto.value.AutoValue;
import io.opentelemetry.exporter.internal.otlp.AttributeKeyValue;
import io.opentelemetry.exporter.otlp.profiles.AttributeUnitData;
import io.opentelemetry.exporter.otlp.profiles.FunctionData;
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.ProfileData;
import io.opentelemetry.exporter.otlp.profiles.ProfileDictionaryData;
import io.opentelemetry.exporter.otlp.profiles.SampleData;
import io.opentelemetry.exporter.otlp.profiles.ValueTypeData;
import io.opentelemetry.sdk.common.InstrumentationScopeInfo;
Expand All @@ -23,8 +18,7 @@

/**
* Auto value implementation of {@link ProfileData}, which represents a complete profile, including
* sample types, samples, mappings to binaries, locations, functions, string table, and additional
* metadata.
* sample types, samples, mappings to binaries, locations, and additional metadata.
*
* <p>This class is internal and is hence not for public use. Its APIs are unstable and can change
* at any time.
Expand All @@ -42,16 +36,10 @@ public abstract class ImmutableProfileData implements ProfileData {
public static ProfileData create(
Resource resource,
InstrumentationScopeInfo instrumentationScopeInfo,
ProfileDictionaryData profileDictionaryData,
List<ValueTypeData> sampleTypes,
List<SampleData> samples,
List<MappingData> mappingTable,
List<LocationData> locationTable,
List<Integer> locationIndices,
List<FunctionData> functionTable,
List<AttributeKeyValue<?>> attributeTable,
List<AttributeUnitData> attributeUnits,
List<LinkData> linkTable,
List<String> stringTable,
long timeNanos,
long durationNanos,
ValueTypeData periodType,
Expand All @@ -66,16 +54,10 @@ public static ProfileData create(
return new AutoValue_ImmutableProfileData(
resource,
instrumentationScopeInfo,
profileDictionaryData,
sampleTypes,
samples,
mappingTable,
locationTable,
locationIndices,
functionTable,
attributeTable,
attributeUnits,
linkTable,
stringTable,
timeNanos,
durationNanos,
periodType,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* 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.internal.otlp.AttributeKeyValue;
import io.opentelemetry.exporter.otlp.profiles.AttributeUnitData;
import io.opentelemetry.exporter.otlp.profiles.FunctionData;
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.ProfileDictionaryData;
import java.util.List;
import javax.annotation.concurrent.Immutable;

/**
* Auto value implementation of {@link ProfileDictionaryData}, which represents profiles data shared
* across the entire message being sent.
*
* <p>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 ImmutableProfileDictionaryData implements ProfileDictionaryData {

/**
* Returns a new ProfileData representing the given data.
*
* @return a new ProfileData representing the given data.
*/
@SuppressWarnings("TooManyParameters")
public static ProfileDictionaryData create(
List<MappingData> mappingTable,
List<LocationData> locationTable,
List<FunctionData> functionTable,
List<AttributeKeyValue<?>> attributeTable,
List<AttributeUnitData> attributeUnits,
List<LinkData> linkTable,
List<String> stringTable) {
return new AutoValue_ImmutableProfileDictionaryData(
mappingTable,
locationTable,
functionTable,
attributeTable,
attributeUnits,
linkTable,
stringTable);
}

ImmutableProfileDictionaryData() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
package io.opentelemetry.exporter.otlp.profiles;

import io.opentelemetry.api.internal.OtelEncodingUtils;
import io.opentelemetry.exporter.internal.otlp.AttributeKeyValue;
import io.opentelemetry.sdk.common.InstrumentationScopeInfo;
import io.opentelemetry.sdk.resources.Resource;
import java.nio.ByteBuffer;
Expand All @@ -16,7 +15,7 @@

/**
* Represents a complete profile, including sample types, samples, mappings to binaries, locations,
* functions, string table, and additional metadata.
* and additional metadata.
*
* @see "profiles.proto::Profile"
*/
Expand All @@ -29,41 +28,18 @@ public interface ProfileData {
/** Returns the instrumentation scope that generated this profile. */
InstrumentationScopeInfo getInstrumentationScopeInfo();

/** Returns the dictionary data of this profile. */
ProfileDictionaryData getProfileDictionaryData();

/** A description of the samples associated with each Sample.value. */
List<ValueTypeData> getSampleTypes();

/** The set of samples recorded in this profile. */
List<SampleData> getSamples();

/**
* Mapping from address ranges to the image/binary/library mapped into that address range.
* mapping[0] will be the main binary.
*/
List<MappingData> getMappingTable();

/** Locations referenced by samples via location_indices. */
List<LocationData> getLocationTable();

/** Array of locations referenced by samples. */
List<Integer> getLocationIndices();

/** Functions referenced by locations. */
List<FunctionData> getFunctionTable();

/** Lookup table for attributes. */
List<AttributeKeyValue<?>> getAttributeTable();

/** Represents a mapping between Attribute Keys and Units. */
List<AttributeUnitData> getAttributeUnits();

/** Lookup table for links. */
List<LinkData> getLinkTable();

/**
* A common table for strings referenced by various messages. string_table[0] must always be "".
*/
List<String> getStringTable();

/** Time of collection (UTC) represented as nanoseconds past the epoch. */
long getTimeNanos();

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/

package io.opentelemetry.exporter.otlp.profiles;

import io.opentelemetry.exporter.internal.otlp.AttributeKeyValue;
import java.util.List;
import javax.annotation.concurrent.Immutable;

/**
* Represents profiles data shared across the entire message being sent.
*
* @see "profiles.proto::ProfilesDictionary"
*/
@Immutable
public interface ProfileDictionaryData {

/**
* Mapping from address ranges to the image/binary/library mapped into that address range.
* mapping[0] will be the main binary.
*/
List<MappingData> getMappingTable();

/** Locations referenced by samples via location_indices. */
List<LocationData> getLocationTable();

/** Functions referenced by locations. */
List<FunctionData> getFunctionTable();

/** Lookup table for attributes. */
List<AttributeKeyValue<?>> getAttributeTable();

/** Represents a mapping between Attribute Keys and Units. */
List<AttributeUnitData> getAttributeUnits();

/** Lookup table for links. */
List<LinkData> getLinkTable();

/**
* A common table for strings referenced by various messages. string_table[0] must always be "".
*/
List<String> getStringTable();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/

package io.opentelemetry.exporter.otlp.profiles;

import io.opentelemetry.exporter.internal.marshal.MarshalerUtil;
import io.opentelemetry.exporter.internal.marshal.MarshalerWithSize;
import io.opentelemetry.exporter.internal.marshal.Serializer;
import io.opentelemetry.exporter.internal.otlp.KeyValueMarshaler;
import io.opentelemetry.proto.profiles.v1development.internal.ProfilesDictionary;
import java.io.IOException;
import java.nio.charset.StandardCharsets;

final class ProfileDictionaryMarshaler extends MarshalerWithSize {

private final MappingMarshaler[] mappingTableMarshalers;
private final LocationMarshaler[] locationTableMarshalers;
private final FunctionMarshaler[] functionTableMarshalers;
private final KeyValueMarshaler[] attributeTableMarshalers;
private final AttributeUnitMarshaler[] attributeUnitMarshalers;
private final LinkMarshaler[] linkTableMarshalers;
private final byte[][] stringTable;

static ProfileDictionaryMarshaler create(ProfileDictionaryData profileDictionaryData) {

MappingMarshaler[] mappingMarshalers =
MappingMarshaler.createRepeated(profileDictionaryData.getMappingTable());
LocationMarshaler[] locationMarshalers =
LocationMarshaler.createRepeated(profileDictionaryData.getLocationTable());
FunctionMarshaler[] functionMarshalers =
FunctionMarshaler.createRepeated(profileDictionaryData.getFunctionTable());
KeyValueMarshaler[] attributeTableMarshalers =
KeyValueMarshaler.createRepeated(profileDictionaryData.getAttributeTable());
AttributeUnitMarshaler[] attributeUnitsMarshalers =
AttributeUnitMarshaler.createRepeated(profileDictionaryData.getAttributeUnits());
LinkMarshaler[] linkMarshalers =
LinkMarshaler.createRepeated(profileDictionaryData.getLinkTable());

byte[][] convertedStrings = new byte[profileDictionaryData.getStringTable().size()][];
for (int i = 0; i < profileDictionaryData.getStringTable().size(); i++) {
convertedStrings[i] =
profileDictionaryData.getStringTable().get(i).getBytes(StandardCharsets.UTF_8);
}

return new ProfileDictionaryMarshaler(
mappingMarshalers,
locationMarshalers,
functionMarshalers,
attributeTableMarshalers,
attributeUnitsMarshalers,
linkMarshalers,
convertedStrings);
}

private ProfileDictionaryMarshaler(
MappingMarshaler[] mappingTableMarshalers,
LocationMarshaler[] locationTableMarshalers,
FunctionMarshaler[] functionTableMarshalers,
KeyValueMarshaler[] attributeTableMarshalers,
AttributeUnitMarshaler[] attributeUnitMarshalers,
LinkMarshaler[] linkTableMarshalers,
byte[][] stringTableUtf8) {
super(
calculateSize(
mappingTableMarshalers,
locationTableMarshalers,
functionTableMarshalers,
attributeTableMarshalers,
attributeUnitMarshalers,
linkTableMarshalers,
stringTableUtf8));
this.mappingTableMarshalers = mappingTableMarshalers;
this.locationTableMarshalers = locationTableMarshalers;
this.functionTableMarshalers = functionTableMarshalers;
this.attributeTableMarshalers = attributeTableMarshalers;
this.attributeUnitMarshalers = attributeUnitMarshalers;
this.linkTableMarshalers = linkTableMarshalers;
this.stringTable = stringTableUtf8;
}

@Override
protected void writeTo(Serializer output) throws IOException {
output.serializeRepeatedMessage(ProfilesDictionary.MAPPING_TABLE, mappingTableMarshalers);
output.serializeRepeatedMessage(ProfilesDictionary.LOCATION_TABLE, locationTableMarshalers);
output.serializeRepeatedMessage(ProfilesDictionary.FUNCTION_TABLE, functionTableMarshalers);
output.serializeRepeatedMessage(ProfilesDictionary.ATTRIBUTE_TABLE, attributeTableMarshalers);
output.serializeRepeatedMessage(ProfilesDictionary.ATTRIBUTE_UNITS, attributeUnitMarshalers);
output.serializeRepeatedMessage(ProfilesDictionary.LINK_TABLE, linkTableMarshalers);
output.serializeRepeatedString(ProfilesDictionary.STRING_TABLE, stringTable);
}

private static int calculateSize(
MappingMarshaler[] mappingMarshalers,
LocationMarshaler[] locationMarshalers,
FunctionMarshaler[] functionMarshalers,
KeyValueMarshaler[] attributeTableMarshalers,
AttributeUnitMarshaler[] attributeUnitMarshalers,
LinkMarshaler[] linkMarshalers,
byte[][] stringTable) {
int size;
size = 0;
size += MarshalerUtil.sizeRepeatedMessage(ProfilesDictionary.MAPPING_TABLE, mappingMarshalers);
size +=
MarshalerUtil.sizeRepeatedMessage(ProfilesDictionary.LOCATION_TABLE, locationMarshalers);
size +=
MarshalerUtil.sizeRepeatedMessage(ProfilesDictionary.FUNCTION_TABLE, functionMarshalers);
size +=
MarshalerUtil.sizeRepeatedMessage(
ProfilesDictionary.ATTRIBUTE_TABLE, attributeTableMarshalers);
size +=
MarshalerUtil.sizeRepeatedMessage(
ProfilesDictionary.ATTRIBUTE_UNITS, attributeUnitMarshalers);
size += MarshalerUtil.sizeRepeatedMessage(ProfilesDictionary.LINK_TABLE, linkMarshalers);
size += MarshalerUtil.sizeRepeatedString(ProfilesDictionary.STRING_TABLE, stringTable);

return size;
}
}
Loading
Loading