Giter Site home page Giter Site logo

open-telemetry / opentelemetry-dotnet-contrib Goto Github PK

View Code? Open in Web Editor NEW
435.0 435.0 261.0 5.1 MB

This repository contains set of components extending functionality of the OpenTelemetry .NET SDK. Instrumentation libraries, exporters, and other components can find their home here.

Home Page: https://opentelemetry.io

License: Apache License 2.0

C# 98.56% Python 0.13% PowerShell 1.12% Dockerfile 0.08% Shell 0.03% Jinja 0.07% HTML 0.01% JavaScript 0.01%
dotnet dotnet-core opentelemetry

opentelemetry-dotnet-contrib's People

Contributors

cijothomas avatar codeblanch avatar dependabot[bot] avatar eddynaka avatar eerhardt avatar ejsmith avatar fred2u avatar gao-artur avatar github-actions[bot] avatar havret avatar joegoldman2 avatar kielek avatar lupengamzn avatar martincostello avatar matt-hensley avatar mic-max avatar ngruson avatar opentelemetrybot avatar rajkumar-rangaraj avatar repl-chris avatar reyang avatar rypdal avatar srprash avatar timothymothra avatar twenzel avatar utpilla avatar vishweshbankwar avatar xiang17 avatar yun-ting avatar zivaninstana avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

opentelemetry-dotnet-contrib's Issues

Using new stackexchange.redis connection multiplexer for each blazor component, how do I instrument them?

Question

Given I have a service like this https://github.com/philipbawn/redis-blazor-experiments/blob/main/MyServices/QueueManagementService.cs which I add to my service collection as a transient service services.AddTransient();

How should I instrument the StackExchange.Redis calls?

I don't believe I can't use a shared connection multiplexer across the entire Blazor application (singleton) like in open-telemetry/opentelemetry-dotnet#1554 because I'd like each component to have different redis channel subscriptions as well as in the future use the access control lists (ACL) in redis to limit what keys each component has access to.

The connection multiplexer can only be registered as a singleton.

SqlClient instrumentation doesn't work on netfx using Microsoft.Data.SqlClient 3.0.0

New major release of SqlClient has changed their EventSource from this:

[Event(BeginExecuteEventId, Keywords = Keywords.ExecutionTrace, Task = Tasks.ExecuteCommand, Opcode = EventOpcode.Start)]
internal void BeginExecute(int objectId, string dataSource, string database, string commandText)
{
	if (Log.IsExecutionTraceEnabled())
	{
		WriteEvent(BeginExecuteEventId, objectId, dataSource, database, commandText);
	}
}

