Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Features/filter #296

Merged
merged 4 commits into from
Aug 1, 2016
Merged

Features/filter #296

merged 4 commits into from
Aug 1, 2016

Conversation

gupele
Copy link
Contributor

@gupele gupele commented Jul 29, 2016

No description provided.

*
* Created by gupele on 7/26/2016.
*/
public class DebugProcessor implements TelemetryProcessor {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May be worth to make this sample a little easier to read:

  1. I would rename to SampleProcessor (instead of DebugProcessor)
  2. Maybe rename setBad to setPass
  3. Add documentation that explains the goal of the filter and that in the sample filter setPass chooses whether to pass all telemetry or to drop all telemetry.

@gupele gupele merged commit 16bc1f4 into master Aug 1, 2016
@jgogstad
Copy link
Contributor

jgogstad commented Aug 8, 2016

Any documentation on how to configure the processors that came in 1.0.5? For example how to configure the Sets in PageViewTelemetryFilter.

@gupele
Copy link
Contributor Author

gupele commented Aug 8, 2016

Hi @jgogstad,

The filters go into a new XML tag "TelemetryProcessor". There you can choose and customize the built in ones and/or new custom filters

For example,

<ApplicationInsights>
   <TelemetryProcessors>

      <BuiltInProcessors>
           <Processor type="TraceTelemetryFilter">
                  <Add name="FromSeverityLevel" value="ERROR"/>
           </Processor>

           <Processor type="RequestTelemetryFilter">
                  <Add name="MinimumDurationInMS" value="100"/>
                  <Add name="NotNeededResponseCodes" value="200-400"/>
           </Processor>

           <Processor type="PageViewTelemetryFilter">
                  <Add name="DurationThresholdInMS" value="100"/>
           </Processor>

           <Processor type="SyntheticSourceFilter"/>

     </BuiltInProcessors>

     <CustomProcessors>
        <Processor type="com.microsoft.applicationinsights.sample.SampleFilter">
            <Add name="Pass" value="false"/>
        </Processor>
    </CustomProcessors>

 </TelemetryProcessors>
</ApplicationInsights>

In this example the configuration file declares built in filters and one custom one.
Basically, to instantiate a filter you need to implement the TelemetryProcessor interface

The method to implement is 'public boolean process(Telemetry telemetry)' where a telemetry is passed to the method which returns a boolean value:
'True' - The telemetry is 'approved'. Note that other filters can veto the telemetry which will prevent it from being sent
'False' - The telemetry is not approved. This means the telemetry will not be sent

Filters are a good way to filter out telemetries you don't care for and by doing so reduce the traffic.

The filter can get data from configuration by having a 'setXXX' method that matches its property name.
For example, if the filter has a property 'percentage', it should have a 'setPercentage(string percentage)' method and then you can pass data from configuration like this:

<Processor type="full.path.to.CustomFilter>
<Add name "Percentage" value="50"/>

The framework will instantiate the class and will use reflection to set the value in the proper method (please read the 'SampleFilter).

The framework also sets its own 'common' filters to ease the work of users.

The following are the current 'built in' filters

TraceTelemetryFilter
This filter can filter out log telemetries. In our above example, only logs with severity level of Error and above (Critical) will be sent.
This is a good way to have your app produce logs in lower severity level but on the same time, send only the ones that will be fully helpful

PageViewTelemetryFilter
This filter can filter out PageViewTelemetries.
You can set the 'NotNeededUrls' to collection of urls to prevent them from being sent. For example: <Add name="NotNeededUrls" value="badsite1, badsite2"/> which means that Urls that contain those keywords will not be sent

    You can set the 'NotNeededNames' much in the same way to prevent PageView with those names

    You can set the 'DurationThresholdInMS' to filter out PageViews that had a duration of less than this value

RequestTelemetryFilter
This filter can filter out RequestTelemetries
You can set the 'NotNeededResponseCodes' to prevent from requests with those response codes to be sent. For example <Add name="NotNeededResponseCodes" value="200-400,500"/>

    You can set the 'MinimumDurationInMS' to send only 'slow' requests.

SyntheticSourceFilter
This filter can filter out all telemetries that are originated in a synthetic source (you can also set the source names to block)

TelemetryEventFilter
This filter can filter out EventTelemtries
This filter can be useful in case you use the SDK for creating Event Telemetries but then in production, you would like to prevent some of them from being sent without re-compiling your code.

We will soon have blog post for that and please note that we are working to add more 'built in' filters and enhance the current ones.

Thanks

@jgogstad
Copy link
Contributor

jgogstad commented Aug 8, 2016

Thanks for the clarification! I tried your sample configuration, and it resulted in a NullPointerException. See #305

@dhaval24 dhaval24 deleted the features/filter branch December 2, 2017 00:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants