Skip to content
This repository has been archived by the owner on Jul 25, 2024. It is now read-only.

Try exporter with latest version of OTel .NET SDK #37

Merged
merged 7 commits into from
Jan 17, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 22 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@ directly to [Dynatrace](https://www.dynatrace.com).
More information on exporting OpenTelemetry metrics to Dynatrace can be found in the
[Dynatrace documentation](https://www.dynatrace.com/support/help/extend-dynatrace/opentelemetry/opentelemetry-metrics).

This exporter is built against the OpenTelemetry .NET
SDK [v1.2.0](https://github.com/open-telemetry/opentelemetry-dotnet/releases/tag/core-1.2.0) which is the first stable
release for the metrics SDK and should be compatible with this and later versions.
This exporter is built against the OpenTelemetry .NET SDK [v1.3.2](https://github.com/open-telemetry/opentelemetry-dotnet/releases/tag/core-1.3.2).

## Getting started

The general setup of OpenTelemetry .NET is explained in the official [Getting Started Guide](https://github.com/open-telemetry/opentelemetry-dotnet/blob/core-1.2.0/docs/metrics/getting-started/README.md).
The general setup of OpenTelemetry .NET is explained in the official [Getting Started Guide](https://github.com/open-telemetry/opentelemetry-dotnet/blob/core-1.3.2/docs/metrics/getting-started/README.md).

To add the exporter to your project, install the [Dynatrace.OpenTelemetry.Exporter.Metrics](https://www.nuget.org/packages/Dynatrace.OpenTelemetry.Exporter.Metrics) package to your project.
This can be done through the NuGet package manager in Visual Studio or by running the following command in your project folder:
Expand All @@ -28,6 +26,12 @@ This exporter package targets [.NET Standard 2.0](https://docs.microsoft.com/en-
To set up a Dynatrace metrics exporter, add the following code to your project:

```csharp
using System.Diagnostics;
joaopgrassi marked this conversation as resolved.
Show resolved Hide resolved
using System.Diagnostics.Metrics;
using OpenTelemetry;
using OpenTelemetry.Metrics;
using Dynatrace.OpenTelemetry.Exporter.Metrics;

// A Meter instance is obtained via the System.Diagnostics.DiagnosticSource package
var meter = new Meter("my_meter", "0.0.1");

Expand Down Expand Up @@ -59,6 +63,13 @@ and it is recommended to restrict the token access to that scope.
More information about the token setup can be found [here](#dynatrace-api-token).

```csharp
using System.Diagnostics;
using System.Diagnostics.Metrics;
using Microsoft.Extensions.Logging;
using OpenTelemetry;
using OpenTelemetry.Metrics;
using Dynatrace.OpenTelemetry.Exporter.Metrics;

// Not required, but potentially helpful.
// The exporter logs information about preparing and exporting metrics.
var loggerFactory = LoggerFactory.Create(builder =>
Expand Down Expand Up @@ -96,6 +107,13 @@ configured in the `DynatraceExporterOptions`.
Read the [Configuration section](#configuration) to learn more about each of them.

```csharp
using System.Diagnostics;
using System.Diagnostics.Metrics;
using Microsoft.Extensions.Logging;
using OpenTelemetry;
using OpenTelemetry.Metrics;
using Dynatrace.OpenTelemetry.Exporter.Metrics;

using var provider = Sdk.CreateMeterProviderBuilder()
.AddMeter(meter.Name)
.AddDynatraceExporter(cfg =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
<PackageReference Include="Moq" Version="4.18.1" />
<PackageReference Include="OpenTelemetry.Exporter.Console" Version="1.2.0" />
<PackageReference Include="OpenTelemetry.Exporter.InMemory" Version="1.2.0-rc5" />
<PackageReference Include="OpenTelemetry.Exporter.InMemory" Version="1.3.2" />
<PackageReference Include="xunit" Version="2.4.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.0" />
<PackageReference Include="coverlet.collector" Version="1.2.0" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<Company>Dynatrace</Company>
<Product>Dynatrace OpenTelemetry Metrics Exporter for .NET</Product>
<PackageId>Dynatrace.OpenTelemetry.Exporter.Metrics</PackageId>
<Version>1.0.0</Version>
<Version>1.1.0</Version>
<Description>See https://github.com/dynatrace-oss/opentelemetry-metric-dotnet to learn more.</Description>
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
<Copyright>Copyright 2020 Dynatrace LLC; Licensed under the Apache License, Version 2.0</Copyright>
Expand All @@ -18,7 +18,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="OpenTelemetry" Version="1.2.0" />
<PackageReference Include="OpenTelemetry" Version="1.3.2" />
<PackageReference Include="Dynatrace.MetricUtils" Version="0.3.0" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,10 @@ private static MeterProviderBuilder AddDynatraceExporter(
}

var metricExporter = new DynatraceMetricsExporter(options, logger);
var metricReader = new PeriodicExportingMetricReader(metricExporter, options.MetricExportIntervalMilliseconds);
metricReader.TemporalityPreference = MetricReaderTemporalityPreference.Delta;
var metricReader = new PeriodicExportingMetricReader(metricExporter, options.MetricExportIntervalMilliseconds)
{
TemporalityPreference = MetricReaderTemporalityPreference.Delta
};
return builder.AddReader(metricReader);
}
}
Expand Down