-
Notifications
You must be signed in to change notification settings - Fork 11
Add Blazor WebAssembly pivot to browser telemetry documentation #51
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
base: main
Are you sure you want to change the base?
Conversation
…nd Blazor WebAssembly options Co-authored-by: IEvangelist <7679720+IEvangelist@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds Blazor WebAssembly as an alternative approach to the existing JavaScript SDK for sending browser telemetry to the Aspire dashboard, addressing issue #50. This enables .NET developers to use familiar .NET OpenTelemetry APIs instead of JavaScript for telemetry configuration in browser applications.
- Added a
PivotSelectorcomponent to allow users to choose between "Razor Pages with JavaScript" and "Blazor WebAssembly" approaches - Documented Blazor WebAssembly configuration with OpenTelemetry packages, code examples, and best practices
- Updated introductory text to be approach-agnostic
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| using var otel = Sdk.CreateTracerProviderBuilder() | ||
| .SetResourceBuilder(resourceBuilder) | ||
| .AddSource("ui") | ||
| .AddOtlpExporter(options => | ||
| { | ||
| options.Endpoint = new Uri("https://localhost:21036"); | ||
| options.ExportProcessorType = ExportProcessorType.Simple; | ||
| }) | ||
| .Build(); | ||
| using var source = new ActivitySource("ui"); | ||
| using (var activity = source.StartActivity("trace-click", ActivityKind.Client)) | ||
| { | ||
| activity?.AddEvent(new ActivityEvent("Trace button click")); | ||
| } |
Copilot
AI
Nov 17, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Creating a new TracerProvider and ActivitySource on every button click is inefficient and goes against OpenTelemetry best practices. The tracer provider and activity source should be created once during application startup and reused. This pattern will create significant overhead in production scenarios. The best practices section mentions this issue, but the example code demonstrates the anti-pattern.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot apply changes based on this feedback
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in commit 481c3b5. The code now initializes TracerProvider and ActivitySource once in OnInitialized() and reuses them for each trace operation. Added proper disposal via IDisposable implementation.
| .AddSource("ui") | ||
| .AddOtlpExporter(options => | ||
| { | ||
| options.Endpoint = new Uri("https://localhost:21036"); |
Copilot
AI
Nov 17, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The hardcoded endpoint URL uses port 21036, which differs from the dashboard configuration examples shown earlier in the document (ports 16175, 4318, or 18890). This inconsistency may confuse users. Consider using one of the documented ports or clarifying why this specific port is used.
| options.Endpoint = new Uri("https://localhost:21036"); | |
| options.Endpoint = new Uri("https://localhost:4318"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in commit 481c3b5. Changed all instances from port 21036 to 4318, which is the standard HTTP OTLP port documented in the dashboard configuration section.
…bly examples and configuration details
Co-authored-by: IEvangelist <7679720+IEvangelist@users.noreply.github.com>
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
Hey @copilot please take a look at this op feedback #50 (comment) |
Co-authored-by: IEvangelist <7679720+IEvangelist@users.noreply.github.com>
Fixed in commit 61cf7a0. All three points from the original issue feedback have been addressed:
Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|


Summary
This PR addresses issue #50 by adding a
PivotSelectorcomponent to the browser telemetry documentation, allowing users to choose between two approaches:Changes Made
Fixes Applied (Based on Code Review Feedback)
1. Fixed OpenTelemetry Best Practices (Comment #2535580905)
Issue: The original code created a new
TracerProviderandActivitySourceon every button click, which is inefficient and goes against OpenTelemetry best practices.Fix:
OnInitialized()methodTracerProviderandActivitySourceinstancesIDisposableimplementation2. Fixed Port Number (Comment #2535580921)
Issue: The hardcoded endpoint URL used port 21036, which differs from the documented dashboard ports (16175, 4318, or 18890).
Fix:
https://localhost:21036tohttps://localhost:43183. Added Browser Compatibility Protocol (Original Issue Author Feedback)
Issue: The default gRPC protocol doesn't work in browsers. The examples were missing critical browser compatibility settings.
Fix:
options.Protocol = OtlpExportProtocol.HttpProtobuf;to both examples@using OpenTelemetry.ExporterdirectiveOTEL_EXPORTER_OTLP_HEADERSfor API key authenticationappsettings.json/IConfigurationUpdated Code Example
Screenshot
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.