Skip to content

[DO NOT MERGE] Chore/update metrics #248

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

poshinchen
Copy link
Contributor

@poshinchen poshinchen commented Jun 18, 2025

!!!Need to wait until the PR is merged: #219 !!!

Description

Start emitting metrics in Strands to the collector if configured.

Documentation PR

Will add them once the exporter work is finished

Type of Change

Other (please describe):

Emit strands metrics

Testing

  • I ran hatch run prepare
  • Unit tests
  • Manually setup meter and view metrics in console:
# Set up the resource
resource = Resource.create({ResourceAttributes.SERVICE_NAME: "strands-otel-test", "environment": "test"})

# Set up metrics with console exporter

from opentelemetry import metrics
from opentelemetry.sdk.resources import Resource
from opentelemetry.sdk.metrics import MeterProvider
from opentelemetry.sdk.metrics.export import ConsoleMetricExporter, PeriodicExportingMetricReader

console_metric_reader = PeriodicExportingMetricReader(ConsoleMetricExporter())
metrics_provider = MeterProvider(resource=resource, metric_readers=[console_metric_reader])
metrics.set_meter_provider(metrics_provider)

agent = Agent(tools=[calculator])
result = agent("what is 16*16?")


## Checklist
- [x] I have read the CONTRIBUTING document
- [x] I have added any necessary tests that prove my fix is effective or my feature works
- [ ] I have updated the documentation accordingly
- [ ] I have added an appropriate example to the documentation to outline the feature, or no new docs are needed
- [x] My changes generate no new warnings
- [ ] Any dependent changes have been merged and published

----

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

@poshinchen poshinchen deployed to auto-approve June 18, 2025 21:33 — with GitHub Actions Active
@poshinchen poshinchen marked this pull request as ready for review June 18, 2025 21:33
@poshinchen poshinchen requested a review from a team June 18, 2025 21:38
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.

1 participant