-
Notifications
You must be signed in to change notification settings - Fork 305
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
284 additions
and
23 deletions.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
.github/ISSUE_TEMPLATE/comp_extensions_persistentstorage.abstractions.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
--- | ||
name: OpenTelemetry.Extensions.PersistentStorage.Abstractions | ||
about: Issue with OpenTelemetry.Extensions.PersistentStorage.Abstractions | ||
labels: comp:extensions.persistentstorage.abstractions | ||
--- | ||
|
||
# Issue with OpenTelemetry.Extensions.PersistentStorage.Abstractions | ||
|
||
List of [all OpenTelemetry NuGet | ||
packages](https://www.nuget.org/profiles/OpenTelemetry) and version that you are | ||
using (e.g. `OpenTelemetry 1.0.2`): | ||
|
||
* TBD | ||
|
||
Runtime version (e.g. `net462`, `net48`, `netcoreapp3.1`, `net6.0` etc. You can | ||
find this information from the `*.csproj` file): | ||
|
||
* TBD | ||
|
||
**Is this a feature request or a bug?** | ||
|
||
* [ ] Feature Request | ||
* [ ] Bug | ||
|
||
**What is the expected behavior?** | ||
|
||
What do you expect to see? | ||
|
||
**What is the actual behavior?** | ||
|
||
What did you see instead? If you are reporting a bug, create a self-contained | ||
project using the template of your choice and apply the minimum required code to | ||
result in the issue you're observing. We will close this issue if: | ||
|
||
* The repro project you share with us is complex. We can't investigate custom | ||
projects, so don't point us to such, please. | ||
* If we can not reproduce the behavior you're reporting. | ||
|
||
## Additional Context | ||
|
||
Add any other context about the feature request here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,4 +18,4 @@ jobs: | |
runs-on: ubuntu-latest | ||
|
||
steps: | ||
run: 'echo "No build required"' | ||
- run: 'echo "No build required"' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,171 @@ | ||
# Geneva Exporters for OpenTelemetry .NET | ||
# Geneva Exporter for OpenTelemetry .NET | ||
|
||
[![NuGet](https://img.shields.io/nuget/v/OpenTelemetry.Exporter.Geneva.svg)](https://www.nuget.org/packages/OpenTelemetry.Exporter.Geneva) | ||
[![NuGet](https://img.shields.io/nuget/dt/OpenTelemetry.Exporter.Geneva.svg)](https://www.nuget.org/packages/OpenTelemetry.Exporter.Geneva) | ||
|
||
TBD | ||
The Geneva Exporter exports telemetry to | ||
[Event Tracing for Windows (ETW)](https://docs.microsoft.com/windows/win32/etw/about-event-tracing) | ||
or to a | ||
[Unix Domain Socket (UDS)](https://en.wikipedia.org/wiki/Unix_domain_socket) | ||
on the local machine. | ||
|
||
## Installation | ||
|
||
```shell | ||
dotnet add package OpenTelemetry.Exporter.Geneva | ||
``` | ||
|
||
## Configuration | ||
|
||
The three types of telemetry are handled separately in OpenTelemetry. | ||
Therefore, each type of telemetry **must be** enabled separately. | ||
|
||
### Enable Logs | ||
|
||
Install the latest stable version of | ||
[`Microsoft.Extensions.Logging`](https://www.nuget.org/packages/Microsoft.Extensions.Logging/) | ||
|
||
```shell | ||
dotnet add package OpenTelemetry.Exporter.Geneva | ||
``` | ||
|
||
This snippet shows how to configure the Geneva Exporter for Logs | ||
|
||
```csharp | ||
using var loggerFactory = LoggerFactory.Create(loggingBuilder => loggingBuilder | ||
.AddOpenTelemetry(openTelemetryLoggerOptions => | ||
{ | ||
openTelemetryLoggerOptions.AddGenevaLogExporter(genevaExporterOptions => | ||
{ | ||
genevaExporterOptions.ConnectionString = "EtwSession=OpenTelemetry"; | ||
}); | ||
})); | ||
``` | ||
|
||
The above code must be in application startup. In case of ASP.NET Core | ||
applications, this should be in `ConfigureServices` of `Startup` class. | ||
For ASP.NET applications, this should be in `Global.aspx.cs`. | ||
|
||
Since OpenTelemetry .NET SDK is a | ||
[LoggingProvider](https://docs.microsoft.com/dotnet/core/extensions/logging-providers), | ||
use the built-in mechanism to apply [Log | ||
filtering](https://docs.microsoft.com/dotnet/core/extensions/logging?tabs=command-line#how-filtering-rules-are-applied). | ||
This filtering lets you control the Logs that are sent to each registered | ||
provider, including the OpenTelemetry provider. `OpenTelemetry` is the | ||
[alias](https://docs.microsoft.com/dotnet/api/microsoft.extensions.logging.provideraliasattribute) | ||
for `OpenTelemetryLoggerProvider`, that may be used when configuring filtering | ||
rules. | ||
|
||
**NOTE:** _Some application types (e.g. [ASP.NET | ||
Core](https://docs.microsoft.com/aspnet/core/fundamentals/logging/#configure-logging-1)) | ||
have default logging settings. Please review them to make sure | ||
`OpenTelemetryLoggingProvider` is configured to receive Logs of appropriate | ||
levels and category. | ||
|
||
### Enable Traces | ||
|
||
This snippet shows how to configure the Geneva Exporter for Traces | ||
|
||
```csharp | ||
using var tracerProvider = Sdk.CreateTracerProviderBuilder() | ||
.SetSampler(new AlwaysOnSampler()) | ||
.AddSource("DemoSource") | ||
.AddGenevaTraceExporter(options => { | ||
options.ConnectionString = "EtwSession=OpenTelemetry"; | ||
}) | ||
.Build(); | ||
``` | ||
|
||
The above code must be in application startup. In case of ASP.NET Core | ||
applications, this should be in `ConfigureServices` of `Startup` class. | ||
For ASP.NET applications, this should be in `Global.aspx.cs`. | ||
|
||
### GenevaExporterOptions (for Logs and Traces) | ||
|
||
`GenevaExporterOptions` contains various options to configure the Geneva | ||
Exporter. | ||
|
||
#### `ConnectionString` (required for Logs and Traces) | ||
|
||
On Linux the connection string has the format `Endpoint=unix:{UDS Path}`. | ||
|
||
On Windows the connection string has the format `EtwSession={ETW session}`. | ||
|
||
#### `CustomFields` (optional) | ||
|
||
A list of fields which should be stored as individual table columns. | ||
|
||
#### `PrepopulatedFields` (optional) | ||
|
||
This is a collection of fields that will be applied to all the Logs and Traces | ||
sent through this exporter. | ||
|
||
#### `TableNameMappings` (optional) | ||
|
||
This defines the mapping for the table name used to store Logs and Traces. | ||
|
||
The default table name used for Traces is `Span`. For changing the table name | ||
for Traces, add an entry with key as `Span`, and value as the custom table name. | ||
|
||
The default table name used for Logs is `Log`. Mappings can be specified for | ||
each | ||
[category](https://docs.microsoft.com/dotnet/core/extensions/logging#log-category) | ||
of the log. For changing the default table name for Logs, add an entry with key | ||
as `*`, and value as the custom table name. | ||
|
||
### Enable Metrics | ||
|
||
This snippet shows how to configure the Geneva Exporter for Metrics | ||
|
||
```csharp | ||
using var meterProvider = Sdk.CreateMeterProviderBuilder() | ||
.AddMeter("TestMeter") | ||
.AddGenevaMetricExporter(options => | ||
{ | ||
options.ConnectionString = "Account=OTelMonitoringAccount;Namespace=OTelMetricNamespace"; | ||
}) | ||
.Build(); | ||
``` | ||
|
||
The above code must be in application startup. In case of ASP.NET Core | ||
applications, this should be in `ConfigureServices` of `Startup` class. | ||
For ASP.NET applications, this should be in `Global.aspx.cs`. | ||
|
||
### GenevaMetricExporterOptions (for Metrics) | ||
|
||
`GenevaMetricExporterOptions` contains various options which are required to | ||
configure the GenevaMetricExporter. | ||
|
||
#### `ConnectionString` (required for Metrics) | ||
|
||
On Windows **DO NOT** provide an ETW session name for Metrics, only specify | ||
Account and Namespace. For example: | ||
`Account={MetricAccount};Namespace={MetricNamespace}`. | ||
|
||
On Linux provide an `Endpoint` in addition to the `Account` and `Namespace`. | ||
For example: | ||
`Endpoint=unix:{UDS Path};Account={MetricAccount};Namespace={MetricNamespace}`. | ||
|
||
#### `MetricExportIntervalMilliseconds` (optional) | ||
|
||
Set the exporter's periodic time interval to export Metrics. The default value | ||
is 20000 milliseconds. | ||
|
||
#### `PrepopulatedMetricDimensions` (optional) | ||
|
||
This is a collection of the dimensions that will be applied to _every_ metric | ||
exported by the exporter. | ||
|
||
## Troubleshooting | ||
|
||
Before digging into a problem, check if you hit a known issue by looking at the | ||
[CHANGELOG.md](./CHANGELOG.md) and [GitHub | ||
issues](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/issues). | ||
|
||
Geneva Exporters uses an | ||
[EventSource](https://docs.microsoft.com/dotnet/api/system.diagnostics.tracing.eventsource) | ||
with the name "OpenTelemetry-Exporter-Geneva" for its internal logging. Please | ||
follow the [troubleshooting guide for OpenTelemetry | ||
.NET](https://github.com/open-telemetry/opentelemetry-dotnet/tree/main/src/OpenTelemetry#troubleshooting) | ||
for instructions on seeing Logs from the geneva exporter, as well as other | ||
OpenTelemetry components. |
40 changes: 40 additions & 0 deletions
40
src/OpenTelemetry.Exporter.Geneva/ReentrantActivityExportProcessor.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// <copyright file="ReentrantActivityExportProcessor.cs" company="OpenTelemetry Authors"> | ||
// Copyright The OpenTelemetry Authors | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// </copyright> | ||
|
||
using System.Diagnostics; | ||
|
||
namespace OpenTelemetry.Exporter.Geneva; | ||
|
||
// This export processor exports without synchronization. | ||
// Once OpenTelemetry .NET officially support this, | ||
// we can get rid of this class. | ||
// This is currently only used in ETW export, where we know | ||
// that the underlying system is safe under concurrent calls. | ||
internal class ReentrantActivityExportProcessor : ReentrantExportProcessor<Activity> | ||
{ | ||
public ReentrantActivityExportProcessor(BaseExporter<Activity> exporter) | ||
: base(exporter) | ||
{ | ||
} | ||
|
||
protected override void OnExport(Activity data) | ||
{ | ||
if (data.Recorded) | ||
{ | ||
base.OnExport(data); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.