Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Host Error with OpenTelemetry.Extensions.Hosting #7007

Closed
kolanos opened this issue Dec 22, 2020 · 3 comments · Fixed by #7253
Closed

Host Error with OpenTelemetry.Extensions.Hosting #7007

kolanos opened this issue Dec 22, 2020 · 3 comments · Fixed by #7253

Comments

@kolanos
Copy link

kolanos commented Dec 22, 2020

When running func start --csharp when using OpenTelemetry.Extensions.Hosting in a function-app it gives the following error:

Microsoft (R) Build Engine version 16.7.0+7fb82e5b2 for .NET
Copyright (C) Microsoft Corporation. All rights reserved.

  Determining projects to restore...
  All projects are up-to-date for restore.
  DoNothingApp -> /Users/kolanos/Web/newrelic/DoNothingApp/DoNothingApp/bin/output/DoNothingApp.dll

Build succeeded.
    0 Warning(s)
    0 Error(s)

Time Elapsed 00:00:01.69


Azure Functions Core Tools
Core Tools Version:       3.0.3160 Commit hash: 00aa7f43cc5c5f15241b5e6e5363256f19ceb990
Function Runtime Version: 3.0.14916.0

[2020-12-22T14:13:36.225Z] A host error has occurred during startup operation '8ad1dca7-4289-4911-ac9e-ac29c0d56a6f'.
[2020-12-22T14:13:36.225Z] func: Invalid host services. Microsoft.Azure.WebJobs.Script.WebHost: The following service registrations did not match the expected services:
[2020-12-22T14:13:36.225Z]   [Invalid] ServiceType: Microsoft.Extensions.Hosting.IHostedService, Lifetime: Singleton, ImplementationType: OpenTelemetry.Extensions.Hosting.Implementation.TelemetryHostedService, OpenTelemetry.Extensions.Hosting, Version=1.0.0.1, Culture=neutral, PublicKeyToken=7bd6737fe5b67e3c.

See here for an example function app using OpenTelemetry.Extensions.Hosting.

cc @fabiocav

@v-anvari
Copy link

v-anvari commented Dec 23, 2020

Hi @kolanos , I was able to reproduce the issue. " builder.Services.AddOpenTelemetryTracing( )" throws the exception. The error should be because Azure Functions doesn't allow to register any IHostedService as a part of your Startup operation.

Explained in #5447 (comment)

Error:

Line: builder.Services.AddOpenTelemetryTracing((serviceProvider, tracerBuilder) ----Startup file
Results:
◢ | ServiceType | {Name = "IHostedService" FullName = "Microsoft.Extensions.Hosting.IHostedService"} | System.Type {System.RuntimeType}
Exception:
| DeclaringMethod | '((System.RuntimeType)(new System.Linq.SystemCore_EnumerableDebugView<Microsoft.Extensions.DependencyInjection.ServiceDescriptor>(builder.Services).Items[60]).ServiceType).DeclaringMethod' threw an exception of type 'System.InvalidOperationException' | System.Reflection.MethodBase {System.InvalidOperationException}

I could get rid of the error and thus gaining a successful deployment by commenting out "[assembly: FunctionsStartup(typeof(FunctionApp1.Startup))]" from the startup file

@brettsam or @fabiocav, would you have any inputs on this

@fabiocav
Copy link
Member

Moving this to sprint 97, but we might be able to spend some time investigating in sprint 96.

@fabiocav fabiocav assigned madelinegordon and unassigned fabiocav Mar 3, 2021
@fabiocav
Copy link
Member

Similar change here: #6729

@ghost ghost locked as resolved and limited conversation to collaborators May 6, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants