I was looking for adding custom attribute in the traces of opentelemetry.I want to add the session values like unique Id as the custom attribute to track each traces from each user.But in startup I am unable to access the Session.Finally my question is, Why I can't access session in Startup? If not accessible measns What are the way to accomplish my requirements which are mentioned above in bold letters in opentelemetry?
Add a custom attribute in traces from opentelemetry in .NET core 3.1
584 Views Asked by pradeep At
1
There are 1 best solutions below
Related Questions in C#
- How to call a C language function from x86 assembly code?
- What does: "char *argv[]" mean?
- User input sanitization program, which takes a specific amount of arguments and passes the execution to a bash script
- How to crop a BMP image in half using C
- How can I get the difference in minutes between two dates and hours?
- Why will this code compile although it defines two variables with the same name?
- Compiling eBPF program in Docker fails due to missing '__u64' type
- Why can't I use the file pointer after the first read attempt fails?
- #include Header files in C with definition too
- OpenCV2 on CLion
- What is causing the store latency in this program?
- How to refer to the filepath of test data in test sourcecode?
- 9 Digit Addresses in Hexadecimal System in MacOS
- My server TCP doesn't receive messages from the client in C
- Printing the characters obtained from the array s using printf?
Related Questions in ASP.NET-CORE
- Windows environment variables at appsettings.json
- Which approach is right while creating a service for your update method?
- New Blazor Web App, Password Reset "A valid antiforgery token was not provided"
- No webpage was found for the web address: https://localhost:7002/Category/Add?area=Admin. Why is my URL generated like ?area=Admin instead of /Admin/
- how to get the html for a tag helper in code
- How to share authorization implemented in the server project with the client project in Blazor Web App Auto project?
- Why https is disabled on publish in .NET Core 7.0
- How to set language in a server-side rendering blazor app
- How can I debug server side rendering blazor code in a component?
- ASP.NET Core 6 randomly returning 200 with empty response
- ASP.NET Core MVC : NullReferenceException: Object reference not set to an instance of an object
- ASP.NET Core Identity Custom Register Endpoint
- VS Community 2022 cannot install dotnet-ef when i try to publish
- How does ASP.NET Core Identity ensure username is unique under concurrent conditions?
- In clean architecture, is the presentation layer allowed to communicate directly with the infrastructure layer?
Related Questions in SESSION
- Multiple Processes, Multiple Processors, Single Priority Queue - Java Thread-Safe and Concurrency -
- Securing routes with sessionStorage in NextJS
- Cant handle Session's cookie when Safari/iOS
- Quart_Sessions Redis deletes keys and create backups instead
- I cannot get ID from session in GET method in Next.js 14
- I am new to flutter, just trying to set and get logged in user's session but maybe I am missing something
- I'm going nuts with Heroku session management issues
- Have a problem with get session in nextjs
- Session custom property getting undefined when calling Node js API from Javascript fetch
- Best Approach for Preserving User Input Across Blazor Pages in ASP.NET Core Application with User-Specific Data Storage
- spring security + form login + redis session storage -> keep coming out anonymous User
- Check user login in backend
- Next.js Middleware for Session Authentication Redirects: Errors Encountered
- Ansible prompt "No existing session" in manual executing the playbook
- Running a program on different computers with different users that access a central database simultaneously - VB.NET XAMPP/MySQL
Related Questions in INSTRUMENTATION
- Setup sentry to only log transactions occuring on a specific subpage
- How can I modify the core api in java ?
- OpenJDK Tracking ReentrantLock lock and unlock
- How to lookup the function addresses of ALL functions instrumented with gcc -finstrument-functions flag?
- (Instrument API, Agent)My ClassFileTransformer's transform method fails to recognize a specific class in Springboot
- Initializing Non-Primtive Field by ByteBuddy in Aspect
- EF Core connection pool metrics in Prometheus
- Why IntelPin tool build gets linker error when using wincrypt functions?
- Is it possible to use bpf_override_return in uprobes/uretprobes?
- Memory trace of a function and all the functions called by it
- Overhead of pintool with no instrumentation done
- How can I determine which CMake targets were added by a command?
- Compilation failure on custom class with package java.util
- How to inject a script in html pages without touching the application code in ASP.NET Core
- .NET command line dynamic profiler not capturing data
Related Questions in OPEN-TELEMETRY
- OpenTelemetry in an multi-tenant ASP.NET Core app
- OpenTelemetry OLTP Java server example
- Opentelemetry Surpresses Kafka Produce Message Java
- Trace a single endpoint with AWS Distro for OpenTelemetry (ADOT)
- Open telemetry integration in java
- Create new Opentelemetry Trace in java
- Why not let the `instanceid` of `opampextension` directly use the value of `service.instance.id`?
- Opentelemetry helm charts could not create replicaset on Kubernetes
- How to get SQL statements using open telemetry and auto-instrumentation on IIS
- How to implement Sunbird telemetry in React
- Load ESM module using import-in-the-middle
- OpenTelemetry + Jaeger tracing "Warnings: invalid parent span IDs=XXXX; skipping clock skew adjustment"
- prometheus metric failed when add process metric
- How to ensure consistent trace_id across microservices with OpenTelemetry and gRPC in Go
- Opentelemetry manual traceparent creation
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular # Hahtags
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
In ASP.NET Core, the
Startupclass configures services and the app's request pipeline. The session is not accessible inStartupbecause it's not set up at that point. Sessions are typically established once the request pipeline is running, which is well after theStartupconfiguration is complete.The session state is established within the context of an HTTP request. During the startup configuration, the application is setting up how it will handle requests, but no request has been made yet.
However, to add custom attributes like a unique user identifier to OpenTelemetry traces, you can follow these steps:
1)Create a custom middleware that runs after the session has been established. In this middleware, you can access the session values and set the custom attributes.
2)Use a telemetry initializer that can access the
HttpContextand, by extension, the session state to enrich the telemetry with the session information.3)If you're using MVC, you could also use an action filter to add the session information to the telemetry. This would be done in the context of an action execution where session data is available.
You could refer this document which will help you understand how to manage session state :
https://learn.microsoft.com/en-us/aspnet/core/fundamentals/app-state?view=aspnetcore-7.0