Search in sources :

Example 11 with KeyValue

use of com.vmware.vim25.KeyValue in project data-prepper by opensearch-project.

the class RawEventTest method testRawEventWithAttributes.

@Test
public void testRawEventWithAttributes() {
    final KeyValue childAttr1 = KeyValue.newBuilder().setKey("statement").setValue(AnyValue.newBuilder().setIntValue(1_000).build()).build();
    final KeyValue childAttr2 = KeyValue.newBuilder().setKey("statement.params").setValue(AnyValue.newBuilder().setStringValue("us-east-1").build()).build();
    final Span.Event spanEvent = Span.Event.newBuilder().setName("Error").setTimeUnixNano(1598013600000000321L).addAllAttributes(Arrays.asList(childAttr1, childAttr2)).build();
    final RawEvent rawEvent = RawEvent.buildRawEvent(spanEvent);
    assertThat(rawEvent.getAttributes().size() == 2).isTrue();
    assertThat((Long) rawEvent.getAttributes().get(childAttr1.getKey()) == childAttr1.getValue().getIntValue()).isTrue();
    assertThat(rawEvent.getAttributes().get(OTelProtoHelper.REPLACE_DOT_WITH_AT.apply(childAttr2.getKey())).equals(childAttr2.getValue().getStringValue())).isTrue();
    assertThat(rawEvent.getName().equals("Error")).isTrue();
    assertThat(rawEvent.getTime().equals("2020-08-21T12:40:00.000000321Z")).isTrue();
}
Also used : KeyValue(io.opentelemetry.proto.common.v1.KeyValue) Span(io.opentelemetry.proto.trace.v1.Span) Test(org.junit.Test)

Example 12 with KeyValue

use of com.vmware.vim25.KeyValue in project data-prepper by opensearch-project.

the class RawLinkTest method testRawEventWithAttributes.

@Test
public void testRawEventWithAttributes() throws DecoderException {
    final KeyValue childAttr1 = KeyValue.newBuilder().setKey("statement").setValue(AnyValue.newBuilder().setIntValue(1_000).build()).build();
    final KeyValue childAttr2 = KeyValue.newBuilder().setKey("statement.params").setValue(AnyValue.newBuilder().setStringValue("us-east-1").build()).build();
    final Span.Link spanLink = Span.Link.newBuilder().setSpanId(ByteString.copyFrom(TestUtils.getRandomBytes(8))).setTraceId(ByteString.copyFrom(TestUtils.getRandomBytes(16))).setTraceState("Some State").addAllAttributes(Arrays.asList(childAttr1, childAttr2)).build();
    final RawLink rawLink = RawLink.buildRawLink(spanLink);
    assertThat(rawLink.getAttributes().size() == 2).isTrue();
    assertThat((Long) rawLink.getAttributes().get(childAttr1.getKey()) == childAttr1.getValue().getIntValue()).isTrue();
    assertThat(rawLink.getAttributes().get(OTelProtoHelper.REPLACE_DOT_WITH_AT.apply(childAttr2.getKey())).equals(childAttr2.getValue().getStringValue())).isTrue();
    assertThat(rawLink.getTraceState().equals("Some State")).isTrue();
    assertThat(ByteString.copyFrom(Hex.decodeHex(rawLink.getTraceId())).equals(spanLink.getTraceId())).isTrue();
    assertThat(ByteString.copyFrom(Hex.decodeHex(rawLink.getSpanId())).equals(spanLink.getSpanId())).isTrue();
}
Also used : KeyValue(io.opentelemetry.proto.common.v1.KeyValue) Span(io.opentelemetry.proto.trace.v1.Span) Test(org.junit.Test)

Example 13 with KeyValue

use of com.vmware.vim25.KeyValue in project cs-actions by CloudSlang.

the class DeployOvfTemplateService method getOvfCreateImportSpecParams.

