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

Implemented Plugin.cs to enable Application Singals Instrumentation. #20

Merged
merged 8 commits into from
May 29, 2024

Conversation

AsakerMohd
Copy link
Collaborator

@AsakerMohd AsakerMohd commented May 24, 2024

Issue #, if available:

Description of changes:
This PR has multiple changes that were needed to get instrumentation working as expected. The changes are listed below:

  1. Implemented Plugin.cs to inject the processors, AlwaysRecordSampler, and XrayIdGenerator to the otel instrumentation. This was based on the java instrumentation
  2. Updated Build.cs to copy dependencies when creating the OpenTelemetry Distro. This needs to be refined since the dependencies are hard coded.
  3. Added a new AwsMetricAttributesSpanProcessor.cs module that replaces AwsMetricAttributesSpanExporter.cs. AwsMetricAttributesSpanExporter is a wrapper that wraps around existing exporters to modify spans. Since we don't have access to these exporters, Created AwsMetricAttributesSpanProcessor which does the same thing as the exporter in terms of span modification and registered that processor as the first processor. Since, according to spec, processors are invoked in order of registration, we can be confident that the spans being exported would be modified as expected. The processor implementation is based on the java exporter implementation.
  4. There has been a change to some of the http attributes keys that hold important http data that was made by OTEL. As a result, A list of attributes has been added to AwsSpanProcessingUtil.cs and link to semantic conventions is there for more info.

Testing:
Started up a sample app and collector and verified that the collector was getting spans that were populated with aws attributes for application signals and that appeared on the traces console on cloudwatch:

2024-05-28T18:44:52.301Z      info    TracesExporter  {"kind": "exporter", "data_type": "traces", "name": "logging", "resource spans": 1, "spans": 2}
otel-1  | 2024-05-28T18:44:52.301Z      info    ResourceSpans #0
otel-1  | Resource SchemaURL: 
otel-1  | Resource attributes:
otel-1  |      -> telemetry.distro.name: Str(aws-otel-dotnet-instrumentation)
otel-1  |      -> host.name: Str(f5bf6a1d41f5)
otel-1  |      -> process.owner: Str(root)
otel-1  |      -> process.pid: Int(1)
otel-1  |      -> process.runtime.description: Str(.NET 8.0.5)
otel-1  |      -> process.runtime.name: Str(.NET)
otel-1  |      -> process.runtime.version: Str(8.0.5)
otel-1  |      -> container.id: Str(f5bf6a1d41f53788db6a3b2859943a7c2ec92532036857c61dc5892a8851fab4)
otel-1  |      -> telemetry.distro.version: Str(1.6.0)
otel-1  |      -> telemetry.sdk.name: Str(opentelemetry)
otel-1  |      -> telemetry.sdk.language: Str(dotnet)
otel-1  |      -> telemetry.sdk.version: Str(1.8.1)
otel-1  |      -> service.name: Str(aws-otel-integ-test)
otel-1  | ScopeSpans #0
otel-1  | ScopeSpans SchemaURL: 
otel-1  | InstrumentationScope System.Net.Http 
otel-1  | Span #0
otel-1  |     Trace ID       : 66562623076d5f71658e7a84257d28de
otel-1  |     Parent ID      : 669b08274be25f69
otel-1  |     ID             : ac0e96a11a9fa988
otel-1  |     Name           : GET
otel-1  |     Kind           : Client
otel-1  |     Start time     : 2024-05-28 18:44:51.4112682 +0000 UTC
otel-1  |     End time       : 2024-05-28 18:44:51.997091 +0000 UTC
otel-1  |     Status code    : Unset
otel-1  |     Status message : 
otel-1  | Attributes:
otel-1  |      -> aws.local.operation: Str(GET /outgoing-http-call)
otel-1  |      -> http.request.method: Str(GET)
otel-1  |      -> server.address: Str(aws.amazon.com)
otel-1  |      -> server.port: Int(443)
otel-1  |      -> url.full: Str(https://aws.amazon.com/)
otel-1  |      -> network.protocol.version: Str(1.1)
otel-1  |      -> http.response.status_code: Int(200)
otel-1  |      -> aws.local.service: Str(aws-otel-integ-test)
otel-1  |      -> aws.remote.service: Str(aws.amazon.com:443)
otel-1  |      -> aws.remote.operation: Str(GET /)
otel-1  |      -> aws.span.kind: Str(ActivityKind)
otel-1  | ScopeSpans #1
otel-1  | ScopeSpans SchemaURL: 
otel-1  | InstrumentationScope Microsoft.AspNetCore 
otel-1  | Span #0
otel-1  |     Trace ID       : 66562623076d5f71658e7a84257d28de
otel-1  |     Parent ID      : 
otel-1  |     ID             : 669b08274be25f69
otel-1  |     Name           : GET outgoing-http-call
otel-1  |     Kind           : Server
otel-1  |     Start time     : 2024-05-28 18:44:51.1719128 +0000 UTC
otel-1  |     End time       : 2024-05-28 18:44:52.129685 +0000 UTC
otel-1  |     Status code    : Unset
otel-1  |     Status message : 
otel-1  | Attributes:
otel-1  |      -> server.address: Str(localhost)
otel-1  |      -> server.port: Int(8080)
otel-1  |      -> http.request.method: Str(GET)
otel-1  |      -> url.scheme: Str(http)
otel-1  |      -> url.path: Str(/outgoing-http-call)
otel-1  |      -> network.protocol.version: Str(1.1)
otel-1  |      -> user_agent.original: Str(Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:126.0) Gecko/20100101 Firefox/126.0)
otel-1  |      -> http.route: Str(outgoing-http-call)
otel-1  |      -> http.response.status_code: Int(200)
otel-1  |      -> aws.local.service: Str(aws-otel-integ-test)
otel-1  |      -> aws.local.operation: Str(GET outgoing-http-call)
otel-1  |      -> aws.span.kind: Str(LOCAL_ROOT)
otel-1  |       {"kind": "exporter", "data_type": "traces", "name": "logging"}


