![]() |
VOOZH | about |
dotnet add package AElf.OpenTelemetry --version 8.2.1
NuGet\Install-Package AElf.OpenTelemetry -Version 8.2.1
<PackageReference Include="AElf.OpenTelemetry" Version="8.2.1" />
<PackageVersion Include="AElf.OpenTelemetry" Version="8.2.1" />Directory.Packages.props
<PackageReference Include="AElf.OpenTelemetry" />Project file
paket add AElf.OpenTelemetry --version 8.2.1
#r "nuget: AElf.OpenTelemetry, 8.2.1"
#:package AElf.OpenTelemetry@8.2.1
#addin nuget:?package=AElf.OpenTelemetry&version=8.2.1Install as a Cake Addin
#tool nuget:?package=AElf.OpenTelemetry&version=8.2.1Install as a Cake Tool
An OpenTelemetry module for use in ABP and Orleans framework.
This project is a module for ABP and Orleans framework to use OpenTelemetry. It provides a simple and fast way to integrate OpenTelemetry in ABP and Orleans framework.
The module will provide instrumentation for both ASP and Orleans out of the box:
Run the following command in your project to install this module:
dotnet add package AElf.OpenTelemetry
To configure your opentelemetry service name, version and collector's endpoint, you need to add the following to your appsettings.json file:
{
"OpenTelemetry": {
"ServiceName": "YourServiceName",
"ServiceVersion": "YourServiceVersion",
"CollectorEndpoint": "http://localhost:4315"
}
}
Add the following dependency to your project's Module class:
using AElf.OpenTelemetry;
[DependsOn(
typeof(OpenTelemetryModule)
)]
public class MyTemplateModule : AbpModule
This will automatically register the OpenTelemetry module and setup your project for instrumentation.
For Orleans, you need to add the following to your SiloBuilder:
hostBuilder.UseOrleans((context, siloBuilder) =>
{
siloBuilder.AddActivityPropagation();
});
Do the same for the Clientbuilder:
hostBuilder.UseOrleansClient((context, clientBuilder) =>
{
clientBuilder.AddActivityPropagation();
});
This will automatically propagate the respective activities of the Orleans grain calls.
Here are some examples of how to use this module.
AggregateExecutionTime is an attribute that can be used to measure the execution time of a class's method. It can be used in both ABP and Orleans framework, either on the class or method level.
Class level:
using AElf.OpenTelemetry.ExecutionTime;
[AggregateExecutionTime]
public class MessageValidatorGrain : Grain
Method level:
[AggregateExecutionTime]
public Task<bool> IsOffensive(string message)
The attribute can also be used in ABP's services or controllers.
[AggregateExecutionTime]
public class AuthorAppService : ApplicationService
This will automatically measure the execution time of the method of the class and send the data to the OpenTelemetry collector.
Do note that for Controllers and Application Services in ABP, please make sure that the method you would like metrics for is a virtual method for the attribute to work.
For custom instrumentation, you can use the IInstrumentationProvider interface to create custom spans and metrics. Get the instrumentation provider from the DI container and use it to create spans and metrics.
public class MessageValidatorGrain : Grain, IMessageValidator
{
private readonly ILogger _logger;
private readonly ActivitySource _activitySource;
private static readonly string[] OffensiveWords = new string[] {"offensive", "bad", "rude"};
public MessageValidatorGrain(ILogger<MessageValidatorGrain> logger, IInstrumentationProvider instrumentationProvider)
{
_logger = logger;
_activitySource = instrumentationProvider.ActivitySource;
}
public Task<bool> IsOffensive(string message)
{
// This will start a custom trace for the IsOffensive method
using var myActivity = _activitySource.StartActivity($"{nameof(MessageValidatorGrain)}.IsOffensive");
_logger.LogInformation("""
IsOffensive message received: message = "{Message}"
""",
message);
return Task.FromResult(OffensiveWords.Any(message.Contains));
}
}
If you encounter a bug or have a feature request, please use the Issue Tracker. The project is also open to contributions, so feel free to fork the project and open pull requests.
Distributed under the MIT License. See for more information.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net7.0 net7.0 is compatible. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 is compatible. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
Showing the top 1 NuGet packages that depend on AElf.OpenTelemetry:
| Package | Downloads |
|---|---|
|
AeFinder.Grains
Package Description |
This package is not used by any popular GitHub repositories.