private static boolean handleSpecialSpanTag()

in apm-agent-plugins/apm-opentracing-plugin/src/main/java/co/elastic/apm/agent/opentracingimpl/ApmSpanInstrumentation.java [231:279]


            private static boolean handleSpecialSpanTag(SpanImpl span, String key, Object value) {
                //noinspection IfCanBeSwitch
                if ("type".equals(key)) {
                    if (span.getSubtype() == null && span.getAction() == null) {
                        span.setType(value.toString(), null, null);
                    } else {
                        span.withType(value.toString());
                    }
                    return true;
                } else if ("subtype".equals(key)) {
                    span.withSubtype(value.toString());
                    return true;
                } else if ("action".equals(key)) {
                    span.withAction(value.toString());
                    return true;
                } else if ("sampling.priority".equals(key)) {
                    // mid-trace sampling is not allowed
                    return true;
                } else if ("db.type".equals(key)) {
                    span.getContext().getDb().withType(value.toString());
                    span.withType("db").withSubtype(value.toString());
                    return true;
                } else if ("db.instance".equals(key)) {
                    span.getContext().getDb().withInstance(value.toString());
                    return true;
                } else if ("db.statement".equals(key)) {
                    span.getContext().getDb().withStatement(value.toString());
                    span.withAction("query");
                    return true;
                } else if ("span.kind".equals(key)) {
                    if (span.getType() == null && ("producer".equals(value) || "client".equals(value))) {
                        span.withType("external");
                    }
                    return true;
                } else if ("http.status_code".equals(key) && value instanceof Number) {
                    int status = ((Number) value).intValue();
                    span.getContext().getHttp().withStatusCode(status);
                    span.withSubtype("http")
                        .withOutcome(ResultUtil.getOutcomeByHttpClientStatus(status));
                    return true;
                } else if ("http.url".equals(key) && value instanceof String) {
                    span.getContext().getHttp().withUrl((String) value);
                    return true;
                } else if ("http.method".equals(key) && value instanceof String) {
                    span.getContext().getHttp().withMethod((String) value);
                    return true;
                }
                return false;
            }