Skip to content

Latest commit

 

History

History
171 lines (125 loc) · 8.71 KB

wavefrontsender.md

File metadata and controls

171 lines (125 loc) · 8.71 KB

Set Up an IWavefrontSender Instance

Table of Content

Overview

You can send metrics, histograms, or trace data from your application to the Wavefront service using a Wavefront proxy or direct ingestions.

  • Use a Wavefront proxy, which then forwards the data to the Wavefront service. This is the recommended choice for a large-scale deployment that needs resilience to internet outages, control over data queuing and filtering, and more.
  • Use direct ingestion to send the data directly to the Wavefront service. This is the simplest way to get up and running quickly.

The IWavefrontSender interface has two implementations:

Option 1: Sending Data via the Wavefront Proxy

Prerequisite Before your application can use a WavefrontProxyClient, you must set up and start a Wavefront proxy.

When sending data via the Wavefront proxy, you need to create a WavefrontProxyClient. Include the following information.

  • The name of the host that will run the Wavefront proxy.
  • One or more proxy listening ports to send data to. The ports you specify depend on the kinds of data you want to send (metrics, histograms, and/or trace data). You must specify at least one listener port.
  • Optional settings for tuning communication with the proxy.

Note: See Advanced Proxy Configuration and Installation for details.

// Create the builder with the proxy hostname or address
WavefrontProxyClient.Builder wfProxyClientBuilder = new WavefrontProxyClient.Builder(proxyHostName);

// Set the proxy port to send metrics to. Default: 2878
wfProxyClientBuilder.MetricsPort(2878);

// Set a proxy port to send histograms to.  Recommended: 2878
wfProxyClientBuilder.DistributionPort(2878);

// Set a proxy port to send trace data to. Recommended: 30000
wfProxyClientBuilder.TracingPort(30_000);

// Optional: Set a nondefault interval (in seconds) for flushing data from the sender to the proxy. Default: 5 seconds
wfProxyClientBuilder.FlushIntervalSeconds(2);

// Create the WavefrontProxyClient
IWavefrontSender wavefrontSender = wfProxyClientBuilder.Build();

Note: When you set up a Wavefront proxy on the specified proxy host, you specify the port it will listen to for each type of data to be sent. The WavefrontProxyClient must send data to the same ports that the Wavefront proxy listens to. Consequently, the port-related builder methods must specify the same port numbers as the corresponding proxy configuration properties. See the following table:

WavefrontProxyClient builder method Corresponding property in wavefront.conf
MetricsPort() pushListenerPorts=
DistributionPort() histogramDistListenerPorts=
TracingPort() traceListenerPorts=

Option 2: Sending Data via Direct Ingestion

When sending data via direct ingestion, you need to create a WavefrontDirectIngestionClient, and build it with the Wavefront URL and API token to send data directly to Wavefront.

Prerequisite

  • Verify that you have the Direct Data Ingestion permission. For details, see Examine Groups, Roles, and Permissions.
  • The URL of your Wavefront instance. This is the URL you connect to when you log in to Wavefront, typically something like https://<domain>.wavefront.com.
  • Obtain the API token.

Initialize the WavefrontDirectIngestionClient

You initialize a WavefrontDirectIngestionClient by building it with the access information you obtained in the Prerequisite section.

You can optionally call builder methods to tune the following ingestion properties:

  • Max queue size - Internal buffer capacity of the Wavefront sender. Any data in excess of this size is dropped.
  • Flush interval - Interval for flushing data from the Wavefront sender directly to Wavefront.
  • Batch size - Amount of data to send to Wavefront in each flush interval.

Together, the batch size and flush interval control the maximum theoretical throughput of the Wavefront sender. Override the defaults only to set higher values.

// Create a builder with the Wavefront URL and a Wavefront API token
// that was created with direct ingestion permission.
WavefrontDirectIngestionClient.Builder wfDirectIngestionClientBuilder =
  new WavefrontDirectIngestionClient.Builder(wavefrontURL, token);

// Optional: Override the max queue size (in data points). Default: 50,000
wfDirectIngestionClientBuilder.MaxQueueSize(100_000);

// Optional: Override the batch size (in data points). Default: 10,000
wfDirectIngestionClientBuilder.BatchSize(20_000);

// Optional: Override the flush interval (in seconds). Default: 1 second
wfDirectIngestionClientBuilder.FlushIntervalSeconds(2);

// Create a WavefrontDirectIngestionClient.
IWavefrontSender wavefrontSender = wfDirectIngestionClientBuilder.Build();

Share an IWavefrontSender Instance

If you are using multiple Wavefront C# SDKs within the same process, you can instantiate the IWavefrontSender just once and share it among the SDKs.

For example, the following snippet shows how to use the same Wavefront sender when setting up the wavefront-appmetrics-sdk-csharp and wavefront-opentracing-sdk-csharp SDKs.

// Create a Wavefront sender, assuming you have a configuration file
IWavefrontSender wavefrontSender = BuildProxyOrDirectSender(config);

// Create a WavefrontSpanReporter for the OpenTracing SDK
IReporter spanReporter = new WavefrontSpanReporter.Builder()
  .WithSource("wavefront-tracing-example")
  .Build(wavefrontSender);

// Create a Wavefront reporter for the App Metrics SDK
IMetricsRoot metrics = new MetricsBuilder()
  .Report.ToWavefront(wavefrontSender)
  .Build();
...

Note: If you use the SDKs in different processes, you must instantiate one IWavefrontSender instance per process.

Where to Go Next

To continue, select one of the Wavefront C# SDK links in the table below.

SDK Type SDK Description .Net/C# SDKs
OpenTracing SDK Implements the OpenTracing specification. Lets you define, collect, and report custom trace data from any part of your application code.
Automatically derives RED metrics from the reported spans.
C# OpenTracing SDK
Metrics SDK Implements a standard metrics library. Lets you define, collect, and report custom business metrics and histograms from any part of your application code. App Metrics SDK
Framework SDK Reports predefined traces, metrics, and histograms from the APIs of a supported app framework. Lets you get started quickly with minimal code changes. ASP.Net core
Sender SDK Lets you send raw values to Wavefront for storage as metrics, histograms, or traces, e.g., to import CSV data into Wavefront. C# Sender SDK