Skip to content

Commit

Permalink
fix: Set OTLP logs endpoint when using HTTP_PROTOBUF (#182)
Browse files Browse the repository at this point in the history
  • Loading branch information
manikmagar authored May 21, 2024
1 parent 65840ea commit 45045d7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public class OtlpExporter extends AbstractExporter {
public static final String OTEL_EXPORTER_OTLP_ENDPOINT = "otel.exporter.otlp.endpoint";
public static final String OTEL_EXPORTER_OTLP_TRACES_ENDPOINT = "otel.exporter.otlp.traces.endpoint";
public static final String OTEL_EXPORTER_OTLP_METRICS_ENDPOINT = "otel.exporter.otlp.metrics.endpoint";
public static final String OTEL_EXPORTER_OTLP_LOGS_ENDPOINT = "otel.exporter.otlp.logs.endpoint";
public static final String OTEL_EXPORTER_OTLP_COMPRESSION = "otel.exporter.otlp.compression";
public static final String OTEL_EXPORTER_OTLP_HEADERS = "otel.exporter.otlp.headers";
@Parameter
Expand Down Expand Up @@ -101,6 +102,7 @@ public Map<String, String> getExporterProperties() {
if (protocol.equals(Protocol.HTTP_PROTOBUF)) {
config.put(OTEL_EXPORTER_OTLP_TRACES_ENDPOINT, getSignalEndpoint("traces"));
config.put(OTEL_EXPORTER_OTLP_METRICS_ENDPOINT, getSignalEndpoint("metrics"));
config.put(OTEL_EXPORTER_OTLP_LOGS_ENDPOINT, getSignalEndpoint("logs"));
}
if (!OtlpRequestCompression.NONE.equals(requestCompression)) {
config.put(OTEL_EXPORTER_OTLP_COMPRESSION, requestCompression.getValue());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,17 @@ public void verifyConfigProperties() {
java.util.List<Header> headers = new java.util.ArrayList<>();
headers.add(new Header("test", "value"));
headers.add(new Header("test2", "value2"));
OtlpExporter otlpExporter = new OtlpExporter("http://localhost", OtlpExporter.Protocol.HTTP_PROTOBUF,
OtlpExporter otlpExporter = new OtlpExporter("http://localhost/v1", OtlpExporter.Protocol.HTTP_PROTOBUF,
OtlpExporter.OtlpRequestCompression.GZIP, headers);
assertThat(otlpExporter.getExporterProperties())
.containsEntry(OTEL_TRACES_EXPORTER_KEY, OTLP)
.containsEntry(OTEL_EXPORTER_OTLP_COMPRESSION, OtlpExporter.OtlpRequestCompression.GZIP.getValue())
.containsEntry(OTEL_EXPORTER_OTLP_PROTOCOL, Protocol.HTTP_PROTOBUF.getValue())
.containsEntry(OTEL_EXPORTER_OTLP_HEADERS, "test=value,test2=value2")
.containsEntry(OTEL_EXPORTER_OTLP_ENDPOINT, "http://localhost")
.containsEntry(OTEL_EXPORTER_OTLP_TRACES_ENDPOINT, "http://localhost/traces");
.containsEntry(OTEL_EXPORTER_OTLP_ENDPOINT, "http://localhost/v1")
.containsEntry(OTEL_EXPORTER_OTLP_TRACES_ENDPOINT, "http://localhost/v1/traces")
.containsEntry(OTEL_EXPORTER_OTLP_LOGS_ENDPOINT, "http://localhost/v1/logs")
.containsEntry(OTEL_EXPORTER_OTLP_METRICS_ENDPOINT, "http://localhost/v1/metrics");
}

@Test
Expand Down

0 comments on commit 45045d7

Please sign in to comment.