Skip to content

Commit

Permalink
Add exporter data model impl for profiling signal type. (#6498)
Browse files Browse the repository at this point in the history
  • Loading branch information
jhalliday authored Jul 8, 2024
1 parent 5ebb37a commit 6b1092a
Show file tree
Hide file tree
Showing 13 changed files with 494 additions and 1 deletion.
2 changes: 2 additions & 0 deletions exporters/otlp/profiles/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@ otelJava.moduleName.set("io.opentelemetry.exporter.otlp.profiles")

dependencies {
api(project(":sdk:common"))

annotationProcessor("com.google.auto.value:auto-value")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* 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.AttributeUnitData;
import javax.annotation.concurrent.Immutable;

/**
* Auto value implementation of {@link AttributeUnitData}, which represents a mapping between
* Attribute Keys and Units.
*
* <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 ImmutableAttributeUnitData implements AttributeUnitData {

/**
* Returns a new AttributeUnitData mapping the given key to the given unit.
*
* @return a new AttributeUnitData mapping the given key to the given unit.
*/
public static AttributeUnitData create(long attributeKey, long unitIndex) {
return new AutoValue_ImmutableAttributeUnitData(attributeKey, unitIndex);
}

ImmutableAttributeUnitData() {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* 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.
*
* <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 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(
long nameIndex, long systemNameIndex, long filenameIndex, long startLine) {
return new AutoValue_ImmutableFunctionData(
nameIndex, systemNameIndex, filenameIndex, startLine);
}

ImmutableFunctionData() {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* 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.LabelData;
import javax.annotation.concurrent.Immutable;

/**
* Auto value implementation of {@link LabelData}, which provides additional context for a sample.
*
* <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 ImmutableLabelData implements LabelData {

/**
* Returns a new LabelData describing the given context for a sample.
*
* @return a new LabelData describing the given context for a sample.
*/
public static LabelData create(long keyIndex, long strIndex, long num, long numUnitIndex) {
return new AutoValue_ImmutableLabelData(keyIndex, strIndex, num, numUnitIndex);
}

ImmutableLabelData() {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* 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.
*
* <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 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(long functionIndex, long line, long column) {
return new AutoValue_ImmutableLineData(functionIndex, line, column);
}

ImmutableLineData() {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* 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.
*
* <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 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() {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* 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.
*
* <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 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(
long mappingIndex,
long address,
List<LineData> lines,
boolean folded,
int typeIndex,
List<Long> attributes) {
return new AutoValue_ImmutableLocationData(
mappingIndex, address, lines, folded, typeIndex, attributes);
}

ImmutableLocationData() {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* 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.BuildIdKind;
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.
*
* <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 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,
long filenameIndex,
long buildIdIndex,
BuildIdKind buildIdKind,
List<Long> attributeIndices,
boolean hasFunctions,
boolean hasFilenames,
boolean hasLineNumbers,
boolean hasInlineFrames) {
return new AutoValue_ImmutableMappingData(
memoryStart,
memoryLimit,
fileOffset,
filenameIndex,
buildIdIndex,
buildIdKind,
attributeIndices,
hasFunctions,
hasFilenames,
hasLineNumbers,
hasInlineFrames);
}

ImmutableMappingData() {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* 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.Attributes;
import io.opentelemetry.exporter.otlp.profiles.ProfileContainerData;
import io.opentelemetry.exporter.otlp.profiles.ProfileData;
import io.opentelemetry.sdk.common.InstrumentationScopeInfo;
import io.opentelemetry.sdk.resources.Resource;
import java.nio.ByteBuffer;
import javax.annotation.Nullable;
import javax.annotation.concurrent.Immutable;

/**
* Auto value implementation of {@link ProfileContainerData}, which represents a single profile.
*
* <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 ImmutableProfileContainerData implements ProfileContainerData {

/**
* Returns a new ProfileContainerData representing the given profile information.
*
* @return a new ProfileContainerData representing the given profile information.
*/
@SuppressWarnings("TooManyParameters")
public static ProfileContainerData create(
Resource resource,
InstrumentationScopeInfo instrumentationScopeInfo,
String profileId,
long startEpochNanos,
long endEpochNanos,
Attributes attributes,
int totalAttributeCount,
@Nullable String originalPayloadFormat,
ByteBuffer originalPayload,
ProfileData profile) {
return new AutoValue_ImmutableProfileContainerData(
resource,
instrumentationScopeInfo,
profileId,
startEpochNanos,
endEpochNanos,
attributes,
totalAttributeCount,
originalPayloadFormat,
originalPayload,
profile);
}

ImmutableProfileContainerData() {}

public ByteBuffer getOriginalPayloadReadOnly() {
return getOriginalPayload().asReadOnlyBuffer();
}
}
Loading

0 comments on commit 6b1092a

Please sign in to comment.