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

Instrumentation raw objects should be sent as custom properties #1099

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/OpenTelemetry.Instrumentation.Grpc/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

* Grpc instrumentation will now add the raw Request object to the Activity it
creates
([#1099](https://github.com/open-telemetry/opentelemetry-dotnet/pull/1099))

## 0.4.0-beta.2

Released 2020-07-24
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public override void OnStartActivity(Activity activity, object payload)

activity.SetKind(ActivityKind.Client);
activity.DisplayName = grpcMethod?.Trim('/');
activity.SetCustomProperty("GrpcHandler.Request", request);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious - do we want this to be OTel.GrpcHandler.Request? For example, if someone is debugging a crash dump, they would get some hint that it was added by OpenTelemetry.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also think we should expose these strings as public constants in someway, part of the respective instrumentation projects, so that users dont have to remember the string property name.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree to prefix "Otel."

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added the "OTel" prefix everywhere we were calling SetCustomProperty. Moved most things to constants. But didn't tackle exposing them right now. Looked around Grpc, it doesn't have really anything that is public other than the builder extension. So we need to figure out how we want that to work. Have a constants class in each project or something? Future PR 😄

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is unclear to me who is going to benefit from these constants. My take is that if the string literal is only going to show up in the repo once, twice or three times, literal string seems to provide better readability.


this.activitySource.Start(activity);

Expand Down
3 changes: 3 additions & 0 deletions src/OpenTelemetry.Instrumentation.Http/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## Unreleased

* ASP.NET Core instrumentation will now add the raw Request, Response, and/or
Exception objects to the Activity it creates
([#1099](https://github.com/open-telemetry/opentelemetry-dotnet/pull/1099))
* Changed the default propagation to support W3C Baggage
([#1048](https://github.com/open-telemetry/opentelemetry-dotnet/pull/1048))
* The default ITextFormat is now `CompositePropagator(TraceContextFormat,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ public override void OnStartActivity(Activity activity, object payload)

activity.SetKind(ActivityKind.Client);
activity.DisplayName = HttpTagHelper.GetOperationNameForHttpMethod(request.Method);
activity.SetCustomProperty("HttpHandler.Request", request);

this.activitySource.Start(activity);

Expand Down Expand Up @@ -135,7 +136,8 @@ public override void OnStopActivity(Activity activity, object payload)

if (this.stopResponseFetcher.Fetch(payload) is HttpResponseMessage response)
{
// response could be null for DNS issues, timeouts, etc...
activity.SetCustomProperty("HttpHandler.Response", response);

activity.SetTag(SemanticConventions.AttributeHttpStatusCode, (int)response.StatusCode);

activity.SetStatus(
Expand All @@ -158,6 +160,8 @@ public override void OnException(Activity activity, object payload)
return;
}

activity.SetCustomProperty("HttpHandler.Exception", exc);

if (exc is HttpRequestException)
{
if (exc.InnerException is SocketException exception)
Expand Down
6 changes: 5 additions & 1 deletion src/OpenTelemetry.Instrumentation.SqlClient/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@

## Unreleased

* Renamed from `AddSqlClientDependencyInstrumentation` to `AddSqlClientInstrumentation`
* .NET Core SqlClient instrumentation will now add the raw Command object to the
Activity it creates
([#1099](https://github.com/open-telemetry/opentelemetry-dotnet/pull/1099))
* Renamed from `AddSqlClientDependencyInstrumentation` to
`AddSqlClientInstrumentation`

## 0.4.0-beta.2

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ public override void OnCustom(string name, Activity activity, object payload)
var database = this.databaseFetcher.Fetch(connection);

activity.DisplayName = (string)database;
activity.SetCustomProperty("SqlHandler.Command", command);

if (activity.IsAllDataRequested)
{
Expand Down