-
Notifications
You must be signed in to change notification settings - Fork 214
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce otlp/http support #5322
base: main
Are you sure you want to change the base?
Changes from all commits
9cc19b8
0c4e1ed
f7e2d7d
bebcda0
5ca7896
2f84fea
9270dca
c5924fd
d27477e
cdcc631
fb83bef
eb4c1c1
2bcde24
0704d70
8db67d2
32d2646
4acbe0d
354f054
7f65282
6decceb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,12 +10,10 @@ | |
import com.google.protobuf.ByteString; | ||
import io.opentelemetry.proto.collector.metrics.v1.ExportMetricsServiceRequest; | ||
import io.opentelemetry.proto.common.v1.AnyValue; | ||
import io.opentelemetry.proto.common.v1.InstrumentationLibrary; | ||
import io.opentelemetry.proto.common.v1.InstrumentationScope; | ||
import io.opentelemetry.proto.common.v1.KeyValue; | ||
import io.opentelemetry.proto.metrics.v1.Exemplar; | ||
import io.opentelemetry.proto.metrics.v1.Gauge; | ||
import io.opentelemetry.proto.metrics.v1.InstrumentationLibraryMetrics; | ||
import io.opentelemetry.proto.metrics.v1.NumberDataPoint; | ||
import io.opentelemetry.proto.metrics.v1.ResourceMetrics; | ||
import io.opentelemetry.proto.metrics.v1.ScopeMetrics; | ||
|
@@ -71,60 +69,6 @@ void init() { | |
rawProcessor = new OTelMetricsRawProcessor(testsettings, new OtelMetricsRawProcessorConfig()); | ||
} | ||
|
||
@Test | ||
void testInstrumentationLibrary() throws JsonProcessingException { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wouldn't this test still be required for backward compatibility? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @KarstenSchnitter the spec changed happened about 4 years ago. I do not think we need provide backward compatibility. @dlvenable what do you think? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not sure if any customers are using older protocol. In fact, the behavior is broken for new agents for a long time. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If it is broken anyway, I am fine with dropping backward compatibility. |
||
NumberDataPoint.Builder p1 = NumberDataPoint.newBuilder().setAsInt(4); | ||
Gauge gauge = Gauge.newBuilder().addDataPoints(p1).build(); | ||
|
||
io.opentelemetry.proto.metrics.v1.Metric.Builder metric = io.opentelemetry.proto.metrics.v1.Metric.newBuilder() | ||
.setGauge(gauge) | ||
.setUnit("seconds") | ||
.setName("name") | ||
.setDescription("description"); | ||
|
||
InstrumentationLibraryMetrics isntLib = InstrumentationLibraryMetrics.newBuilder() | ||
.addMetrics(metric) | ||
.setInstrumentationLibrary(InstrumentationLibrary.newBuilder() | ||
.setName("ilname") | ||
.setVersion("ilversion") | ||
.build()) | ||
.build(); | ||
|
||
Resource resource = Resource.newBuilder() | ||
.addAttributes(KeyValue.newBuilder() | ||
.setKey("service.name") | ||
.setValue(AnyValue.newBuilder().setStringValue("service").build()) | ||
).build(); | ||
|
||
ResourceMetrics resourceMetrics = ResourceMetrics.newBuilder() | ||
.addInstrumentationLibraryMetrics(isntLib) | ||
.setResource(resource) | ||
.build(); | ||
|
||
ExportMetricsServiceRequest exportMetricRequest = ExportMetricsServiceRequest.newBuilder() | ||
.addResourceMetrics(resourceMetrics).build(); | ||
|
||
Record<ExportMetricsServiceRequest> record = new Record<>(exportMetricRequest); | ||
|
||
Collection<Record<? extends Metric>> records = rawProcessor.doExecute(Collections.singletonList(record)); | ||
List<Record<? extends Metric>> list = new ArrayList<>(records); | ||
|
||
Record<? extends Metric> dataPrepperResult = list.get(0); | ||
ObjectMapper objectMapper = new ObjectMapper(); | ||
Map<String, Object> map = objectMapper.readValue(dataPrepperResult.getData().toJsonString(), Map.class); | ||
assertThat(map).contains(entry("kind", Metric.KIND.GAUGE.toString())); | ||
assertThat(map).contains(entry("unit", "seconds")); | ||
assertThat(map).contains(entry("serviceName", "service")); | ||
assertThat(map).contains(entry("resource.attributes.service@name", "service")); | ||
assertThat(map).contains(entry("description", "description")); | ||
assertThat(map).contains(entry("value", 4.0D)); | ||
assertThat(map).contains(entry("startTime", "1970-01-01T00:00:00Z")); | ||
assertThat(map).contains(entry("time", "1970-01-01T00:00:00Z")); | ||
assertThat(map).contains(entry("instrumentationLibrary.name", "ilname")); | ||
assertThat(map).contains(entry("instrumentationLibrary.version", "ilversion")); | ||
|
||
} | ||
|
||
@Test | ||
void testScopeMetricsLibrary() throws JsonProcessingException { | ||
NumberDataPoint.Builder p1 = NumberDataPoint.newBuilder().setAsInt(4); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know, that instrumentation library was migrated to instrumentation scope. Is this removal required to address the changed data model?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes.
InstrumentaionLibrarySpans
have been removed.Basically the hierarchy has been changed. In 0.16.x
InstrumentationLibrarySpans
carried the span information. Now instrumentation information lives next to the span information inside theScopeSpan
object