{"id":26057646,"url":"https://github.com/wavefronthq/wavefront-sdk-csharp","last_synced_at":"2025-04-11T05:06:46.004Z","repository":{"id":33266627,"uuid":"143469346","full_name":"wavefrontHQ/wavefront-sdk-csharp","owner":"wavefrontHQ","description":"Wavefront Core C# SDK","archived":false,"fork":false,"pushed_at":"2023-01-12T23:33:45.000Z","size":265,"stargazers_count":4,"open_issues_count":4,"forks_count":9,"subscribers_count":32,"default_branch":"master","last_synced_at":"2025-04-11T05:06:37.714Z","etag":null,"topics":["core","csharp","monitoring","sdk","wavefront"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wavefrontHQ.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-08-03T20:12:02.000Z","updated_at":"2023-01-17T15:43:30.000Z","dependencies_parsed_at":"2023-01-15T00:13:24.148Z","dependency_job_id":null,"html_url":"https://github.com/wavefrontHQ/wavefront-sdk-csharp","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wavefrontHQ%2Fwavefront-sdk-csharp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wavefrontHQ%2Fwavefront-sdk-csharp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wavefrontHQ%2Fwavefront-sdk-csharp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wavefrontHQ%2Fwavefront-sdk-csharp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wavefrontHQ","download_url":"https://codeload.github.com/wavefrontHQ/wavefront-sdk-csharp/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248345265,"owners_count":21088244,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["core","csharp","monitoring","sdk","wavefront"],"created_at":"2025-03-08T11:58:13.087Z","updated_at":"2025-04-11T05:06:45.964Z","avatar_url":"https://github.com/wavefrontHQ.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Wavefront by VMware SDK for C# [![travis build status](https://travis-ci.com/wavefrontHQ/wavefront-sdk-csharp.svg?branch=master)](https://travis-ci.com/wavefrontHQ/wavefront-sdk-csharp) [![NuGet](https://img.shields.io/nuget/v/Wavefront.SDK.CSharp.svg)](https://www.nuget.org/packages/Wavefront.SDK.CSharp)\n\n## Table of Content\n* [Prerequisites](#Prerequisites)\n* [Set Up an IWavefrontSender](#set-up-an-iwavefrontsender)\n* [Send Data to Wavefront](#send-data-to-wavefront)\n* [Close the IWavefrontSender](#close-the-iwavefrontsender)\n* [License](#License)\n* [How to Get Support and Contribute](#how-to-get-support-and-contribute)\n\n# Welcome to the Wavefront C# SDK\n\nWavefront by VMware C# SDK lets you send raw data from your .NET application to the Wavefront `IWavefrontSender` interface. The data is then stored as metrics, histograms, and trace data. This SDK is also called the Wavefront Sender SDK for C#. \n\nAlthough this library is mostly used by the other Wavefront C# SDKs to send data to Wavefront, you can also use this SDK directly. For example, you can send data directly from a data store or CSV file to Wavefront.\n\n**Before you start implementing, let us make sure you are using the correct SDK!**\n\n![C# Sender SDK Decision Tree](docs/csharp_sender_sdk.png)\n\n\u003e ***Note***:\n\u003e \u003c/br\u003e\n\u003e   * **This is the Wavefront by VMware SDK for C# (Wavefront Sender SDK for C#)!**\n\u003e   If this SDK is not what you were looking for, see the [table](#wavefront-sdks) below.\n\n\n#### Wavefront SDKs\n\u003ctable id=\"SDKlevels\" style=\"width: 100%\"\u003e\n\u003ctr\u003e\n  \u003cth width=\"10%\"\u003eSDK Type\u003c/th\u003e\n  \u003cth width=\"45%\"\u003eSDK Description\u003c/th\u003e\n  \u003cth width=\"45%\"\u003eSupported Languages\u003c/th\u003e\n\u003c/tr\u003e\n\n\u003ctr\u003e\n  \u003ctd\u003e\u003ca href=\"https://docs.wavefront.com/wavefront_sdks.html#sdks-for-collecting-metrics-and-histograms\"\u003eMetrics SDK\u003c/a\u003e\u003c/td\u003e\n  \u003ctd align=\"justify\"\u003eImplements a standard metrics library. Lets you define, collect, and report custom business metrics and histograms from any part of your application code.   \u003c/td\u003e\n  \u003ctd\u003e\n    \u003cul\u003e\n    \u003cli\u003e\n    \u003cb\u003eJava\u003c/b\u003e: \u003ca href =\"https://github.com/wavefrontHQ/wavefront-dropwizard-metrics-sdk-java\"\u003eDropwizard\u003c/a\u003e \u003cb\u003e|\u003c/b\u003e \u003ca href =\"https://github.com/wavefrontHQ/wavefront-runtime-sdk-jvm\"\u003eJVM\u003c/a\u003e\n    \u003c/li\u003e\n    \u003cli\u003e\n    \u003cb\u003ePython\u003c/b\u003e: \u003ca href =\"https://github.com/wavefrontHQ/wavefront-pyformance\"\u003ePyformance SDK\u003c/a\u003e\n    \u003c/li\u003e\n    \u003cli\u003e\n      \u003cb\u003eGo\u003c/b\u003e: \u003ca href =\"https://github.com/wavefrontHQ/go-metrics-wavefront\"\u003eGo Metrics SDK\u003c/a\u003e\n      \u003c/li\u003e\n    \u003cli\u003e\n    \u003cb\u003e.Net/C#\u003c/b\u003e: \u003ca href =\"https://github.com/wavefrontHQ/wavefront-appmetrics-sdk-csharp\"\u003eApp Metrics SDK\u003c/a\u003e\n    \u003c/li\u003e\n    \u003c/ul\u003e\n  \u003c/td\u003e\n\u003c/tr\u003e\n\n\u003ctr\u003e\n  \u003ctd\u003e\u003ca href=\"https://docs.wavefront.com/wavefront_sdks.html#sdks-for-sending-raw-data-to-wavefront\"\u003eSender SDK\u003c/a\u003e\u003c/td\u003e\n  \u003ctd align=\"justify\"\u003eLets you send raw data to Wavefront for storage as metrics, histograms, or traces, e.g., to import CSV data into Wavefront.\n  \u003c/td\u003e\n  \u003ctd\u003e\n    \u003cul\u003e\n    \u003cli\u003e\n    \u003cb\u003eJava\u003c/b\u003e: \u003ca href =\"https://github.com/wavefrontHQ/wavefront-sdk-java\"\u003eSender SDK\u003c/a\u003e\n    \u003c/li\u003e\n    \u003cli\u003e\n    \u003cb\u003ePython\u003c/b\u003e: \u003ca href =\"https://github.com/wavefrontHQ/wavefront-sdk-python\"\u003eSender SDK\u003c/a\u003e\n    \u003c/li\u003e\n    \u003cli\u003e\n    \u003cb\u003eGo\u003c/b\u003e: \u003ca href =\"https://github.com/wavefrontHQ/wavefront-sdk-go\"\u003eSender SDK\u003c/a\u003e\n    \u003c/li\u003e\n    \u003cli\u003e\n    \u003cb\u003e.Net/C#\u003c/b\u003e: \u003ca href =\"https://github.com/wavefrontHQ/wavefront-sdk-csharp\"\u003eSender SDK\u003c/a\u003e\n    \u003c/li\u003e\n    \u003cli\u003e\n    \u003cb\u003eC++\u003c/b\u003e: \u003ca href =\"https://github.com/wavefrontHQ/wavefront-sdk-cpp\"\u003eSender SDK\u003c/a\u003e\n    \u003c/li\u003e\n    \u003c/ul\u003e\n  \u003c/td\u003e\n\u003c/tr\u003e\n\n\u003c/table\u003e\n\n## Prerequisites\n* Supported Frameworks\n  * .NET Framework (\u003e= 4.5.2)\n  * .NET Standard (\u003e= 2.0)\n\n* Installation\n  \n  Install the [NuGet package](https://www.nuget.org/packages/Wavefront.SDK.CSharp/) using the Package Manager Console or the .NET CLI Console\n  \n  * Package Manager Console\n      ```\n      PM\u003e Install-Package Wavefront.SDK.CSharp\n      ```\n  * .NET CLI Console\n      ```\n      \u003e dotnet add package Wavefront.SDK.CSharp\n      ```\n  \n## Set Up an IWavefrontSender\n\nYou can send metrics, histograms, or trace data from your application to the Wavefront service using a Wavefront proxy or direct ingestions.\n\n* Option 1: Use a [**Wavefront proxy**](https://docs.wavefront.com/proxies.html), 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.\n[Create a ProxyConfiguration](#option-1-sending-data-via-the-wavefront-proxy) to send data to a Wavefront proxy.\n  \n* Use [**direct ingestion**](https://docs.wavefront.com/direct_ingestion.html) to send the data directly to the Wavefront service. This is the simplest way to get up and running quickly.\n[Create a DirectConfiguration](#option-2-sending-data-via-direct-ingestion) to send data directly to a Wavefront service.\n  \n### Option 1: Sending Data via the Wavefront Proxy\n\nBefore data can be sent from your application, you must ensure the Wavefront proxy is configured and running:\n* [Install](http://docs.wavefront.com/proxies_installing.html) a Wavefront proxy on the specified proxy host .\n* Make sure you have [Proxies permission](https://docs.wavefront.com/permissions_overview.html) in Wavefront.\n* [Configure](http://docs.wavefront.com/proxies_configuring.html) the proxy to listen to the specified port(s) by setting the corresponding properties: `pushListenerPorts`, `histogramDistListenerPorts`, `traceListenerPorts`\n* Start (or restart) the proxy.\n\n```csharp\n// Create the builder with the proxy hostname or address\nWavefrontProxyClient.Builder wfProxyClientBuilder = new WavefrontProxyClient.Builder(proxyHostName);\n\n// Note: At least one of metrics/histogram/tracing port is required.\n// Only set a port if you wish to send that type of data to Wavefront and you\n// have the port enabled on the proxy.\n\n// Set the pushListenerPort (example: 2878) to send metrics to Wavefront\nwfProxyClientBuilder.MetricsPort(2878);\n\n// Set the histogramDistListenerPort (example: 2878) to send histograms to Wavefront\nwfProxyClientBuilder.DistributionPort(2878);\n\n// Set the traceListenerPort (example: 30,000) to send opentracing spans to Wavefront\nwfProxyClientBuilder.TracingPort(30_000);\n\n// Optional: Set this to override the default flush interval of 5 seconds\nwfProxyClientBuilder.FlushIntervalSeconds(2);\n\n// Finally create a WavefrontProxyClient\nIWavefrontSender wavefrontSender = wfProxyClientBuilder.Build();\n```\n\n### Option 2: Sending Data via Direct Ingestion\nTo create a `WavefrontDirectIngestionClient`, you must have access to a Wavefront instance with [Direct Data Ingestion permission](https://docs.wavefront.com/permissions_overview.html):\n\n```csharp\n// Create a builder with the URL of the form \"https://DOMAIN.wavefront.com\"\n// and a Wavefront API token with direct ingestion permission\nWavefrontDirectIngestionClient.Builder wfDirectIngestionClientBuilder =\n  new WavefrontDirectIngestionClient.Builder(wavefrontURL, token);\n\n// Optional configuration properties.\n// Only override the defaults to set higher values.\n\n// This is the size of internal buffer beyond which data is dropped\n// Optional: Set this to override the default max queue size of 50,000\nwfDirectIngestionClientBuilder.MaxQueueSize(100_000);\n\n// This is the max batch of data sent per flush interval\n// Optional: Set this to override the default batch size of 10,000\nwfDirectIngestionClientBuilder.BatchSize(20_000);\n\n// Together with batch size controls the max theoretical throughput of the sender\n// Optional: Set this to override the default flush interval value of 1 second\nwfDirectIngestionClientBuilder.FlushIntervalSeconds(2);\n\n// Finally create a WavefrontDirectIngestionClient\nIWavefrontSender wavefrontSender = wfDirectIngestionClientBuilder.Build();\n```\n\n## Send Data to Wavefront\n \n Wavefront supports different metric types, such as gauges, counters, delta counters, histograms, traces, and spans. See [Metrics](https://docs.wavefront.com/metric_types.html) for details. To send data to Wavefront using `IWavefrontSender` you need to instantiate the following:\n * [Metrics and Delta Counters](#Metrics-and-Delta-Counters)\n * [Distributions (Histograms)](#distributions-histograms)\n * [Tracing Spans](#Tracing-Spans)\n\n### Metrics and Delta Counters\n\n```csharp\n// Wavefront Metrics Data format\n// \u003cmetricName\u003e \u003cmetricValue\u003e [\u003ctimestamp\u003e] source=\u003csource\u003e [pointTags]\n// Example: \"new-york.power.usage 42422 1533529977 source=localhost datacenter=dc1\"\nwavefrontSender.SendMetric(\n    \"new-york.power.usage\",\n    42422.0,\n    DateTimeUtils.UnixTimeMilliseconds(DateTime.UtcNow),\n    \"localhost\",\n    new Dictionary\u003cstring, string\u003e { { \"datacenter\", \"dc1\" } }.ToImmutableDictionary()\n);\n\n// Wavefront Delta Counter format\n// \u003cmetricName\u003e \u003cmetricValue\u003e source=\u003csource\u003e [pointTags]\n// Example: \"lambda.thumbnail.generate 10 source=lambda_thumbnail_service image-format=jpeg\"\nwavefrontSender.SendDeltaCounter(\n    \"lambda.thumbnail.generate\",\n    10,\n    \"lambda_thumbnail_service\",\n    new Dictionary\u003cstring, string\u003e { { \"image-format\", \"jpeg\" } }.ToImmutableDictionary()\n);\n```\n\n### Distributions (Histograms)\n\n```csharp\n// Wavefront Histogram Data format\n// {!M | !H | !D} [\u003ctimestamp\u003e] #\u003ccount\u003e \u003cmean\u003e [centroids] \u003chistogramName\u003e source=\u003csource\u003e\n// [pointTags]\n// Example: You can choose to send to at most 3 bins: Minute, Hour, Day\n// \"!M 1533529977 #20 30.0 #10 5.1 request.latency source=appServer1 region=us-west\"\n// \"!H 1533529977 #20 30.0 #10 5.1 request.latency source=appServer1 region=us-west\"\n// \"!D 1533529977 #20 30.0 #10 5.1 request.latency source=appServer1 region=us-west\"\nwavefrontSender.SendDistribution(\n    \"request.latency\",\n    ImmutableList.Create(\n        new KeyValuePair\u003cdouble, int\u003e(30.0, 20),\n        new KeyValuePair\u003cdouble, int\u003e(5.1, 10)\n    ),\n    ImmutableHashSet.Create(\n        HistogramGranularity.Minute,\n        HistogramGranularity.Hour,\n        HistogramGranularity.Day\n    ),\n    DateTimeUtils.UnixTimeMilliseconds(DateTime.UtcNow),\n    \"appServer1\",\n    new Dictionary\u003cstring, string\u003e { { \"region\", \"us-west\" } }.ToImmutableDictionary()\n);\n```\n\n### Tracing Spans\n\nWhen you use a Sender SDK, you won’t see span-level RED metrics by default unless you use the Wavefront proxy and define a custom tracing port (`TracingPort`). See [Instrument Your Application with Wavefront Sender SDKs](https://docs.wavefront.com/tracing_instrumenting_frameworks.html#instrument-your-application-with-wavefront-sender-sdks) for details.\n\n\n```csharp\n // Wavefront Tracing Span Data format\n // \u003ctracingSpanName\u003e source=\u003csource\u003e [pointTags] \u003cstart_millis\u003e \u003cduration_milliseconds\u003e\n // Example: \"getAllUsers source=localhost\n //           traceId=7b3bf470-9456-11e8-9eb6-529269fb1459\n //           spanId=0313bafe-9457-11e8-9eb6-529269fb1459\n //           parent=2f64e538-9457-11e8-9eb6-529269fb1459\n //           application=Wavefront http.method=GET\n //           1552949776000 343\"\nwavefrontSender.SendSpan(\n    \"getAllUsers\",\n    DateTimeUtils.UnixTimeMilliseconds(DateTime.UtcNow),\n    343,\n    \"localhost\",\n    new Guid(\"7b3bf470-9456-11e8-9eb6-529269fb1459\"),\n    new Guid(\"0313bafe-9457-11e8-9eb6-529269fb1459\"),\n    ImmutableList.Create(new Guid(\"2f64e538-9457-11e8-9eb6-529269fb1459\")),\n    null,\n    ImmutableList.Create(\n        new KeyValuePair\u003cstring, string\u003e(\"application\", \"Wavefront\"),\n        new KeyValuePair\u003cstring, string\u003e(\"service\", \"istio\"),\n        new KeyValuePair\u003cstring, string\u003e(\"http.method\", \"GET\")\n    ),\n    null\n);\n```\n\n## Close the IWavefrontSender\nBefore shutting down your application, flush the buffer and close the sender.\n\n```csharp\n// If there are any failures observed while sending metrics/histograms/tracing-spans above,\n// you get the total failure count using the below API\nint totalFailures = wavefrontSender.GetFailureCount();\n\n// on-demand buffer flush (may want to do this if you are shutting down your application)\nwavefrontSender.Flush();\n\n// close the sender connection before shutting down application\n// this will flush in-flight buffer and close connection\nwavefrontSender.Close();\n```\n\n## License\n[Apache 2.0 License](LICENSE).\n\n## How to Get Support and Contribute\n\n* Reach out to us on our public [Slack channel](https://www.wavefront.com/join-public-slack).\n* If you run into any issues, let us know by creating a GitHub issue.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwavefronthq%2Fwavefront-sdk-csharp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwavefronthq%2Fwavefront-sdk-csharp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwavefronthq%2Fwavefront-sdk-csharp/lists"}