-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add OpenTelemetry support to Example application * add docs about OpenTelemetry
- Loading branch information
Showing
21 changed files
with
7,286 additions
and
5 deletions.
There are no files selected for viewing
51 changes: 51 additions & 0 deletions
51
commercetools.Sdk/Examples/commercetools.Api.CheckoutApp/Instrumentation.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,51 @@ | ||
using System; | ||
|
||
// <copyright file="Instrumentation.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> | ||
|
||
namespace commercetools.Api.CheckoutApp | ||
{ | ||
using System.Diagnostics; | ||
using System.Diagnostics.Metrics; | ||
|
||
/// <summary> | ||
/// It is recommended to use a custom type to hold references for | ||
/// ActivitySource and Instruments. This avoids possible type collisions | ||
/// with other components in the DI container. | ||
/// </summary> | ||
public class Instrumentation : IDisposable | ||
{ | ||
internal const string ActivitySourceName = "Commercetools.CheckoutApp"; | ||
internal const string MeterName = "Commercetools.CheckoutApp"; | ||
private readonly Meter meter; | ||
|
||
public Instrumentation() | ||
{ | ||
string? version = typeof(Instrumentation).Assembly.GetName().Version?.ToString(); | ||
this.ActivitySource = new ActivitySource(ActivitySourceName, version); | ||
this.meter = new Meter(MeterName, version); | ||
} | ||
|
||
public ActivitySource ActivitySource { get; } | ||
|
||
public void Dispose() | ||
{ | ||
this.ActivitySource.Dispose(); | ||
this.meter.Dispose(); | ||
} | ||
} | ||
} | ||
|
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
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
15 changes: 14 additions & 1 deletion
15
...ercetools.Sdk/Examples/commercetools.Api.CheckoutApp/commercetools.Api.CheckoutApp.csproj
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,11 +1,24 @@ | ||
<Project Sdk="Microsoft.NET.Sdk.Web"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>netcoreapp3.1</TargetFramework> | ||
<TargetFramework>net7.0</TargetFramework> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\commercetools.Sdk.Api\commercetools.Sdk.Api.csproj" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="OpenTelemetry.AutoInstrumentation" Version="1.0.0-rc.2" /> | ||
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.5.1-beta.1" /> | ||
<PackageReference Include="OpenTelemetry.Instrumentation.Http" Version="1.5.1-beta.1" /> | ||
<PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.5.1" /> | ||
<PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.5.1" /> | ||
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.5.1-beta.1" /> | ||
<PackageReference Include="OpenTelemetry.Instrumentation.GrpcNetClient" Version="1.5.1-beta.1" /> | ||
<PackageReference Include="OpenTelemetry.Instrumentation.Http" Version="1.5.1-beta.1" /> | ||
<PackageReference Include="OpenTelemetry.Instrumentation.Runtime" Version="1.5.0" /> | ||
<PackageReference Include="OpenTelemetry.ResourceDetectors.Container" Version="1.0.0-beta.4" /> | ||
</ItemGroup> | ||
|
||
</Project> |
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 @@ | ||
|
||
|
||
# Images | ||
IMAGE_VERSION=1.4.0 | ||
IMAGE_NAME=ghcr.io/open-telemetry/demo | ||
|
||
# Demo Platform | ||
ENV_PLATFORM=local | ||
|
||
# OpenTelemetry Collector | ||
OTEL_COLLECTOR_HOST=otelcol | ||
OTEL_COLLECTOR_PORT_GRPC=4317 | ||
OTEL_COLLECTOR_PORT_HTTP=4318 | ||
OTEL_EXPORTER_OTLP_ENDPOINT=http://${OTEL_COLLECTOR_HOST}:${OTEL_COLLECTOR_PORT_GRPC} | ||
PUBLIC_OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=http://localhost:8080/otlp-http/v1/traces | ||
|
||
# OpenTelemetry Resource Definitions | ||
OTEL_RESOURCE_ATTRIBUTES="service.namespace=opentelemetry-demo" | ||
|
||
# Metrics Temporality | ||
OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE=cumulative | ||
|
||
# ******************** | ||
# Telemetry Components | ||
# ******************** | ||
# Grafana | ||
GRAFANA_SERVICE_PORT=3000 | ||
GRAFANA_SERVICE_HOST=grafana | ||
|
||
# Jaeger | ||
JAEGER_SERVICE_PORT=16686 | ||
JAEGER_SERVICE_HOST=jaeger | ||
|
||
# Prometheus | ||
PROMETHEUS_SERVICE_PORT=9090 | ||
PROMETHEUS_SERVICE_HOST=prometheus | ||
PROMETHEUS_ADDR=${PROMETHEUS_SERVICE_HOST}:${PROMETHEUS_SERVICE_PORT} | ||
|
||
# NewRelic | ||
NEW_RELIC_OTLP_ENDPOINT=https://otlp.eu01.nr-data.net:4317 | ||
NEW_RELIC_LICENSE_KEY= |
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,15 @@ | ||
# OpenTelemetry | ||
|
||
This folder contains a preconfigured docker compose file for local experiments | ||
with OpenTelemetry. It includes a OpenTelemetry collector, a Jaeger UI, Prometheus, Grafana, and | ||
NewRelic as export target. | ||
|
||
To start it use the following command: | ||
|
||
```bash | ||
docker-compose --env-file .env up --no-build | ||
``` | ||
|
||
The collector is preconfigured to export metric, traces and log entries to NewRelic. | ||
In order to activate it add your NewRelic api key to the `.env` file and restart the | ||
containers. |
Oops, something went wrong.