Sematext-Metrics
1.0.1
dotnet add package Sematext-Metrics --version 1.0.1
NuGet\Install-Package Sematext-Metrics -Version 1.0.1
<PackageReference Include="Sematext-Metrics" Version="1.0.1" />
paket add Sematext-Metrics --version 1.0.1
#r "nuget: Sematext-Metrics, 1.0.1"
// Install Sematext-Metrics as a Cake Addin #addin nuget:?package=Sematext-Metrics&version=1.0.1 // Install Sematext-Metrics as a Cake Tool #tool nuget:?package=Sematext-Metrics&version=1.0.1
sematext-metrics
A .Net Standard Client for Sematext Custom Metrics
A free account to generate API tokens is available at www.sematext.com
Installation
Package Manager
Install-Package Sematext-Metrics
.Net CLI
dotnet add package Sematext-Metrics
Initialization
Once you create an account and application via the sematext web ui you will have an app token to use when you initialize the MetricsClient
var client = new MetricsClient(<YOUR APP TOKEN>);
Usage
Send a single metric
// create a new metric
var metric = new Metric(timestamp: TimeHelper.EpochFromUtc,
name: "coffee-consumed",
value: 4,
aggregateType: AggregateTypes.Sum,
filter1: "floor=1",
filter2: "strength=bold");
// send the metric to sematext
await client.SendAsync(metric);
Send multiple metrics
// create a list to hold multple metrics
var metrics = new List<Metric>();
// create the first metric
metrics.Add(new Metric(timestamp: TimeHelper.EpochFromUtc,
name: "coffee-consumed",
value: 4,
aggregateType: AggregateTypes.Sum,
filter1: "floor=1",
filter2: "strength=bold"));
// create the second metric
metrics.Add(new Metric(timestamp: TimeHelper.EpochFromUtc,
name: "coffee-consumed",
value: 1,
aggregateType: AggregateTypes.Sum,
filter1: "floor=3",
filter2: "strength=medium"));
// send the metrics to sematext
await client.SendAsync(metrics);
Configuration
To send metrics to a different api endpoint (if you are running an on-premise SPM setup) you can override the default endpoint when you initialize the MetricsClient
var customEndpoint = new Uri("http://spm-receiver.example.com/spm-receiver/custom/receive.raw");
var client = new MetricsClient(<YOUR APP TOKEN>, customEndpoint);
Running the unit tests
If you want to run the unit tests in the solution you first need to set an environment variable named SEMATEXT_APP_TOKEN
. This environment variable is used in the TestCaseBase
class when it creates the MetricsClient
that is used to run the unit tests.
Powershell
[Environment]::SetEnvironmentVariable("SEMATEXT_APP_TOKEN", "<YOUR APP TOKEN>", "User")
Further Reading
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Newtonsoft.Json (>= 10.0.3)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Changed metric values from int to double so it will support both counter and measurement style metrics