https://github.com/alastairwyse/applicationmetrics.metricloggers.opentelemetry
An ApplicationMetrics metric logger which writes metric and instrumentation events using the OpenTelemetry protocol
https://github.com/alastairwyse/applicationmetrics.metricloggers.opentelemetry
Science Score: 26.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (6.1%) to scientific vocabulary
Repository
An ApplicationMetrics metric logger which writes metric and instrumentation events using the OpenTelemetry protocol
Basic Info
- Host: GitHub
- Owner: alastairwyse
- License: apache-2.0
- Language: C#
- Default Branch: master
- Size: 43 KB
Statistics
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
- Releases: 0
Metadata Files
README.md
ApplicationMetrics.MetricLoggers.OpenTelemetry
An implementation of an ApplicationMetrics metric logger which writes metrics and instrumentation using the OpenTelemetry protocol.
Metric Mappings
Metric types in ApplicationMetrics are mapped to the following OpenTelemetry instruments...
| ApplicationMetrics Metric Type | OpenTelemetry Instrument | | ------------------------------ | ----------- | | CountMetric | Counter | | AmountMetric | Counter or Histogram (configurable, defaults to Counter) | | StatusMetric | Gauge | | IntervalMetric | Counter or Histogram (configurable, defaults to Histogram) |
Setup
The OpenTelemetryMetricLogger class use the OTLP Exporter for OpenTelemetry .NET library, and hence can be configued via an OtlpExporterOptions object. This OtlpExporterOptions object can be set via OpenTelemetryMetricLogger constructor parameter 'otlpExporterConfigurationAction'. The code below demonstrates the setup and use case (with fake metrics logged) of the OpenTelemetryMetricLogger class...
C#
var meterOptions = new MeterOptions("OpenTelemetryMetricLoggerTest");
Action<OtlpExporterOptions> otlpExporterConfigurationAction = (options) =>
{
options.Protocol = OtlpExportProtocol.HttpProtobuf;
options.Endpoint = new Uri("http://127.0.0.1:4318/v1/metrics");
};
using (var metricLogger = new OpenTelemetryMetricLogger(IntervalMetricBaseTimeUnit.Millisecond, true, meterOptions, otlpExporterConfigurationAction))
{
Guid beginId = metricLogger.Begin(new MessageSendTime());
Thread.Sleep(20);
metricLogger.Increment(new MessageSent());
metricLogger.Add(new MessageSize(), 2661);
metricLogger.End(beginId, new MessageSendTime());
}
Alternate mappings for AmountMetric and IntervalMetrics can be set via the OpenTelemetryMetricLogger constructor...
C#
var metricLogger = new OpenTelemetryMetricLogger
(
IntervalMetricBaseTimeUnit.Millisecond,
true,
meterOptions,
otlpExporterConfigurationAction,
OpenTelemetryMetricType.Historgram, // mapping for AmountMetrics
OpenTelemetryMetricType.Counter // mapping for IntervalMetrics
)
The OpenTelemetryMetricLogger class accepts the following constructor parameters...
| Parameter Name | Description | | -------------- | ----------- | | intervalMetricBaseTimeUnit | The base time unit to use to log interval metrics. | | intervalMetricChecking | Specifies whether an exception should be thrown if the correct order of interval metric logging is not followed (e.g. End() method called before Begin()). This parameter is ignored when the the OpenTelemetryMetricLogger operates in 'interleaved' mode. | | meterName | (optional) The name set on the underlying OpenTelemetry Meter class. | | meterOptions | (optional) The options to set on the underlying OpenTelemetry Meter class. | | otlpExporterConfigurationAction | An action which configures the underlying OpenTelemetry exporter. | | amountMetricMappedType | (optional) The type of OpenTelemetry instruments that AmountMetrics are mapped to. | | intervalMetricMappedType | (optional) The type of OpenTelemetry instruments that IntervalMetrics are mapped to. |
Non-interleaved Method Overloads
Methods which support 'non-interleaved' interval metric logging (i.e. overloads of End() and CancelBegin() methods which don't accept a Guid) have been configured as explicit implementations on interface IMetricLogger. Hence they cannot be called on an instance of OpenTelemetryMetricLogger without first casting the instance to IMetricLogger. This is to discourage the use of these methods as they will be deprecated in a future version of ApplicationMetrics.
Links
The documentation below was written for version 1.* of ApplicationMetrics. Minor implementation details may have changed in versions 2.0.0 and above, however the basic principles and use cases documented are still valid. Note also that this documentation demonstrates the older 'non-interleaved' method of logging interval metrics.
Full documentation for the project...
http://www.alastairwyse.net/methodinvocationremoting/application-metrics.html
A detailed sample implementation...
http://www.alastairwyse.net/methodinvocationremoting/sample-application-5.html
Release History
| Version | Changes | | ------- | ------- | | 1.1.0 | Updated to ApplicationMetrics version 7.0.0. | | 1.0.0 | Initial release. |
Owner
- Name: Alastair Wyse
- Login: alastairwyse
- Kind: user
- Repositories: 20
- Profile: https://github.com/alastairwyse
GitHub Events
Total
- Push event: 3
- Create event: 3
Last Year
- Push event: 3
- Create event: 3
Packages
- Total packages: 1
-
Total downloads:
- nuget 167 total
- Total dependent packages: 0
- Total dependent repositories: 0
- Total versions: 1
- Total maintainers: 1
nuget.org: applicationmetrics.metricloggers.opentelemetry
An ApplicationMetrics metric logger which writes metric and instrumentation events using the OpenTelemetry protocol.
- Homepage: https://github.com/alastairwyse/ApplicationMetrics.MetricLoggers.OpenTelemetry/
- License: Apache-2.0
-
Latest release: 1.1.0
published 12 months ago
Rankings
Maintainers (1)
Dependencies
- ApplicationMetrics 6.4.1
- OpenTelemetry.Exporter.OpenTelemetryProtocol 1.11.1
- Microsoft.NET.Test.Sdk 17.13.0
- NSubstitute 5.3.0
- NUnit 3.14.0
- NUnit3TestAdapter 5.0.0