Skip to content

Commit 06251ed

Browse files
committed
Add gRPC export for profiles signal type.
Changes per code review feedback
1 parent 7e8fc25 commit 06251ed

File tree

12 files changed

+75
-368
lines changed

12 files changed

+75
-368
lines changed

exporters/otlp/profiles/build.gradle.kts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ dependencies {
1616
implementation(project(":exporters:otlp:common"))
1717

1818
implementation(project(":exporters:otlp:all"))
19-
implementation("io.grpc:grpc-stub")
19+
compileOnly("io.grpc:grpc-stub")
2020

2121
annotationProcessor("com.google.auto.value:auto-value")
2222

@@ -26,4 +26,5 @@ dependencies {
2626
testImplementation("io.opentelemetry.proto:opentelemetry-proto")
2727
testImplementation(project(":exporters:otlp:testing-internal"))
2828
testImplementation(project(":exporters:sender:okhttp"))
29+
testImplementation("io.grpc:grpc-stub")
2930
}

exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/MultiProfilesExporter.java

Lines changed: 0 additions & 104 deletions
This file was deleted.
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@
88
import io.opentelemetry.sdk.common.CompletableResultCode;
99
import java.util.Collection;
1010

11-
final class NoopProfilesExporter implements ProfilesExporter {
11+
final class NoopProfileExporter implements ProfileExporter {
1212

13-
private static final ProfilesExporter INSTANCE = new NoopProfilesExporter();
13+
private static final ProfileExporter INSTANCE = new NoopProfileExporter();
1414

15-
static ProfilesExporter getInstance() {
15+
static ProfileExporter getInstance() {
1616
return INSTANCE;
1717
}
1818

1919
@Override
20-
public CompletableResultCode export(Collection<ProfileData> spans) {
20+
public CompletableResultCode export(Collection<ProfileData> profiles) {
2121
return CompletableResultCode.ofSuccess();
2222
}
2323

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,20 @@
1515

1616
/** Exports profiles using OTLP via gRPC, using OpenTelemetry's protobuf model. */
1717
@ThreadSafe
18-
public class OtlpGrpcProfilesExporter implements ProfilesExporter {
18+
public class OtlpGrpcProfileExporter implements ProfileExporter {
1919

2020
private final GrpcExporterBuilder<Marshaler> builder;
2121
private final GrpcExporter<Marshaler> delegate;
2222

2323
/**
24-
* Returns a new {@link OtlpGrpcProfilesExporter} using the default values.
24+
* Returns a new {@link OtlpGrpcProfileExporter} using the default values.
2525
*
2626
* <p>To load configuration values from environment variables and system properties, use <a
2727
* href="https://github.com/open-telemetry/opentelemetry-java/tree/main/sdk-extensions/autoconfigure">opentelemetry-sdk-extension-autoconfigure</a>.
2828
*
29-
* @return a new {@link OtlpGrpcProfilesExporter} instance.
29+
* @return a new {@link OtlpGrpcProfileExporter} instance.
3030
*/
31-
public static OtlpGrpcProfilesExporter getDefault() {
31+
public static OtlpGrpcProfileExporter getDefault() {
3232
return builder().build();
3333
}
3434

@@ -41,7 +41,7 @@ public static OtlpGrpcProfilesExporterBuilder builder() {
4141
return new OtlpGrpcProfilesExporterBuilder();
4242
}
4343

44-
OtlpGrpcProfilesExporter(
44+
OtlpGrpcProfileExporter(
4545
GrpcExporterBuilder<Marshaler> builder, GrpcExporter<Marshaler> delegate) {
4646
this.builder = builder;
4747
this.delegate = delegate;

exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/OtlpGrpcProfilesExporterBuilder.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ public final class OtlpGrpcProfilesExporterBuilder {
4040
private static final URI DEFAULT_ENDPOINT = URI.create(DEFAULT_ENDPOINT_URL);
4141
private static final long DEFAULT_TIMEOUT_SECS = 10;
4242

43+
// TODO maybe make more efficient by adding support for MEMORY_MODE
44+
4345
// Visible for testing
4446
final GrpcExporterBuilder<Marshaler> delegate;
4547

@@ -227,7 +229,7 @@ public OtlpGrpcProfilesExporterBuilder setExecutorService(ExecutorService execut
227229
*
228230
* @return a new exporter's instance
229231
*/
230-
public OtlpGrpcProfilesExporter build() {
231-
return new OtlpGrpcProfilesExporter(delegate, delegate.build());
232+
public OtlpGrpcProfileExporter build() {
233+
return new OtlpGrpcProfileExporter(delegate, delegate.build());
232234
}
233235
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*
2+
* Copyright The OpenTelemetry Authors
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
package io.opentelemetry.exporter.otlp.profiles;
7+
8+
import io.opentelemetry.sdk.common.CompletableResultCode;
9+
import java.io.Closeable;
10+
import java.util.Collection;
11+
import java.util.concurrent.TimeUnit;
12+
13+
/**
14+
* An interface that allows different profiling services to export recorded data in their own
15+
* format.
16+
*/
17+
public interface ProfileExporter extends Closeable {
18+
19+
/**
20+
* Called to export sampled {@code ProfileData}s. Note that export operations can be performed
21+
* simultaneously depending on the type of processor being used.
22+
*
23+
* @param profiles the collection of sampled profiles to be exported.
24+
* @return the result of the export, which is often an asynchronous operation.
25+
*/
26+
CompletableResultCode export(Collection<ProfileData> profiles);
27+
28+
/**
29+
* Exports the collection of sampled {@code ProfileData}s that have not yet been exported. Note
30+
* that export operations can be performed simultaneously depending on the type of span processor
31+
* being used.
32+
*
33+
* @return the result of the flush, which is often an asynchronous operation.
34+
*/
35+
CompletableResultCode flush();
36+
37+
/**
38+
* Asynchronously terminate operation of the exporter.
39+
*
40+
* @return a {@link CompletableResultCode} which is completed when shutdown completes.
41+
*/
42+
CompletableResultCode shutdown();
43+
44+
/** Closes this {@link ProfileExporter}, releasing any resources. */
45+
@Override
46+
default void close() {
47+
shutdown().join(10, TimeUnit.SECONDS);
48+
}
49+
}

exporters/otlp/profiles/src/main/java/io/opentelemetry/exporter/otlp/profiles/ProfilesExporter.java

Lines changed: 0 additions & 97 deletions
This file was deleted.

exporters/otlp/profiles/src/test/java/io/opentelemetry/exporter/otlp/profiles/FakeTelemetryUtil.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import java.util.Collections;
1515

1616
// TODO eventually merge with io.opentelemetry.exporter.otlp.testing.internal.FakeTelemetryUtil
17-
public class FakeTelemetryUtil {
17+
class FakeTelemetryUtil {
1818

1919
private FakeTelemetryUtil() {}
2020

@@ -25,7 +25,7 @@ private FakeTelemetryUtil() {}
2525
.build();
2626

2727
/** Generate a fake {@link ProfileData}. */
28-
public static ProfileData generateFakeProfileData() {
28+
static ProfileData generateFakeProfileData() {
2929
String profileId = "0123456789abcdef0123456789abcdef";
3030
return ImmutableProfileData.create(
3131
Resource.create(Attributes.empty()),

0 commit comments

Comments
 (0)