DiagnosticListener.Subscribe Método

Definição

Esses métodos permitem adicionar um assinante e alguns deles fornecem métodos de filtragem de eventos opcionais.These methods allow adding a subscriber, and some of them provide optional event filtering methods.

Sobrecargas

Subscribe(IObserver<KeyValuePair<String,Object>>)

Adiciona um assinante.Adds a subscriber.

Subscribe(IObserver<KeyValuePair<String,Object>>, Func<String,Object,Object,Boolean>)

Adiciona um assinante e opcionalmente filtra eventos com base em seu nome e até dois objetos de contexto.Adds a subscriber, and optionally filters events based on their name and up to two context objects.

Subscribe(IObserver<KeyValuePair<String,Object>>, Predicate<String>)

Adiciona um assinante e, opcionalmente, filtra eventos com base em seu nome.Adds a subscriber, and optionally filters events based on their name.

Subscribe(IObserver<KeyValuePair<String,Object>>, Func<String,Object,Object,Boolean>, Action<Activity,Object>, Action<Activity,Object>)

Adiciona um assinante, opcionalmente, filtra eventos com base em seu nome e até dois objetos de contexto e especifica os métodos a serem chamados quando os provedores importam ou exportam atividades de fora do processo.Adds a subscriber, optionally filters events based on their name and up to two context objects, and specifies methods to call when providers import or export activites from outside the process.

Subscribe(IObserver<KeyValuePair<String,Object>>)

Adiciona um assinante.Adds a subscriber.

public:
 virtual IDisposable ^ Subscribe(IObserver<System::Collections::Generic::KeyValuePair<System::String ^, System::Object ^>> ^ observer);
public virtual IDisposable Subscribe (IObserver<System.Collections.Generic.KeyValuePair<string,object?>> observer);
public IDisposable Subscribe (IObserver<System.Collections.Generic.KeyValuePair<string,object>> observer);
public virtual IDisposable Subscribe (IObserver<System.Collections.Generic.KeyValuePair<string,object>> observer);
abstract member Subscribe : IObserver<System.Collections.Generic.KeyValuePair<string, obj>> -> IDisposable
override this.Subscribe : IObserver<System.Collections.Generic.KeyValuePair<string, obj>> -> IDisposable
Public Overridable Function Subscribe (observer As IObserver(Of KeyValuePair(Of String, Object))) As IDisposable
Public Function Subscribe (observer As IObserver(Of KeyValuePair(Of String, Object))) As IDisposable

Parâmetros

observer
IObserver<KeyValuePair<String,Object>>

Um assinante.A subscriber.

Retornos

IDisposable

Uma referência a uma interface que permite que o ouvinte para de receber notificações antes que o DiagnosticSource tenha terminado de enviá-las.A reference to an interface that allows the listener to stop receiving notifications before the DiagnosticSource has finished sending them.

Implementações

Aplica-se a

Subscribe(IObserver<KeyValuePair<String,Object>>, Func<String,Object,Object,Boolean>)

Adiciona um assinante e opcionalmente filtra eventos com base em seu nome e até dois objetos de contexto.Adds a subscriber, and optionally filters events based on their name and up to two context objects.

public:
 virtual IDisposable ^ Subscribe(IObserver<System::Collections::Generic::KeyValuePair<System::String ^, System::Object ^>> ^ observer, Func<System::String ^, System::Object ^, System::Object ^, bool> ^ isEnabled);
public virtual IDisposable Subscribe (IObserver<System.Collections.Generic.KeyValuePair<string,object?>> observer, Func<string,object?,object?,bool>? isEnabled);
public virtual IDisposable Subscribe (IObserver<System.Collections.Generic.KeyValuePair<string,object>> observer, Func<string,object,object,bool> isEnabled);
abstract member Subscribe : IObserver<System.Collections.Generic.KeyValuePair<string, obj>> * Func<string, obj, obj, bool> -> IDisposable
override this.Subscribe : IObserver<System.Collections.Generic.KeyValuePair<string, obj>> * Func<string, obj, obj, bool> -> IDisposable
Public Overridable Function Subscribe (observer As IObserver(Of KeyValuePair(Of String, Object)), isEnabled As Func(Of String, Object, Object, Boolean)) As IDisposable

Parâmetros

observer
IObserver<KeyValuePair<String,Object>>

Um assinante.A subscriber.

isEnabled
Func<String,Object,Object,Boolean>

Um delegado que filtra eventos com base em seu nome e até dois objetos de contexto (que podem ser null) ou null se um filtro de evento não for desejável.A delegate that filters events based on their name and up to two context objects (which can be null), or null to if an event filter is not desirable.

Retornos

IDisposable

Uma referência a uma interface que permite que o ouvinte para de receber notificações antes que o DiagnosticSource tenha terminado de enviá-las.A reference to an interface that allows the listener to stop receiving notifications before the DiagnosticSource has finished sending them.

