Code samples

We emphasize in the code sample topic that, when you are done with a Ring Buffer target, you should release its resources by executing an alter-drop ALTER EVENT SESSION ... ON DATABASE DROP TARGET ...; statement. Later you can add another instance of Ring Buffer by ALTER EVENT SESSION ... ON DATABASE ADD TARGET ....

A best practice is to include the event session option of STARTUP_STATE = ON in your CREATE EVENT SESSION or ALTER EVENT SESSION statements.

The = ON value supports an automatic restart after a reconfiguration of the logical database due to a failover.

New catalog views

The extended events feature is supported by several catalog views. Catalog views tell you about metadata or definitions of user-created event sessions in the current database. The views do not return information about instances of active event sessions.

Name ofcatalog view

Description

sys.database_event_session_actions

Returns a row for each action on each event of an event session.

sys.database_event_session_events

Returns a row for each event in an event session.

sys.database_event_session_fields

Returns a row for each customize-able column that was explicitly set on events and targets.

sys.database_event_session_targets

Returns a row for each event target for an event session.

sys.database_event_sessions

Returns a row for each event session in the SQL Database database.

In Microsoft SQL Server, similar catalog views have names that include .server_ instead of .database_. The name pattern is like sys.server_event_%.

Restrictions

There are a couple of security-related differences befitting the cloud environment of SQL Database:

Extended events are founded on the single-tenant isolation model. An event session in one database cannot access data or events from another database.

You cannot issue a CREATE EVENT SESSION statement in the context of the master database.

Permission model

You must have Control permission on the database to issue a CREATE EVENT SESSION statement. The database owner (dbo) has Control permission.

Storage container authorizations

The SAS token you generate for your Azure Storage container must specify rwl for the permissions. The rwl value provides the following permissions:

Read

Write

List

Performance considerations

There are scenarios where intensive use of extended events can accumulate more active memory than is healthy for the overall system. Therefore the Azure SQL Database system dynamically sets and adjusts limits on the amount of active memory that can be accumulated by an event session. Many factors go into the dynamic calculation.

If you receive an error message that says a memory maximum was enforced, some corrective actions you can take are:

Run fewer concurrent event sessions.

Through your CREATE and ALTER statements for event sessions, reduce the amount of memory you specify on the MAX_MEMORY clause.

Network latency

The Event File target might experience network latency or failures while persisting data to Azure Storage blobs. Other events in SQL Database might be delayed while they wait for the network communication to complete. This delay can slow your workload.

Other code sample topics for extended events are available at the following links. However, you must routinely check any sample to see whether the sample targets Microsoft SQL Server versus Azure SQL Database. Then you can decide whether minor changes are needed to run the sample.