Comments (6)
question:
Is https://github.com/open-telemetry/opentelemetry-dotnet/tree/main/src/OpenTelemetry.Extensions.Hosting expected to be used with Asp.Net app at all? Asp.Net instrumentation, examples - none of them show that pattern.
I know this question wasn't for me, but I can suggest that this shouldn't concern the individual instrumentation packages themselves: note that the Http or Wcf or EntityFrameworkCore or any other instrumentations are agnostic of how the are instantiated, so they work with IConfiguration if present, and fallback to envvar if not.
I strongly believe this should be the case for all instrumentations, even if they normally aren't used with the Hosting package.
Again, keep in mind that people can use parts of Microsoft.Extensions.Hosting
anywhere. Either they use just DI, or they use DI + Configuration, or they use DI + Configuration + Logging, etc. This is what we are doing to modernize areas that can be modernized of our projects. We don't use the running parts of hosting however, like the hosted services mechanism, application lifetime, etc.
from opentelemetry-dotnet-contrib.
So what the SDK does is make sure there is always an IConfiguration
available. In the case of Microsoft.Extensions.Hosting
that IConfiguration
is the host one. In the case of the "detached" build-up APIs ("Sdk.Create*" and "OpenTelemetrySdk.Create" being added in 1.10.0) the IConfiguration
is created automatically from envvars.
Issue here seems to be Owin and AspNet aren't using the IConfiguration
. My guess would be due to some static coupling. I'll take a quick look and see if there is a way to solve that.
from opentelemetry-dotnet-contrib.
but I can suggest that this shouldn't concern the individual instrumentation packages themselves: note that the Http or Wcf or EntityFrameworkCore or any other instrumentations are agnostic of how the are instantiated, so they work with IConfiguration if present, and fallback to envvar if not.
I strongly believe this should be the case for all instrumentations, even if they normally aren't used with the Hosting package.
Yes I agree with that. @CodeBlanch has designed the infra pieces (core api/sdk) with this in mind already. Don't think every instrumentation/component has fully embraced it yet.
from opentelemetry-dotnet-contrib.
@julealgon Here is a diff which should fix Owin: https://github.com/open-telemetry/opentelemetry-dotnet-contrib/compare/main...CodeBlanch:owin-iconfiguration-support?expand=1
You have any bandwidth to run with that and take it to PR by chance? I'm pretty swamped at the moment.
AspNet package should be similar process just rinse and repeat 😄
from opentelemetry-dotnet-contrib.
question:
Is https://github.com/open-telemetry/opentelemetry-dotnet/tree/main/src/OpenTelemetry.Extensions.Hosting expected to be used with Asp.Net app at all? Asp.Net instrumentation, examples - none of them show that pattern.
from opentelemetry-dotnet-contrib.
You have any bandwidth to run with that and take it to PR by chance? I'm pretty swamped at the moment.
Not at the moment as I still need to run the CLA process through with my company.
I figured I'd share the workaround we used though, just in case others end up running into the same issue while this gets worked on.
First, I created a simple extension method that I could easily call on 2 of our projects (one that uses Owin instrumentation, and another that uses the AspNet instrumentation):
.ConfigureServices((context, services) =>
{
services.AddOpenTelemetry()
.PropagateLegacySettingsToEnvironmentVariables(context.Configuration)
...
.ConfigureResource(c => c ...)
.WithMetrics(m => m ...)
.WithTracing(t => t ...)
.UseOtlpExporter();
}
Code is fairly straightforward: just take the 2 "problematic" flags and forcibly set them as real environment variables in the process:
public static IOpenTelemetryBuilder PropagateLegacySettingsToEnvironmentVariables(
this IOpenTelemetryBuilder builder,
IConfiguration configuration)
{
ArgumentNullException.ThrowIfNull(builder);
ArgumentNullException.ThrowIfNull(configuration);
ReadOnlySpan<string> legacySettingNames = [
"OTEL_DOTNET_EXPERIMENTAL_ASPNET_DISABLE_URL_QUERY_REDACTION",
"OTEL_DOTNET_EXPERIMENTAL_OWIN_DISABLE_URL_QUERY_REDACTION",
];
foreach (var settingName in legacySettingNames)
{
if (configuration[settingName] is string settingValue)
{
Environment.SetEnvironmentVariable(settingName, settingValue);
}
}
return builder;
}
Once this is fixed, we'll drop the extension without too much impact if at all.
from opentelemetry-dotnet-contrib.
Related Issues (20)
- [Resources.Azure] Rename `AddAppServiceDetector` to `AddAzureAppServiceDetector` HOT 1
- Rename `OpenTelemetry.Instrumentation.StackExchangeRedis` to a more generic name HOT 1
- [HttpClient] add {target} to span name
- RuntimeInstrumentationOptions has no properties HOT 1
- AWS X-Ray traces without span info
- [ConfluentKafka] Implement a process span to ease connecting traces
- Add unit tests to ConfluentKafka instrumentration
- Add instructions to configure ConfluentKafka instrumentation HOT 2
- Add CoreWCF Instrumentation HOT 1
- Migrate semantic conventions generation to Weaver
- Activity.DisplayName is overwritten by instrumentation libraries HOT 10
- Missing documentation for `OTEL_DOTNET_EXPERIMENTAL_OWIN_DISABLE_URL_QUERY_REDACTION` HOT 5
- [Instrumentation.StackExchangeRedis] Vunerability warning due to transitive dependency HOT 1
- AWS Instrumenting doesn't work when AWS DynamoDb Client is created in a DI class
- Make DisableUrlQueryRedaction option in OpenTelemetry.Instrumentation.Http public HOT 2
- Add additional os.types HOT 1
- Populate additional os fields HOT 1
- Provide OS Platform HOT 2
- Registering instrumentation libraries more than once adds duplicate Activity listeners
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from opentelemetry-dotnet-contrib.