To this (PR open-telemetry/opentelemetry-dotnet#897):

internal void TryBeginExecuteEvent(int objectId, Guid? connectionId, string commandText, [System.Runtime.CompilerServices.CallerMemberName] string memberName = "")
{
	if (Log.IsExecutionTraceEnabled())
	{
		BeginExecute(GetFormattedMessage(SqlCommand_ClassName, memberName, EventType.INFO,
			string.Format("Object Id {0}, Client Connection Id {1}, Command Text {2}", objectId, connectionId, commandText)));
	}
}

// ...

[Event(BeginExecuteEventId, Keywords = Keywords.ExecutionTrace, Task = Tasks.ExecuteCommand, Opcode = EventOpcode.Start)]
internal void BeginExecute(string message) =>
	WriteEvent(BeginExecuteEventId, message);

Our SqlEventSourceListener expects 4 items in the payload (ObjectId, DataSource, Database, CommandText) but now gets only "Message" and doesn't log anything.

It looks like we're unable to get the server/db anymore on netfx which is unfortunate. Opening this issue here to track resolution, but probably best to ask SqlClient team to make some changes in their EventSource if they can.

Enricher for WCF Instrumentation

I am attempting to collect telemetry data from a legacy WCF service, and would like to enrich the activity started with some tags created from WCF message.

Instrumentation packages from opentelemetry-dotnet repo has options to set an enricher, like this(example from https://github.com/open-telemetry/opentelemetry-dotnet/blob/main/src/OpenTelemetry.Instrumentation.Http/HttpClientInstrumentationOptions.cs):

/// <summary>
/// Gets or sets an action to enrich an Activity.
/// </summary>
/// <remarks>
/// <para><see cref="Activity"/>: the activity being enriched.</para>
/// <para>string: the name of the event.</para>
/// <para>object: the raw object from which additional information can be extracted to enrich the activity.
/// The type of this object depends on the event, which is given by the above parameter.</para>
/// </remarks>
public Action<Activity, string, object> Enrich { get; set; }

Ideally all instrumentation in this repo should support this(as it seems to be a convention for instrumentation), but at current I only need this for WCF.

Add Additional Standard Tags in AddAspNetCoreInstrumentation

Feature Request

Is your feature request related to a problem?

There are several tags specified by the open telemetry specification that are not logged by default in AddAspNetCoreInstrumentation. It would be nice if we could add an option to log them too.

Describe the solution you'd like:

I currently use the following code to log them:

options.Enrich = (activity, eventName, obj) =>
{
    if (obj is HttpRequest request)
    {
        var context = request.HttpContext;
        activity.AddTag(OpenTelemetryAttributeName.Http.Flavor, GetHttpFlavour(request.Protocol));
        activity.AddTag(OpenTelemetryAttributeName.Http.Scheme, request.Scheme);
        activity.AddTag(OpenTelemetryAttributeName.Http.ClientIP, context.Connection.RemoteIpAddress);
        activity.AddTag(OpenTelemetryAttributeName.Http.RequestContentLength, request.ContentLength);
        activity.AddTag(OpenTelemetryAttributeName.Http.RequestContentType, request.ContentType);

        var user = context.User;
        if (user.Identity?.Name is not null)
        {
            activity.AddTag(OpenTelemetryAttributeName.EndUser.Id, user.Identity.Name);
            activity.AddTag(OpenTelemetryAttributeName.EndUser.Scope, string.Join(',', user.Claims.Select(x => x.Value)));
        }
    }
    else if (obj is HttpResponse response)
    {
        activity.AddTag(OpenTelemetryAttributeName.Http.ResponseContentLength, response.ContentLength);
        activity.AddTag(OpenTelemetryAttributeName.Http.ResponseContentType, response.ContentType);
    }

    static string GetHttpFlavour(string protocol)
    {
        if (HttpProtocol.IsHttp10(protocol))
        {
            return HttpFlavour.Http10;
        }
        else if (HttpProtocol.IsHttp11(protocol))
        {
            return HttpFlavour.Http11;
        }
        else if (HttpProtocol.IsHttp2(protocol))
        {
            return HttpFlavour.Http20;
        }
        else if (HttpProtocol.IsHttp3(protocol))
        {
            return HttpFlavour.Http30;
        }

        throw new InvalidOperationException($"Protocol {protocol} not recognised.");
    }
};

/// <summary>
/// Constants for semantic attribute names outlined by the OpenTelemetry specifications.
/// <see href="https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/trace/semantic_conventions/README.md"/>.
/// </summary>
public static class OpenTelemetryAttributeName
{
    /// <summary>
    /// Constants for deployment semantic attribute names outlined by the OpenTelemetry specifications.
    /// <see href="https://github.com/open-telemetry/opentelemetry-specification/blob/11cc73939a32e3a2e6f11bdeab843c61cf8594e9/specification/resource/semantic_conventions/deployment_environment.md"/>.
    /// </summary>
    public static class Deployment
    {
        /// <summary>
        /// The name of the deployment environment (aka deployment tier).
        /// </summary>
        /// <example>staging; production.</example>
        public const string Environment = "deployment.environment";
    }

    /// <summary>
    /// Constants for end user semantic attribute names outlined by the OpenTelemetry specifications.
    /// <see href="https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/trace/semantic_conventions/span-general.md"/>.
    /// </summary>
    public static class EndUser
    {
        /// <summary>
        /// Username or client_id extracted from the access token or Authorization header in the inbound request from outside the system.
        /// </summary>
        /// <example>E.g. username.</example>
        public const string Id = "enduser.id";

        /// <summary>
        /// Actual/assumed role the client is making the request under extracted from token or application security context.
        /// </summary>
        /// <example>E.g. admin.</example>
        public const string Role = "enduser.role";

        /// <summary>
        /// Scopes or granted authorities the client currently possesses extracted from token or application security context.
        /// The value would come from the scope associated with an OAuth 2.0 Access Token or an attribute value in a SAML 2.0 Assertion.
        /// </summary>
        /// <example>E.g. read:message,write:files.</example>
        public const string Scope = "enduser.scope";
    }

    /// <summary>
    /// Constants for HTTP semantic attribute names outlined by the OpenTelemetry specifications.
    /// <see href="https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/trace/semantic_conventions/http.md"/>.
    /// </summary>
    public static class Http
    {
        /// <summary>
        /// The URI scheme identifying the used protocol.
        /// </summary>
        /// <example>E.g. http or https.</example>
        public const string Scheme = "http.scheme";

        /// <summary>
        /// Kind of HTTP protocol used.
        /// </summary>
        /// <example>E.g. 1.0, 1.1, 2.0, SPDY or QUIC.</example>
        public const string Flavor = "http.flavor";

        /// <summary>
        /// The IP address of the original client behind all proxies, if known (e.g. from X-Forwarded-For).
        /// </summary>
        /// <example>E.g. 83.164.160.102.</example>
        public const string ClientIP = "http.client_ip";

        /// <summary>
        /// The size of the request payload body in bytes. This is the number of bytes transferred excluding headers and is often,
        /// but not always, present as the Content-Length header. For requests using transport encoding, this should be the
        /// compressed size.
        /// </summary>
        /// <example>E.g. 3495.</example>
        public const string RequestContentLength = "http.request_content_length";

        /// <summary>
        /// The content type of the request body.
        /// </summary>
        /// <example>E.g. application/json.</example>
        public const string RequestContentType = "http.request_content_type";

        /// <summary>
        /// The size of the response payload body in bytes. This is the number of bytes transferred excluding headers and is often,
        /// but not always, present as the Content-Length header. For requests using transport encoding, this should be the
        /// compressed size.
        /// </summary>
        /// <example>E.g. 3495.</example>
        public const string ResponseContentLength = "http.response_content_length";

        /// <summary>
        /// The content type of the response body.
        /// </summary>
        /// <example>E.g. application/json.</example>
        public const string ResponseContentType = "http.response_content_type";
    }

    /// <summary>
    /// Constants for host semantic attribute names outlined by the OpenTelemetry specifications.
    /// <see href="https://github.com/open-telemetry/opentelemetry-specification/blob/11cc73939a32e3a2e6f11bdeab843c61cf8594e9/specification/resource/semantic_conventions/host.md"/>.
    /// </summary>
    public static class Host
    {
        /// <summary>
        /// Name of the host. On Unix systems, it may contain what the hostname command returns, or the fully qualified hostname,
        /// or another name specified by the user.
        /// </summary>
        /// <example>E.g. opentelemetry-test.</example>
        public const string Name = "host.name";
    }

    /// <summary>
    /// Constants for service semantic attribute names outlined by the OpenTelemetry specifications.
    /// <see href="https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/trace/semantic_conventions/messaging.md"/>.
    /// </summary>
    public static class Service
    {
        /// <summary>
        /// The name of the service sending messages.
        /// </summary>
        public const string Name = "service.name";
    }
}

Describe alternatives you've considered.

Currently using the Enrich method to add additional tags but would be nice if these were built in as they are defined by the specification.

Proposal for efficient maintenance of contrib repo

Introduction

I'm opening this issue to discuss and derive concensus on processes and practices required to maintain the openetelemetry-dotnet-contrib repo efficiently. The scope of maintainance of the repo includes defining a structure for the repo and its components, assigning approvers and maintainers, establishing practices for code reviews, and outlining release process of components to nuget.

Goals

  • Rigid structure for any contributed project under /src/ path. eg: List of approvers, Readme, Changelog, etc. This can be called out in the CONTRIBUTING.md
  • Assign approvers for each sub folder under /src/ and /test/ folders, and maintainers for the contrib repo.
  • The master branch of the contrib repo is building successfully at all the times.
  • All the test projects under /test/ folder are running successfully and coverage report is generated for each PR submitted.
  • Since the contrib repo has decoupled components as projects, the ability to release any particular project as a nuget package on demand.
  • There is a proper channel for approvers to request the maintainers for a release.

Current state and limitations

  • Single source of OpenTelemetry package version applied to all the projects in contrib repo. This hinders a single project to update the OpenTelemetry version independently.
  • Single continuous build and release workflow. This workflow releases all the projects within the repository with the same version number.
  • If any one of the project breaks, the complete build fails and none of the projects are built and released.
  • Current maintainers may not be subject matter experts (SME) on all the components and therefore PR moves slow. This can discourage willing contributors from contributing new important features and improvements.

Proposed Changes & Processes

Managing responsibilities

  • A set of approvers to be appointed to each of the components under /src/ and its corresponding tests within /test/ folders. These approvers are voluntary and are SMEs on the given component. The job of an approver is to address issues, review pull requests, and maintain a high bar for their components.
  • A set of maintainers to be appointed for the comlete repo. The maintainer is responsible for maintaining the overall quality of the repo, merge in pull requests already approved by an approver, and do releases.
  • If an issue is reported on the repo for a component, the maintainer should tag and engage the approver assigned for the component.
  • If a PR is opened for a component, the relevant approver should review it in detail. Once the PR looks good, the approver should approve it, engage a maintainer to get their approval and merge the PR. No PR should be merged in without a maintainer's approval.
  • Refer to the CODEOWNERS in opentelemetry-collector-contrib repo.

OpenTelemetry version targeting

  • Each project should declare its dependency on a minimum version of OpenTelemetry package in its .csproj file. example:

    <PackageReference Include="OpenTelemetry" Version="1.0.0" />
  • The OpenTelemetry package version declared in the root /build/Common.props should always be the latest. This way any project not specifying its own OpenTelemetry package dependency will always be built with the latest one.
    Caution: If there are breaking changes introduced in new version of OpenTelemetry, the depending component may break.

Continuous build

  • Ideally, if each component targets its own OpenTelemetry version, the build for the complete solution should always be passing.
  • The CI should be triggered on each PR and merge to master branch as it does today through a GH workflow for linux and windows.

Release on demand

  • The ability to release a component is solely possessed by a maintainer of the repo.
  • If a new version of a component needs to be released, the approver needs to do the following:
    • Update the CHANGELOG of the component.
    • Open an issue requesting the release. Mention the full component name (eg: OpenTelemetry.Contrib.Extensions.AWSXRay), the version number, and link to changelog.
    • Tag a maintainer.
  • The maintainer will then review the issue and trigger the release workflow.
  • The current release workflow does a nightly build, package, and upload to MyGet. This workflow can be modified to run on demand with inputs as the project name and version. The workflow will then build, test, package, and release just that component to Nuget.
  • There is no need for a full contrib repo release. Why? 1. Not all components may have changes ready to release. 2. Not all components may follow same versioning strategy.

FileLoadException out of the box running AspNet sample

Bug Report

List of NuGet packages and
version that you are using:

Using examples/Examples.AspNet project, that references current source files.

In my project I use:
OpenTelemetry 1.1.0
OpenTelemetry.Api 1.1.0
OpenTelemetry.Instrumentation.Http 1.0.0-rc7
OpenTelemetry.Exporter.Console 1.1.0

Runtime version net48,net461

Symptom

When I run an app with enabled tracing a FileLoadException occurs, referencing an System.Diagnostics.DiagnosticSource assembly.
Removing <add name="TelemetryCorrelationHttpModule" type="Microsoft.AspNet.TelemetryCorrelation.TelemetryCorrelationHttpModule, Microsoft.AspNet.TelemetryCorrelation" preCondition="integratedMode,managedHandler"/> helps to run the app, in case AspNet, but it is not an option.
In case of ConsoleApp FileNotFoundException references System.Runtime.CompilerServices.Unsafe assembly.

Sorry for local error text, but I think you've got the idea.
image

What is the expected behavior?

I expect application to run and collect traces.

What is the actual behavior?

App doesn't run at all.

Reproduce

This repo, examples/Examples.AspNet

Additional Context

It seems that OpenTelemetry uses DiagnoticSource v5.0.1, and something else in basic packages uses another version. Somehow these two versions conflict with each other. I've tried handle this with <bindingRedirect>, but had no luck.

OWIN Instrumentation

Is there any plan to support OWIN? Looks like it is supported Asp.Net and Asp.Net Core but I have a WebAPI with Asp.Net self hosted using OWIN and I'd like to start using OpenTelemetry.

Add Badge for Code Coverage

Is your feature request related to a problem?
Most of the existing OpenTelemetry repositories display a badge for code coverage. In an effort to have the Dotnet contrib repository to be up to date and consistent with the other established SDKs and repositories, there should be a code coverage badge in the main README.md file.

Describe the solution you'd like.
As a developer contributing to OpenTelemetry, I recommend adding a code coverage percentage badge at the top of the README document of the Dotnet Contrib repo. Code coverage badges are a common feature of many modern open source projects, which improves readability and convenience to developers. By adding a code coverage badge to the README.md, with a quick scan, any observer will be able to know the status of the repository.

cc: @alolita

Stackdriver Exporter Out of Date

The version available in Nuget for Stackdriver Exporter is out of date 0.6.0-beta It does appear that it has been updated to 1.1.0-beta4 in the master branch. Could this be deployed to Nuget?

This is resulting in the following error when trying to build with newer versions of OpenTelemetry .net
[CS7069] Reference to type 'TracerProviderBuilder' claims it is defined in 'OpenTelemetry', but it could not be found

B3Format extract creates an ActivityContext with default id when not passed in the request

Describe your environment. Describe any aspect of your environment relevant to the problem:

  • SDK version: 0.0.0-alpha.428 of OpenTelemetry.Exporter.Zipkin, OpenTelemetry.Extensions.Hosting, OpenTelemetry.Instrumentation.AspNetCore, OpenTelemetry.Instrumentation.Dependencies
  • .NET runtime version (.NET or .NET Core, TargetFramework in the .csproj file): .netcore 2.1
  • Platform and OS version: macOs 10.14.5

I've set up the aspnetcore instrumentation on netcoreapp2.1 with the following in Startup.cs

services.AddOpenTelemetry((builder) => 
                    builder
                        .AddRequestInstrumentation((options) => { options.TextFormat = new B3Format(); })
                        .UseZipkinExporter((o) =>
                    {
                        o.ServiceName = "service-name;
                        o.Endpoint = new Uri("http://some-zipkin");
                    })
                );

While testing a request I noticed that the activity was given a SpanId of 0000000000000000 and TraceId of 00000000000000000000000000000000. It seems like when the HttpInListener detects a Request assembly with a major version < 3, the TextFormat option is used to pull the trace id's out from the http request headers and create a new ActivityContext. However, if these are not set in the request we end up with default id's of all 0's.

This seems to be caused by this line in the B3Format Extract function that returns RemoteInvalidContext.

I would expect these id's to be generated when not set on the HttpRequest, denoting a call made to an edge service and starting a new Trace.

Steps to reproduce.
Setup an aspnetcore 2.1 server with the following in Startup.cs

services.AddOpenTelemetry((builder) => 
                    builder
                        .AddRequestInstrumentation((options) => { options.TextFormat = new B3Format(); })
                        .UseZipkinExporter((o) =>
                    {
                        o.ServiceName = "service-name;
                        o.Endpoint = new Uri("http://some-zipkin");
                    })
                );

Make an httpRequest to the server without the X-B3-TraceId and X-B3-SpanId headers sent.

See trace sent to zipkin with default SpanId and TraceId

What is the expected behavior?
New TraceId and SpanId generated by the sdk.

What is the actual behavior?
Default ids

Proper way to add RouteValues as tags??

Best practice for getting RouteValues and setting them as tags

Describe your environment.
.NET core 3.1 app that exposes REST based API endpoints

Here is my otel initialization:

            service.AddOpenTelemetryTracing((builder) => builder
                .SetResourceBuilder(
                    ResourceBuilder.
                    CreateDefault().
                    AddService(distributedTracingOptions.DistributedTracingSettings.ApplicationName).
                    AddAttributes(infrastructureTags))                    
                .AddAspNetCoreInstrumentation((options) => //inbound requests to host application
                    {
                        options.RecordException = true;
                        options.Enrich = distributedTracingOptions.StandardEnrichParentSpan;
                    })                    
                .AddHttpClientInstrumentation((options) => //outbound requests from host application
                    {
                        options.RecordException = true;
                        options.Enrich = distributedTracingOptions.StandardEnrichChildSpan;
                    })
                .SetSampler(new AlwaysOnSampler())
                .AddOtlpExporter(options =>
                {
                    options.Endpoint = OtlpUri;
                })
            );

What are you trying to achieve?
Following the guidance on enriching spans gets me access to the HttpRequest and HttpResponse objects. I already get a nice normalized URL in the Operation and in the http.route tag, so that is good. There is also an http.path tag that contains the original URL with the route values in them, which sort of works.

But, to make things more queryable it would be nice to store the individual route values as tags. For instance, if I have a REST based endpoint like this:

/api/endpoint/{statecode}/action

I'd like to do queries on my traces like this:

http.route.value.statecode = "HI"

This way I'd be able to carve up the traces based on particular route values as well as look for trends on route values that might have more errors or higher latency.

I can get access to the route values through the HttpResponse object like this:

var routeData = httpResponse.HttpContext.GetRouteData();

From there it is pretty simple to add all the tags to the activity. But is this okay?? The route data is not available on the request object during the ActivityStart event, so I have to wait until the ActivityStop event and grab it off the context object. Not sure if that is safe or not.

Thanks.

Add labels to entry level tasks for new contributors

Hi,

based on open-telemetry/community#469 I have added open-telemetry/opentelemetry-dotnet-contrib to Up For Grabs:

https://up-for-grabs.net/#/filters?names=645

There are currently no issues with label help wanted. Please add this label to your entry level tasks, so people can find a way to contribute easily.

If "help wanted" is not the right label, let me know and I can change it (e.g. to "good first issue" or "up-for-grabs"), or you can provide a pull request by editing https://github.com/up-for-grabs/up-for-grabs.net/blob/gh-pages/_data/projects/opentelemetry-dotnet-contrib.yml

Thanks!

Grpc.Core.RpcException + Crashes when using Opentelemetry Stackdriver Exporter

It's not reliably reproducible, but managed to crash 2 different staging instances.

Runtime:
GCP image: windows-server-2019-dc-core-v20200609
Windows Server Core 2019 LTSC
netframework application built for .net 472 running on net48

Versions:

  • Optenelemetry: 0.6.0-beta.1
  • Opentelemetry.Api: 0.6.0-beta.1
  • OpenTelemetry.Contrib.Exporter.Stackdriver: 0.6.0-beta
  • Grpc.Core: 2.33.1
  • Google.Apis.Auth: 1.49.0
  • Google.Apis.Core: 1.49.0
  • Google.Protobuf: 3.13.0
  • Google.Cloud.Monitoring.V3: 2.1.0
  • Google.Cloud.Trace.V2: 2.0.0

Exception Message:

Grpc.Core.RpcException: 'Status(StatusCode="Unknown", Detail="Stream removed", DebugException="Grpc.Core.Internal.CoreErrorDetailException: {"created":"@1605690661.501000000","description":"Error received from peer ipv4:108.177.127.95:443","file":"T:\src\github\grpc\workspace_csharp_ext_windows_x64\src\core\lib\surface\call.cc","file_line":1062,"grpc_message":"Stream removed","grpc_status":2}")'

Stacktraces:

OS Thread Id: 0x1e0 (11)
        Child SP               IP Call Site
0000000693cfe458 00007ff8ae6302b4 [HelperMethodFrame: 0000000693cfe458] 
0000000693cfe540 00007ff8a1e08e70 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
0000000693cfe570 00007ff8a14a9aae System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(System.Threading.Tasks.Task)
0000000693cfe5a0 00007ff8442b5884 Grpc.Core.Internal.AsyncCall`2[[System.__Canon, mscorlib],[System.__Canon, mscorlib]].UnaryCall(System.__Canon)
0000000693cfe7b0 00007ff8442b3e28 Grpc.Core.DefaultCallInvoker.BlockingUnaryCall[[System.__Canon, mscorlib],[System.__Canon, mscorlib]](Grpc.Core.Method`2<System.__Canon,System.__Canon>, System.String, Grpc.Core.CallOptions, System.__Canon)
0000000693cfe938 00007ff8a27c1f7c [StubHelperFrame: 0000000693cfe938] 
0000000693cfe990 00007ff8442b3108 Grpc.Core.Interceptors.InterceptingCallInvoker.<BlockingUnaryCall>b__3_0[[System.__Canon, mscorlib],[System.__Canon, mscorlib]](System.__Canon, Grpc.Core.Interceptors.ClientInterceptorContext`2<System.__Canon,System.__Canon>)
0000000693cfea90 00007ff8442b2cae Grpc.Core.ClientBase+ClientBaseConfiguration+ClientBaseConfigurationInterceptor.BlockingUnaryCall[[System.__Canon, mscorlib],[System.__Canon, mscorlib]](System.__Canon, Grpc.Core.Interceptors.ClientInterceptorContext`2<System.__Canon,System.__Canon>, BlockingUnaryCallContinuation`2<System.__Canon,System.__Canon>)
0000000693cfebd8 00007ff8a27c1f7c [StubHelperFrame: 0000000693cfebd8] 
0000000693cfec30 00007ff8442b2be9 Grpc.Core.Interceptors.InterceptingCallInvoker.BlockingUnaryCall[[System.__Canon, mscorlib],[System.__Canon, mscorlib]](Grpc.Core.Method`2<System.__Canon,System.__Canon>, System.String, Grpc.Core.CallOptions, System.__Canon)
0000000693cfedd8 00007ff8a27c1f7c [StubHelperFrame: 0000000693cfedd8] 
0000000693cfee30 00007ff8442b2a0a Google.Cloud.Trace.V2.TraceService+TraceServiceClient.BatchWriteSpans(Google.Cloud.Trace.V2.BatchWriteSpansRequest, Grpc.Core.CallOptions)
0000000693cfee80 00007ff8442a7ad9 Google.Api.Gax.Grpc.ApiCall+GrpcCallAdapter`2[[System.__Canon, mscorlib],[System.__Canon, mscorlib]].CallSync(System.__Canon, Google.Api.Gax.Grpc.CallSettings)
0000000693cfef40 00007ff8442a775f Google.Api.Gax.Grpc.ApiCallRetryExtensions+<>c__DisplayClass1_0`2[[System.__Canon, mscorlib],[System.__Canon, mscorlib]].<WithRetry>b__0(System.__Canon, Google.Api.Gax.Grpc.CallSettings)
0000000693cfeff0 00007ff843f56c8f OpenTelemetry.Contrib.Exporter.Stackdriver.StackdriverTraceExporter.Export(OpenTelemetry.Batch`1<System.Diagnostics.Activity> ByRef)
0000000693cff050 00007ff843799622 OpenTelemetry.Trace.BatchExportActivityProcessor.ExporterProc()
0000000693cff0c0 00007ff8a143df12 System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
0000000693cff190 00007ff8a143dd95 System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
0000000693cff1c0 00007ff8a143dd65 System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
0000000693cff210 00007ff8a14e3e85 System.Threading.ThreadHelper.ThreadStart()
0000000693cff460 00007ff8a27c6953 [GCFrame: 0000000693cff460] 
0000000693cff7c0 00007ff8a27c6953 [DebuggerU2MCatchHandlerFrame: 0000000693cff7c0] 
0:011> * ================================== FAILING MANAGED STACK END================================================
0:011> * ================================== FAILING NATIVE STACK ================================================
0:011> kn
  *** Stack trace for last set context - .thread/.cxr resets it
 # Child-SP          RetAddr           Call Site
00 00000006`93cfe190 00007ff8`a293d605 KERNELBASE!RaiseException+0x69
01 00000006`93cfe270 00007ff8`a293e114 clr!RaiseTheExceptionInternalOnly+0x31f
02 00000006`93cfe390 00007ff8`a1e08e70 clr!IL_Throw+0x114
03 00000006`93cfe540 00007ff8`a14a9aae mscorlib_ni!System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()$##60053EB+0x20
04 00000006`93cfe570 00007ff8`442b5884 mscorlib_ni!System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(System.Threading.Tasks.Task)$##6005D24+0x3e
05 00000006`93cfe5a0 00007ff8`442b3e28 0x00007ff8`442b5884
06 00000006`93cfe7b0 00007ff8`a27c1f7c 0x00007ff8`442b3e28
07 00000006`93cfe8e0 00007ff8`442b3108 clr!InstantiatingMethodStubWorker+0xbc
08 00000006`93cfe990 00007ff8`442b2cae 0x00007ff8`442b3108
09 00000006`93cfea90 00007ff8`a27c1f7c 0x00007ff8`442b2cae
0a 00000006`93cfeb80 00007ff8`442b2be9 clr!InstantiatingMethodStubWorker+0xbc
0b 00000006`93cfec30 00007ff8`a27c1f7c 0x00007ff8`442b2be9
0c 00000006`93cfed80 00007ff8`442b2a0a clr!InstantiatingMethodStubWorker+0xbc
0d 00000006`93cfee30 00007ff8`442a7ad9 0x00007ff8`442b2a0a
0e 00000006`93cfee80 00007ff8`442a775f 0x00007ff8`442a7ad9
0f 00000006`93cfef40 00007ff8`43f56c8f 0x00007ff8`442a775f
10 00000006`93cfeff0 00007ff8`43799622 0x00007ff8`43f56c8f
11 00000006`93cff050 00007ff8`a143df12 0x00007ff8`43799622
12 00000006`93cff0c0 00007ff8`a143dd95 mscorlib_ni!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)$##6003AEF+0x172
13 00000006`93cff190 00007ff8`a143dd65 mscorlib_ni!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)$##6003AEE+0x15
14 00000006`93cff1c0 00007ff8`a14e3e85 mscorlib_ni!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)$##6003AED+0x55
15 00000006`93cff210 00007ff8`a27c6953 mscorlib_ni!System.Threading.ThreadHelper.ThreadStart()$##6003C00+0x55
16 00000006`93cff250 00007ff8`a27c6858 clr!CallDescrWorkerInternal+0x83
17 00000006`93cff290 00007ff8`a27c7118 clr!CallDescrWorkerWithHandler+0x4e
18 00000006`93cff2d0 00007ff8`a28cec8f clr!MethodDescCallSite::CallTargetWorker+0x102
19 00000006`93cff3d0 00007ff8`a27c7d10 clr!ThreadNative::KickOffThread_Worker+0xffffffff`fffff02f
1a 00000006`93cff630 00007ff8`a27c7c83 clr!ManagedThreadBase_DispatchInner+0x40
1b 00000006`93cff670 00007ff8`a27c7bc2 clr!ManagedThreadBase_DispatchMiddle+0x6c
1c 00000006`93cff770 00007ff8`a27c7da7 clr!ManagedThreadBase_DispatchOuter+0x4c
1d 00000006`93cff7e0 00007ff8`a28ceb79 clr!ManagedThreadBase_FullTransitionWithAD+0x2f
1e 00000006`93cff840 00007ff8`a27cb5f5 clr!ThreadNative::KickOffThread+0xe6
1f 00000006`93cff920 00007ff8`ac1b7974 clr!Thread::intermediateThreadProc+0x8b
20 00000006`93cffbe0 00007ff8`ae5fa271 kernel32!BaseThreadInitThunk+0x14
21 00000006`93cffc10 00000000`00000000 ntdll!RtlUserThreadStart+0x21
0:011> * ================================== FAILING NATIVE STACK END================================================

Correlate consequent spans from a request to DB

I am using the OpenTelemetry.Contrib.Instrumentation.MySqlData package to get traces for the queries I make to my db and export them to Jaeger. In my .NET Core controller action I make multiple calls to the db. However, the instrumentation only correlates the first one to the current activity (in my case it is an activity for an http request) and all the other calls are traced separately. Is there a way to work around or fix this so that all the db calls' traces are shown as children of the same root activity (the http request activity)? I am also using the OpenTelemetry.Instrumentation.AspNetCore package for the Web API instrumentation.

I am attaching a screenshot from my Jaeger. It shows the trace for the http request inside which is the first db call trace but all other db call traces are shown separately.
image

aspnet instrumentation zipkin exporter span name is router template

Question

Describe your environment.

.netfx 4.8
opentelemetry-dotnet 1.0.0-rc1.1

What are you trying to achieve?

current zipkin span name is router template
if use asp.net mvc default route template,
all span name is same, indistinguishable.
should it be "http.path" value?

Additional Context

[
    {
        "traceId": "96f718411e470c43ab817025b77cfd06",
        "name": "api/{controller}/{action}/{id}",
        "id": "8ee946841c01fc43",
        "kind": "SERVER",
        "timestamp": 1608102106455063,
        "duration": 172749,
        "localEndpoint": {
            "serviceName": "mp",
            "ipv4": "192.168.1.251",
            "ipv6": "fe80::a096:4ad4:ac95:fbf0"
        },
        "annotations": [],
        "tags": {
            "telemetry.sdk.name": "opentelemetry",
            "telemetry.sdk.language": "dotnet",
            "telemetry.sdk.version": "1.0.0.1",
            "http.host": "localhost:4469",
            "http.method": "POST",
            "http.path": "/api/Auth/Login",
            "http.user_agent": "PostmanRuntime/7.26.8",
            "http.url": "http://localhost:4469/api/Auth/Login",
            "http.status_code": "200",
            "otel.status_code": "0",
            "http.route": "api/{controller}/{action}/{id}",
            "otel.library.name": "OpenTelemetry.Instrumentation.AspNet",
            "otel.library.version": "1.0.0.1"
        }
    }
]

Adding only HttpClient instrumentation to ASP.NET Core app does not work

Bug Report

If you only add HttpClient instrumentation to an ASP.NET Core app, no spans from HttpClient are collected.

The issue is not specific to HttpClient instrumentation. I have also reproduced this when adding only Grpc.Net.Client instrumentation.

Reproduce

dotnet new webapi
dotnet add package --version 0.5.0-beta.2 OpenTelemetry.Instrumentation.Http
dotnet add package --version 0.5.0-beta.2 OpenTelemetry.Exporter.Console
dotnet add package --version 0.5.0-beta.2 OpenTelemetry.Instrumentation.AspNetCore

# Replace contents of Startup.cs with code below

dotnet run

# Navigate to https://localhost:5001/WeatherForecast
# This example uses the Console exporter. Observe no spans generated.
# Follow the instructions in the code comments to resolve the issue.
using System.Net.Http;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using OpenTelemetry.Trace;

public class Startup
{
    public void ConfigureServices(IServiceCollection services)
    {
        services.AddOpenTelemetryTracerProvider(builder => {
            builder
                // Uncomment the following line enabling AspNetCore instrumentation
                // This will result in seeing a span for both AspNetCore requests and the HttpClient invocation
                // .AddAspNetCoreInstrumentation()
                .AddHttpClientInstrumentation()
                .AddConsoleExporter();
        });

        services.AddControllers();
    }

    public void Configure(IApplicationBuilder app)
    {
        app.Use(async (context, next) =>
        {
            await next.Invoke();
            using var client = new HttpClient();
            await client.GetStringAsync("https://opentelemetry.io");
        });

        app.UseRouting();

        app.UseEndpoints(endpoints =>
        {
            endpoints.MapControllers();
        });
    }
}

Update

See my analysis below for the reason why this occurs. Some thoughts come to my mind on how best to address this issue.

  1. We could document this behavior and note that ASP.NET Core instrumentation is required.
  2. We could also document any potential workarounds. For instance, using a different sampler rather than the default ParentBasedSampler.
  3. Though, if we want to pursue making this work as is, then I think we need to devise a way to ignore the Activity created by ASP.NET Core in sampling decisions when OpenTelemetry has not been configured to use ASP.NET Core instrumentation.

EFCore nuget package seems to not be up to date

I get
[CS7069] Reference to type 'TracerProviderBuilder' claims it is defined in 'OpenTelemetry', but it could not be found

(OpenTelemetry 1.1.0-beta2 as that's required for aspnetcore lib).

OTEL instrumentation causing issues with AWS SDK

Hello! We've been kicking the tires on instrumenting with OTEL for .NET, had things working nicely in development then deployed to our test environment at which point we started seeing some errors communicating through the AWS SDK. The specific calls we saw failures for were: Assume Role and the KMS APIs (my guess is the errors are related).

Here are libraries we are using for instrumentation:

    <PackageReference Include="MongoDB.Driver.Core.Extensions.OpenTelemetry" Version="1.0.0-rc.3" />
    <PackageReference Include="OpenTelemetry.Exporter.Zipkin" Version="1.0.0-rc1.1" />
    <PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.0.0-rc1.1" />
    <PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.0.0-rc1.1" />
    <PackageReference Include="OpenTelemetry.Instrumentation.Http" Version="1.0.0-rc1.1" />

And here is how we are configuring in ConfigureServices

            services.AddOpenTelemetryTracing((sp, builder) =>
            {
                builder
                    .AddAspNetCoreInstrumentation()
                    .AddHttpClientInstrumentation()
                    .AddSource(Levitate.Common.Timing.MethodTimer.ActivitySource.Name)
                    .AddZipkinExporter(opts =>
                    {
                        opts.Endpoint = Configuration.GetValue<Uri>("ZipkinExporter");
                    })
                    .SetResourceBuilder(ResourceBuilder.CreateDefault().AddService("our-service"));
            });

When this bit of code is included, within the next 10-15 minutes after a successful deployment we start seeing one of two errors:

  • Calls to Assume Role fail
  • Call to KMS Decrypt API fail (my assumption here is since the Assume Role call fails, we end up with invalid credentials so KMS rightfully fails).

If we remove OTEL tracing, everything behaves as expected.

Missing error logging in StackDriver exporter

The StackDriver exporter uses Google's TraceServiceClient as exporting mechanism. If a call to it throws any type of exception, a failure status is returned, but the thrown exception is not logged.

This behavior makes trouble shooting difficult. The details of the exception probably contains valuable information of why the call failed.

FluentBit exporter

Define a data format and create an exporter from OpenTelemetry to FluentBit. This will allow customers to use existing log delivery pipeline to upload telemetry collected by the rich set of various OpenTelemetry SDKs.

This issue is features as a Community Bridge project for Q3-Q4 2020.

Instrumentation.SqlClient Span has Duration of 0 sec

Bug Report

      <PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="3.1.9" />
      <PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="3.1.2" />
      <PackageReference Include="OpenTelemetry.Exporter.Jaeger" Version="1.0.0-rc1.1" />
      <PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.0.0-rc1.1" />
      <PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.0.0-rc1.1" />
      <PackageReference Include="OpenTelemetry.Instrumentation.Http" Version="1.0.0-rc1.1" />
      <PackageReference Include="OpenTelemetry.Instrumentation.SqlClient" Version="1.0.0-rc1.1" />

Runtime versionnetcoreapp3.1

Symptom

I tested SqlClient instrumentation with a dummy app and noticed
the Duration of the SqlClient Span is always 0ms or 1ms. (See Screenshot)

My test SQL Statement has a sleep (WAITFOR DELAY) in it, so it takes at least a couple seconds even on localhost.
It looks like the span is created after all sql work is done.

What is the expected behavior?

I expected to observe a span duration that is reflecting the actual execution time of the SQL Statement in the database.
Since the README does not contain any details / example,

I was expecting the Span to start on calling Connection.Open() or command.ExecuteReader() (?)

What is the actual behavior?

The autoinstrumented activity (span) has a duration of 0ms or 1ms on localhost. After closely looking at the reported Start Times one can see the span is started after opening the Connection and before command.ExecuteReader()):

Starttime Event
139.31ms Post Open Connection
139.34ms SqlClient Span Demo, service localhost, Duration 1ms
140.47ms Post ExecuteReader

It looks like the span is instantly stopped?

Reproduce

// Startup.cs

services.AddTransient<IDbConnection>(sqlConnection => new SqlConnection(
                @"Server=localhost\SQL2017DEV;Database=Demo;Trusted_Connection=True;Application Name=""Weather BackendService"""));
                
// Controller

using (var command = _sqlConnection.CreateCommand())
{
    var rowCount = new Random().Next(1500, 70000);
    var tableName = @"DummyData";
    command.CommandText = $@"SELECT TOP({rowCount}) * FROM {tableName}; WAITFOR DELAY '00:00:{rowCount/10000:00}'";
    command.CommandTimeout = 10; // seconds
    
    using var dbActivity = Startup.Source.StartActivity($"SQL DB {_sqlConnection.Database} - Get Table {tableName}");

    try
    {
        Activity.Current?.AddEvent(new ActivityEvent("Pre Open Connection"));
        
        command.Connection.Open();
        
        Activity.Current?.AddEvent(new ActivityEvent("Post Open Connection"));
        using (var sqlReader = command.ExecuteReader())
        {
            Activity.Current?.AddEvent(new ActivityEvent("Post ExecuteReader"));
            while (sqlReader.Read())
            {
                try
                {
                    // do something
                }
                catch (Exception ex)
                {
                    _logger.LogError(ex, "Parsing Sql Table Row Failed");
                }
            }
            Activity.Current?.AddEvent(new ActivityEvent("Post While Read()"));
        }
    }
    finally
    {
        command.Connection.Close();
        Activity.Current?.AddEvent(new ActivityEvent("Post Close Connection"));
        dbActivity?.Stop();
        Activity.Current?.AddEvent(new ActivityEvent("Post Stop Activity"));
    }
}
Activity.Current?.AddEvent(new ActivityEvent("Post using CreateCommand"));

Thread.Sleep(30);
// ...

Result

Sql-Span-Duration
Sql-Span-Logs
Log-Post-Activity

Not all ASP.NET requests are exported

Bug Report

List of NuGet packages and
version:

  • OpenTelemetry.Instrumentation.AspNet 1.0.0-rc1.1
  • OpenTelemetry.Instrumentation.Http 1.0.0-rc1.1
  • OpenTelemetry.Contrib.Exporter.Stackdriver local build

Runtime version:

  • net472

Symptom

We are running an ASP.NET (classic) application with the telemetry module provided by Microsoft in Microsoft.AspNet.TelemetryCorrelation 1.0.8. HTTP requests and ASP.NET instrumentation are enabled and exported to Stackdriver through a local build of the contrib project with updated dependecy to underlying open-telemetry package to 1.0.0-rc1.1. For many requests, this works as expected and trace data is ingested by Cloud Trace. However, some requests are never properly instrumented. One may suspect the local build of Stackdriver as the culprit, but I believe that the issue lays somewhere in the ASP.NET instrumentation library. After debugging the code I have made the following observations:

When everything works:

  • The activity Microsoft.AspNet.HttpReqIn is correctly created by the TelemetryCorrelationHttpModule.
  • The method OnStartActivity on OpenTelemetry.Instrumentation.AspNet.Implementation.HttpInListener is called
  • The AspNet-activity is stopped
  • The method OnStopActivity on OpenTelemetry.Instrumentation.AspNet.Implementation.HttpInListener is called
  • Export is triggered on registered exporters

When traces are not exported:

  • The activity Microsoft.AspNet.HttpReqIn is correctly created by the TelemetryCorrelationHttpModule.
  • The method OnStartActivity on OpenTelemetry.Instrumentation.AspNet.Implementation.HttpInListener is called
  • The AspNet-activity is stopped
  • The method OnStopActivity on OpenTelemetry.Instrumentation.AspNet.Implementation.HttpInListener is not called
  • Export is not triggered on registered exporters

When backtracking why OnStopActivity is not called, I noticed that OpenTelemetry.Instrumentation.DiagnosticSourceListener's OnNext method bails out here when called with Microsoft.AspNet.HttpReqIn.Stop kvp because Activity.Current is null.

What is the expected behavior?

All HTTP requests to the ASP.NET should be instrumented and exported

What is the actual behavior?

Some http requests are not instrumented and exported

Reproduce

Unfortunately, I have not been able to create a small repro app. I will continue to investigate this issue and see if I can get back with easier repro-steps.

Adding gRPC instrumentation but not HttpClient causes issues with parenting

Both the gRPC .NET and HttpClient libraries generate their own Activity for outgoing calls.

gRPC .NET uses HttpClient behind the scenes, so when you configure OpenTelemetry with both gRPC and HttpClient instrumentation you'll see that the Activity generated by gRPC is the parent of the Activity generated by HttpClient.

However, if you only include gRPC instrumentation or if you only include HttpClient instrumentation the chain of parenting can become broken since the library still generates their respective Activity. Another way this can occur is if you add both gRPC and HttpClient instrumentation, but you configure SuppressDownstreamInstrumentation for the gRPC instrumentation thereby excluding the child HttpClient Activity from the trace.

This issue is somewhat related to #1779 in that the general issue is that libraries generate Activities regardless of whether OpenTelemetry has been configured to be interested in them. I'm not sure there are good answers here, but it would be nice if there were a way to inform a library of whether or not to generate Activities based on how OpenTelemetry is configured for an app.

Maintainers and approvers for contrib repo

As discussed in the last few SIG meetings, and discussed in #57, we have created separate maintainers and approvers group for this repo.

The new maintainers/approvers list currently has the exact same members the main repo. This is done as an initial seeding only, and the members can be completely different. We'd also have per directory approver as well in the future.

If you'd like to be maintainers/approver for this repo, please express your interest below by commenting. Please refer to this guide for overall responsibility of approver/maintainer, https://github.com/open-telemetry/community/blob/main/community-membership.md . Given we are seeding this repo, we can discuss exceptions in the next SIG meeting.

If you are maintainer/approver in the main repo, and want removed from being the maintainer/approve in this repo, please comment below.

Record exceptions in gRPC request handling

Feature Request

Is your feature request related to a problem?

The instrumentation library for AspNetCore records unhandled exceptions during handling of HTTP requests, adding them as an event to the Activity, and calling the configured Enrich action with an "OnException" event.
The same is not true for exceptions thrown during gRPC request handling, as these are swallowed by ServerCallHandlerBase in the Grpc.AspNetCore library.

Describe the solution you'd like:

Record exceptions thrown thrown during gRPC request handling if EnableGrpcAspNetCoreSupport is true:

  • Add an event to the Activity.
  • Call Enrich with an "OnException" event.

This will likely require some diagnostic events to be emitted from the HttpContextServerCallContext in the Grpc.AspNetCore library.

Describe alternatives you've considered.

One work around is to do record the exception and enrich the Activity in a gRPC interceptor, but seems unnecessary boilerplate, requiring separate configuration, in order to bring the features of gRPC tracing up to parity with regular HTTP tracing.

Implement Adaptive Sampling

Implement adaptive sampling for OpenTelemetry, where customers can set a max number of telemetry items per second and the sampling rate will adjust accordingly.

Calling AddEntityFrameworkCoreInstrumentation

Hi, I am trying to call tracerProviderBuilder.AddEntityFrameworkCoreInstrumentation() but it results in compile error error CS7069: Reference to type 'TracerProviderBuilder' claims it is defined in 'OpenTelemetry', but it could not be found.

My dependencies are OpenTelemetry.Contrib.Instrumentation.EntityFrameworkCore:0.6.0-beta.10, OpenTelemetry.Instrumentation.StackExchangeRedis:1.0.0-rc4. The project runtime is netcoreapp3.1, I am using net5 CLI.

Support for tracing on AWS Lambda

This issue is mainly about instrumenting the SDK wrapper for tracing AWS Lambda handler.

What the wrapper needs to implement for an incoming Lambda handler span:

  1. Inherit trace id _X_AMAZON_TRACE_ID from AWS Lambda runtime or upstream
  2. Record AWS Lambda resource attributes

Will keep updating and submit a PR

How to configure AttachLogsToActivityEvent behaviour

I'm trying to use the preview feature AttachLogsToActivityEvent mentioned in the corresponding readme.

I have checked the examples left by @CodeBlanch in PR open-telemetry/opentelemetry-dotnet#114 and managed to get the logging working in an ASP.Net Core project.
However I don't know how to configure it so that the message, state or scope information is logged. This is my configuration:

Program.cs:

Host.CreateDefaultBuilder(args)
    .ConfigureLogging(builder =>
    {
        builder.AddOpenTelemetry(options => options.AttachLogsToActivityEvent(options => {
            options.ScopeConverter = (tags, depth, scope) =>
            {
                //Breakpoints won't get hit here
            };
            options.StateConverter = (tags, state) =>
            {
                //Breakpoints won't get hit here
            };
        }));
    })
    .ConfigureWebHostDefaults(builder => builder.UseStartup<Startup>());

Startup.cs:

services.AddOpenTelemetryTracing(builder =>
{
    builder
        .AddAspNetCoreInstrumentation()
        .AddConsoleExporter();
});

This is what is logged from a controller:

    log [06/10/2021 14:51:57 +00:00]
        CategoryName: Controller
        LogLevel: Information

Any idea about how to configure the state/scope/message logging? It would be useful to document it somewhere (if its already documented, maybe we could reference it from the readme file).

SQL instrumentation infinitely nests its activity when used with sync call inside of async code in a loop

Bug Report

List of NuGet packages:

  • OpenTelemetry.Exporter.OpenTelemetryProtocol 1.1.0-rc1
  • OpenTelemetry.Extensions.Hosting 1.0.0-rc6
  • OpenTelemetry.Instrumentation.SqlClient 1.0.0-rc6

Runtime version:

  • netcoreapp3.1

Symptom

What is the expected behavior?

Activity stops after a DB call completes

What is the actual behavior?

Activity is not stopped after a DB call completes

Reproduce

namespace TelemetrySyncSql
{
    using Microsoft.Extensions.DependencyInjection;
    using Microsoft.Extensions.Hosting;
    using OpenTelemetry;
    using OpenTelemetry.Resources;
    using OpenTelemetry.Trace;
    using System;
    using System.Data.SqlClient;
    using System.Threading;
    using System.Threading.Tasks;

    class Program
    {
        static string connStr = "Data Source=localhost;Initial Catalog=test;User Id=test;Password=test;MultipleActiveResultSets=True";
        static string endpoint = "http://localhost:4317";

        static async Task Main(string[] args)
        {
            await new HostBuilder()
                .ConfigureServices((context, services) =>
                {
                    var builder = Sdk.CreateTracerProviderBuilder();

                    builder.AddSqlClientInstrumentation(options =>
                    {
                        options.EnableConnectionLevelAttributes = true;
                        options.SetDbStatementForText = true;
                    });

                    var resourceBuilder = ResourceBuilder
                        .CreateDefault()
                        .AddService("test-client", null, "1.0.0.0", true, null);

                    builder.SetResourceBuilder(resourceBuilder);

                    builder.AddOtlpExporter(options =>
                    {
                        options.Endpoint = new Uri(endpoint);

                        AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true);
                    });

                    builder.Build();

                    services.AddHostedService<Worker>();

                })
                .UseConsoleLifetime()
                .RunConsoleAsync();
        }

        public class Worker : BackgroundService
        {
            SqlConnection connection;

            public Worker()
            {
                connection = new SqlConnection(connStr);
            }

            protected override async Task ExecuteAsync(CancellationToken stoppingToken)
            {
                connection.Open();

                while (true)
                {
                    GoDb();
                    await Task.Delay(500);
                }

                void GoDb()
                {
                    Console.WriteLine("tick");

                    using var command = new SqlCommand("select 1", connection);

                    var res = command.ExecuteReaderAsync().Result;
                }
            }
        }
    }
}

Additional context

Changing to

while (true)
{
    await GoDb();
    await Task.Delay(500);
}

async Task GoDb()
{
    Console.WriteLine("tick");

    using var command = new SqlCommand("select 1", connection);

    var res = await command.ExecuteReaderAsync();
}

leads to the expected result

Expected behavior of HttpClientInstrumentation RecordException=true

When should HttpClientInstrumentation create an Activity Event when RecordException=true??

Describe your environment.
n/a

Describe any aspect of your environment relevant to the question.

What are you trying to achieve?
I'd like to get the exception details from outbound HttpClient requests added as Activity Events when RecordException=true

Here is my startup.cs configuration:

            service.AddOpenTelemetryTracing((builder) => builder
                .SetResourceBuilder(
                    ResourceBuilder.
                    CreateDefault().
                    AddService("myapp").
                    AddAttributes(infrastructureTags))                    
                .AddAspNetCoreInstrumentation((options) => 
                    {
                        options.RecordException = true;
                        options.Enrich = EnrichParentSpan;
                    })                    
                .AddHttpClientInstrumentation((options) =>
                    {
                        options.RecordException = true;
                        options.Enrich = EnrichChildSpan;
                    })
                .SetSampler(new AlwaysOnSampler())
                .AddOtlpExporter(options =>
                {
                    options.Endpoint = OtlpUri;
                })
            );

If the parent service fails I get an Activity Event with the Exception details. I can also see that the activityEventName in my EnrichParentSpan method is OnException and it gives me access to the Exception object.

If an outbound request fails (404) the client span does not have an Activity Event with the Exception details, but it will set the error tag to true and the status.code tag to 2. When debugging my EnrichChildSpan method the activityEventName is OnStopActivity and I'll get access to the HttpResponseMessage object.

What did you expect to see?
I expected the behavior for inbound and outbound Exception processing to be the same, namely that if an error is returned from an outbound call it would log the same as an inbound call.

Is the expectation that I would code the response processing myself in my EnrichChildSpan method and to something like this??

                try
                {
                    httpResponseMessage.EnsureSuccessStatusCode();
                }
                catch (Exception exception)
                {
                    activity.RecordException(exception);                    
                    throw;
                }

The HttpHandlerDiagnosticListener has an exception method that will record the exception, but it doesn't get hit. Not sure if this is intended, thanks for the clarification.

Additional Context

Add any other context about the problem here. If you followed an existing
documentation, please share the link to it.

[Http Instrumentation] Make it easier to scrub sensitive URI details from output

Feature Request

Before opening a feature request against this repo, consider whether the feature
should/could be implemented in the other OpenTelemetry client
libraries
. If so, please open an issue on
opentelemetry-specification

first.

Is your feature request related to a problem?

If so, provide a concise description of the problem.

The HTTP instrumentation package currently writes out the full request path for most requests, the exception being requests that contain Uri.UserInfo. This is not sufficient for many resource types. For example, the Azure Storage SDK's requests show up in logs with a SAS token appended.

For example:
https://mystorage.blob.core.windows.net/container/myfile.txt?sv=2019-07-07&sr=c&sig=placeholder&se=2021-09-08T22%3A03%3A23Z&sp=r&api-version=2019-07-07&

I can also imagine other scenarios where the URI might otherwise contain sensitive information that cannot be logged.

Describe the solution you'd like:

What do you want to happen instead? What is the expected behavior?

It would be helpful if OpenTelemetry had a configurable high-performance URL scrubber for anywhere URLs could be logged,
to make it as easy as possible for developers to sanitize their log output. This would support (minimally) blocking out any specified query string parameters.

Describe alternatives you've considered.

Which alternative solutions or features have you considered?

In our project today, we configure an enricher to run a Regex replace on all URLs we log, but it feels like there is room for improvement on the default behavior.

Additional Context

Add any other context about the feature request here.

This is definitely in the "nice to have" category. There are ways to solve the problem with the current shipped libraries.

Dapper Collector

Is there any plan to release an OpenTelemetry collector for Dapper? Would this be something that would be implemented at a similar time to open-telemetry/opentelemetry-dotnet#79?

It'd be awesome to have telemetry data automatically populated from dapper, especially as a major reason for using dapper is the performance advantage it can give over something like EFCore.

There is already a collector for StackExchangeRedis (https://github.com/open-telemetry/opentelemetry-dotnet/tree/master/src/OpenTelemetry.Collector.StackExchangeRedis), so I'd be interested to know what would be involved in implementing something similar for dapper.

I'm not sure if Dapper would need to be instrumented for this, so I've created an issue on the Dapper repo too: DapperLib/Dapper#1355

Update to OTel 1.0.0 RC1

This project is completely broken when upgrading to OTel 0.8. ActivitySourceAdapter, DiagnosticSourceSubscriber, ListenerHandler, PropertyFetcher have all been made internal. Is the plan that we have to just copy the source into each of these instrumentations?

WPF Open telemetry tracing Issues

Hi team ,

We have a WPF application which connects to Web API and WCF on the server side . Am not able to add instrumentation to the WPF client application where as to the WCF and Web API it is working fine. Even though I have added open telemetry instrumentation to the WPF application added activities too. Could you please help me in this regard.

Thanks

WCF TelemetryEndpointBehavior does not implement IServiceBehavior

Tried to configure TelemetryEndpointBehavior by default by referencing it in my machine.config's section.

This fails because TelemetryEndpointBehavior does not implement IServiceBehavior interface.

Implementing it is pretty straight forward and did not create any side effects so far.
Could create a pull request if there are no concerns that I missed.

Adjust MassTransit to the semantic conventions

Currently, MassTransit instrumentation does not follow the semantic conventions for messaging traces: https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/trace/semantic_conventions/messaging.md

By default, MassTransit creates an activity for publishing and receiving messages, and populate default tags to be compliant with OpenTracing. But these tags do not conform to the semantic convention spec, for example

  • Span names do not match the spec
  • Default tag names do not match the spec
  • A lot of redundant tags
  • Incorrect span.kind
  • net.peer.* tags are not populated correctly
  • The instrumentation produces an incorrect peer.service tag
  • Detect a sync communication (Request-Reply) and set span.kind=client or span.kind=server
  • Detect temporary destinations (in request-reply) and set messaging.temp_destination tag. Also, span name should be changed to (temporary) send
  • Detect messaging.destination_kind (topic|queue). Is it possible to detect it based on Activity or SendContext?

Collector on ECS Fargate not showing the correct environment in X-Ray

For reference, I've also opened an issue on aws-observability/aws-otel-collector#590 as well.

I'm trying to instrument a .NET application to send data to AWS X-Ray using the latest OpenTelemetry packages and latest version of the aws-otel-collector (v11) and I'm not seeing the expected results when deployed to ECS Fargate. As seen below, the origin/environment is defaulting to "origin": "AWS::ElasticBeanstalk::Environment" and other data like the client_ip is not being displayed.

{
    "Id": "1-60ff0ef9-69b7f7c2497cf80f8ea659c6",
    "Duration": 0.009,
    "LimitExceeded": false,
    "Segments": [
        {
            "Id": "5c06663e843c564c",
            "Document": {
                "id": "5c06663e843c564c",
                "name": "GeoLocationAPI",
                "start_time": 1627328249.489951,
                "trace_id": "1-60ff0ef9-69b7f7c2497cf80f8ea659c6",
                "end_time": 1627328249.4993875,
                "fault": false,
                "error": false,
                "throttle": false,
                "http": {
                    "request": {
                        "url": "http://cdkge-lb8a1-1b4rhmo4ueypd-651829293.us-east-1.elb.amazonaws.com/api/v1/geolocation",
                        "method": "GET",
                        "user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.107 Safari/537.36"
                    },
                    "response": {
                        "status": 200,
                        "content_length": 0
                    }
                },
                "aws": {
                    "elastic_beanstalk": {
                        "version_label": null,
                        "deployment_id": 0,
                        "environment_name": null
                    },
                    "xray": {
                        "auto_instrumentation": false,
                        "sdk_version": "1.1.0.174",
                        "sdk": "opentelemetry for dotnet"
                    }
                },
                "metadata": {
                    "default": {
                        "otel.resource.telemetry.sdk.name": "opentelemetry",
                        "http.route": "api/v{version:apiVersion}/GeoLocation",
                        "http.path": "/api/v1/geolocation",
                        "otel.resource.service.instance.id": "41c9ff05-035c-46a4-938d-8b1d4fbd728c",
                        "otel.resource.service.name": "GeoLocationAPI",
                        "otel.resource.telemetry.sdk.language": "dotnet",
                        "otel.resource.telemetry.sdk.version": "1.1.0.174"
                    }
                },
                "origin": "AWS::ElasticBeanstalk::Environment"
            }
        }
    ]
}

In the traditional X-Ray SDK you can configure AWSXRayPlugins in your appsettings file as seen here. Is there a similar approach or is this a bug?

Package References:

<PackageReference Include="OpenTelemetry" Version="1.1.0" />
<PackageReference Include="OpenTelemetry.Contrib.Extensions.AWSXRay" Version="1.0.1" />
<PackageReference Include="OpenTelemetry.Contrib.Instrumentation.AWS" Version="1.0.1" />
<PackageReference Include="OpenTelemetry.Exporter.Console" Version="1.1.0" />
<PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.1.0" />
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.0.0-rc7" />
<PackageReference Include="OpenTelemetry.Instrumentation.Http" Version="1.0.0-rc7" />

SetDbStatement should be available when compiling against netstandard2.0

Bug Report

  • OpenTelemetry Version="1.0.1"
  • OpenTelemetry.Exporter.Console Version="1.0.1"
  • OpenTelemetry.Instrumentation.SqlClient Version="1.0.0-rc2"

netstandard library imports above packages and that library is then used in a net48 project

Symptom

A clear and concise description of what the bug is.

What is the expected behavior?

SetDbStatementForStoredProcedure, SetDbStatementForText and SetDbStatement settings settable and they take effect depending on the actual runtime platform.

What is the actual behavior?

SetDbStatementForStoredProcedure, SetDbStatementForText are settable but lead to a method not found exception.
SetDbStatement is not there.

Reproduce

OTELRepo.zip

Run ConsoleApp2 in attached solution. You will get method not found exception.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.