2024-05-28 11:45:42 2024-05-28T18:45:42.349Z    info    MetricsExporter {"kind": "exporter", "data_type": "metrics", "name": "logging", "resource metrics": 1, "metrics": 3, "data points": 6}
2024-05-28 11:45:42 2024-05-28T18:45:42.349Z    info    ResourceMetrics #0
2024-05-28 11:45:42 Resource SchemaURL: 
2024-05-28 11:45:42 Resource attributes:
2024-05-28 11:45:42      -> service.name: Str(aws-otel-integ-test)
2024-05-28 11:45:42      -> telemetry.sdk.name: Str(opentelemetry)
2024-05-28 11:45:42      -> telemetry.sdk.language: Str(dotnet)
2024-05-28 11:45:42      -> telemetry.sdk.version: Str(1.8.1)
2024-05-28 11:45:42 ScopeMetrics #0
2024-05-28 11:45:42 ScopeMetrics SchemaURL: 
2024-05-28 11:45:42 InstrumentationScope AwsSpanMetricsProcessor 
2024-05-28 11:45:42 Metric #0
2024-05-28 11:45:42 Descriptor:
2024-05-28 11:45:42      -> Name: Error
2024-05-28 11:45:42      -> Description: 
2024-05-28 11:45:42      -> Unit: 
2024-05-28 11:45:42      -> DataType: ExponentialHistogram
2024-05-28 11:45:42      -> AggregationTemporality: Delta
2024-05-28 11:45:42 ExponentialHistogramDataPoints #0
2024-05-28 11:45:42 Data point attributes:
2024-05-28 11:45:42      -> aws.local.operation: Str(GET /outgoing-http-call)
2024-05-28 11:45:42      -> aws.local.service: Str(aws-otel-integ-test)
2024-05-28 11:45:42      -> aws.remote.operation: Str(GET /)
2024-05-28 11:45:42      -> aws.remote.service: Str(aws.amazon.com:443)
2024-05-28 11:45:42      -> aws.span.kind: Str(ActivityKind)
2024-05-28 11:45:42 StartTimestamp: 2024-05-28 18:44:42.3570055 +0000 UTC
2024-05-28 11:45:42 Timestamp: 2024-05-28 18:45:42.3303903 +0000 UTC
2024-05-28 11:45:42 Count: 1
2024-05-28 11:45:42 Sum: 0.000000
2024-05-28 11:45:42 Min: 0.000000
2024-05-28 11:45:42 Max: 0.000000
2024-05-28 11:45:42 Bucket [0, 0], Count: 1
2024-05-28 11:45:42 ExponentialHistogramDataPoints #1
2024-05-28 11:45:42 Data point attributes:
2024-05-28 11:45:42      -> aws.local.operation: Str(GET outgoing-http-call)
2024-05-28 11:45:42      -> aws.local.service: Str(aws-otel-integ-test)
2024-05-28 11:45:42      -> aws.span.kind: Str(LOCAL_ROOT)
2024-05-28 11:45:42 StartTimestamp: 2024-05-28 18:44:42.3570055 +0000 UTC
2024-05-28 11:45:42 Timestamp: 2024-05-28 18:45:42.3303903 +0000 UTC
2024-05-28 11:45:42 Count: 1
2024-05-28 11:45:42 Sum: 0.000000
2024-05-28 11:45:42 Min: 0.000000
2024-05-28 11:45:42 Max: 0.000000
2024-05-28 11:45:42 Bucket [0, 0], Count: 1
2024-05-28 11:45:42 Metric #1
2024-05-28 11:45:42 Descriptor:
2024-05-28 11:45:42      -> Name: Fault
2024-05-28 11:45:42      -> Description: 
2024-05-28 11:45:42      -> Unit: 
2024-05-28 11:45:42      -> DataType: ExponentialHistogram
2024-05-28 11:45:42      -> AggregationTemporality: Delta
2024-05-28 11:45:42 ExponentialHistogramDataPoints #0
2024-05-28 11:45:42 Data point attributes:
2024-05-28 11:45:42      -> aws.local.operation: Str(GET /outgoing-http-call)
2024-05-28 11:45:42      -> aws.local.service: Str(aws-otel-integ-test)
2024-05-28 11:45:42      -> aws.remote.operation: Str(GET /)
2024-05-28 11:45:42      -> aws.remote.service: Str(aws.amazon.com:443)
2024-05-28 11:45:42      -> aws.span.kind: Str(ActivityKind)
2024-05-28 11:45:42 StartTimestamp: 2024-05-28 18:44:42.3601183 +0000 UTC
2024-05-28 11:45:42 Timestamp: 2024-05-28 18:45:42.330461 +0000 UTC
2024-05-28 11:45:42 Count: 1
2024-05-28 11:45:42 Sum: 0.000000
2024-05-28 11:45:42 Min: 0.000000
2024-05-28 11:45:42 Max: 0.000000
2024-05-28 11:45:42 Bucket [0, 0], Count: 1
2024-05-28 11:45:42 ExponentialHistogramDataPoints #1
2024-05-28 11:45:42 Data point attributes:
2024-05-28 11:45:42      -> aws.local.operation: Str(GET outgoing-http-call)
2024-05-28 11:45:42      -> aws.local.service: Str(aws-otel-integ-test)
2024-05-28 11:45:42      -> aws.span.kind: Str(LOCAL_ROOT)
2024-05-28 11:45:42 StartTimestamp: 2024-05-28 18:44:42.3601183 +0000 UTC
2024-05-28 11:45:42 Timestamp: 2024-05-28 18:45:42.330461 +0000 UTC
2024-05-28 11:45:42 Count: 1
2024-05-28 11:45:42 Sum: 0.000000
2024-05-28 11:45:42 Min: 0.000000
2024-05-28 11:45:42 Max: 0.000000
2024-05-28 11:45:42 Bucket [0, 0], Count: 1
2024-05-28 11:45:42 Metric #2
2024-05-28 11:45:42 Descriptor:
2024-05-28 11:45:42      -> Name: Latency
2024-05-28 11:45:42      -> Description: 
2024-05-28 11:45:42      -> Unit: Milliseconds
2024-05-28 11:45:42      -> DataType: ExponentialHistogram
2024-05-28 11:45:42      -> AggregationTemporality: Delta
2024-05-28 11:45:42 ExponentialHistogramDataPoints #0
2024-05-28 11:45:42 Data point attributes:
2024-05-28 11:45:42      -> aws.local.operation: Str(GET /outgoing-http-call)
2024-05-28 11:45:42      -> aws.local.service: Str(aws-otel-integ-test)
2024-05-28 11:45:42      -> aws.remote.operation: Str(GET /)
2024-05-28 11:45:42      -> aws.remote.service: Str(aws.amazon.com:443)
2024-05-28 11:45:42      -> aws.span.kind: Str(ActivityKind)
2024-05-28 11:45:42 StartTimestamp: 2024-05-28 18:44:42.3602267 +0000 UTC
2024-05-28 11:45:42 Timestamp: 2024-05-28 18:45:42.3305067 +0000 UTC
2024-05-28 11:45:42 Count: 1
2024-05-28 11:45:42 Sum: 585.822800
2024-05-28 11:45:42 Min: 585.822800
2024-05-28 11:45:42 Max: 585.822800
2024-05-28 11:45:42 Bucket (585.822472, 585.822859], Count: 1
2024-05-28 11:45:42 ExponentialHistogramDataPoints #1
2024-05-28 11:45:42 Data point attributes:
2024-05-28 11:45:42      -> aws.local.operation: Str(GET outgoing-http-call)
2024-05-28 11:45:42      -> aws.local.service: Str(aws-otel-integ-test)
2024-05-28 11:45:42      -> aws.span.kind: Str(LOCAL_ROOT)
2024-05-28 11:45:42 StartTimestamp: 2024-05-28 18:44:42.3602267 +0000 UTC
2024-05-28 11:45:42 Timestamp: 2024-05-28 18:45:42.3305067 +0000 UTC
2024-05-28 11:45:42 Count: 1
2024-05-28 11:45:42 Sum: 957.772200
2024-05-28 11:45:42 Min: 957.772200
2024-05-28 11:45:42 Max: 957.772200
2024-05-28 11:45:42 Bucket (957.772169, 957.772802], Count: 1

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@AsakerMohd AsakerMohd requested a review from a team as a code owner May 24, 2024 17:29
@vastin
Copy link
Collaborator

vastin commented May 28, 2024

Following wrong span kind value is known issue and fixed in other PR.

aws.span.kind:` Str(ActivityKind)

vastin
vastin previously approved these changes May 28, 2024
Copy link
Collaborator

@vastin vastin left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Collaborator

@birojnayak birojnayak left a comment

Choose a reason for hiding this comment

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

added one more comment

@vastin
Copy link
Collaborator

vastin commented May 29, 2024

Create an issue #22 to track the follow-up actions for comments.

@AsakerMohd AsakerMohd merged commit 0171a4c into main May 29, 2024
2 checks passed
@AsakerMohd AsakerMohd deleted the instrumentation branch May 29, 2024 20:33
@birojnayak
Copy link
Collaborator

Create an issue #22 to track the follow-up actions for comments.

thank you @vastin ..

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

Successfully merging this pull request may close these issues.

5 participants