Package com.github.loki4j.logback
Class AbstractHttpSender
- java.lang.Object
-
- ch.qos.logback.core.spi.ContextAwareBase
-
- com.github.loki4j.logback.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
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classAbstractHttpSender.BasicAuth
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Optional<java.lang.String>basicAuthTokenToken to pass to HTTP server if basic auth is enabledprotected longconnectionTimeoutMsTime in milliseconds to wait for HTTP connection to Loki to be established before reporting an errorprotected java.lang.StringcontentTypeContent-type header to send to Lokiprotected longrequestTimeoutMsTime in milliseconds to wait for HTTP request to Loki to be responded before reporting an errorprotected java.util.Optional<java.lang.String>tenantIdTenant identifier.protected java.lang.StringurlLoki endpoint to be used for sending batches
-
Constructor Summary
Constructors Constructor Description AbstractHttpSender()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringgetUrl()Get Loki target URLbooleanisStarted()voidsetAuth(AbstractHttpSender.BasicAuth auth)voidsetConnectionTimeoutMs(long connectionTimeoutMs)voidsetContentType(java.lang.String contentType)Content type of the requests to send to Loki.voidsetRequestTimeoutMs(long requestTimeoutMs)voidsetTenantId(java.lang.String tenant)Tenant identifier.voidsetUrl(java.lang.String url)Set Loki target URLvoidstart()voidstop()-
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
-
-
Method Detail
-
start
public void start()
- Specified by:
startin interfacech.qos.logback.core.spi.LifeCycle
-
stop
public void stop()
- Specified by:
stopin interfacech.qos.logback.core.spi.LifeCycle
-
isStarted
public boolean isStarted()
- Specified by:
isStartedin interfacech.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:HttpSenderGet Loki target URL- Specified by:
getUrlin interfaceHttpSender
-
setUrl
public void setUrl(java.lang.String url)
Description copied from interface:HttpSenderSet Loki target URL- Specified by:
setUrlin interfaceHttpSender
-
setAuth
public void setAuth(AbstractHttpSender.BasicAuth auth)
-
setContentType
public void setContentType(java.lang.String contentType)
Description copied from interface:HttpSenderContent type of the requests to send to Loki. It depends on the encoder selected in config (JSON vs Protobuf)- Specified by:
setContentTypein interfaceHttpSender
-
setTenantId
public void setTenantId(java.lang.String tenant)
Description copied from interface:HttpSenderTenant identifier. It is required only for sending logs directly to Loki operating in multi-tenant mode. Otherwise this setting has no effect- Specified by:
setTenantIdin interfaceHttpSender
-
-