private OvfCreateImportSpecParams getOvfCreateImportSpecParams(final VmInputs vmInputs, final ManagedObjectReference hostSystem, final List ovfNetworkMappings, final List<KeyValue> ovfPropertyMappings) {
    final OvfCreateImportSpecParams params = new OvfCreateImportSpecParams();
    params.setHostSystem(hostSystem);
    params.setDeploymentOption("");
    params.setLocale(String.valueOf(vmInputs.getLocale()));
    params.setEntityName(vmInputs.getVirtualMachineName());
    params.setIpAllocationPolicy(vmInputs.getIpAllocScheme());
    params.setIpProtocol(vmInputs.getIpProtocol());
    params.setDiskProvisioning(vmInputs.getDiskProvisioning());
    params.getNetworkMapping().addAll(ovfNetworkMappings);
    params.getPropertyMapping().addAll(ovfPropertyMappings);
    return params;
}
Also used : OvfCreateImportSpecParams(com.vmware.vim25.OvfCreateImportSpecParams)

Example 14 with KeyValue

use of com.vmware.vim25.KeyValue in project wavefront-proxy by wavefrontHQ.

the class OtlpProtobufUtilsTest method transformSpanConvertsResourceAttributesToAnnotations.

@Test
public void transformSpanConvertsResourceAttributesToAnnotations() {
    List<KeyValue> resourceAttrs = Collections.singletonList(otlpAttribute("r-key", "r-value"));
    wavefront.report.Span expectedSpan = OtlpTestHelpers.wfSpanGenerator(Collections.singletonList(new Annotation("r-key", "r-value"))).build();
    actualSpan = OtlpProtobufUtils.transformSpan(OtlpTestHelpers.otlpSpanGenerator().build(), resourceAttrs, null, null, "test-source");
    assertWFSpanEquals(expectedSpan, actualSpan);
}
Also used : KeyValue(io.opentelemetry.proto.common.v1.KeyValue) Annotation(wavefront.report.Annotation) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 15 with KeyValue

use of com.vmware.vim25.KeyValue in project wavefront-proxy by wavefrontHQ.

the class OtlpProtobufUtilsTest method transformSpanGivesSpanAttributesHigherPrecedenceThanResourceAttributes.

@Test
public void transformSpanGivesSpanAttributesHigherPrecedenceThanResourceAttributes() {
    String key = "the-key";
    Span otlpSpan = OtlpTestHelpers.otlpSpanGenerator().addAttributes(otlpAttribute(key, "span-value")).build();
    List<KeyValue> resourceAttrs = Collections.singletonList(otlpAttribute(key, "rsrc-value"));
    actualSpan = OtlpProtobufUtils.transformSpan(otlpSpan, resourceAttrs, null, null, "test-source");
    assertThat(actualSpan.getAnnotations(), not(hasItem(new Annotation(key, "rsrc-value"))));
    assertThat(actualSpan.getAnnotations(), hasItem(new Annotation(key, "span-value")));
}
Also used : KeyValue(io.opentelemetry.proto.common.v1.KeyValue) ByteString(com.google.protobuf.ByteString) Span(io.opentelemetry.proto.trace.v1.Span) Annotation(wavefront.report.Annotation) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Aggregations

KeyValue (io.opentelemetry.proto.common.v1.KeyValue)15 Test (org.junit.Test)11 ByteString (com.google.protobuf.ByteString)9 Annotation (wavefront.report.Annotation)8 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)6 Span (io.opentelemetry.proto.trace.v1.Span)5 KeyValue (com.vmware.vim25.KeyValue)3 ArrayList (java.util.ArrayList)3 VisibleForTesting (com.google.common.annotations.VisibleForTesting)2 ManagedObjectReference (com.vmware.vim25.ManagedObjectReference)2 OvfCreateImportSpecParams (com.vmware.vim25.OvfCreateImportSpecParams)2 OvfCreateImportSpecResult (com.vmware.vim25.OvfCreateImportSpecResult)2 AnyValue (io.opentelemetry.proto.common.v1.AnyValue)2 ArrayValue (io.opentelemetry.proto.common.v1.ArrayValue)2 GetMoRef (com.vmware.photon.controller.model.adapters.vsphere.util.connection.GetMoRef)1 FinderException (com.vmware.photon.controller.model.adapters.vsphere.util.finders.FinderException)1 HttpNfcLeaseDeviceUrl (com.vmware.vim25.HttpNfcLeaseDeviceUrl)1 HttpNfcLeaseInfo (com.vmware.vim25.HttpNfcLeaseInfo)1 KeyAnyValue (com.vmware.vim25.KeyAnyValue)1 OvfFileItem (com.vmware.vim25.OvfFileItem)1