All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.feingto.cloud.dto.apis.ApiLogDTO Maven / Gradle / Ivy

There is a newer version: 2.3.5.RELEASE
Show newest version
package com.feingto.cloud.dto.apis;

import com.feingto.cloud.domain.enums.LogStatus;
import com.feingto.cloud.domain.enums.LogType;
import com.feingto.cloud.domain.enums.Stage;
import com.feingto.cloud.kit.json.JSON;
import lombok.Data;
import lombok.experimental.Accessors;
import org.springframework.http.HttpMethod;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.messaging.Message;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

/**
 * API 日志消息
 *
 * @author longfei
 */
@Data
@Accessors(chain = true)
public class ApiLogDTO implements Serializable {
    private static final long serialVersionUID = -9086222595728796504L;

    private LogType type = LogType.MONITOR;

    private String traceId;

    private String apiId;

    /**
     * 创建人
     */
    private String owner;

    /**
     * API 环境(线上、预发、测试)
     */
    private Stage stage;

    /**
     * 请求路径
     */
    private String path;

    /**
     * 请求方式
     */
    private HttpMethod httpMethod;

    /**
     * 耗时(微秒)
     */
    private Long duration;

    /**
     * 类型 SERVER / CLIENT / PRODUCER / CONSUMER
     *
     * @see brave.Span
     * @see zipkin2.Span
     */
    private String kind;

    private String message;

    /**
     * 返回结果成功/失败
     */
    private boolean success = true;

    private LogStatus status = LogStatus.TRY;

    private Map tags = new HashMap<>();

    public Map getTags() {
        this.tags.put("stage", this.stage.name());
        this.tags.put("http.path", this.path);
        this.tags.put("http.method", this.httpMethod.name());
        return this.tags;
    }

    public Message toMessage() {
        return MessageBuilder.withPayload(JSON.obj2json(this)).build();
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy