Comments (2)
@VladyslavLishchyna I just spent some time trying to reproduce this and so far haven't been able to. Can you provide me with a small app that reproduces the problem? If not, some questions...
- What versions of the OTel packages are you using?
- Can you share your code for configuring the OTel SDK?
Here is how I tried to reproduce it using latest code. Everything seems to work fine.
// Program.cs
using OpenTelemetry.Trace;
using WorkerService;
var builder = Host.CreateApplicationBuilder(args);
builder.Services.AddOpenTelemetry()
.WithTracing(builder => builder.AddSource(Worker.MyActivitySource.Name).AddOtlpExporter());
builder.Services.AddHostedService<Worker>();
var host = builder.Build();
host.Run();
// Worker.cs
using System.Diagnostics;
namespace WorkerService
{
public class Worker : BackgroundService
{
public static ActivitySource MyActivitySource { get; } = new(nameof(MyActivitySource));
private readonly ILogger<Worker> _logger;
public Worker(ILogger<Worker> logger)
{
_logger = logger;
}
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
while (!stoppingToken.IsCancellationRequested)
{
if (_logger.IsEnabled(LogLevel.Information))
{
_logger.LogInformation("Worker running at: {time}", DateTimeOffset.Now);
}
await Task.Delay(1000, stoppingToken);
}
}
public override Task StartAsync(CancellationToken ct)
{
using (MyActivitySource.StartActivity("worker.SomeBackgroundService.started"))
{
return base.StartAsync(ct);
}
}
public override Task StopAsync(CancellationToken ct)
{
using (MyActivitySource.StartActivity("worker.SomeBackgroundService.stopped"))
{
return base.StopAsync(ct);
}
}
}
}
from opentelemetry-dotnet.
Hi @CodeBlanch at first I want to say thanks for your help and attention to this question.
OpenTelemetry.Exporter.OpenTelemetryProtocol version - 1.7.0
Unfortunately I can't share all project, but I prepared little example how we register
private static OpenTelemetryBuilder AddOpenTelemetry(this IServiceCollection services, MyOptions myOptions)
{
var builder = services
.AddOpenTelemetry()
.WithTracing(builder =>
{
builder
.AddSource("Operation")
.AddProcessor<MetricsFilteringProcessor>() //our processor
.TryAddInstrumentation(myOptions.Telemetry); //our extension
});
builder
.WithMetrics(metricsBuilder => ConfigureMetrics(metricsBuilder, myOptions));
builder
.WithTracing(tracerProviderBuilder =>
{
tracerProviderBuilder
.AddSource(myOptions.ApplicationName)
.AddSource(nameof(AddTraceIdToResponseMiddleware))
.SetResourceBuilder(ResourceBuilder.CreateDefault().AddService(myOptions.ApplicationName, serviceVersion: "1.0.0", autoGenerateServiceInstanceId: false, serviceInstanceId: myOptions.Kubernetes.PodName))
.TryAddOtlpExporter(myOptions.Telemetry);
});
return builder;
}
private static void ConfigureMetrics(MeterProviderBuilder builder, MyOptions myOptions)
{
var resourceBuilder = ResourceBuilder
.CreateDefault()
.AddService(myOptions.ApplicationName, serviceVersion: "1.0.0", autoGenerateServiceInstanceId: false, serviceInstanceId: myOptions.Kubernetes.PodName);
builder
.AddMeter(myOptions.ApplicationName)
.AddRuntimeInstrumentation()
.AddProcessInstrumentation()
.SetResourceBuilder(resourceBuilder);
builder.AddView(instrument =>
{
return instrument.GetType().GetGenericTypeDefinition() == typeof(Histogram<>)
? new ExplicitBucketHistogramConfiguration { Boundaries = new double[] { 5, 20, 60, 100, 140, 180, 220, 260, 320, 360, 400, 600, 800, 1100, 1300, 1500, 1900, 2500, 3000, 4000, 6000, 10000, 30000 } }
: null;
});
builder.AddOtlpExporter(otlpOptions =>
{
otlpOptions.Protocol = OpenTelemetry.Exporter.OtlpExportProtocol.Grpc;
otlpOptions.Endpoint = new Uri($"http://{myOptions.Telemetry.JaegerExporter.EnsureGetUdpHost()}:4317");
if (Enum.TryParse<ExportProcessorType>(myOptions.Telemetry.JaegerExporter.ExportProcessorType, out var exportProcessorType))
otlpOptions.ExportProcessorType = exportProcessorType;
if (otlpOptions.ExportProcessorType == ExportProcessorType.Simple)
return;
otlpOptions.BatchExportProcessorOptions.MaxQueueSize = 8192;
otlpOptions.BatchExportProcessorOptions.MaxExportBatchSize = 1024;
otlpOptions.BatchExportProcessorOptions.ScheduledDelayMilliseconds = 200;
otlpOptions.BatchExportProcessorOptions.ExporterTimeoutMilliseconds = 1000;
});
}
from opentelemetry-dotnet.
Related Issues (20)
- [otlp grpc] Handle retry in case of `DEADLINE_EXCEEDED` response code
- [OpenTelemetry.Instrumentation.AspNetCore] Implement gRPC server instrumentation with use of Interceptor instead or extend ResolveSpanStatusForGrpcStatusCode method
- Using TracerShim results in ConditionalWeakTable ArgumentException: "An item with the same key has already been added."
- Promote LoggerProvider from experimental to stable
- Promote MetricPoint reclaim feature for delta aggregation from experimental to stable HOT 2
- Promote cardinality limit view API from experimental to stable
- Add simpler DI-enabled `AddDetector<TResourceDetector>()` overload HOT 6
- OTLP Exporter Enhancements
- [Instruementation.AspNetCore] Fix span names according to sem conv 1.24.0
- Stabilize OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EVENT_LOG_ATTRIBUTES
- Review coding styles settings
- Support for HTTP Client Request/Response Body Size Metrics HOT 1
- [epic] Replace TagTransformer with a higher perf solution
- Unintentional breaking changes? `MethodAccessException` when attempting to migrate from v1.7.0 to v1.8.0-beta.1 HOT 7
- Instrument tags not attached HOT 2
- [BaggagePropagator] Do not encode and decode keys
- envvar-based sampler configuration capability should not be mentioned as part of `1.8.0-beta.1` changelog HOT 2
- Getting duplicate metrics being sent from azure function HOT 5
- Ability to disable timestamps at the end of a metric
- Support .NET 9 Advice API
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.