public String handlePost()

in Elastiflix/java-favorite-otel-manual/src/main/java/com/movieapi/ApiServlet.java [114:141]


    public String handlePost(@RequestParam String user_id, @RequestBody String requestBody) throws InterruptedException, Exception {
        Span span = GlobalOpenTelemetry.getTracer(SERVICE_NAME).spanBuilder("handlePost").startSpan();
        Scope scope = span.makeCurrent();

        handleDelay();
        logger.info("Adding or removing favorites");

        JSONObject json = new JSONObject(requestBody);
        String movieID = Integer.toString(json.getInt("id"));

       /// String movieID = Integer.toString(requestBody.getInt("id"));

        logger.info("Adding or removing favorites for user " +  user_id + ", movieID " + movieID);

        postUserFavorites(user_id,movieID);
        String favorites = getUserFavorites(user_id);
        handleCanary();

        span.addEvent("a span event", Attributes
                .of(AttributeKey.longKey("someKey"), Long.valueOf(93)));

        span.setStatus(StatusCode.OK);

        span.end();

        scope.close();
        return favorites;
    }