Class AbstractHttpSender

  • All Implemented Interfaces:
    ch.qos.logback.core.spi.ContextAware, ch.qos.logback.core.spi.LifeCycle, HttpSender
    Direct Known Subclasses:
    ApacheHttpSender, JavaHttpSender

    public abstract class AbstractHttpSender
    extends ch.qos.logback.core.spi.ContextAwareBase
    implements HttpSender
    Abstract class that implements a common logic shared between standard HTTP sender implementations
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.util.Optional<java.lang.String> basicAuthToken
      Token to pass to HTTP server if basic auth is enabled
      protected long connectionTimeoutMs
      Time in milliseconds to wait for HTTP connection to Loki to be established before reporting an error
      protected java.lang.String contentType
      Content-type header to send to Loki
      protected long requestTimeoutMs
      Time in milliseconds to wait for HTTP request to Loki to be responded before reporting an error
      protected java.util.Optional<java.lang.String> tenantId
      Tenant identifier.
      protected java.lang.String url
      Loki endpoint to be used for sending batches
      • Fields inherited from class ch.qos.logback.core.spi.ContextAwareBase

        context
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String getUrl()
      Get Loki target URL
      boolean isStarted()  
      void setAuth​(AbstractHttpSender.BasicAuth auth)  
      void setConnectionTimeoutMs​(long connectionTimeoutMs)  
      void setContentType​(java.lang.String contentType)
      Content type of the requests to send to Loki.
      void setRequestTimeoutMs​(long requestTimeoutMs)  
      void setTenantId​(java.lang.String tenant)
      Tenant identifier.
      void setUrl​(java.lang.String url)
      Set Loki target URL
      void start()  
      void stop()  
      • Methods inherited from class ch.qos.logback.core.spi.ContextAwareBase

        addError, addError, addInfo, addInfo, addStatus, addWarn, addWarn, getContext, getDeclaredOrigin, getStatusManager, setContext
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface ch.qos.logback.core.spi.ContextAware

        addError, addError, addInfo, addInfo, addStatus, addWarn, addWarn, getContext, setContext
      • Methods inherited from interface com.github.loki4j.logback.HttpSender

        send
    • Field Detail

      • url

        protected java.lang.String url
        Loki endpoint to be used for sending batches
      • tenantId

        protected java.util.Optional<java.lang.String> tenantId
        Tenant identifier. It is required only for sending logs directly to Loki operating in multi-tenant mode. Otherwise this setting has no effect
      • contentType

        protected java.lang.String contentType
        Content-type header to send to Loki
      • connectionTimeoutMs

        protected long connectionTimeoutMs
        Time in milliseconds to wait for HTTP connection to Loki to be established before reporting an error
      • requestTimeoutMs

        protected long requestTimeoutMs
        Time in milliseconds to wait for HTTP request to Loki to be responded before reporting an error
      • basicAuthToken

        protected java.util.Optional<java.lang.String> basicAuthToken
        Token to pass to HTTP server if basic auth is enabled
    • Constructor Detail

      • AbstractHttpSender

        public AbstractHttpSender()
    • Method Detail

      • start

        public void start()
        Specified by:
        start in interface ch.qos.logback.core.spi.LifeCycle
      • stop

        public void stop()
        Specified by:
        stop in interface ch.qos.logback.core.spi.LifeCycle
      • isStarted

        public boolean isStarted()
        Specified by:
        isStarted in interface ch.qos.logback.core.spi.LifeCycle
      • setConnectionTimeoutMs

        public void setConnectionTimeoutMs​(long connectionTimeoutMs)
      • setRequestTimeoutMs

        public void setRequestTimeoutMs​(long requestTimeoutMs)
      • getUrl

        public java.lang.String getUrl()
        Description copied from interface: HttpSender
        Get Loki target URL
        Specified by:
        getUrl in interface HttpSender
      • setUrl

        public void setUrl​(java.lang.String url)
        Description copied from interface: HttpSender
        Set Loki target URL
        Specified by:
        setUrl in interface HttpSender
      • setContentType

        public void setContentType​(java.lang.String contentType)
        Description copied from interface: HttpSender
        Content type of the requests to send to Loki. It depends on the encoder selected in config (JSON vs Protobuf)
        Specified by:
        setContentType in interface HttpSender
      • setTenantId

        public void setTenantId​(java.lang.String tenant)
        Description copied from interface: HttpSender
        Tenant identifier. It is required only for sending logs directly to Loki operating in multi-tenant mode. Otherwise this setting has no effect
        Specified by:
        setTenantId in interface HttpSender