Skip to content

refactor: instrument using new telemetry APIs #866

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

Merged
merged 4 commits into from
Jun 16, 2023

Conversation

aajtodd
Copy link
Contributor

@aajtodd aajtodd commented Jun 16, 2023

Issue #

N/A

Description of changes

  • Refactor instrumentation of the runtime to use the new telemetry APIs
  • Update codegen to instrument operations using the new APIs
    • I expect this may change (e.g. we may choose to move some of this into the runtime if possible). TBD once we start playing around with how telemetry signals and backends.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Comment on lines +67 to +71
writer.write("\n\n")
writer.write("public const val ServiceId: String = #S", ctx.settings.sdkId)
writer.write("public const val SdkVersion: String = #S", ctx.settings.pkg.version)
writer.write("\n\n")

Copy link
Contributor

Choose a reason for hiding this comment

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

Question: Why did these move? Should ServiceApiVersion move as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't remember now but there was a reason 🤔 . ServiceApiVersion is AWS specific, the other two are not.

Comment on lines 283 to 294
write("val span = tracer.createSpan(")
.indent()
.write("#S,", "\${ServiceId}.\${operation}")
.withBlock("#T{", "},", RuntimeTypes.Core.Utils.attributesOf) {
write("#S to ServiceId", "rpc.service")
write("#S to operation", "rpc.method")
writer.declareSection(OperationSpanAttributes)
}
}
.write("#T.CLIENT,", RuntimeTypes.Observability.TelemetryApi.SpanKind)
.write("parentCtx")
.dedent()
.write(")")
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Could use withBlock.

}
}
.write("#T.CLIENT,", RuntimeTypes.Observability.TelemetryApi.SpanKind)
.write("parentCtx")
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Trailing comma

Comment on lines +17 to +22
public interface Builder {
/**
* The [TelemetryProvider] to instrument the component with.
*/
public var telemetryProvider: TelemetryProvider?
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Question: We intend to provide a default value of TelemetryProvider.None right? Why leave the var nullable?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's on the builder, this is how most of our config builders work right? TelemetryConfig.telemetryProvider is non nullable and will get the default.

.call { renderAdditionalMethods(writer) }
.write("")
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this new .write("") call necessary, it wasn't there before?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

well technically none of them are necessary since it's formatting, can remove though

@sonarqubecloud
Copy link

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 3 Code Smells

No Coverage information No Coverage information
7.7% 7.7% Duplication

idea Catch issues before they fail your Quality Gate with our IDE extension sonarlint SonarLint

@aajtodd aajtodd merged commit b7d5b9a into observability Jun 16, 2023
@aajtodd aajtodd deleted the telemetry-refactor-instrumentation branch June 16, 2023 20:00
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.

3 participants