Comentários

Se isEnabled não estiver null , isso indica que alguns eventos não interessantes podem ser ignorados por eficiência.If isEnabled is not null, it indicates that some events are uninteresting can be skipped for efficiency.

Um site de instrumentação específico tem a opção de chamar uma ou mais IsEnabled sobrecargas em que ele passa o nome do evento e até dois outros objetos (específicos do site de instrumentação) como argumentos.A particular instrumentation site has the option of calling one or more IsEnabled overloads in which it passes the name of the event and up to two other (instrumentation site specific) objects as arguments. Se qualquer uma dessas IsEnabled chamadas for feita, esse isEnabled predicado será invocado com valores passados (se forem usadas sobrecargas menores, null serão passadas para objetos de contexto ausentes).If any of these IsEnabled calls are made then this isEnabled predicate is invoked with passed values (if shorter overloads are used, null is passed for missing context objects).

Isso permite que qualquer site de instrumentação específico possa passar para duas informações para o Assinante para fazer uma filtragem sofisticada e eficiente.This gives any particular instrumentation site the ability to pass up to two pieces of information to the subscriber to do sophisticated, efficient filtering. Isso requer mais acoplamento entre o site de instrumentação e o código do Assinante.This requires more coupling between the instrumentation site and the subscriber code.

Espera-se que um site de instrumentação específico possa chamar sobrecargas diferentes de IsEnabled para o mesmo evento, chamando primeiro IsEnabled(String) , que chama o filtro com dois null objetos de contexto.It is expected that a particular instrumentation site may call different overloads of IsEnabled for the same event, first calling IsEnabled(String), which calls the filter with two null context objects. Se isEnabled retornar true , ele chamará novamente com objetos de contexto.If isEnabled returns true, it calls again with context objects. O isEnabled filtro deve ser criado com isso em mente.The isEnabled filter should be designed with this in mind.

Observe que o isEnabled predicado é uma otimização opcional para permitir que o site de instrumentação Evite configurar a carga e chamar Write(String, Object) quando nenhum assinante se preocupa com ele.Note that the isEnabled predicate is an optional optimization to allow the instrumentation site to avoid setting up the payload and calling Write(String, Object) when no subscriber cares about it. Em particular, o site de instrumentação tem a opção de ignorar o IsEnabled predicado (não chamá-lo) e simplesmente chamar Write(String, Object) .In particular, the instrumentation site has the option of ignoring the IsEnabled predicate (not calling it) and simply calling Write(String, Object). Portanto, se o assinante exigir a filtragem, ele precisará fazê-lo por conta própria.Thus, if the subscriber requires the filtering, it needs to do it itself.

Se esse parâmetro for null , nenhuma filtragem será feita (todas as sobrecargas de IsEnabled Return true ).If this parameter is null, no filtering is done (all overloads of IsEnabled return true).

Aplica-se a

Subscribe(IObserver<KeyValuePair<String,Object>>, Predicate<String>)

Adiciona um assinante e, opcionalmente, filtra eventos com base em seu nome.Adds a subscriber, and optionally filters events based on their name.

public:
 virtual IDisposable ^ Subscribe(IObserver<System::Collections::Generic::KeyValuePair<System::String ^, System::Object ^>> ^ observer, Predicate<System::String ^> ^ isEnabled);
public virtual IDisposable Subscribe (IObserver<System.Collections.Generic.KeyValuePair<string,object?>> observer, Predicate<string>? isEnabled);
public virtual IDisposable Subscribe (IObserver<System.Collections.Generic.KeyValuePair<string,object>> observer, Predicate<string> isEnabled);
abstract member Subscribe : IObserver<System.Collections.Generic.KeyValuePair<string, obj>> * Predicate<string> -> IDisposable
override this.Subscribe : IObserver<System.Collections.Generic.KeyValuePair<string, obj>> * Predicate<string> -> IDisposable
Public Overridable Function Subscribe (observer As IObserver(Of KeyValuePair(Of String, Object)), isEnabled As Predicate(Of String)) As IDisposable

Parâmetros

observer
IObserver<KeyValuePair<String,Object>>

Um assinante.A subscriber.

isEnabled
Predicate<String>

Um delegado que filtra eventos com base em seu nome (String).A delegate that filters events based on their name (String). O delegado deverá retornar true se o evento estiver habilitado.The delegate should return true if the event is enabled.

Retornos

IDisposable

Uma referência a uma interface que permite que o ouvinte para de receber notificações antes que o DiagnosticSource tenha terminado de enviá-las.A reference to an interface that allows the listener to stop receiving notifications before the DiagnosticSource has finished sending them.

Comentários

Se isEnabled não for null , alguns eventos não serão interessantes e poderão ser ignorados por eficiência.If isEnabled is not null, some events are uninteresting and can be skipped for efficiency. O isEnabled predicado é uma otimização opcional para permitir que o site de instrumentação Evite configurar a carga e chamar Write(String, Object) quando nenhum assinante se preocupa com ele.The isEnabled predicate is an optional optimization to allow the instrumentation site to avoid setting up the payload and calling Write(String, Object) when no subscriber cares about it. Em particular, o site de instrumentação tem a opção de ignorar o IsEnabled() predicado (não chamá-lo) e simplesmente chamar Write(String, Object) .In particular the instrumentation site has the option of ignoring the IsEnabled() predicate (not calling it) and simply calling Write(String, Object). Portanto, se o assinante exigir a filtragem, ele precisará fazê-lo por conta própria.Thus if the subscriber requires the filtering, it needs to do it itself.

Se isEnabled for null , nenhuma filtragem será feita (todas as sobrecargas de IsEnabled retorno true ).If isEnabled is null, no filtering is done (all overloads of IsEnabled return true).

Aplica-se a

Subscribe(IObserver<KeyValuePair<String,Object>>, Func<String,Object,Object,Boolean>, Action<Activity,Object>, Action<Activity,Object>)

Adiciona um assinante, opcionalmente, filtra eventos com base em seu nome e até dois objetos de contexto e especifica os métodos a serem chamados quando os provedores importam ou exportam atividades de fora do processo.Adds a subscriber, optionally filters events based on their name and up to two context objects, and specifies methods to call when providers import or export activites from outside the process.

public virtual IDisposable Subscribe (IObserver<System.Collections.Generic.KeyValuePair<string,object?>> observer, Func<string,object?,object?,bool>? isEnabled, Action<System.Diagnostics.Activity,object?>? onActivityImport = default, Action<System.Diagnostics.Activity,object?>? onActivityExport = default);
public virtual IDisposable Subscribe (IObserver<System.Collections.Generic.KeyValuePair<string,object>> observer, Func<string,object,object,bool> isEnabled, Action<System.Diagnostics.Activity,object> onActivityImport = default, Action<System.Diagnostics.Activity,object> onActivityExport = default);
abstract member Subscribe : IObserver<System.Collections.Generic.KeyValuePair<string, obj>> * Func<string, obj, obj, bool> * Action<System.Diagnostics.Activity, obj> * Action<System.Diagnostics.Activity, obj> -> IDisposable
override this.Subscribe : IObserver<System.Collections.Generic.KeyValuePair<string, obj>> * Func<string, obj, obj, bool> * Action<System.Diagnostics.Activity, obj> * Action<System.Diagnostics.Activity, obj> -> IDisposable
Public Overridable Function Subscribe (observer As IObserver(Of KeyValuePair(Of String, Object)), isEnabled As Func(Of String, Object, Object, Boolean), Optional onActivityImport As Action(Of Activity, Object) = Nothing, Optional onActivityExport As Action(Of Activity, Object) = Nothing) As IDisposable

Parâmetros

observer
IObserver<KeyValuePair<String,Object>>

Um assinante.A subscriber.

isEnabled
Func<String,Object,Object,Boolean>

Um delegado que filtra eventos com base em seu nome e até dois objetos de contexto (que podem ser null) ou, se um filtro de evento não for desejável, null.A delegate that filters events based on their name and up to two context objects (which can be null), or null if an event filter is not desirable.

onActivityImport
Action<Activity,Object>

Um delegado de ação que recebe a atividade afetada por um evento externo e um objeto que representa a solicitação de entrada.An action delegate that receives the activity affected by an external event and an object that represents the incoming request.

onActivityExport
Action<Activity,Object>

Um delegado de ação que recebe a atividade afetada por um evento externo e um objeto que representa a solicitação de saída.An action delegate that receives the activity affected by an external event and an object that represents the outgoing request.

Retornos

IDisposable

Uma referência a uma interface que permite que o ouvinte para de receber notificações antes que o DiagnosticSource tenha terminado de enviá-las.A reference to an interface that allows the listener to stop receiving notifications before the DiagnosticSource has finished sending them.

Comentários

Se isEnabled for não nulo, alguns eventos não interessantes poderão ser ignorados por eficiência.If isEnabled is non-null, some events are uninteresting can be skipped for efficiency.

Você também pode fornecer os métodos ' onActivityImport ' e ' onActivityExport ' que são chamados quando os provedores importam ou exportam atividades de fora do processo (por exemplo, de solicitações HTTP).You can also supply 'onActivityImport' and 'onActivityExport' methods that are called when providers importing or export activities from outside the process (for example, from HTTP requests). Esses métodos são chamados depois de importar ou exportar a atividade e podem ser usados para modificar a atividade ou a solicitação de saída para adicionar a política.These methods are called after importing or exporting the activity and can be used to modify the activity or the outgoing request to add policy.

Aplica-se a