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

DT-732 AWS X-Ray tracing via OpenTelemetry #153

Merged
merged 3 commits into from
Jun 13, 2024
Merged

DT-732 AWS X-Ray tracing via OpenTelemetry #153

merged 3 commits into from
Jun 13, 2024

Conversation

BenRamchandani
Copy link
Contributor

@BenRamchandani BenRamchandani commented Jun 13, 2024

Description

There are two options for using X-Ray: the X-Ray SDK and OpenTelemetry. The SDK seems more mature, but only supports the servlet API. AWS seems to be encouraging use of OpenTelemetry, although the core library should be stable I've used several integrations which are in alpha.

Add support for OpenTelemetry to the auth service, including running a collector as a sidecar in ECS, all optionally enabled by a Terraform variable and associated feature flag, currently on only for the test environment.

The unit tests log spans to stderr, but otherwise the tracing is disabled locally by default, but can be abled using the feature flag and running the collector with a docker compose profile.

Local testing Tested a bit locally and on test. It definitely sends some stuff to AWS X-Ray, though I haven't tested much past that.

Release Normal Terraform apply. Feature flagged but should still be sanity tested on staging with the flag off.
Depends on communitiesuk/delta-common-infrastructure#420

auth-service/build.gradle.kts Outdated Show resolved Hide resolved
auth-service/.env.template Show resolved Hide resolved
@@ -73,6 +75,7 @@ class ADLdapLoginService(
@Blocking
private fun ldapBind(userDn: String, password: String): IADLdapLoginService.LdapLoginResult {
var context: InitialDirContext? = null
val span = ldapSpanFactory("AD-ldap-user-bind").startSpan()
return try {
context = ldapRepository.bind(userDn, password)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does it make sense to do it inside ldapRepository.bind instead? Or are you deliberately not logging every lookup?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We'd need another span for mapUserFromContext then (my understanding is that's also an LDAP call), and for running the block in useServiceUserBind. I think either would be fine but probably not worth changing

We almost always build in CI and invoking gradle twice slows it down
@BenRamchandani
Copy link
Contributor Author

One thing I meant to mention: OpenTelemetry can also be used for metrics where we currently use MicroMeter, I don't think there's any rush to replace MicroMeter, especially as the OTel libraries aren't all stable, but something to keep in mind

* Add note to Readme
* Update comment in build.gradle.kts
* Move LDAP bind inside LdapServiceUserBind span
@BenRamchandani BenRamchandani merged commit 6872648 into main Jun 13, 2024
6 checks passed
@BenRamchandani BenRamchandani deleted the DT-732 branch June 13, 2024 16:19
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.

2 participants