diff --git a/jetlinks-components/configure-component/pom.xml b/jetlinks-components/configure-component/pom.xml index ca41d05f..a6a54058 100644 --- a/jetlinks-components/configure-component/pom.xml +++ b/jetlinks-components/configure-component/pom.xml @@ -72,7 +72,6 @@ de.ruedigermoeller fst - 2.57 @@ -90,36 +89,53 @@ io.opentelemetry opentelemetry-exporter-logging - 1.14.0 io.opentelemetry opentelemetry-sdk-trace - 1.14.0 io.opentelemetry opentelemetry-sdk - 1.14.0 io.opentelemetry opentelemetry-exporter-jaeger - 1.14.0 + + + + io.opentelemetry + opentelemetry-exporter-common + ${opentelemetry.version} + + + + com.fasterxml.jackson.jr + jackson-jr-objects io.grpc grpc-protobuf - 1.53.0 + + + io.grpc + grpc-netty + + io.grpc grpc-netty-shaded - 1.47.0 + + + io.netty + * + + @@ -133,11 +149,22 @@ ${project.version} + + org.jetlinks.community + timeseries-component + ${project.version} + + com.h2database h2 + + io.lettuce + lettuce-core + + \ No newline at end of file diff --git a/jetlinks-components/configure-component/src/main/java/io/opentelemetry/exporter/jaeger/KeyValueMarshaler.java b/jetlinks-components/configure-component/src/main/java/io/opentelemetry/exporter/jaeger/KeyValueMarshaler.java new file mode 100644 index 00000000..f97b7c51 --- /dev/null +++ b/jetlinks-components/configure-component/src/main/java/io/opentelemetry/exporter/jaeger/KeyValueMarshaler.java @@ -0,0 +1,139 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +package io.opentelemetry.exporter.jaeger; + +import com.fasterxml.jackson.jr.ob.JSON; +import io.opentelemetry.api.common.AttributeKey; +import io.opentelemetry.api.common.Attributes; +import io.opentelemetry.exporter.internal.marshal.MarshalerUtil; +import io.opentelemetry.exporter.internal.marshal.MarshalerWithSize; +import io.opentelemetry.exporter.internal.marshal.ProtoEnumInfo; +import io.opentelemetry.exporter.internal.marshal.Serializer; +import io.opentelemetry.exporter.jaeger.proto.api_v2.internal.KeyValue; +import io.opentelemetry.exporter.jaeger.proto.api_v2.internal.ValueType; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.function.Supplier; + +@SuppressWarnings({ + "checkstyle:LocalVariableName", + "checkstyle:MemberName", + "checkstyle:ParameterName", +}) +final class KeyValueMarshaler extends MarshalerWithSize { + + private static final byte[] EMPTY_BYTES = new byte[0]; + + private final byte[] keyUtf8; + private final ProtoEnumInfo valueType; + private final byte[] vStrUtf8; + private final boolean vBool; + private final long vInt64; + private final double vFloat64; + + static List createRepeated(Attributes attributes) { + if (attributes.isEmpty()) { + return new ArrayList<>(); + } + + List marshalers = new ArrayList<>(attributes.size()); + attributes.forEach((attributeKey, o) -> marshalers.add(create(attributeKey, o))); + return marshalers; + } + + static KeyValueMarshaler create(AttributeKey key, Object value) { + byte[] keyUtf8 = MarshalerUtil.toBytes(key.getKey()); + + // Default is the 0 value, string in this case + ProtoEnumInfo valueType = ValueType.STRING; + byte[] vStrUtf8 = EMPTY_BYTES; + boolean vBool = false; + long vInt64 = 0; + double vFloat64 = 0; + + if (value instanceof Supplier) { + value = ((Supplier) value).get(); + } + + switch (key.getType()) { + case STRING: + valueType = ValueType.STRING; + + vStrUtf8 = MarshalerUtil.toBytes(String.valueOf(value)); + break; + case BOOLEAN: + valueType = ValueType.BOOL; + vBool = (boolean) value; + break; + case LONG: + valueType = ValueType.INT64; + vInt64 = (long) value; + break; + case DOUBLE: + valueType = ValueType.FLOAT64; + vFloat64 = (double) value; + break; + case STRING_ARRAY: + case BOOLEAN_ARRAY: + case LONG_ARRAY: + case DOUBLE_ARRAY: + valueType = ValueType.STRING; + try { + vStrUtf8 = JSON.std.asBytes(value); + } catch (IOException e) { + // Can't happen, just ignore it. + } + break; + } + + return new KeyValueMarshaler(keyUtf8, valueType, vStrUtf8, vBool, vInt64, vFloat64); + } + + KeyValueMarshaler( + byte[] keyUtf8, + ProtoEnumInfo valueType, + byte[] vStrUtf8, + boolean vBool, + long vInt64, + double vFloat64) { + super(calculateSize(keyUtf8, valueType, vStrUtf8, vBool, vInt64, vFloat64)); + this.keyUtf8 = keyUtf8; + this.valueType = valueType; + this.vStrUtf8 = vStrUtf8; + this.vBool = vBool; + this.vInt64 = vInt64; + this.vFloat64 = vFloat64; + } + + @Override + protected void writeTo(Serializer output) throws IOException { + output.serializeString(KeyValue.KEY, keyUtf8); + output.serializeEnum(KeyValue.V_TYPE, valueType); + output.serializeString(KeyValue.V_STR, vStrUtf8); + output.serializeBool(KeyValue.V_BOOL, vBool); + output.serializeInt64(KeyValue.V_INT64, vInt64); + output.serializeDouble(KeyValue.V_FLOAT64, vFloat64); + } + + private static int calculateSize( + byte[] keyUtf8, + ProtoEnumInfo valueType, + byte[] vStrUtf8, + boolean vBool, + long vInt64, + double vFloat64) { + int size = 0; + size += MarshalerUtil.sizeBytes(KeyValue.KEY, keyUtf8); + size += MarshalerUtil.sizeEnum(KeyValue.V_TYPE, valueType); + size += MarshalerUtil.sizeBytes(KeyValue.V_STR, vStrUtf8); + size += MarshalerUtil.sizeBool(KeyValue.V_BOOL, vBool); + size += MarshalerUtil.sizeInt64(KeyValue.V_INT64, vInt64); + size += MarshalerUtil.sizeDouble(KeyValue.V_FLOAT64, vFloat64); + return size; + } +} diff --git a/pom.xml b/pom.xml index 469075ce..a551025b 100644 --- a/pom.xml +++ b/pom.xml @@ -50,6 +50,8 @@ 2.2.8 5.12.1 4.5.2 + 2.57 + 1.53.0 @@ -188,6 +190,18 @@ + + io.asyncer + r2dbc-mysql + 0.9.3 + + + + de.ruedigermoeller + fst + ${fst.version} + + net.java.dev.jna jna @@ -359,6 +373,21 @@ ${fastjson.version} + + io.opentelemetry + opentelemetry-bom + ${opentelemetry.version} + pom + import + + + + + io.opentelemetry + opentelemetry-semconv + ${opentelemetry.version}-alpha + + io.r2dbc r2dbc-bom @@ -478,6 +507,31 @@ ${aliyun.sdk.core} + + io.grpc + grpc-protobuf + ${grpc.version} + + + + + io.grpc + grpc-netty + ${grpc.version} + + + + io.grpc + grpc-netty-shaded + ${grpc.version} + + + io.netty + * + + + +