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 Set<String> |
extraTags
Extras to extract and use as tags, 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 |
addExtraTag(String extraName)
Add an extra to extract and send as tags on all future
Event s, where applicable. |
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() |
Set<String> |
getExtraTags() |
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 |
setExtraTags(Set<String> extraTags)
Set the extras to extract and send as tags on all future
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. |
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 sent.
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 tagspublic void setExtraTags(Set<String> extraTags)
Event
s, where applicable.
For example: when using a logging integration any MDC
keys that are in
the extraTags
set will be extracted and set as tags on the Event
.
extraTags
- Set of extraspublic void addExtraTag(String extraName)
Event
s, where applicable.
For example: when using a logging integration any MDC
keys that are in
the extraTags
set will be extracted and set as tags on the Event
.
extraName
- Extra nameCopyright © 2012–2017. All rights reserved.