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

Improve telemetry instrumentation on core flows #581

Merged
merged 18 commits into from
Nov 13, 2024

Conversation

wcalderipe
Copy link
Collaborator

@wcalderipe wcalderipe commented Nov 13, 2024

This PR improves telemetry instrumentation on core flows as well as adds business metrics to answer a few questions:

  • How many wallets per client and overall?
  • How many sign<Message/Transaction/TypedData/Raw> per client and overall?
  • How many authorization flows were initiated by a client and overall?
  • How many authorization flows were permitted by a client and overall?

Changelog

  • Moved shared constants OTEL_ATTR_CLIENT_ID, REQUEST_HEADER_CLIENT_ID, and REQUEST_HEADER_CLIENT_SECRET tonestjs-shared package.
  • Added middleware in all applications to set the value from the request header x-client-id to the active span.
  • Added granular spans on the evaluation flow of the policy engine.
  • Rename the service name of the Armory from auth to armory.

@wcalderipe wcalderipe self-assigned this Nov 13, 2024
Copy link

vercel bot commented Nov 13, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
devtool ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 13, 2024 5:08pm
manager 🔄 Building (Inspect) Visit Preview 💬 Add feedback Nov 13, 2024 5:08pm

Copy link
Contributor

@Ptroger Ptroger left a comment

Choose a reason for hiding this comment

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

That looks super nice. Seem easy to setup new metrics from there. Appreciated to take a look on how you tested these metric and trace services with the stateful ones. I left a comment about one naming and one question.
Ty for the code comments from earlier PR with links to documentation, it was helpful.

@@ -49,8 +55,6 @@ export const DEFAULT_HTTP_MODULE_PROVIDERS = [
// Headers
//

export const REQUEST_HEADER_CLIENT_ID = 'x-client-id'
export const REQUEST_HEADER_CLIENT_SECRET = 'x-client-secret'
export const REQUEST_HEADER_API_KEY = 'x-api-key'
Copy link
Contributor

Choose a reason for hiding this comment

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

Out of curiosity, why don't we also move the API_KEY one to shared ? Is it just used in armory ?

Copy link
Collaborator Author

@wcalderipe wcalderipe Nov 13, 2024

Choose a reason for hiding this comment

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

I felt that was specific to the Armory, so I left it there. In contrast, x-client are used everywhere.

private logger: LoggerService,
@Inject(MetricService) private metricService: MetricService
) {
this.createCounter = this.metricService.createCounter('authorization_request_create_count')
Copy link
Contributor

@Ptroger Ptroger Nov 13, 2024

Choose a reason for hiding this comment

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

Maybe rename createCounter attribute to something different than metricService create counter method ? Not a big deal but the first few seconds I was confused

Also, it seems so straightforward to setup new metrics, gj

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The class name carries the context needed to understand what "create" means. However, when the class has more than one responsibility, like in the KeyGenerationService, a more verbose name makes sense.

@@ -7,6 +7,8 @@ Policy decision point for fine-grained authorization in web3.0.
- [Open Policy Agent (OPA) binary version >=
0.69](https://www.openpolicyagent.org/docs/latest/#1-download-opa) installed
and accessible in your `$PATH`.
- [Regal](https://github.com/StyraInc/regal?tab=readme-ov-file#getting-started)
for linting Rego code.
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess I should have put that in my latest Regal version PR, ty for adding that

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