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

Trace/Event Telemetry not Correlate to Request/Dependency Telemetry #2886

Open
thegodofjason opened this issue Jul 16, 2024 · 0 comments
Open

Comments

@thegodofjason
Copy link

thegodofjason commented Jul 16, 2024

Hi:
I followed the instructions hereApp insights to write custom telemetry
But I see that the trace not work as the document said that share the same operation id

Along with setting an operation context, StartOperation creates a telemetry item of the type that you specify. It sends the telemetry item when you dispose of the operation or if you explicitly call StopOperation. If you use RequestTelemetry as the telemetry type, its duration is set to the timed interval between start and stop.

Telemetry items reported within a scope of operation become children of such an operation. Operation contexts could be nested.

My test project is .net4.7.2 and install the appinsights nuget
How do I correlate the child trace with parent request correctly? Thanks

image

            // Establish an operation context and associated telemetry item:
            using (var operation = telemetryClient.StartOperation<RequestTelemetry>("operationName"))
            {
                // Telemetry sent in here will use the same operation ID.
                telemetryClient.TrackTrace("test"); // or other Track* calls

                // Set properties of containing telemetry item--for example:
                operation.Telemetry.ResponseCode = "200";

                // Optional: explicitly send telemetry item:
                telemetryClient.StopOperation(operation);
                operation.Dispose();
                telemetryClient.Flush();
            } // When operation is disposed, telemetry item is sent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant