@@ -788,6 +788,50 @@ public LogsProcessor deserialize(JsonParser jp, DeserializationContext ctxt)
788788 log .log (Level .FINER , "Input data does not match schema 'LogsTraceRemapper'" , e );
789789 }
790790
791+ // deserialize LogsSpanRemapper
792+ try {
793+ boolean attemptParsing = true ;
794+ // ensure that we respect type coercion as set on the client ObjectMapper
795+ if (LogsSpanRemapper .class .equals (Integer .class )
796+ || LogsSpanRemapper .class .equals (Long .class )
797+ || LogsSpanRemapper .class .equals (Float .class )
798+ || LogsSpanRemapper .class .equals (Double .class )
799+ || LogsSpanRemapper .class .equals (Boolean .class )
800+ || LogsSpanRemapper .class .equals (String .class )) {
801+ attemptParsing = typeCoercion ;
802+ if (!attemptParsing ) {
803+ attemptParsing |=
804+ ((LogsSpanRemapper .class .equals (Integer .class )
805+ || LogsSpanRemapper .class .equals (Long .class ))
806+ && token == JsonToken .VALUE_NUMBER_INT );
807+ attemptParsing |=
808+ ((LogsSpanRemapper .class .equals (Float .class )
809+ || LogsSpanRemapper .class .equals (Double .class ))
810+ && (token == JsonToken .VALUE_NUMBER_FLOAT
811+ || token == JsonToken .VALUE_NUMBER_INT ));
812+ attemptParsing |=
813+ (LogsSpanRemapper .class .equals (Boolean .class )
814+ && (token == JsonToken .VALUE_FALSE || token == JsonToken .VALUE_TRUE ));
815+ attemptParsing |=
816+ (LogsSpanRemapper .class .equals (String .class ) && token == JsonToken .VALUE_STRING );
817+ }
818+ }
819+ if (attemptParsing ) {
820+ tmp = tree .traverse (jp .getCodec ()).readValueAs (LogsSpanRemapper .class );
821+ // TODO: there is no validation against JSON schema constraints
822+ // (min, max, enum, pattern...), this does not perform a strict JSON
823+ // validation, which means the 'match' count may be higher than it should be.
824+ if (!((LogsSpanRemapper ) tmp ).unparsed ) {
825+ deserialized = tmp ;
826+ match ++;
827+ }
828+ log .log (Level .FINER , "Input data matches schema 'LogsSpanRemapper'" );
829+ }
830+ } catch (Exception e ) {
831+ // deserialization failed, continue
832+ log .log (Level .FINER , "Input data does not match schema 'LogsSpanRemapper'" , e );
833+ }
834+
791835 LogsProcessor ret = new LogsProcessor ();
792836 if (match == 1 ) {
793837 ret .setActualInstance (deserialized );
@@ -896,6 +940,11 @@ public LogsProcessor(LogsTraceRemapper o) {
896940 setActualInstance (o );
897941 }
898942
943+ public LogsProcessor (LogsSpanRemapper o ) {
944+ super ("oneOf" , Boolean .FALSE );
945+ setActualInstance (o );
946+ }
947+
899948 static {
900949 schemas .put ("LogsGrokParser" , new GenericType <LogsGrokParser >() {});
901950 schemas .put ("LogsDateRemapper" , new GenericType <LogsDateRemapper >() {});
@@ -915,6 +964,7 @@ public LogsProcessor(LogsTraceRemapper o) {
915964 "ReferenceTableLogsLookupProcessor" ,
916965 new GenericType <ReferenceTableLogsLookupProcessor >() {});
917966 schemas .put ("LogsTraceRemapper" , new GenericType <LogsTraceRemapper >() {});
967+ schemas .put ("LogsSpanRemapper" , new GenericType <LogsSpanRemapper >() {});
918968 JSON .registerDescendants (LogsProcessor .class , Collections .unmodifiableMap (schemas ));
919969 }
920970
@@ -929,7 +979,7 @@ public Map<String, GenericType> getSchemas() {
929979 * LogsServiceRemapper, LogsMessageRemapper, LogsAttributeRemapper, LogsURLParser,
930980 * LogsUserAgentParser, LogsCategoryProcessor, LogsArithmeticProcessor,
931981 * LogsStringBuilderProcessor, LogsPipelineProcessor, LogsGeoIPParser, LogsLookupProcessor,
932- * ReferenceTableLogsLookupProcessor, LogsTraceRemapper
982+ * ReferenceTableLogsLookupProcessor, LogsTraceRemapper, LogsSpanRemapper
933983 *
934984 * <p>It could be an instance of the 'oneOf' schemas. The oneOf child schemas may themselves be a
935985 * composed schema (allOf, anyOf, oneOf).
@@ -1001,6 +1051,10 @@ public void setActualInstance(Object instance) {
10011051 super .setActualInstance (instance );
10021052 return ;
10031053 }
1054+ if (JSON .isInstanceOf (LogsSpanRemapper .class , instance , new HashSet <Class <?>>())) {
1055+ super .setActualInstance (instance );
1056+ return ;
1057+ }
10041058
10051059 if (JSON .isInstanceOf (UnparsedObject .class , instance , new HashSet <Class <?>>())) {
10061060 super .setActualInstance (instance );
@@ -1011,21 +1065,22 @@ public void setActualInstance(Object instance) {
10111065 + " LogsServiceRemapper, LogsMessageRemapper, LogsAttributeRemapper, LogsURLParser,"
10121066 + " LogsUserAgentParser, LogsCategoryProcessor, LogsArithmeticProcessor,"
10131067 + " LogsStringBuilderProcessor, LogsPipelineProcessor, LogsGeoIPParser,"
1014- + " LogsLookupProcessor, ReferenceTableLogsLookupProcessor, LogsTraceRemapper" );
1068+ + " LogsLookupProcessor, ReferenceTableLogsLookupProcessor, LogsTraceRemapper,"
1069+ + " LogsSpanRemapper" );
10151070 }
10161071
10171072 /**
10181073 * Get the actual instance, which can be the following: LogsGrokParser, LogsDateRemapper,
10191074 * LogsStatusRemapper, LogsServiceRemapper, LogsMessageRemapper, LogsAttributeRemapper,
10201075 * LogsURLParser, LogsUserAgentParser, LogsCategoryProcessor, LogsArithmeticProcessor,
10211076 * LogsStringBuilderProcessor, LogsPipelineProcessor, LogsGeoIPParser, LogsLookupProcessor,
1022- * ReferenceTableLogsLookupProcessor, LogsTraceRemapper
1077+ * ReferenceTableLogsLookupProcessor, LogsTraceRemapper, LogsSpanRemapper
10231078 *
10241079 * @return The actual instance (LogsGrokParser, LogsDateRemapper, LogsStatusRemapper,
10251080 * LogsServiceRemapper, LogsMessageRemapper, LogsAttributeRemapper, LogsURLParser,
10261081 * LogsUserAgentParser, LogsCategoryProcessor, LogsArithmeticProcessor,
10271082 * LogsStringBuilderProcessor, LogsPipelineProcessor, LogsGeoIPParser, LogsLookupProcessor,
1028- * ReferenceTableLogsLookupProcessor, LogsTraceRemapper)
1083+ * ReferenceTableLogsLookupProcessor, LogsTraceRemapper, LogsSpanRemapper )
10291084 */
10301085 @ Override
10311086 public Object getActualInstance () {
@@ -1208,4 +1263,15 @@ public ReferenceTableLogsLookupProcessor getReferenceTableLogsLookupProcessor()
12081263 public LogsTraceRemapper getLogsTraceRemapper () throws ClassCastException {
12091264 return (LogsTraceRemapper ) super .getActualInstance ();
12101265 }
1266+
1267+ /**
1268+ * Get the actual instance of `LogsSpanRemapper`. If the actual instance is not
1269+ * `LogsSpanRemapper`, the ClassCastException will be thrown.
1270+ *
1271+ * @return The actual instance of `LogsSpanRemapper`
1272+ * @throws ClassCastException if the instance is not `LogsSpanRemapper`
1273+ */
1274+ public LogsSpanRemapper getLogsSpanRemapper () throws ClassCastException {
1275+ return (LogsSpanRemapper ) super .getActualInstance ();
1276+ }
12111277}
0 commit comments