public class SentryClient extends Object
Event
s to a Sentry server.
It is recommended that you create an instance of Sentry through
SentryClientFactory.createSentryClient(io.sentry.dsn.Dsn)
, which will use the best factory available.
Modifier and Type | Field and Description |
---|---|
protected String |
dist
Identifies the distribution of the application.
|
protected String |
environment
Identifies the environment the application is running in.
|
protected Map<String,Object> |
extra
Extra data to be sent to sentry.
|
protected Set<String> |
mdcTags
Tags to extract from the MDC system and set on
Event s, where applicable. |
protected String |
release
Identifies the version of the application.
|
protected String |
serverName
Server name to be sent to sentry.
|
protected Map<String,String> |
tags
Additional tags to be sent to sentry.
|
Constructor and Description |
---|
SentryClient(Connection connection,
ContextManager contextManager)
Constructs a
SentryClient instance using the provided connection. |
Modifier and Type | Method and Description |
---|---|
void |
addBuilderHelper(EventBuilderHelper builderHelper)
Adds a builder helper.
|
void |
addEventSendCallback(EventSendCallback eventSendCallback)
Add a callback that is called after an
Event is sent to Sentry. |
void |
addExtra(String name,
Object value)
Add to the extra data that will be sent with all future
Event s. |
void |
addExtraTag(String extraName)
Deprecated.
prefer
addMdcTag(String) |
void |
addMdcTag(String tagName)
Add a tag to extract from the MDC system and set on
Event s, where applicable. |
void |
addShouldSendEventCallback(ShouldSendEventCallback shouldSendEventCallback)
Add a callback that is called before an
Event is sent to Sentry. |
void |
addTag(String name,
String value)
Add a tag that will be sent with all future
Event s. |
void |
clearContext()
Clears the
ContextManager data. |
void |
closeConnection()
Closes the connection for the
SentryClient instance. |
List<EventBuilderHelper> |
getBuilderHelpers() |
Context |
getContext() |
String |
getDist() |
String |
getEnvironment() |
Map<String,Object> |
getExtra() |
Set<String> |
getMdcTags() |
String |
getRelease() |
String |
getServerName() |
Map<String,String> |
getTags() |
void |
removeBuilderHelper(EventBuilderHelper builderHelper)
Removes a builder helper.
|
void |
runBuilderHelpers(EventBuilder eventBuilder)
Runs the
EventBuilderHelper against the EventBuilder to obtain additional information with a
MDC-like system. |
void |
sendEvent(Event event)
Sends a built
Event to the Sentry server. |
void |
sendEvent(EventBuilder eventBuilder)
Builds and sends an
Event to the Sentry server. |
void |
sendException(Throwable throwable)
Sends an exception (or throwable) to the Sentry server.
|
void |
sendMessage(String message)
Sends a message to the Sentry server.
|
void |
setDist(String dist) |
void |
setEnvironment(String environment) |
void |
setExtra(Map<String,Object> extra)
Set the extra data that will be sent with all future
Event s. |
void |
setExtraTags(Set<String> extraTags)
Deprecated.
prefer
setMdcTags(Set) |
void |
setMdcTags(Set<String> mdcTags)
Set the tags to extract from the MDC system and set on
Event s, where applicable. |
void |
setRelease(String release) |
void |
setServerName(String serverName) |
void |
setTags(Map<String,String> tags)
Set the tags that will be sent with all future
Event s. |
protected void |
setupUncaughtExceptionHandler()
Setup and store the
SentryUncaughtExceptionHandler so that it can be
disabled on closeConnection() . |
String |
toString() |
protected String release
Might be null in which case the release information will not be sent with the event.
protected String dist
Might be null in which case the release distribution will not be sent with the event.
protected String environment
Might be null in which case the environment information will not be sent with the event.
protected String serverName
Might be null in which case the hostname is found via a reverse DNS lookup.
protected Map<String,String> tags
Might be empty in which case no tags are added to the events.
protected Set<String> mdcTags
Event
s, where applicable.public SentryClient(Connection connection, ContextManager contextManager)
SentryClient
instance using the provided connection.
Note that the most recently constructed instance is stored statically so it can be used with
the static helper methods.connection
- Underlying Connection
instance to use for sending eventscontextManager
- ContextManager
instance to use for storing contextual datapublic void runBuilderHelpers(EventBuilder eventBuilder)
EventBuilderHelper
against the EventBuilder
to obtain additional information with a
MDC-like system.eventBuilder
- event builder containing a not yet finished event.public void sendEvent(Event event)
Event
to the Sentry server.event
- event to send to Sentry.public void sendEvent(EventBuilder eventBuilder)
Event
to the Sentry server.eventBuilder
- EventBuilder
to send to Sentry.public void sendMessage(String message)
The message will be logged at the Event.Level#INFO
level.
message
- message to send to Sentry.public void sendException(Throwable throwable)
The exception will be logged at the Event.Level#ERROR
level.
throwable
- exception to send to Sentry.public void removeBuilderHelper(EventBuilderHelper builderHelper)
builderHelper
- builder helper to remove.public void addBuilderHelper(EventBuilderHelper builderHelper)
builderHelper
- builder helper to add.public List<EventBuilderHelper> getBuilderHelpers()
public void closeConnection()
SentryClient
instance.public void clearContext()
ContextManager
data.public Context getContext()
public String getRelease()
public String getDist()
public String getEnvironment()
public String getServerName()
public void setRelease(String release)
public void setDist(String dist)
public void setEnvironment(String environment)
public void setServerName(String serverName)
public void addTag(String name, String value)
Event
s.name
- Tag namevalue
- Tag valuepublic void setTags(Map<String,String> tags)
Event
s.tags
- Map of tags@Deprecated public void setExtraTags(Set<String> extraTags)
setMdcTags(Set)
Event
s, where applicable.extraTags
- Set of tags to extract from the MDC systempublic void setMdcTags(Set<String> mdcTags)
Event
s, where applicable.mdcTags
- Set of tags to extract from the MDC system@Deprecated public void addExtraTag(String extraName)
addMdcTag(String)
Event
s, where applicable.extraName
- Tag name to extract from the MDC systempublic void addMdcTag(String tagName)
Event
s, where applicable.tagName
- Tag name to extract from the MDC systempublic void addExtra(String name, Object value)
Event
s.name
- Data namevalue
- Data valuepublic void setExtra(Map<String,Object> extra)
Event
s.extra
- Map of extra datapublic void addEventSendCallback(EventSendCallback eventSendCallback)
Event
is sent to Sentry.eventSendCallback
- callback instancepublic void addShouldSendEventCallback(ShouldSendEventCallback shouldSendEventCallback)
Event
is sent to Sentry.shouldSendEventCallback
- callback instanceprotected void setupUncaughtExceptionHandler()
SentryUncaughtExceptionHandler
so that it can be
disabled on closeConnection()
.Copyright © 2012–2018. All rights reserved.