Skip to content

Commit

Permalink
Merge branch 'main' into deprecate-masstransit
Browse files Browse the repository at this point in the history
  • Loading branch information
Kielek authored Jan 9, 2023
2 parents 032dc0a + 70f9f0f commit 92ab77d
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/component_owners.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ components:
test/OpenTelemetry.Extensions.Tests/:
- codeblanch
test/OpenTelemetry.Extensions.Docker.Tests/:
- swetharavichandrancisco
- iskiselev
test/OpenTelemetry.Extensions.PersistentStorage.Tests/:
- vishweshbankwar
test/OpenTelemetry.Instrumentation.AWSLambda.Tests/:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Runtime.InteropServices;
using System.Threading;

Expand Down Expand Up @@ -286,7 +287,7 @@ internal int SerializeActivity(Activity activity)
}
else if (string.Equals(entry.Key, "otel.status_code", StringComparison.Ordinal))
{
if (string.Equals(entry.Value.ToString(), "ERROR", StringComparison.Ordinal))
if (string.Equals(Convert.ToString(entry.Value, CultureInfo.InvariantCulture), "ERROR", StringComparison.Ordinal))
{
isStatusSuccess = false;
}
Expand All @@ -295,7 +296,7 @@ internal int SerializeActivity(Activity activity)
}
else if (string.Equals(entry.Key, "otel.status_description", StringComparison.Ordinal))
{
statusDescription = entry.Value.ToString();
statusDescription = Convert.ToString(entry.Value, CultureInfo.InvariantCulture);
continue;
}
else if (this.m_customFields == null || this.m_customFields.ContainsKey(entry.Key))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ public static Span ToSpan(this Activity activity, string projectId)
{
AttributeMap =
{
activity.Tags?.ToDictionary(
activity.Tags.ToDictionary(
s => s.Key,
s => s.Value?.ToAttributeValue()),
s => s.Value.ToAttributeValue()),
},
};
}
Expand Down
19 changes: 16 additions & 3 deletions src/OpenTelemetry.Instrumentation.ElasticsearchClient/README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
# Elasticsearch Client Instrumentation for OpenTelemetry .NET

## NEST/Elasticsearch.Net

[![NuGet](https://img.shields.io/nuget/v/OpenTelemetry.Instrumentation.ElasticsearchClient.svg)](https://www.nuget.org/packages/OpenTelemetry.Instrumentation.ElasticsearchClient)
[![NuGet](https://img.shields.io/nuget/dt/OpenTelemetry.Instrumentation.ElasticsearchClient.svg)](https://www.nuget.org/packages/OpenTelemetry.Instrumentation.ElasticsearchClient)

Automatically instruments events emitted by the NEST/Elasticsearch.Net client library.
Automatically instruments events emitted by the [NEST/Elasticsearch.Net](https://www.nuget.org/packages/NEST)
client library.

## Installation
### Installation

```shell
dotnet add package OpenTelemetry.Instrumentation.ElasticsearchClient
```

## Configuration
### Configuration

ASP.NET Core instrumentation example:

Expand All @@ -26,9 +29,19 @@ services.AddOpenTelemetryTracing(x =>
});
```

## Elastic.Clients.Elasticsearch

[Elastic.Clients.Elasticsearch](https://www.nuget.org/packages/Elastic.Clients.Elasticsearch),
that deprecates `NEST/Elasticsearch.Net`,
brings native support for OpenTelemetry. To instrument it you need
to configure the OpenTelemetry SDK to listen to the `ActivitySource`
used by the library by calling `AddSource("Elastic.Clients.Elasticsearch.ElasticsearchClient")`
on the `TracerProviderBuilder`.

## References

* [OpenTelemetry Project](https://opentelemetry.io/)
* [Elasticsearch](https://www.elastic.co/)
* [NEST Client](https://www.nuget.org/packages/NEST/)
* [Elasticsearch.Net Client](https://www.nuget.org/packages/Elasticsearch.Net/)
* [Elastic.Clients.Elasticsearch](https://www.nuget.org/packages/Elastic.Clients.Elasticsearch/)
23 changes: 23 additions & 0 deletions src/OpenTelemetry.Instrumentation.Wcf/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,29 @@ contracts you want to instrument:
}
```

## Known issues

WCF library does not provide any extension points to handle exception thrown on
communication (e.g. EndpointNotFoundException). Because of that in case of such
an event the `Activity` will not be stopped correctly. This can be handled in
an application code by catching the exception and stopping the `Activity` manually.

```csharp
StatusResponse? response = null;
try
{
response = await client.PingAsync(statusRequest).ConfigureAwait(false);
}
catch (Exception)
{
var activity = Activity.Current;
if (activity != null && activity.Source.Name.Contains("OpenTelemetry.Instrumentation.Wcf"))
{
activity.Stop();
}
}
```

## References

* [OpenTelemetry Project](https://opentelemetry.io/)
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ internal static Activity CreateTestActivity(
{ "doubleKey2", 1F },
{ "boolKey", true },
{ "nullKey", null },
{ "http.url", null },
};
if (additionalAttributes != null)
{
Expand Down Expand Up @@ -225,7 +226,7 @@ internal static Activity CreateTestActivity(
var activitySource = new ActivitySource(nameof(CreateTestActivity));

var tags = setAttributes ?
attributes.Where(x => x.Value != null).Select(kvp => new KeyValuePair<string, object>(kvp.Key, kvp.Value.ToString()))
attributes.Select(kvp => new KeyValuePair<string, object>(kvp.Key, kvp.Value?.ToString()))
: null;
var links = addLinks ?
new[]
Expand Down

0 comments on commit 92ab77d

Please sign in to comment.